diff --git a/drivers/media/dvb-frontends/tda8083.c b/drivers/media/dvb-frontends/tda8083.c index 5be11fd65e3b..4d81ea111eac 100644 --- a/drivers/media/dvb-frontends/tda8083.c +++ b/drivers/media/dvb-frontends/tda8083.c @@ -85,6 +85,19 @@ static inline u8 tda8083_readreg (struct tda8083_state* state, u8 reg) return val; } +static inline u8 tda8083_readreg_check (struct tda8083_state* state, u8 reg, int *success) +{ + u8 val; + + if(tda8083_readregs (state, reg, &val, 1)) + *success = 0; + + else + *success = 1; + + return val; +} + static int tda8083_set_inversion(struct tda8083_state *state, enum fe_spectral_inversion inversion) { @@ -415,17 +428,25 @@ struct dvb_frontend* tda8083_attach(const struct tda8083_config* config, struct i2c_adapter* i2c) { struct tda8083_state* state = NULL; + u8 retval; + int *success; /* allocate memory for the internal state */ 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; + retval = tda8083_readreg_check(state, 0x00, success); + + if(!(*success)) goto error; + /* check if the demod is there */ - if ((tda8083_readreg(state, 0x00)) != 0x05) goto error; + if ((retval) != 0x05) goto error; + /* create dvb_frontend */ memcpy(&state->frontend.ops, &tda8083_ops, sizeof(struct dvb_frontend_ops));