diff --git a/drivers/media/dvb-frontends/tda8083.c b/drivers/media/dvb-frontends/tda8083.c index d2d89cfa8221..f04e99fc11c7 100644 --- a/drivers/media/dvb-frontends/tda8083.c +++ b/drivers/media/dvb-frontends/tda8083.c @@ -80,12 +80,10 @@ static inline u8 tda8083_readreg (struct tda8083_state* state, u8 reg) { u8 val; - if(tda8083_readregs (state, reg, &val, 1)) { - return 0x00; - } - - - return val; + if(tda8083_readregs (state, reg, &val, 1)) + return val; + + return 0; } static int tda8083_set_inversion(struct tda8083_state *state, @@ -418,17 +416,23 @@ struct dvb_frontend* tda8083_attach(const struct tda8083_config* config, struct i2c_adapter* i2c) { struct tda8083_state* state = NULL; + u8 ret_readreg; /* allocate memory for the internal state */ - state = kzalloc(sizeof(struct tda8083_state), GFP_KERNEL); + state = kzalloc(sizeof(struct tda8083_state), GFP_KERNEL); if (state == NULL) goto error; + memset(state, 0, sizeof(struct tda8083_state)); /* setup the state */ state->config = config; state->i2c = i2c; + ret_readreg = tda8083_readreg(state, 0x00); + + if((!ret_readreg)) goto error; + /* check if the demod is there */ - if ((tda8083_readreg(state, 0x00)) != 0x05) goto error; + if ((ret_readreg) != 0x05) goto error; /* create dvb_frontend */ memcpy(&state->frontend.ops, &tda8083_ops, sizeof(struct dvb_frontend_ops));