Commit 704a28e8 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] drxk: prevent doing something wrong when init is not ok

If firmware is not loaded for some reason, or if it is not ready
yet, it makes no sense to honour to any DVB callbacks.

So, return -EAGAIN, as the error condition may be temporary.
If the device doesn't initialize, either because it requires a
firmware or because there's an error during init_drxk, returns
-ENODEV, to indicate such error, on all DVB callbacks.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 20bfe7ae
...@@ -2851,7 +2851,7 @@ static int ConfigureI2CBridge(struct drxk_state *state, bool bEnableBridge) ...@@ -2851,7 +2851,7 @@ static int ConfigureI2CBridge(struct drxk_state *state, bool bEnableBridge)
dprintk(1, "\n"); dprintk(1, "\n");
if (state->m_DrxkState == DRXK_UNINITIALIZED) if (state->m_DrxkState == DRXK_UNINITIALIZED)
goto error; return 0;
if (state->m_DrxkState == DRXK_POWERED_DOWN) if (state->m_DrxkState == DRXK_POWERED_DOWN)
goto error; goto error;
...@@ -6197,6 +6197,7 @@ static int init_drxk(struct drxk_state *state) ...@@ -6197,6 +6197,7 @@ static int init_drxk(struct drxk_state *state)
} }
error: error:
if (status < 0) { if (status < 0) {
state->m_DrxkState = DRXK_NO_DEV;
drxk_i2c_unlock(state); drxk_i2c_unlock(state);
printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__); printk(KERN_ERR "drxk: Error %d on %s\n", status, __func__);
} }
...@@ -6209,6 +6210,7 @@ static void load_firmware_cb(const struct firmware *fw, ...@@ -6209,6 +6210,7 @@ static void load_firmware_cb(const struct firmware *fw,
{ {
struct drxk_state *state = context; struct drxk_state *state = context;
dprintk(1, ": %s\n", fw ? "firmware loaded" : "firmware not loaded");
if (!fw) { if (!fw) {
printk(KERN_ERR printk(KERN_ERR
"drxk: Could not load firmware file %s.\n", "drxk: Could not load firmware file %s.\n",
...@@ -6250,6 +6252,12 @@ static int drxk_sleep(struct dvb_frontend *fe) ...@@ -6250,6 +6252,12 @@ static int drxk_sleep(struct dvb_frontend *fe)
struct drxk_state *state = fe->demodulator_priv; struct drxk_state *state = fe->demodulator_priv;
dprintk(1, "\n"); dprintk(1, "\n");
if (state->m_DrxkState == DRXK_NO_DEV)
return -ENODEV;
if (state->m_DrxkState == DRXK_UNINITIALIZED)
return 0;
ShutDown(state); ShutDown(state);
return 0; return 0;
} }
...@@ -6259,6 +6267,10 @@ static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable) ...@@ -6259,6 +6267,10 @@ static int drxk_gate_ctrl(struct dvb_frontend *fe, int enable)
struct drxk_state *state = fe->demodulator_priv; struct drxk_state *state = fe->demodulator_priv;
dprintk(1, "%s\n", enable ? "enable" : "disable"); dprintk(1, "%s\n", enable ? "enable" : "disable");
if (state->m_DrxkState == DRXK_NO_DEV)
return -ENODEV;
return ConfigureI2CBridge(state, enable ? true : false); return ConfigureI2CBridge(state, enable ? true : false);
} }
...@@ -6271,6 +6283,12 @@ static int drxk_set_parameters(struct dvb_frontend *fe) ...@@ -6271,6 +6283,12 @@ static int drxk_set_parameters(struct dvb_frontend *fe)
dprintk(1, "\n"); dprintk(1, "\n");
if (state->m_DrxkState == DRXK_NO_DEV)
return -ENODEV;
if (state->m_DrxkState == DRXK_UNINITIALIZED)
return -EAGAIN;
if (!fe->ops.tuner_ops.get_if_frequency) { if (!fe->ops.tuner_ops.get_if_frequency) {
printk(KERN_ERR printk(KERN_ERR
"drxk: Error: get_if_frequency() not defined at tuner. Can't work without it!\n"); "drxk: Error: get_if_frequency() not defined at tuner. Can't work without it!\n");
...@@ -6324,6 +6342,12 @@ static int drxk_read_status(struct dvb_frontend *fe, fe_status_t *status) ...@@ -6324,6 +6342,12 @@ static int drxk_read_status(struct dvb_frontend *fe, fe_status_t *status)
u32 stat; u32 stat;
dprintk(1, "\n"); dprintk(1, "\n");
if (state->m_DrxkState == DRXK_NO_DEV)
return -ENODEV;
if (state->m_DrxkState == DRXK_UNINITIALIZED)
return -EAGAIN;
*status = 0; *status = 0;
GetLockStatus(state, &stat, 0); GetLockStatus(state, &stat, 0);
if (stat == MPEG_LOCK) if (stat == MPEG_LOCK)
...@@ -6337,8 +6361,15 @@ static int drxk_read_status(struct dvb_frontend *fe, fe_status_t *status) ...@@ -6337,8 +6361,15 @@ static int drxk_read_status(struct dvb_frontend *fe, fe_status_t *status)
static int drxk_read_ber(struct dvb_frontend *fe, u32 *ber) static int drxk_read_ber(struct dvb_frontend *fe, u32 *ber)
{ {
struct drxk_state *state = fe->demodulator_priv;
dprintk(1, "\n"); dprintk(1, "\n");
if (state->m_DrxkState == DRXK_NO_DEV)
return -ENODEV;
if (state->m_DrxkState == DRXK_UNINITIALIZED)
return -EAGAIN;
*ber = 0; *ber = 0;
return 0; return 0;
} }
...@@ -6350,6 +6381,12 @@ static int drxk_read_signal_strength(struct dvb_frontend *fe, ...@@ -6350,6 +6381,12 @@ static int drxk_read_signal_strength(struct dvb_frontend *fe,
u32 val = 0; u32 val = 0;
dprintk(1, "\n"); dprintk(1, "\n");
if (state->m_DrxkState == DRXK_NO_DEV)
return -ENODEV;
if (state->m_DrxkState == DRXK_UNINITIALIZED)
return -EAGAIN;
ReadIFAgc(state, &val); ReadIFAgc(state, &val);
*strength = val & 0xffff; *strength = val & 0xffff;
return 0; return 0;
...@@ -6361,6 +6398,12 @@ static int drxk_read_snr(struct dvb_frontend *fe, u16 *snr) ...@@ -6361,6 +6398,12 @@ static int drxk_read_snr(struct dvb_frontend *fe, u16 *snr)
s32 snr2; s32 snr2;
dprintk(1, "\n"); dprintk(1, "\n");
if (state->m_DrxkState == DRXK_NO_DEV)
return -ENODEV;
if (state->m_DrxkState == DRXK_UNINITIALIZED)
return -EAGAIN;
GetSignalToNoise(state, &snr2); GetSignalToNoise(state, &snr2);
*snr = snr2 & 0xffff; *snr = snr2 & 0xffff;
return 0; return 0;
...@@ -6372,6 +6415,12 @@ static int drxk_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) ...@@ -6372,6 +6415,12 @@ static int drxk_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
u16 err; u16 err;
dprintk(1, "\n"); dprintk(1, "\n");
if (state->m_DrxkState == DRXK_NO_DEV)
return -ENODEV;
if (state->m_DrxkState == DRXK_UNINITIALIZED)
return -EAGAIN;
DVBTQAMGetAccPktErr(state, &err); DVBTQAMGetAccPktErr(state, &err);
*ucblocks = (u32) err; *ucblocks = (u32) err;
return 0; return 0;
...@@ -6380,9 +6429,16 @@ static int drxk_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) ...@@ -6380,9 +6429,16 @@ static int drxk_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
static int drxk_get_tune_settings(struct dvb_frontend *fe, struct dvb_frontend_tune_settings static int drxk_get_tune_settings(struct dvb_frontend *fe, struct dvb_frontend_tune_settings
*sets) *sets)
{ {
struct drxk_state *state = fe->demodulator_priv;
struct dtv_frontend_properties *p = &fe->dtv_property_cache; struct dtv_frontend_properties *p = &fe->dtv_property_cache;
dprintk(1, "\n"); dprintk(1, "\n");
if (state->m_DrxkState == DRXK_NO_DEV)
return -ENODEV;
if (state->m_DrxkState == DRXK_UNINITIALIZED)
return -EAGAIN;
switch (p->delivery_system) { switch (p->delivery_system) {
case SYS_DVBC_ANNEX_A: case SYS_DVBC_ANNEX_A:
case SYS_DVBC_ANNEX_C: case SYS_DVBC_ANNEX_C:
......
...@@ -94,7 +94,15 @@ enum DRXPowerMode { ...@@ -94,7 +94,15 @@ enum DRXPowerMode {
enum AGC_CTRL_MODE { DRXK_AGC_CTRL_AUTO = 0, DRXK_AGC_CTRL_USER, DRXK_AGC_CTRL_OFF }; enum AGC_CTRL_MODE { DRXK_AGC_CTRL_AUTO = 0, DRXK_AGC_CTRL_USER, DRXK_AGC_CTRL_OFF };
enum EDrxkState { DRXK_UNINITIALIZED = 0, DRXK_STOPPED, DRXK_DTV_STARTED, DRXK_ATV_STARTED, DRXK_POWERED_DOWN }; enum EDrxkState {
DRXK_UNINITIALIZED = 0,
DRXK_STOPPED,
DRXK_DTV_STARTED,
DRXK_ATV_STARTED,
DRXK_POWERED_DOWN,
DRXK_NO_DEV /* If drxk init failed */
};
enum EDrxkCoefArrayIndex { enum EDrxkCoefArrayIndex {
DRXK_COEF_IDX_MN = 0, DRXK_COEF_IDX_MN = 0,
DRXK_COEF_IDX_FM , DRXK_COEF_IDX_FM ,
......
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