Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] zd1301: fix building interface driver without demodulator

If the USB driver is enabled but the demodulator is not, we get a link error:

ERROR: "zd1301_demod_get_dvb_frontend" [drivers/media/usb/dvb-usb-v2/zd1301.ko] undefined!
ERROR: "zd1301_demod_get_i2c_adapter" [drivers/media/usb/dvb-usb-v2/zd1301.ko] undefined!

Such a configuration obviously makes no sense, but we should not fail
the build. This tries to mimic what we have for other drivers by turning
the build failure into a runtime failure.

Alternatively we could use an unconditional 'select' or 'depends on' to enforce
a sane configuration.

Fixes: 47d65372b3b6 ("[media] zd1301_demod: ZyDAS ZD1301 DVB-T demodulator driver")
Fixes: 992b39872b80 ("[media] zd1301: ZyDAS ZD1301 DVB USB interface driver")

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

authored by

Arnd Bergmann and committed by
Mauro Carvalho Chehab
0d1270df 9165ba16

+22
+18
drivers/media/dvb-frontends/zd1301_demod.h
··· 34 34 int (*reg_write)(void *, u16, u8); 35 35 }; 36 36 37 + #if IS_REACHABLE(CONFIG_DVB_ZD1301_DEMOD) 37 38 /** 38 39 * zd1301_demod_get_dvb_frontend() - Get pointer to DVB frontend 39 40 * @pdev: Pointer to platform device ··· 52 51 */ 53 52 54 53 struct i2c_adapter *zd1301_demod_get_i2c_adapter(struct platform_device *); 54 + 55 + #else 56 + 57 + static inline struct dvb_frontend *zd1301_demod_get_dvb_frontend(struct platform_device *dev) 58 + { 59 + printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 60 + 61 + return NULL; 62 + } 63 + static inline struct i2c_adapter *zd1301_demod_get_i2c_adapter(struct platform_device *dev) 64 + { 65 + printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 66 + 67 + return NULL; 68 + } 69 + 70 + #endif 55 71 56 72 #endif /* ZD1301_DEMOD_H */
+4
drivers/media/usb/dvb-usb-v2/zd1301.c
··· 168 168 169 169 adapter = zd1301_demod_get_i2c_adapter(pdev); 170 170 frontend = zd1301_demod_get_dvb_frontend(pdev); 171 + if (!adapter || !frontend) { 172 + ret = -ENODEV; 173 + goto err_module_put_demod; 174 + } 171 175 172 176 /* Add I2C tuner */ 173 177 dev->mt2060_pdata.i2c_write_max = 9;