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 / mt352.c
index d32dc4d..aaaec90 100644 (file)
@@ -35,6 +35,8 @@
 #include <linux/moduleparam.h>
 #include <linux/init.h>
 #include <linux/delay.h>
+#include <linux/string.h>
+#include <linux/slab.h>
 
 #include "dvb_frontend.h"
 #include "mt352_priv.h"
@@ -462,9 +464,11 @@ static int mt352_read_signal_strength(struct dvb_frontend* fe, u16* strength)
 {
        struct mt352_state* state = fe->demodulator_priv;
 
-       u16 signal = ((mt352_read_register(state, AGC_GAIN_1) << 8) & 0x0f) |
-                     (mt352_read_register(state, AGC_GAIN_0));
+       /* align the 12 bit AGC gain with the most significant bits */
+       u16 signal = ((mt352_read_register(state, AGC_GAIN_1) & 0x0f) << 12) |
+               (mt352_read_register(state, AGC_GAIN_0) << 4);
 
+       /* inverse of gain is signal strength */
        *strength = ~signal;
        return 0;
 }
@@ -531,9 +535,8 @@ struct dvb_frontend* mt352_attach(const struct mt352_config* config,
        struct mt352_state* state = NULL;
 
        /* allocate memory for the internal state */
-       state = kmalloc(sizeof(struct mt352_state), GFP_KERNEL);
+       state = kzalloc(sizeof(struct mt352_state), GFP_KERNEL);
        if (state == NULL) goto error;
-       memset(state,0,sizeof(*state));
 
        /* setup the state */
        state->i2c = i2c;