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

[media] stv090x: remove export symbol for stv090x_set_gpio()

Drivers that use dvb_attach can have just one exported symbol,
or they will cause compilation breakages depending on the
selected frontends.

As Jim reported:
drivers/built-in.o: In function `technisat_usb2_set_voltage':
technisat-usb2.c:(.text+0x3b4919): undefined reference to `stv090x_set_gpio'
make: *** [vmlinux] Error 1

That happens because, on his configuration, the configuration
is:

CONFIG_DVB_USB=y
CONFIG_DVB_STV090x=m

Luis proposed ar way to fix, but that would just force the
STV090x to be selected, even if one wants to use a device
with a different frontend.

Instead, let's do the right thing: move set_gpio to the
configuration structure and fill it during dvb_attach().

This way, the driver can still call it, and dvb_attach()
will load stv090x module only if the device really needs it.

Reported by: Jim Davis <jim.epost@gmail.com>

Cc: Luis Rodriguez <mcgrof@suse.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

+14 -16
+5 -4
drivers/media/dvb-frontends/stv090x.c
··· 4870 4870 return -1; 4871 4871 } 4872 4872 4873 - int stv090x_set_gpio(struct dvb_frontend *fe, u8 gpio, u8 dir, u8 value, 4874 - u8 xor_value) 4873 + static int stv090x_set_gpio(struct dvb_frontend *fe, u8 gpio, u8 dir, 4874 + u8 value, u8 xor_value) 4875 4875 { 4876 4876 struct stv090x_state *state = fe->demodulator_priv; 4877 4877 u8 reg = 0; ··· 4882 4882 4883 4883 return stv090x_write_reg(state, STV090x_GPIOxCFG(gpio), reg); 4884 4884 } 4885 - EXPORT_SYMBOL(stv090x_set_gpio); 4886 4885 4887 4886 static struct dvb_frontend_ops stv090x_ops = { 4888 4887 .delsys = { SYS_DVBS, SYS_DVBS2, SYS_DSS }, ··· 4918 4919 }; 4919 4920 4920 4921 4921 - struct dvb_frontend *stv090x_attach(const struct stv090x_config *config, 4922 + struct dvb_frontend *stv090x_attach(struct stv090x_config *config, 4922 4923 struct i2c_adapter *i2c, 4923 4924 enum stv090x_demodulator demod) 4924 4925 { ··· 4978 4979 /* workaround for stuck DiSEqC output */ 4979 4980 if (config->diseqc_envelope_mode) 4980 4981 stv090x_send_diseqc_burst(&state->frontend, SEC_MINI_A); 4982 + 4983 + config->set_gpio = stv090x_set_gpio; 4981 4984 4982 4985 dprintk(FE_ERROR, 1, "Attaching %s demodulator(%d) Cut=0x%02x", 4983 4986 state->device == STV0900 ? "STV0900" : "STV0903",
+5 -11
drivers/media/dvb-frontends/stv090x.h
··· 101 101 int (*tuner_set_refclk) (struct dvb_frontend *fe, u32 refclk); 102 102 int (*tuner_get_status) (struct dvb_frontend *fe, u32 *status); 103 103 void (*tuner_i2c_lock) (struct dvb_frontend *fe, int lock); 104 + 105 + /* dir = 0 -> output, dir = 1 -> input/open-drain */ 106 + int (*set_gpio)(struct dvb_frontend *fe, u8 gpio, u8 dir, u8 value, 107 + u8 xor_value); 104 108 }; 105 109 106 110 #if IS_ENABLED(CONFIG_DVB_STV090x) 107 111 108 - extern struct dvb_frontend *stv090x_attach(const struct stv090x_config *config, 112 + extern struct dvb_frontend *stv090x_attach(struct stv090x_config *config, 109 113 struct i2c_adapter *i2c, 110 114 enum stv090x_demodulator demod); 111 - 112 - /* dir = 0 -> output, dir = 1 -> input/open-drain */ 113 - extern int stv090x_set_gpio(struct dvb_frontend *fe, u8 gpio, 114 - u8 dir, u8 value, u8 xor_value); 115 115 116 116 #else 117 117 ··· 123 123 return NULL; 124 124 } 125 125 126 - static inline int stv090x_set_gpio(struct dvb_frontend *fe, u8 gpio, 127 - u8 opd, u8 value, u8 xor_value) 128 - { 129 - printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 130 - return -ENODEV; 131 - } 132 126 #endif /* CONFIG_DVB_STV090x */ 133 127 134 128 #endif /* __STV090x_H */
+4 -1
drivers/media/usb/dvb-usb/technisat-usb2.c
··· 449 449 return 0; 450 450 } 451 451 452 + static struct stv090x_config technisat_usb2_stv090x_config; 453 + 452 454 /* frontend attach */ 453 455 static int technisat_usb2_set_voltage(struct dvb_frontend *fe, 454 456 fe_sec_voltage_t voltage) ··· 474 472 } 475 473 476 474 for (i = 0; i < 3; i++) 477 - if (stv090x_set_gpio(fe, i+2, 0, gpio[i], 0) != 0) 475 + if (technisat_usb2_stv090x_config.set_gpio(fe, i+2, 0, 476 + gpio[i], 0) != 0) 478 477 return -EREMOTEIO; 479 478 return 0; 480 479 }