Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / media / dvb / frontends / or51132.c
index cc0a77c..80e0f28 100644 (file)
@@ -36,6 +36,8 @@
 #include <linux/moduleparam.h>
 #include <linux/init.h>
 #include <linux/delay.h>
+#include <linux/string.h>
+#include <linux/slab.h>
 #include <asm/byteorder.h>
 
 #include "dvb_frontend.h"
@@ -370,22 +372,19 @@ static int or51132_set_parameters(struct dvb_frontend* fe,
                or51132_setmode(fe);
        }
 
-       /* Change only if we are actually changing the channel */
-       if (state->current_frequency != param->frequency) {
-               dvb_pll_configure(state->config->pll_desc, buf,
-                                 param->frequency, 0);
-               dprintk("set_parameters tuner bytes: 0x%02x 0x%02x "
-                       "0x%02x 0x%02x\n",buf[0],buf[1],buf[2],buf[3]);
-               if (i2c_writebytes(state, state->config->pll_address ,buf, 4))
-                       printk(KERN_WARNING "or51132: set_parameters error "
-                              "writing to tuner\n");
-
-               /* Set to current mode */
-               or51132_setmode(fe);
+       dvb_pll_configure(state->config->pll_desc, buf,
+                         param->frequency, 0);
+       dprintk("set_parameters tuner bytes: 0x%02x 0x%02x "
+               "0x%02x 0x%02x\n",buf[0],buf[1],buf[2],buf[3]);
+       if (i2c_writebytes(state, state->config->pll_address ,buf, 4))
+               printk(KERN_WARNING "or51132: set_parameters error "
+                      "writing to tuner\n");
 
-               /* Update current frequency */
-               state->current_frequency = param->frequency;
-       }
+       /* Set to current mode */
+       or51132_setmode(fe);
+
+       /* Update current frequency */
+       state->current_frequency = param->frequency;
        return 0;
 }
 
@@ -469,6 +468,7 @@ static int or51132_read_signal_strength(struct dvb_frontend* fe, u16* strength)
        unsigned char snd_buf[2];
        u8 rcvr_stat;
        u16 snr_equ;
+       u32 signal_strength;
        int usK;
 
        snd_buf[0]=0x04;
@@ -503,8 +503,12 @@ static int or51132_read_signal_strength(struct dvb_frontend* fe, u16* strength)
        rcvr_stat = rec_buf[1];
        usK = (rcvr_stat & 0x10) ? 3 : 0;
 
-        /* The value reported back from the frontend will be FFFF=100% 0000=0% */
-       *strength = (((8952 - i20Log10(snr_equ) - usK*100)/3+5)*65535)/1000;
+       /* The value reported back from the frontend will be FFFF=100% 0000=0% */
+       signal_strength = (((8952 - i20Log10(snr_equ) - usK*100)/3+5)*65535)/1000;
+       if (signal_strength > 0xffff)
+               *strength = 0xffff;
+       else
+               *strength = signal_strength;
        dprintk("read_signal_strength %i\n",*strength);
 
        return 0;
@@ -578,8 +582,7 @@ struct dvb_frontend* or51132_attach(const struct or51132_config* config,
        return &state->frontend;
 
 error:
-       if (state)
-               kfree(state);
+       kfree(state);
        return NULL;
 }