All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil-cisco@xs4all.nl>
To: linux-media@vger.kernel.org
Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Subject: [PATCH 10/14] usb/dvb-usb-v2/rtl28xxu.c: clean up code to fix smatch warning
Date: Wed, 20 Jan 2021 10:43:02 +0100	[thread overview]
Message-ID: <20210120094306.784318-11-hverkuil-cisco@xs4all.nl> (raw)
In-Reply-To: <20210120094306.784318-1-hverkuil-cisco@xs4all.nl>

Fixes this smatch warning:

drivers/media/usb/dvb-usb-v2/rtl28xxu.c:1040 rtl2832u_frontend_attach() warn: missing error code 'ret'

It is actually a bogus warning since in this particular case ret isn't
meant to be set. But by reworking the code a bit the code is actually
a lot more understandable and it fixes this warning.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 35 +++++++++----------------
 1 file changed, 13 insertions(+), 22 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
index 3952cc534b4a..97ed17a141bb 100644
--- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
+++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c
@@ -944,12 +944,6 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
 	if (dev->slave_demod) {
 		struct i2c_board_info info = {};
 
-		/*
-		 * We continue on reduced mode, without DVB-T2/C, using master
-		 * demod, when slave demod fails.
-		 */
-		ret = 0;
-
 		/* attach slave demodulator */
 		if (dev->slave_demod == SLAVE_DEMOD_MN88472) {
 			struct mn88472_config mn88472_config = {};
@@ -964,14 +958,11 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
 			info.platform_data = &mn88472_config;
 			request_module(info.type);
 			client = i2c_new_client_device(&d->i2c_adap, &info);
-			if (!i2c_client_has_driver(client)) {
-				dev->slave_demod = SLAVE_DEMOD_NONE;
+			if (!i2c_client_has_driver(client))
 				goto err_slave_demod_failed;
-			}
 
 			if (!try_module_get(client->dev.driver->owner)) {
 				i2c_unregister_device(client);
-				dev->slave_demod = SLAVE_DEMOD_NONE;
 				goto err_slave_demod_failed;
 			}
 
@@ -986,14 +977,11 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
 			info.platform_data = &mn88473_config;
 			request_module(info.type);
 			client = i2c_new_client_device(&d->i2c_adap, &info);
-			if (!i2c_client_has_driver(client)) {
-				dev->slave_demod = SLAVE_DEMOD_NONE;
+			if (!i2c_client_has_driver(client))
 				goto err_slave_demod_failed;
-			}
 
 			if (!try_module_get(client->dev.driver->owner)) {
 				i2c_unregister_device(client);
-				dev->slave_demod = SLAVE_DEMOD_NONE;
 				goto err_slave_demod_failed;
 			}
 
@@ -1009,10 +997,8 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
 			adap->fe[1] = dvb_attach(cxd2841er_attach_t_c,
 						 &cxd2837er_config,
 						 &d->i2c_adap);
-			if (!adap->fe[1]) {
-				dev->slave_demod = SLAVE_DEMOD_NONE;
+			if (!adap->fe[1])
 				goto err_slave_demod_failed;
-			}
 			adap->fe[1]->id = 1;
 			dev->i2c_client_slave_demod = NULL;
 		} else {
@@ -1029,14 +1015,11 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
 			info.platform_data = &si2168_config;
 			request_module(info.type);
 			client = i2c_new_client_device(&d->i2c_adap, &info);
-			if (!i2c_client_has_driver(client)) {
-				dev->slave_demod = SLAVE_DEMOD_NONE;
+			if (!i2c_client_has_driver(client))
 				goto err_slave_demod_failed;
-			}
 
 			if (!try_module_get(client->dev.driver->owner)) {
 				i2c_unregister_device(client);
-				dev->slave_demod = SLAVE_DEMOD_NONE;
 				goto err_slave_demod_failed;
 			}
 
@@ -1047,10 +1030,18 @@ static int rtl2832u_frontend_attach(struct dvb_usb_adapter *adap)
 		}
 	}
 	return 0;
-err_slave_demod_failed:
+
 err:
 	dev_dbg(&d->intf->dev, "failed=%d\n", ret);
 	return ret;
+
+err_slave_demod_failed:
+	/*
+	 * We continue on reduced mode, without DVB-T2/C, using master
+	 * demod, when slave demod fails.
+	 */
+	dev->slave_demod = SLAVE_DEMOD_NONE;
+	return 0;
 }
 
 static int rtl28xxu_frontend_attach(struct dvb_usb_adapter *adap)
-- 
2.29.2


  parent reply	other threads:[~2021-01-20 10:45 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-20  9:42 [PATCH 00/14] Fixes for smatch/sparse/sysbot/compiler warnings Hans Verkuil
2021-01-20  9:42 ` [PATCH 01/14] atomisp/pci/hmm: fix wrong printk format Hans Verkuil
2021-01-20  9:42 ` [PATCH 02/14] v4l2-ctrls.c: fix shift-out-of-bounds in std_validate Hans Verkuil
2021-01-20  9:42 ` [PATCH 03/14] meson/ge2d: set ret to -ENOMEM Hans Verkuil
2021-01-20  9:42 ` [PATCH 04/14] davinci/vpbe.c: ret contains the return code, not err Hans Verkuil
2021-01-20  9:42 ` [PATCH 05/14] tuners/it913x.c: fix missing error code Hans Verkuil
2021-01-20  9:42 ` [PATCH 06/14] i2c/ov8865.c: fix error checks using wrong variable Hans Verkuil
2021-01-23 22:39   ` Sakari Ailus
2021-01-20  9:42 ` [PATCH 07/14] sti/c8sectpfe: set correct return code Hans Verkuil
2021-01-20  9:43 ` [PATCH 08/14] sti/hva: add missing clk_disable_unprepare() Hans Verkuil
2021-01-20  9:43 ` [PATCH 09/14] pci/ivtv: release memory regions on error Hans Verkuil
2021-01-20  9:43 ` Hans Verkuil [this message]
2021-01-20  9:43 ` [PATCH 11/14] dvb-frontends/rtl2832.c: fix missing error code Hans Verkuil
2021-01-20  9:43 ` [PATCH 12/14] dvb-frontends/af9033.c: fix missing error codes Hans Verkuil
2021-01-20  9:43 ` [PATCH 13/14] atomisp/pci: add missing include Hans Verkuil
2021-01-20  9:43 ` [PATCH 14/14] i2c/ov02a10.c: add cast to fix type mismatch Hans Verkuil
2021-01-23 22:36 ` [PATCH 00/14] Fixes for smatch/sparse/sysbot/compiler warnings Sakari Ailus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210120094306.784318-11-hverkuil-cisco@xs4all.nl \
    --to=hverkuil-cisco@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.