2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2025-01-03 19:24:02 +08:00

[media] xc5000: Don't try forever to load the firmware

With the current code, if something bad happens during the
firmware init process, the device will keep trying forever,
and removing it would cause an OOPS.

Instead, try only a limited amount of time. If not, fails.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
This commit is contained in:
Mauro Carvalho Chehab 2014-07-30 10:36:32 -03:00
parent 2fcfd317f6
commit 2621c0b322

View File

@ -1101,16 +1101,17 @@ static int xc5000_get_status(struct dvb_frontend *fe, u32 *status)
static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe, int force) static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe, int force)
{ {
struct xc5000_priv *priv = fe->tuner_priv; struct xc5000_priv *priv = fe->tuner_priv;
int ret = 0; int ret, i;
u16 pll_lock_status; u16 pll_lock_status;
u16 fw_ck; u16 fw_ck;
cancel_delayed_work(&priv->timer_sleep); cancel_delayed_work(&priv->timer_sleep);
if (force || xc5000_is_firmware_loaded(fe) != 0) { if (!force && xc5000_is_firmware_loaded(fe) == 0)
return 0;
fw_retry:
/* Try up to 5 times to load firmware */
for (i = 0; i < 5; i++) {
ret = xc5000_fwupload(fe); ret = xc5000_fwupload(fe);
if (ret != 0) if (ret != 0)
return ret; return ret;
@ -1118,25 +1119,25 @@ fw_retry:
msleep(20); msleep(20);
if (priv->fw_checksum_supported) { if (priv->fw_checksum_supported) {
if (xc5000_readreg(priv, XREG_FW_CHECKSUM, &fw_ck) if (xc5000_readreg(priv, XREG_FW_CHECKSUM, &fw_ck)) {
!= 0) {
dprintk(1, "%s() FW checksum reading failed.\n", dprintk(1, "%s() FW checksum reading failed.\n",
__func__); __func__);
goto fw_retry; continue;
} }
if (fw_ck == 0) { if (!fw_ck) {
dprintk(1, "%s() FW checksum failed = 0x%04x\n", dprintk(1, "%s() FW checksum failed = 0x%04x\n",
__func__, fw_ck); __func__, fw_ck);
goto fw_retry; continue;
} }
} }
/* Start the tuner self-calibration process */ /* Start the tuner self-calibration process */
ret |= xc_initialize(priv); ret = xc_initialize(priv);
if (ret) {
if (ret != 0) dprintk(1, "Can't request Self-callibration. Reloading firmware\n");
goto fw_retry; continue;
}
/* Wait for calibration to complete. /* Wait for calibration to complete.
* We could continue but XC5000 will clock stretch subsequent * We could continue but XC5000 will clock stretch subsequent
@ -1146,15 +1147,15 @@ fw_retry:
msleep(100); msleep(100);
if (priv->init_status_supported) { if (priv->init_status_supported) {
if (xc5000_readreg(priv, XREG_INIT_STATUS, &fw_ck) != 0) { if (xc5000_readreg(priv, XREG_INIT_STATUS, &fw_ck)) {
dprintk(1, "%s() FW failed reading init status.\n", dprintk(1, "%s() FW failed reading init status.\n",
__func__); __func__);
goto fw_retry; continue;
} }
if (fw_ck == 0) { if (!fw_ck) {
dprintk(1, "%s() FW init status failed = 0x%04x\n", __func__, fw_ck); dprintk(1, "%s() FW init status failed = 0x%04x\n", __func__, fw_ck);
goto fw_retry; continue;
} }
} }
@ -1164,12 +1165,13 @@ fw_retry:
if (pll_lock_status > 63) { if (pll_lock_status > 63) {
/* PLL is unlocked, force reload of the firmware */ /* PLL is unlocked, force reload of the firmware */
printk(KERN_ERR "xc5000: PLL not running after fwload.\n"); printk(KERN_ERR "xc5000: PLL not running after fwload.\n");
goto fw_retry; continue;
} }
} }
/* Default to "CABLE" mode */ /* Default to "CABLE" mode */
ret |= xc_write_reg(priv, XREG_SIGNALSOURCE, XC_RF_MODE_CABLE); ret = xc_write_reg(priv, XREG_SIGNALSOURCE, XC_RF_MODE_CABLE);
break;
} }
return ret; return ret;