Commit 1b0bfee3 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] mt2063: don't crash if device is not initialized

Instead of crash, return -ENODEV, if the device is not poperly
initialized.

Also, give a second chance for it to initialize, at set_params
calls.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent b5a91067
...@@ -220,6 +220,8 @@ enum MT2063_Register_Offsets { ...@@ -220,6 +220,8 @@ enum MT2063_Register_Offsets {
struct mt2063_state { struct mt2063_state {
struct i2c_adapter *i2c; struct i2c_adapter *i2c;
bool init;
const struct mt2063_config *config; const struct mt2063_config *config;
struct dvb_tuner_ops ops; struct dvb_tuner_ops ops;
struct dvb_frontend *frontend; struct dvb_frontend *frontend;
...@@ -1974,6 +1976,8 @@ static int mt2063_init(struct dvb_frontend *fe) ...@@ -1974,6 +1976,8 @@ static int mt2063_init(struct dvb_frontend *fe)
if (status < 0) if (status < 0)
return status; return status;
state->init = true;
return 0; return 0;
} }
...@@ -1984,6 +1988,9 @@ static int mt2063_get_status(struct dvb_frontend *fe, u32 *tuner_status) ...@@ -1984,6 +1988,9 @@ static int mt2063_get_status(struct dvb_frontend *fe, u32 *tuner_status)
dprintk(2, "\n"); dprintk(2, "\n");
if (!state->init)
return -ENODEV;
*tuner_status = 0; *tuner_status = 0;
status = mt2063_lockStatus(state); status = mt2063_lockStatus(state);
if (status < 0) if (status < 0)
...@@ -2019,6 +2026,12 @@ static int mt2063_set_analog_params(struct dvb_frontend *fe, ...@@ -2019,6 +2026,12 @@ static int mt2063_set_analog_params(struct dvb_frontend *fe,
dprintk(2, "\n"); dprintk(2, "\n");
if (!state->init) {
status = mt2063_init(fe);
if (status < 0)
return status;
}
switch (params->mode) { switch (params->mode) {
case V4L2_TUNER_RADIO: case V4L2_TUNER_RADIO:
pict_car = 38900000; pict_car = 38900000;
...@@ -2082,6 +2095,12 @@ static int mt2063_set_params(struct dvb_frontend *fe) ...@@ -2082,6 +2095,12 @@ static int mt2063_set_params(struct dvb_frontend *fe)
s32 if_mid; s32 if_mid;
s32 rcvr_mode; s32 rcvr_mode;
if (!state->init) {
status = mt2063_init(fe);
if (status < 0)
return status;
}
dprintk(2, "\n"); dprintk(2, "\n");
if (c->bandwidth_hz == 0) if (c->bandwidth_hz == 0)
...@@ -2132,6 +2151,9 @@ static int mt2063_get_frequency(struct dvb_frontend *fe, u32 *freq) ...@@ -2132,6 +2151,9 @@ static int mt2063_get_frequency(struct dvb_frontend *fe, u32 *freq)
dprintk(2, "\n"); dprintk(2, "\n");
if (!state->init)
return -ENODEV;
*freq = state->frequency; *freq = state->frequency;
return 0; return 0;
} }
...@@ -2142,6 +2164,9 @@ static int mt2063_get_bandwidth(struct dvb_frontend *fe, u32 *bw) ...@@ -2142,6 +2164,9 @@ static int mt2063_get_bandwidth(struct dvb_frontend *fe, u32 *bw)
dprintk(2, "\n"); dprintk(2, "\n");
if (!state->init)
return -ENODEV;
*bw = state->AS_Data.f_out_bw - 750000; *bw = state->AS_Data.f_out_bw - 750000;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment