diff mbox series

media: dib0700: fix link error for dibx000_i2c_set_speed

Message ID 20190313211709.486583-1-arnd@arndb.de
State Superseded
Headers show
Series media: dib0700: fix link error for dibx000_i2c_set_speed | expand

Commit Message

Arnd Bergmann March 13, 2019, 9:16 p.m. UTC
When CONFIG_DVB_DIB9000 is disabled, we can still compile code that
now fails to link against dibx000_i2c_set_speed:

drivers/media/usb/dvb-usb/dib0700_devices.o: In function `dib01x0_pmu_update.constprop.7':
dib0700_devices.c:(.text.unlikely+0x1c9c): undefined reference to `dibx000_i2c_set_speed'

The call sites are both through dib01x0_pmu_update(), which gets
passed an 'i2c' pointer from dib9000_get_i2c_master(), which has
returned NULL. Checking this pointer seems to be a good idea
anyway, and it avoids the link failure.

Fixes: b7f54910ce01 ("V4L/DVB (4647): Added module for DiB0700 based devices")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

---
 drivers/media/usb/dvb-usb/dib0700_devices.c | 4 ++++
 1 file changed, 4 insertions(+)

-- 
2.20.0

Comments

Arnd Bergmann June 28, 2019, 12:14 p.m. UTC | #1
On Wed, Apr 3, 2019 at 6:34 PM Sean Young <sean@mess.org> wrote:
>

> On Wed, Mar 13, 2019 at 10:16:53PM +0100, Arnd Bergmann wrote:

> > When CONFIG_DVB_DIB9000 is disabled, we can still compile code that

> > now fails to link against dibx000_i2c_set_speed:

> >

> > drivers/media/usb/dvb-usb/dib0700_devices.o: In function `dib01x0_pmu_update.constprop.7':

> > dib0700_devices.c:(.text.unlikely+0x1c9c): undefined reference to `dibx000_i2c_set_speed'

> >

> > The call sites are both through dib01x0_pmu_update(), which gets

> > passed an 'i2c' pointer from dib9000_get_i2c_master(), which has

> > returned NULL. Checking this pointer seems to be a good idea

> > anyway, and it avoids the link failure.

>

> So I reproduced the link failure with attached config, and your patch

> does not fix it.


I ran into the old problem I reported once more, and checked my
original patch, as well as your configuration file, which indeed shows
the same symptom.

Interestingly, the link error after my patch appears to be the result
of a compiler bug, as the function reference is from dead code that
should have been eliminated. Sending a replacement patch now.

        Arnd
diff mbox series

Patch

diff --git a/drivers/media/usb/dvb-usb/dib0700_devices.c b/drivers/media/usb/dvb-usb/dib0700_devices.c
index 9311f7d4bba5..4cbc64ea17d7 100644
--- a/drivers/media/usb/dvb-usb/dib0700_devices.c
+++ b/drivers/media/usb/dvb-usb/dib0700_devices.c
@@ -2445,6 +2445,8 @@  static int dib9090_tuner_attach(struct dvb_usb_adapter *adap)
 	if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &dib9090_dib0090_config) == NULL)
 		return -ENODEV;
 	i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
+	if (!i2c)
+		return -ENODEV;
 	if (dib01x0_pmu_update(i2c, data_dib190, 10) != 0)
 		return -ENODEV;
 	dib0700_set_i2c_speed(adap->dev, 1500);
@@ -2524,6 +2526,8 @@  static int nim9090md_tuner_attach(struct dvb_usb_adapter *adap)
 	if (dvb_attach(dib0090_fw_register, adap->fe_adap[0].fe, i2c, &nim9090md_dib0090_config[0]) == NULL)
 		return -ENODEV;
 	i2c = dib9000_get_i2c_master(adap->fe_adap[0].fe, DIBX000_I2C_INTERFACE_GPIO_1_2, 0);
+	if (!i2c)
+		return -ENODEV;
 	if (dib01x0_pmu_update(i2c, data_dib190, 10) < 0)
 		return -ENODEV;