Commit 5264a522 authored by Shuah Khan's avatar Shuah Khan Committed by Mauro Carvalho Chehab

[media] media: tuner xc5000 - release firmwware from xc5000_release()

xc5000 releases firmware right after loading it. Change it to
save the firmware and release it from xc5000_release(). This
helps avoid fecthing firmware when forced firmware load requests
come in to change analog tv frequence and when firmware needs to
be reloaded after suspend and resume.
Signed-off-by: default avatarShuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 8eb988f1
...@@ -70,6 +70,8 @@ struct xc5000_priv { ...@@ -70,6 +70,8 @@ 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;
}; };
/* Misc Defines */ /* Misc Defines */
...@@ -1136,20 +1138,23 @@ static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe, int force) ...@@ -1136,20 +1138,23 @@ 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) {
printk(KERN_ERR "xc5000: Upload failed. (file not found?)\n"); 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) {
printk(KERN_ERR "xc5000: Firmware file with incorrect size\n"); pr_err("xc5000: Firmware file with incorrect size\n");
ret = -EINVAL; release_firmware(fw);
goto err; 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++) {
...@@ -1232,7 +1237,6 @@ static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe, int force) ...@@ -1232,7 +1237,6 @@ static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe, int force)
else else
printk(KERN_CONT " - too many retries. Giving up\n"); printk(KERN_CONT " - too many retries. Giving up\n");
release_firmware(fw);
return ret; return ret;
} }
...@@ -1316,6 +1320,8 @@ static int xc5000_release(struct dvb_frontend *fe) ...@@ -1316,6 +1320,8 @@ static int xc5000_release(struct dvb_frontend *fe)
if (priv) { if (priv) {
cancel_delayed_work(&priv->timer_sleep); cancel_delayed_work(&priv->timer_sleep);
hybrid_tuner_release_state(priv); hybrid_tuner_release_state(priv);
if (priv->firmware)
release_firmware(priv->firmware);
} }
mutex_unlock(&xc5000_list_mutex); mutex_unlock(&xc5000_list_mutex);
......
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