Commit 8e1f5da5 authored by Ricardo Ribalda's avatar Ricardo Ribalda Committed by Hans Verkuil
Browse files

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: default avatarRicardo Ribalda <ribalda@chromium.org>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
parent cf8da329
Loading
Loading
Loading
Loading
+17 −22
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ struct xc5000_priv {
	struct dvb_frontend *fe;
	struct delayed_work timer_sleep;

	const struct firmware   *firmware;
	bool inited;
};

/* Misc Defines */
@@ -1110,7 +1110,6 @@ static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe, int force)
	if (!force && xc5000_is_firmware_loaded(fe) == 0)
		return 0;

	if (!priv->firmware) {
	ret = request_firmware(&fw, desired_fw->name,
			       priv->i2c_props.adap->dev.parent);
	if (ret) {
@@ -1124,9 +1123,6 @@ static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe, int force)
		release_firmware(fw);
		return -EINVAL;
	}
		priv->firmware = fw;
	} else
		fw = priv->firmware;

	/* Try up to 5 times to load firmware */
	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:
	release_firmware(fw);
	if (!ret)
		printk(KERN_INFO "xc5000: Firmware %s loaded and running.\n",
		       desired_fw->name);
@@ -1274,7 +1271,7 @@ static int xc5000_resume(struct dvb_frontend *fe)

	/* suspended before firmware is loaded.
	   Avoid firmware load in resume path. */
	if (!priv->firmware)
	if (!priv->inited)
		return 0;

	return xc5000_set_params(fe);
@@ -1293,6 +1290,8 @@ static int xc5000_init(struct dvb_frontend *fe)
	if (debug)
		xc_debug_dump(priv);

	priv->inited = true;

	return 0;
}

@@ -1306,10 +1305,6 @@ static void xc5000_release(struct dvb_frontend *fe)

	if (priv) {
		cancel_delayed_work(&priv->timer_sleep);
		if (priv->firmware) {
			release_firmware(priv->firmware);
			priv->firmware = NULL;
		}
		hybrid_tuner_release_state(priv);
	}