* [PATCH RFC] [media] dib0700: remove redundant else
@ 2016-10-08 12:03 Nicholas Mc Guire
2016-10-10 9:30 ` Mauro Carvalho Chehab
0 siblings, 1 reply; 3+ messages in thread
From: Nicholas Mc Guire @ 2016-10-08 12:03 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Alejandro Torrado, Nicolas Sugino, linux-media, linux-kernel,
Nicholas Mc Guire
The if and else are identical and can be consolidated here.
Fixes: commit 91be260faaf8 ("[media] dib8000: Add support for Mygica/Geniatech S2870")
Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
---
Problem found by coccinelle script
Based only on reviewing this driver it seems that the dib0090_config
is not an array and thus this is a cut&past bug - but not having access
to the driver I can not say. Other cases that have the
conditioning on (adap->id == 0) e.g. dib7070p_dib0070 actually have
a config array (dib7070p_dib0070_config[]). So the if/else here most
likely is unnecessary.
The patch is actually a partial revert of commit 91be260faaf8 ("[media]
dib8000: Add support for Mygica/Geniatech S2870") where this if/else
was deliberately introduced but without any specific comments.
This needs a review by someone that has access to the details of the driver.
Patch was compile tested with: x86_64_defconfig + CONFIG_MEDIA_SUPPORT=m,
CONFIG_MEDIA_USB_SUPPORT=y, CONFIG_MEDIA_DIGITAL_TV_SUPPORT=y,
CONFIG_DVB_USB=m, CONFIG_DVB_USB_V2=m, CONFIG_MEDIA_RC_SUPPORT=y,
CONFIG_DVB_USB_DIB0700=m
Patch is against 4.8.0 (localversion-next is -next-20161006)
drivers/media/usb/dvb-usb/dib0700_devices.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/media/usb/dvb-usb/dib0700_devices.c b/drivers/media/usb/dvb-usb/dib0700_devices.c
index 0857b56..3cd8566 100644
--- a/drivers/media/usb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/usb/dvb-usb/dib0700_devices.c
@@ -1736,13 +1736,9 @@ static int dib809x_tuner_attach(struct dvb_usb_adapter *adap)
struct dib0700_adapter_state *st = adap->priv;
struct i2c_adapter *tun_i2c = st->dib8000_ops.get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1);
- if (adap->id == 0) {
- if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
- return -ENODEV;
- } else {
- if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL)
- return -ENODEV;
- }
+ if (dvb_attach(dib0090_register, adap->fe_adap[0].fe,
+ tun_i2c, &dib809x_dib0090_config) == NULL)
+ return -ENODEV;
st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params;
adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override;
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH RFC] [media] dib0700: remove redundant else 2016-10-08 12:03 [PATCH RFC] [media] dib0700: remove redundant else Nicholas Mc Guire @ 2016-10-10 9:30 ` Mauro Carvalho Chehab 2016-10-10 9:41 ` Patrick Boettcher 0 siblings, 1 reply; 3+ messages in thread From: Mauro Carvalho Chehab @ 2016-10-10 9:30 UTC (permalink / raw) To: Nicholas Mc Guire Cc: Mauro Carvalho Chehab, Alejandro Torrado, Nicolas Sugino, linux-media, linux-kernel, Patrick Boettcher Em Sat, 8 Oct 2016 14:03:19 +0200 Nicholas Mc Guire <hofrat@osadl.org> escreveu: > The if and else are identical and can be consolidated here. > > Fixes: commit 91be260faaf8 ("[media] dib8000: Add support for Mygica/Geniatech S2870") > > Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org> > --- > > Problem found by coccinelle script > > Based only on reviewing this driver it seems that the dib0090_config > is not an array and thus this is a cut&past bug - but not having access > to the driver I can not say. Other cases that have the > conditioning on (adap->id == 0) e.g. dib7070p_dib0070 actually have > a config array (dib7070p_dib0070_config[]). So the if/else here most > likely is unnecessary. > > The patch is actually a partial revert of commit 91be260faaf8 ("[media] > dib8000: Add support for Mygica/Geniatech S2870") where this if/else > was deliberately introduced but without any specific comments. > > This needs a review by someone that has access to the details of the driver. > > Patch was compile tested with: x86_64_defconfig + CONFIG_MEDIA_SUPPORT=m, > CONFIG_MEDIA_USB_SUPPORT=y, CONFIG_MEDIA_DIGITAL_TV_SUPPORT=y, > CONFIG_DVB_USB=m, CONFIG_DVB_USB_V2=m, CONFIG_MEDIA_RC_SUPPORT=y, > CONFIG_DVB_USB_DIB0700=m > > Patch is against 4.8.0 (localversion-next is -next-20161006) > > drivers/media/usb/dvb-usb/dib0700_devices.c | 10 +++------- > 1 file changed, 3 insertions(+), 7 deletions(-) > > diff --git a/drivers/media/usb/dvb-usb/dib0700_devices.c b/drivers/media/usb/dvb-usb/dib0700_devices.c > index 0857b56..3cd8566 100644 > --- a/drivers/media/usb/dvb-usb/dib0700_devices.c > +++ b/drivers/media/usb/dvb-usb/dib0700_devices.c > @@ -1736,13 +1736,9 @@ static int dib809x_tuner_attach(struct dvb_usb_adapter *adap) > struct dib0700_adapter_state *st = adap->priv; > struct i2c_adapter *tun_i2c = st->dib8000_ops.get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1); > > - if (adap->id == 0) { > - if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL) > - return -ENODEV; > - } else { > - if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL) > - return -ENODEV; > - } > + if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, > + tun_i2c, &dib809x_dib0090_config) == NULL) > + return -ENODEV; I suspect that this patch is wrong. It should be, instead, using fe_adap[1] on the else. Patrick, Could you please take a look? Regards, Thanks, Mauro ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RFC] [media] dib0700: remove redundant else 2016-10-10 9:30 ` Mauro Carvalho Chehab @ 2016-10-10 9:41 ` Patrick Boettcher 0 siblings, 0 replies; 3+ messages in thread From: Patrick Boettcher @ 2016-10-10 9:41 UTC (permalink / raw) To: Mauro Carvalho Chehab Cc: Nicholas Mc Guire, Mauro Carvalho Chehab, Alejandro Torrado, Nicolas Sugino, linux-media, linux-kernel On Mon, 10 Oct 2016 06:30:35 -0300 Mauro Carvalho Chehab <mchehab@s-opensource.com> wrote: > > drivers/media/usb/dvb-usb/dib0700_devices.c | 10 +++------- > > 1 file changed, 3 insertions(+), 7 deletions(-) > > > > diff --git a/drivers/media/usb/dvb-usb/dib0700_devices.c > > b/drivers/media/usb/dvb-usb/dib0700_devices.c index > > 0857b56..3cd8566 100644 --- > > a/drivers/media/usb/dvb-usb/dib0700_devices.c +++ > > b/drivers/media/usb/dvb-usb/dib0700_devices.c @@ -1736,13 +1736,9 > > @@ static int dib809x_tuner_attach(struct dvb_usb_adapter *adap) > > struct dib0700_adapter_state *st = adap->priv; struct i2c_adapter > > *tun_i2c = st->dib8000_ops.get_i2c_master(adap->fe_adap[0].fe, > > DIBX000_I2C_INTERFACE_TUNER, 1); > > - if (adap->id == 0) { > > - if (dvb_attach(dib0090_register, > > adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL) > > - return -ENODEV; > > - } else { > > - if (dvb_attach(dib0090_register, > > adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL) > > - return -ENODEV; > > - } > > + if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, > > + tun_i2c, &dib809x_dib0090_config) == NULL) > > + return -ENODEV; > > > I suspect that this patch is wrong. It should be, instead, using > fe_adap[1] on the else. > > Patrick, > > Could you please take a look? I think you're right, it should be fe_adap[1], but I have lost track of these devices and don't know the correct answer. However, this code was introduced by commit 91be260faaf8561dc51e72033c346f6ab28d40d8 Author: Nicolas Sugino <nsugino@3way.com.ar> Date: Thu Nov 26 19:00:28 2015 -0200 [media] dib8000: Add support for Mygica/Geniatech S2870 MyGica/Geniatech S2870 is very similar to the S870 but with dual tuner. The card is recognised as Geniatech STK8096-PVR. [mchehab@osg.samsung.com: Fix some checkpatch.pl issues] Signed-off-by: Nicolas Sugino <nsugino@3way.com.ar> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com> diff --git a/drivers/media/usb/dvb-usb/dib0700_devices.c b/drivers/media/usb/dvb-usb/dib0700_devices.c index 7ed4964..ea0391e 100644 --- a/drivers/media/usb/dvb-usb/dib0700_devices.c +++ b/drivers/media/usb/dvb-usb/dib0700_devices.c @@ -1736,8 +1736,13 @@ static int dib809x_tuner_attach(struct dvb_usb_adapter *adap) struct dib0700_adapter_state *st = adap->priv; struct i2c_adapter *tun_i2c = st->dib8000_ops.get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_TUNER, 1); - if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL) - return -ENODEV; + if (adap->id == 0) { + if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL) + return -ENODEV; + } else { + if (dvb_attach(dib0090_register, adap->fe_adap[0].fe, tun_i2c, &dib809x_dib0090_config) == NULL) + return -ENODEV; + } st->set_param_save = adap->fe_adap[0].fe->ops.tuner_ops.set_params; adap->fe_adap[0].fe->ops.tuner_ops.set_params = dib8096_set_param_override; [..] Maybe Nicolas can help (and test). -- Patrick. ^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-10-10 9:41 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-10-08 12:03 [PATCH RFC] [media] dib0700: remove redundant else Nicholas Mc Guire 2016-10-10 9:30 ` Mauro Carvalho Chehab 2016-10-10 9:41 ` Patrick Boettcher
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).