[media] af9033: Don't export functions for the hardware filter
authorMauro Carvalho Chehab <m.chehab@samsung.com>
Fri, 14 Mar 2014 17:29:06 +0000 (14:29 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Fri, 14 Mar 2014 23:26:59 +0000 (20:26 -0300)
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>
drivers/media/dvb-frontends/af9033.c
drivers/media/dvb-frontends/af9033.h
drivers/media/usb/dvb-usb-v2/af9035.c
drivers/media/usb/dvb-usb-v2/af9035.h

index 5a1c508c7417b31ad996cd9b247766a71f19dc1a..be4bec2a96408b896b9e3e6e62a4a8ac70c4d566 100644 (file)
@@ -989,7 +989,7 @@ err:
        return ret;
 }
 
-int af9033_pid_filter_ctrl(struct dvb_frontend *fe, int onoff)
+static int af9033_pid_filter_ctrl(struct dvb_frontend *fe, int onoff)
 {
        struct af9033_state *state = fe->demodulator_priv;
        int ret;
@@ -1007,9 +1007,8 @@ err:
 
        return ret;
 }
-EXPORT_SYMBOL(af9033_pid_filter_ctrl);
 
-int af9033_pid_filter(struct dvb_frontend *fe, int index, u16 pid, int onoff)
+static int af9033_pid_filter(struct dvb_frontend *fe, int index, u16 pid, int onoff)
 {
        struct af9033_state *state = fe->demodulator_priv;
        int ret;
@@ -1040,12 +1039,12 @@ err:
 
        return ret;
 }
-EXPORT_SYMBOL(af9033_pid_filter);
 
 static struct dvb_frontend_ops af9033_ops;
 
 struct dvb_frontend *af9033_attach(const struct af9033_config *config,
-               struct i2c_adapter *i2c)
+                                  struct i2c_adapter *i2c,
+                                  struct af9033_ops *ops)
 {
        int ret;
        struct af9033_state *state;
@@ -1120,6 +1119,11 @@ struct dvb_frontend *af9033_attach(const struct af9033_config *config,
        memcpy(&state->fe.ops, &af9033_ops, sizeof(struct dvb_frontend_ops));
        state->fe.demodulator_priv = state;
 
+       if (ops) {
+               ops->pid_filter = af9033_pid_filter;
+               ops->pid_filter_ctrl = af9033_pid_filter_ctrl;
+       }
+
        return &state->fe;
 
 err:
index de245f9adb652e539952466cfa6a17f8ad962b6f..539f4db678b87f0076093f8f85b9139e182dc31d 100644 (file)
@@ -78,17 +78,24 @@ struct af9033_config {
 };
 
 
-#if IS_ENABLED(CONFIG_DVB_AF9033)
-extern struct dvb_frontend *af9033_attach(const struct af9033_config *config,
-       struct i2c_adapter *i2c);
+struct af9033_ops {
+       int (*pid_filter_ctrl)(struct dvb_frontend *fe, int onoff);
+       int (*pid_filter)(struct dvb_frontend *fe, int index, u16 pid,
+                         int onoff);
+};
 
-extern int af9033_pid_filter_ctrl(struct dvb_frontend *fe, int onoff);
 
-extern int af9033_pid_filter(struct dvb_frontend *fe, int index, u16 pid,
-       int onoff);
+#if IS_ENABLED(CONFIG_DVB_AF9033)
+extern
+struct dvb_frontend *af9033_attach(const struct af9033_config *config,
+                                  struct i2c_adapter *i2c,
+                                  struct af9033_ops *ops);
+
 #else
-static inline struct dvb_frontend *af9033_attach(
-       const struct af9033_config *config, struct i2c_adapter *i2c)
+static inline
+struct dvb_frontend *af9033_attach(const struct af9033_config *config,
+                                  struct i2c_adapter *i2c,
+                                  struct af9033_ops *ops)
 {
        pr_warn("%s: driver disabled by Kconfig\n", __func__);
        return NULL;
index 31d09a23c82eb8048b4eca23704223f6eaf43057..021e4d35e4d7d5f65311c13bb70c33df07b40d3f 100644 (file)
@@ -963,7 +963,7 @@ static int af9035_frontend_attach(struct dvb_usb_adapter *adap)
 
        /* attach demodulator */
        adap->fe[0] = dvb_attach(af9033_attach, &state->af9033_config[adap->id],
-                       &d->i2c_adap);
+                       &d->i2c_adap, &state->ops);
        if (adap->fe[0] == NULL) {
                ret = -ENODEV;
                goto err;
@@ -1373,13 +1373,17 @@ static int af9035_get_stream_config(struct dvb_frontend *fe, u8 *ts_type,
 
 static int af9035_pid_filter_ctrl(struct dvb_usb_adapter *adap, int onoff)
 {
-       return af9033_pid_filter_ctrl(adap->fe[0], onoff);
+       struct state *state = adap_to_priv(adap);
+
+       return state->ops.pid_filter_ctrl(adap->fe[0], onoff);
 }
 
 static int af9035_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid,
                int onoff)
 {
-       return af9033_pid_filter(adap->fe[0], index, pid, onoff);
+       struct state *state = adap_to_priv(adap);
+
+       return state->ops.pid_filter(adap->fe[0], index, pid, onoff);
 }
 
 static int af9035_probe(struct usb_interface *intf,
index a1c68d829b8ce7be68542ad1085dad46ce636b49..c21902fdd4c44e8d04ecce5962487921f4a92c16 100644 (file)
@@ -62,6 +62,8 @@ struct state {
        u8 dual_mode:1;
        u16 eeprom_addr;
        struct af9033_config af9033_config[2];
+
+       struct af9033_ops ops;
 };
 
 static const u32 clock_lut_af9035[] = {
This page took 0.028621 seconds and 5 git commands to generate.