media: tunner: xc5000: Refactor firmware load
Make sure the firmware is released when we leave xc_load_fw_and_init_tuner() This change makes smatch happy: drivers/media/tuners/xc5000.c:1213 xc_load_fw_and_init_tuner() warn: 'fw' from request_firmware() not released on lines: 1213. Cc: Shuah Khan <shuah.kh@samsung.com> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
This commit is contained in:
parent
cf8da3293b
commit
8e1f5da59d
@ -58,7 +58,7 @@ struct xc5000_priv {
|
|||||||
struct dvb_frontend *fe;
|
struct dvb_frontend *fe;
|
||||||
struct delayed_work timer_sleep;
|
struct delayed_work timer_sleep;
|
||||||
|
|
||||||
const struct firmware *firmware;
|
bool inited;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Misc Defines */
|
/* Misc Defines */
|
||||||
@ -1110,23 +1110,19 @@ static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe, int force)
|
|||||||
if (!force && xc5000_is_firmware_loaded(fe) == 0)
|
if (!force && xc5000_is_firmware_loaded(fe) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!priv->firmware) {
|
ret = request_firmware(&fw, desired_fw->name,
|
||||||
ret = request_firmware(&fw, desired_fw->name,
|
priv->i2c_props.adap->dev.parent);
|
||||||
priv->i2c_props.adap->dev.parent);
|
if (ret) {
|
||||||
if (ret) {
|
pr_err("xc5000: Upload failed. rc %d\n", ret);
|
||||||
pr_err("xc5000: Upload failed. rc %d\n", ret);
|
return ret;
|
||||||
return ret;
|
}
|
||||||
}
|
dprintk(1, "firmware read %zu bytes.\n", fw->size);
|
||||||
dprintk(1, "firmware read %zu bytes.\n", fw->size);
|
|
||||||
|
|
||||||
if (fw->size != desired_fw->size) {
|
if (fw->size != desired_fw->size) {
|
||||||
pr_err("xc5000: Firmware file with incorrect size\n");
|
pr_err("xc5000: Firmware file with incorrect size\n");
|
||||||
release_firmware(fw);
|
release_firmware(fw);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
priv->firmware = fw;
|
|
||||||
} else
|
|
||||||
fw = priv->firmware;
|
|
||||||
|
|
||||||
/* Try up to 5 times to load firmware */
|
/* Try up to 5 times to load firmware */
|
||||||
for (i = 0; i < 5; i++) {
|
for (i = 0; i < 5; i++) {
|
||||||
@ -1204,6 +1200,7 @@ static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe, int force)
|
|||||||
}
|
}
|
||||||
|
|
||||||
err:
|
err:
|
||||||
|
release_firmware(fw);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
printk(KERN_INFO "xc5000: Firmware %s loaded and running.\n",
|
printk(KERN_INFO "xc5000: Firmware %s loaded and running.\n",
|
||||||
desired_fw->name);
|
desired_fw->name);
|
||||||
@ -1274,7 +1271,7 @@ static int xc5000_resume(struct dvb_frontend *fe)
|
|||||||
|
|
||||||
/* suspended before firmware is loaded.
|
/* suspended before firmware is loaded.
|
||||||
Avoid firmware load in resume path. */
|
Avoid firmware load in resume path. */
|
||||||
if (!priv->firmware)
|
if (!priv->inited)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return xc5000_set_params(fe);
|
return xc5000_set_params(fe);
|
||||||
@ -1293,6 +1290,8 @@ static int xc5000_init(struct dvb_frontend *fe)
|
|||||||
if (debug)
|
if (debug)
|
||||||
xc_debug_dump(priv);
|
xc_debug_dump(priv);
|
||||||
|
|
||||||
|
priv->inited = true;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1306,10 +1305,6 @@ static void xc5000_release(struct dvb_frontend *fe)
|
|||||||
|
|
||||||
if (priv) {
|
if (priv) {
|
||||||
cancel_delayed_work(&priv->timer_sleep);
|
cancel_delayed_work(&priv->timer_sleep);
|
||||||
if (priv->firmware) {
|
|
||||||
release_firmware(priv->firmware);
|
|
||||||
priv->firmware = NULL;
|
|
||||||
}
|
|
||||||
hybrid_tuner_release_state(priv);
|
hybrid_tuner_release_state(priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user