aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/frontends')
-rw-r--r--drivers/media/dvb/frontends/isl6421.c28
-rw-r--r--drivers/media/dvb/frontends/isl6421.h2
-rw-r--r--drivers/media/dvb/frontends/lnbp21.c28
-rw-r--r--drivers/media/dvb/frontends/lnbp21.h2
4 files changed, 22 insertions, 38 deletions
diff --git a/drivers/media/dvb/frontends/isl6421.c b/drivers/media/dvb/frontends/isl6421.c
index 58c34db31071..0fc18f5a7167 100644
--- a/drivers/media/dvb/frontends/isl6421.c
+++ b/drivers/media/dvb/frontends/isl6421.c
@@ -42,12 +42,11 @@ struct isl6421 {
42 u8 override_and; 42 u8 override_and;
43 struct i2c_adapter *i2c; 43 struct i2c_adapter *i2c;
44 u8 i2c_addr; 44 u8 i2c_addr;
45 void (*release_chain)(struct dvb_frontend* fe);
46}; 45};
47 46
48static int isl6421_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) 47static int isl6421_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
49{ 48{
50 struct isl6421 *isl6421 = (struct isl6421 *) fe->misc_priv; 49 struct isl6421 *isl6421 = (struct isl6421 *) fe->sec_priv;
51 struct i2c_msg msg = { .addr = isl6421->i2c_addr, .flags = 0, 50 struct i2c_msg msg = { .addr = isl6421->i2c_addr, .flags = 0,
52 .buf = &isl6421->config, 51 .buf = &isl6421->config,
53 .len = sizeof(isl6421->config) }; 52 .len = sizeof(isl6421->config) };
@@ -75,7 +74,7 @@ static int isl6421_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage
75 74
76static int isl6421_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg) 75static int isl6421_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg)
77{ 76{
78 struct isl6421 *isl6421 = (struct isl6421 *) fe->misc_priv; 77 struct isl6421 *isl6421 = (struct isl6421 *) fe->sec_priv;
79 struct i2c_msg msg = { .addr = isl6421->i2c_addr, .flags = 0, 78 struct i2c_msg msg = { .addr = isl6421->i2c_addr, .flags = 0,
80 .buf = &isl6421->config, 79 .buf = &isl6421->config,
81 .len = sizeof(isl6421->config) }; 80 .len = sizeof(isl6421->config) };
@@ -93,31 +92,26 @@ static int isl6421_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg)
93 92
94static void isl6421_release(struct dvb_frontend *fe) 93static void isl6421_release(struct dvb_frontend *fe)
95{ 94{
96 struct isl6421 *isl6421 = (struct isl6421 *) fe->misc_priv;
97
98 /* power off */ 95 /* power off */
99 isl6421_set_voltage(fe, SEC_VOLTAGE_OFF); 96 isl6421_set_voltage(fe, SEC_VOLTAGE_OFF);
100 97
101 /* free data & call next release routine */ 98 /* free */
102 fe->ops.release = isl6421->release_chain; 99 kfree(fe->sec_priv);
103 kfree(fe->misc_priv); 100 fe->sec_priv = NULL;
104 fe->misc_priv = NULL;
105 if (fe->ops.release)
106 fe->ops.release(fe);
107} 101}
108 102
109int isl6421_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 i2c_addr, 103struct dvb_frontend *isl6421_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 i2c_addr,
110 u8 override_set, u8 override_clear) 104 u8 override_set, u8 override_clear)
111{ 105{
112 struct isl6421 *isl6421 = kmalloc(sizeof(struct isl6421), GFP_KERNEL); 106 struct isl6421 *isl6421 = kmalloc(sizeof(struct isl6421), GFP_KERNEL);
113 if (!isl6421) 107 if (!isl6421)
114 return -ENOMEM; 108 return NULL;
115 109
116 /* default configuration */ 110 /* default configuration */
117 isl6421->config = ISL6421_ISEL1; 111 isl6421->config = ISL6421_ISEL1;
118 isl6421->i2c = i2c; 112 isl6421->i2c = i2c;
119 isl6421->i2c_addr = i2c_addr; 113 isl6421->i2c_addr = i2c_addr;
120 fe->misc_priv = isl6421; 114 fe->sec_priv = isl6421;
121 115
122 /* bits which should be forced to '1' */ 116 /* bits which should be forced to '1' */
123 isl6421->override_or = override_set; 117 isl6421->override_or = override_set;
@@ -128,19 +122,17 @@ int isl6421_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 i2c_addr
128 /* detect if it is present or not */ 122 /* detect if it is present or not */
129 if (isl6421_set_voltage(fe, SEC_VOLTAGE_OFF)) { 123 if (isl6421_set_voltage(fe, SEC_VOLTAGE_OFF)) {
130 kfree(isl6421); 124 kfree(isl6421);
131 fe->misc_priv = NULL; 125 return NULL;
132 return -EIO;
133 } 126 }
134 127
135 /* install release callback */ 128 /* install release callback */
136 isl6421->release_chain = fe->ops.release;
137 fe->ops.release = isl6421_release; 129 fe->ops.release = isl6421_release;
138 130
139 /* override frontend ops */ 131 /* override frontend ops */
140 fe->ops.set_voltage = isl6421_set_voltage; 132 fe->ops.set_voltage = isl6421_set_voltage;
141 fe->ops.enable_high_lnb_voltage = isl6421_enable_high_lnb_voltage; 133 fe->ops.enable_high_lnb_voltage = isl6421_enable_high_lnb_voltage;
142 134
143 return 0; 135 return fe;
144} 136}
145EXPORT_SYMBOL(isl6421_attach); 137EXPORT_SYMBOL(isl6421_attach);
146 138
diff --git a/drivers/media/dvb/frontends/isl6421.h b/drivers/media/dvb/frontends/isl6421.h
index 675f80a19b99..b5deacfe6d2f 100644
--- a/drivers/media/dvb/frontends/isl6421.h
+++ b/drivers/media/dvb/frontends/isl6421.h
@@ -40,7 +40,7 @@
40#define ISL6421_DCL 0x40 40#define ISL6421_DCL 0x40
41 41
42/* override_set and override_clear control which system register bits (above) to always set & clear */ 42/* override_set and override_clear control which system register bits (above) to always set & clear */
43extern int isl6421_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 i2c_addr, 43extern struct dvb_frontend *isl6421_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 i2c_addr,
44 u8 override_set, u8 override_clear); 44 u8 override_set, u8 override_clear);
45 45
46#endif 46#endif
diff --git a/drivers/media/dvb/frontends/lnbp21.c b/drivers/media/dvb/frontends/lnbp21.c
index e933edc8dd29..37bba32f29a5 100644
--- a/drivers/media/dvb/frontends/lnbp21.c
+++ b/drivers/media/dvb/frontends/lnbp21.c
@@ -40,12 +40,11 @@ struct lnbp21 {
40 u8 override_or; 40 u8 override_or;
41 u8 override_and; 41 u8 override_and;
42 struct i2c_adapter *i2c; 42 struct i2c_adapter *i2c;
43 void (*release_chain)(struct dvb_frontend* fe);
44}; 43};
45 44
46static int lnbp21_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) 45static int lnbp21_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
47{ 46{
48 struct lnbp21 *lnbp21 = (struct lnbp21 *) fe->misc_priv; 47 struct lnbp21 *lnbp21 = (struct lnbp21 *) fe->sec_priv;
49 struct i2c_msg msg = { .addr = 0x08, .flags = 0, 48 struct i2c_msg msg = { .addr = 0x08, .flags = 0,
50 .buf = &lnbp21->config, 49 .buf = &lnbp21->config,
51 .len = sizeof(lnbp21->config) }; 50 .len = sizeof(lnbp21->config) };
@@ -73,7 +72,7 @@ static int lnbp21_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
73 72
74static int lnbp21_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg) 73static int lnbp21_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg)
75{ 74{
76 struct lnbp21 *lnbp21 = (struct lnbp21 *) fe->misc_priv; 75 struct lnbp21 *lnbp21 = (struct lnbp21 *) fe->sec_priv;
77 struct i2c_msg msg = { .addr = 0x08, .flags = 0, 76 struct i2c_msg msg = { .addr = 0x08, .flags = 0,
78 .buf = &lnbp21->config, 77 .buf = &lnbp21->config,
79 .len = sizeof(lnbp21->config) }; 78 .len = sizeof(lnbp21->config) };
@@ -91,29 +90,24 @@ static int lnbp21_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg)
91 90
92static void lnbp21_release(struct dvb_frontend *fe) 91static void lnbp21_release(struct dvb_frontend *fe)
93{ 92{
94 struct lnbp21 *lnbp21 = (struct lnbp21 *) fe->misc_priv;
95
96 /* LNBP power off */ 93 /* LNBP power off */
97 lnbp21_set_voltage(fe, SEC_VOLTAGE_OFF); 94 lnbp21_set_voltage(fe, SEC_VOLTAGE_OFF);
98 95
99 /* free data & call next release routine */ 96 /* free data */
100 fe->ops.release = lnbp21->release_chain; 97 kfree(fe->sec_priv);
101 kfree(fe->misc_priv); 98 fe->sec_priv = NULL;
102 fe->misc_priv = NULL;
103 if (fe->ops.release)
104 fe->ops.release(fe);
105} 99}
106 100
107int lnbp21_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 override_set, u8 override_clear) 101struct dvb_frontend *lnbp21_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 override_set, u8 override_clear)
108{ 102{
109 struct lnbp21 *lnbp21 = kmalloc(sizeof(struct lnbp21), GFP_KERNEL); 103 struct lnbp21 *lnbp21 = kmalloc(sizeof(struct lnbp21), GFP_KERNEL);
110 if (!lnbp21) 104 if (!lnbp21)
111 return -ENOMEM; 105 return NULL;
112 106
113 /* default configuration */ 107 /* default configuration */
114 lnbp21->config = LNBP21_ISEL; 108 lnbp21->config = LNBP21_ISEL;
115 lnbp21->i2c = i2c; 109 lnbp21->i2c = i2c;
116 fe->misc_priv = lnbp21; 110 fe->sec_priv = lnbp21;
117 111
118 /* bits which should be forced to '1' */ 112 /* bits which should be forced to '1' */
119 lnbp21->override_or = override_set; 113 lnbp21->override_or = override_set;
@@ -124,19 +118,17 @@ int lnbp21_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 override_
124 /* detect if it is present or not */ 118 /* detect if it is present or not */
125 if (lnbp21_set_voltage(fe, SEC_VOLTAGE_OFF)) { 119 if (lnbp21_set_voltage(fe, SEC_VOLTAGE_OFF)) {
126 kfree(lnbp21); 120 kfree(lnbp21);
127 fe->misc_priv = NULL; 121 return NULL;
128 return -EIO;
129 } 122 }
130 123
131 /* install release callback */ 124 /* install release callback */
132 lnbp21->release_chain = fe->ops.release;
133 fe->ops.release = lnbp21_release; 125 fe->ops.release = lnbp21_release;
134 126
135 /* override frontend ops */ 127 /* override frontend ops */
136 fe->ops.set_voltage = lnbp21_set_voltage; 128 fe->ops.set_voltage = lnbp21_set_voltage;
137 fe->ops.enable_high_lnb_voltage = lnbp21_enable_high_lnb_voltage; 129 fe->ops.enable_high_lnb_voltage = lnbp21_enable_high_lnb_voltage;
138 130
139 return 0; 131 return fe;
140} 132}
141EXPORT_SYMBOL(lnbp21_attach); 133EXPORT_SYMBOL(lnbp21_attach);
142 134
diff --git a/drivers/media/dvb/frontends/lnbp21.h b/drivers/media/dvb/frontends/lnbp21.h
index 047a4ab68c01..8c2df67d81ee 100644
--- a/drivers/media/dvb/frontends/lnbp21.h
+++ b/drivers/media/dvb/frontends/lnbp21.h
@@ -40,6 +40,6 @@
40#include <linux/dvb/frontend.h> 40#include <linux/dvb/frontend.h>
41 41
42/* override_set and override_clear control which system register bits (above) to always set & clear */ 42/* override_set and override_clear control which system register bits (above) to always set & clear */
43extern int lnbp21_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 override_set, u8 override_clear); 43extern struct dvb_frontend *lnbp21_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 override_set, u8 override_clear);
44 44
45#endif 45#endif