aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <m.chehab@samsung.com>2014-03-14 13:29:06 -0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-03-14 19:26:59 -0400
commited97a6fe5308e5982d118a25f0697b791af5ec50 (patch)
tree3aefde16fcc9edf3c402347fab583eceb1aae44b /drivers/media
parentb24c2b4fb126007e36c5a67461527a5bfed33d17 (diff)
[media] af9033: Don't export functions for the hardware filter
Exporting functions for hardware filter is a bad idea, as it breaks compilation if: CONFIG_DVB_USB_AF9035=y CONFIG_DVB_AF9033=m Because the PID filter function calls would be hardcoded at af9035. The same doesn't happen with af9033_attach() because the dvb_attach() doesn't hardcode it. Instead, it dynamically links it at runtime. However, calling dvb_attach() multiple times is problematic, as it increments module kref. So, the better is to pass one parameter for the af9033 module to fill the hardware filters, and then use it inside af9035. Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com> Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/dvb-frontends/af9033.c14
-rw-r--r--drivers/media/dvb-frontends/af9033.h23
-rw-r--r--drivers/media/usb/dvb-usb-v2/af9035.c10
-rw-r--r--drivers/media/usb/dvb-usb-v2/af9035.h2
4 files changed, 33 insertions, 16 deletions
diff --git a/drivers/media/dvb-frontends/af9033.c b/drivers/media/dvb-frontends/af9033.c
index 5a1c508c7417..be4bec2a9640 100644
--- a/drivers/media/dvb-frontends/af9033.c
+++ b/drivers/media/dvb-frontends/af9033.c
@@ -989,7 +989,7 @@ err:
989 return ret; 989 return ret;
990} 990}
991 991
992int af9033_pid_filter_ctrl(struct dvb_frontend *fe, int onoff) 992static int af9033_pid_filter_ctrl(struct dvb_frontend *fe, int onoff)
993{ 993{
994 struct af9033_state *state = fe->demodulator_priv; 994 struct af9033_state *state = fe->demodulator_priv;
995 int ret; 995 int ret;
@@ -1007,9 +1007,8 @@ err:
1007 1007
1008 return ret; 1008 return ret;
1009} 1009}
1010EXPORT_SYMBOL(af9033_pid_filter_ctrl);
1011 1010
1012int af9033_pid_filter(struct dvb_frontend *fe, int index, u16 pid, int onoff) 1011static int af9033_pid_filter(struct dvb_frontend *fe, int index, u16 pid, int onoff)
1013{ 1012{
1014 struct af9033_state *state = fe->demodulator_priv; 1013 struct af9033_state *state = fe->demodulator_priv;
1015 int ret; 1014 int ret;
@@ -1040,12 +1039,12 @@ err:
1040 1039
1041 return ret; 1040 return ret;
1042} 1041}
1043EXPORT_SYMBOL(af9033_pid_filter);
1044 1042
1045static struct dvb_frontend_ops af9033_ops; 1043static struct dvb_frontend_ops af9033_ops;
1046 1044
1047struct dvb_frontend *af9033_attach(const struct af9033_config *config, 1045struct dvb_frontend *af9033_attach(const struct af9033_config *config,
1048 struct i2c_adapter *i2c) 1046 struct i2c_adapter *i2c,
1047 struct af9033_ops *ops)
1049{ 1048{
1050 int ret; 1049 int ret;
1051 struct af9033_state *state; 1050 struct af9033_state *state;
@@ -1120,6 +1119,11 @@ struct dvb_frontend *af9033_attach(const struct af9033_config *config,
1120 memcpy(&state->fe.ops, &af9033_ops, sizeof(struct dvb_frontend_ops)); 1119 memcpy(&state->fe.ops, &af9033_ops, sizeof(struct dvb_frontend_ops));
1121 state->fe.demodulator_priv = state; 1120 state->fe.demodulator_priv = state;
1122 1121
1122 if (ops) {
1123 ops->pid_filter = af9033_pid_filter;
1124 ops->pid_filter_ctrl = af9033_pid_filter_ctrl;
1125 }
1126
1123 return &state->fe; 1127 return &state->fe;
1124 1128
1125err: 1129err:
diff --git a/drivers/media/dvb-frontends/af9033.h b/drivers/media/dvb-frontends/af9033.h
index de245f9adb65..539f4db678b8 100644
--- a/drivers/media/dvb-frontends/af9033.h
+++ b/drivers/media/dvb-frontends/af9033.h
@@ -78,17 +78,24 @@ struct af9033_config {
78}; 78};
79 79
80 80
81#if IS_ENABLED(CONFIG_DVB_AF9033) 81struct af9033_ops {
82extern struct dvb_frontend *af9033_attach(const struct af9033_config *config, 82 int (*pid_filter_ctrl)(struct dvb_frontend *fe, int onoff);
83 struct i2c_adapter *i2c); 83 int (*pid_filter)(struct dvb_frontend *fe, int index, u16 pid,
84 int onoff);
85};
84 86
85extern int af9033_pid_filter_ctrl(struct dvb_frontend *fe, int onoff);
86 87
87extern int af9033_pid_filter(struct dvb_frontend *fe, int index, u16 pid, 88#if IS_ENABLED(CONFIG_DVB_AF9033)
88 int onoff); 89extern
90struct dvb_frontend *af9033_attach(const struct af9033_config *config,
91 struct i2c_adapter *i2c,
92 struct af9033_ops *ops);
93
89#else 94#else
90static inline struct dvb_frontend *af9033_attach( 95static inline
91 const struct af9033_config *config, struct i2c_adapter *i2c) 96struct dvb_frontend *af9033_attach(const struct af9033_config *config,
97 struct i2c_adapter *i2c,
98 struct af9033_ops *ops)
92{ 99{
93 pr_warn("%s: driver disabled by Kconfig\n", __func__); 100 pr_warn("%s: driver disabled by Kconfig\n", __func__);
94 return NULL; 101 return NULL;
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c
index 31d09a23c82e..021e4d35e4d7 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -963,7 +963,7 @@ static int af9035_frontend_attach(struct dvb_usb_adapter *adap)
963 963
964 /* attach demodulator */ 964 /* attach demodulator */
965 adap->fe[0] = dvb_attach(af9033_attach, &state->af9033_config[adap->id], 965 adap->fe[0] = dvb_attach(af9033_attach, &state->af9033_config[adap->id],
966 &d->i2c_adap); 966 &d->i2c_adap, &state->ops);
967 if (adap->fe[0] == NULL) { 967 if (adap->fe[0] == NULL) {
968 ret = -ENODEV; 968 ret = -ENODEV;
969 goto err; 969 goto err;
@@ -1373,13 +1373,17 @@ static int af9035_get_stream_config(struct dvb_frontend *fe, u8 *ts_type,
1373 1373
1374static int af9035_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff) 1374static int af9035_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
1375{ 1375{
1376 return af9033_pid_filter_ctrl(adap->fe[0], onoff); 1376 struct state *state = adap_to_priv(adap);
1377
1378 return state->ops.pid_filter_ctrl(adap->fe[0], onoff);
1377} 1379}
1378 1380
1379static int af9035_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid, 1381static int af9035_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid,
1380 int onoff) 1382 int onoff)
1381{ 1383{
1382 return af9033_pid_filter(adap->fe[0], index, pid, onoff); 1384 struct state *state = adap_to_priv(adap);
1385
1386 return state->ops.pid_filter(adap->fe[0], index, pid, onoff);
1383} 1387}
1384 1388
1385static int af9035_probe(struct usb_interface *intf, 1389static int af9035_probe(struct usb_interface *intf,
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.h b/drivers/media/usb/dvb-usb-v2/af9035.h
index a1c68d829b8c..c21902fdd4c4 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.h
+++ b/drivers/media/usb/dvb-usb-v2/af9035.h
@@ -62,6 +62,8 @@ struct state {
62 u8 dual_mode:1; 62 u8 dual_mode:1;
63 u16 eeprom_addr; 63 u16 eeprom_addr;
64 struct af9033_config af9033_config[2]; 64 struct af9033_config af9033_config[2];
65
66 struct af9033_ops ops;
65}; 67};
66 68
67static const u32 clock_lut_af9035[] = { 69static const u32 clock_lut_af9035[] = {