Skip to content

Commit

Permalink
[media] zd1301: fix building interface driver without demodulator
Browse files Browse the repository at this point in the history
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: 47d6537 ("[media] zd1301_demod: ZyDAS ZD1301 DVB-T demodulator driver")
Fixes: 992b398 ("[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>
  • Loading branch information
Arnd Bergmann authored and Mauro Carvalho Chehab committed Feb 8, 2017
1 parent 9165ba1 commit 0d1270d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
18 changes: 18 additions & 0 deletions drivers/media/dvb-frontends/zd1301_demod.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ struct zd1301_demod_platform_data {
int (*reg_write)(void *, u16, u8);
};

#if IS_REACHABLE(CONFIG_DVB_ZD1301_DEMOD)
/**
* zd1301_demod_get_dvb_frontend() - Get pointer to DVB frontend
* @pdev: Pointer to platform device
Expand All @@ -52,4 +53,21 @@ struct dvb_frontend *zd1301_demod_get_dvb_frontend(struct platform_device *);

struct i2c_adapter *zd1301_demod_get_i2c_adapter(struct platform_device *);

#else

static inline struct dvb_frontend *zd1301_demod_get_dvb_frontend(struct platform_device *dev)
{
printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);

return NULL;
}
static inline struct i2c_adapter *zd1301_demod_get_i2c_adapter(struct platform_device *dev)
{
printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);

return NULL;
}

#endif

#endif /* ZD1301_DEMOD_H */
4 changes: 4 additions & 0 deletions drivers/media/usb/dvb-usb-v2/zd1301.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ static int zd1301_frontend_attach(struct dvb_usb_adapter *adap)

adapter = zd1301_demod_get_i2c_adapter(pdev);
frontend = zd1301_demod_get_dvb_frontend(pdev);
if (!adapter || !frontend) {
ret = -ENODEV;
goto err_module_put_demod;
}

/* Add I2C tuner */
dev->mt2060_pdata.i2c_write_max = 9;
Expand Down

0 comments on commit 0d1270d

Please sign in to comment.