diff options
author | Patrick Boettcher <pb@linuxtv.org> | 2006-05-14 04:01:31 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-06-25 01:00:42 -0400 |
commit | dea74869f3c62b0b7addd67017b22b394e942aac (patch) | |
tree | d1a597caea6615c76f34896cc832fd1371f2e776 /drivers/media/dvb/dvb-usb | |
parent | 332bed5fc25ab0eb84215ecd89a4acd48219eee0 (diff) |
V4L/DVB (4028): Change dvb_frontend_ops to be a real field instead of a pointer field inside dvb_frontend
The dvb_frontend_ops is a pointer inside dvb_frontend. That's why every demod-driver
is having a field of dvb_frontend_ops in its private-state-struct and
using the reference for filling the pointer-field in dvb_frontend.
- It saves at least two lines of code per demod-driver,
- reduces object size (one less dereference per frontend_ops-access),
- be coherent with dvb_tuner_ops,
- makes it a little bit easier for newbies to understand how it works and
- avoids stupid mistakes because you would have to copy the dvb_frontend_ops
always, before you could assign the static pointer directly, which was
dangerous.
Signed-off-by: Patrick Boettcher <pb@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb/dvb-usb')
-rw-r--r-- | drivers/media/dvb/dvb-usb/cxusb.c | 12 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/dibusb-mb.c | 7 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/digitv.c | 4 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/dtt200u-fe.c | 4 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/dvb-usb-dvb.c | 8 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/dvb-usb-i2c.c | 8 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/umt-010.c | 2 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/vp702x-fe.c | 3 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/vp7045-fe.c | 5 |
9 files changed, 25 insertions, 28 deletions
diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c index 500785e41e28..d0063ae120bd 100644 --- a/drivers/media/dvb/dvb-usb/cxusb.c +++ b/drivers/media/dvb/dvb-usb/cxusb.c | |||
@@ -360,8 +360,8 @@ static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_device *d) | |||
360 | memcpy(d->pll_init, bpll, 4); | 360 | memcpy(d->pll_init, bpll, 4); |
361 | d->pll_desc = &dvb_pll_fmd1216me; | 361 | d->pll_desc = &dvb_pll_fmd1216me; |
362 | 362 | ||
363 | d->fe->ops->tuner_ops.init = dvb_usb_tuner_init_i2c; | 363 | d->fe->ops.tuner_ops.init = dvb_usb_tuner_init_i2c; |
364 | d->fe->ops->tuner_ops.set_params = dvb_usb_tuner_set_params_i2c; | 364 | d->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c; |
365 | 365 | ||
366 | return 0; | 366 | return 0; |
367 | } | 367 | } |
@@ -370,7 +370,7 @@ static int cxusb_dee1601_tuner_attach(struct dvb_usb_device *d) | |||
370 | { | 370 | { |
371 | d->pll_addr = 0x61; | 371 | d->pll_addr = 0x61; |
372 | d->pll_desc = &dvb_pll_thomson_dtt7579; | 372 | d->pll_desc = &dvb_pll_thomson_dtt7579; |
373 | d->fe->ops->tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; | 373 | d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; |
374 | return 0; | 374 | return 0; |
375 | } | 375 | } |
376 | 376 | ||
@@ -378,7 +378,7 @@ static int cxusb_lgz201_tuner_attach(struct dvb_usb_device *d) | |||
378 | { | 378 | { |
379 | d->pll_addr = 0x61; | 379 | d->pll_addr = 0x61; |
380 | d->pll_desc = &dvb_pll_lg_z201; | 380 | d->pll_desc = &dvb_pll_lg_z201; |
381 | d->fe->ops->tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; | 381 | d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; |
382 | return 0; | 382 | return 0; |
383 | } | 383 | } |
384 | 384 | ||
@@ -386,13 +386,13 @@ static int cxusb_dtt7579_tuner_attach(struct dvb_usb_device *d) | |||
386 | { | 386 | { |
387 | d->pll_addr = 0x60; | 387 | d->pll_addr = 0x60; |
388 | d->pll_desc = &dvb_pll_thomson_dtt7579; | 388 | d->pll_desc = &dvb_pll_thomson_dtt7579; |
389 | d->fe->ops->tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; | 389 | d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; |
390 | return 0; | 390 | return 0; |
391 | } | 391 | } |
392 | 392 | ||
393 | static int cxusb_lgdt3303_tuner_attach(struct dvb_usb_device *d) | 393 | static int cxusb_lgdt3303_tuner_attach(struct dvb_usb_device *d) |
394 | { | 394 | { |
395 | d->fe->ops->tuner_ops.set_params = cxusb_lgh064f_tuner_set_params; | 395 | d->fe->ops.tuner_ops.set_params = cxusb_lgh064f_tuner_set_params; |
396 | return 0; | 396 | return 0; |
397 | } | 397 | } |
398 | 398 | ||
diff --git a/drivers/media/dvb/dvb-usb/dibusb-mb.c b/drivers/media/dvb/dvb-usb/dibusb-mb.c index def0c111ce0a..f4c45f386ebc 100644 --- a/drivers/media/dvb/dvb-usb/dibusb-mb.c +++ b/drivers/media/dvb/dvb-usb/dibusb-mb.c | |||
@@ -20,11 +20,12 @@ static int dibusb_dib3000mb_frontend_attach(struct dvb_usb_device *d) | |||
20 | struct dibusb_state *st = d->priv; | 20 | struct dibusb_state *st = d->priv; |
21 | 21 | ||
22 | demod_cfg.demod_address = 0x8; | 22 | demod_cfg.demod_address = 0x8; |
23 | d->fe->ops->tuner_ops.init = dvb_usb_tuner_init_i2c; | ||
24 | d->fe->ops->tuner_ops.set_params = dvb_usb_tuner_set_params_i2c; | ||
25 | 23 | ||
26 | if ((d->fe = dib3000mb_attach(&demod_cfg,&d->i2c_adap,&st->ops)) == NULL) | 24 | if ((d->fe = dib3000mb_attach(&demod_cfg,&d->i2c_adap,&st->ops)) == NULL) { |
25 | d->fe->ops.tuner_ops.init = dvb_usb_tuner_init_i2c; | ||
26 | d->fe->ops.tuner_ops.set_params = dvb_usb_tuner_set_params_i2c; | ||
27 | return -ENODEV; | 27 | return -ENODEV; |
28 | } | ||
28 | 29 | ||
29 | d->tuner_pass_ctrl = st->ops.tuner_pass_ctrl; | 30 | d->tuner_pass_ctrl = st->ops.tuner_pass_ctrl; |
30 | 31 | ||
diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c index 56814ba8037b..c14d9efb48fd 100644 --- a/drivers/media/dvb/dvb-usb/digitv.c +++ b/drivers/media/dvb/dvb-usb/digitv.c | |||
@@ -129,11 +129,11 @@ static struct nxt6000_config digitv_nxt6000_config = { | |||
129 | static int digitv_frontend_attach(struct dvb_usb_device *d) | 129 | static int digitv_frontend_attach(struct dvb_usb_device *d) |
130 | { | 130 | { |
131 | if ((d->fe = mt352_attach(&digitv_mt352_config, &d->i2c_adap)) != NULL) { | 131 | if ((d->fe = mt352_attach(&digitv_mt352_config, &d->i2c_adap)) != NULL) { |
132 | d->fe->ops->tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; | 132 | d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; |
133 | return 0; | 133 | return 0; |
134 | } | 134 | } |
135 | if ((d->fe = nxt6000_attach(&digitv_nxt6000_config, &d->i2c_adap)) != NULL) { | 135 | if ((d->fe = nxt6000_attach(&digitv_nxt6000_config, &d->i2c_adap)) != NULL) { |
136 | d->fe->ops->tuner_ops.set_params = digitv_nxt6000_tuner_set_params; | 136 | d->fe->ops.tuner_ops.set_params = digitv_nxt6000_tuner_set_params; |
137 | return 0; | 137 | return 0; |
138 | } | 138 | } |
139 | return -EIO; | 139 | return -EIO; |
diff --git a/drivers/media/dvb/dvb-usb/dtt200u-fe.c b/drivers/media/dvb/dvb-usb/dtt200u-fe.c index 2df6da2b54f8..17413adec7a1 100644 --- a/drivers/media/dvb/dvb-usb/dtt200u-fe.c +++ b/drivers/media/dvb/dvb-usb/dtt200u-fe.c | |||
@@ -18,7 +18,6 @@ struct dtt200u_fe_state { | |||
18 | 18 | ||
19 | struct dvb_frontend_parameters fep; | 19 | struct dvb_frontend_parameters fep; |
20 | struct dvb_frontend frontend; | 20 | struct dvb_frontend frontend; |
21 | struct dvb_frontend_ops ops; | ||
22 | }; | 21 | }; |
23 | 22 | ||
24 | static int dtt200u_fe_read_status(struct dvb_frontend* fe, fe_status_t *stat) | 23 | static int dtt200u_fe_read_status(struct dvb_frontend* fe, fe_status_t *stat) |
@@ -163,9 +162,8 @@ struct dvb_frontend* dtt200u_fe_attach(struct dvb_usb_device *d) | |||
163 | deb_info("attaching frontend dtt200u\n"); | 162 | deb_info("attaching frontend dtt200u\n"); |
164 | 163 | ||
165 | state->d = d; | 164 | state->d = d; |
166 | memcpy(&state->ops,&dtt200u_fe_ops,sizeof(struct dvb_frontend_ops)); | ||
167 | 165 | ||
168 | state->frontend.ops = &state->ops; | 166 | memcpy(&state->frontend.ops,&dtt200u_fe_ops,sizeof(struct dvb_frontend_ops)); |
169 | state->frontend.demodulator_priv = state; | 167 | state->frontend.demodulator_priv = state; |
170 | 168 | ||
171 | return &state->frontend; | 169 | return &state->frontend; |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c b/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c index 2517b228381d..ec631708c394 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c | |||
@@ -183,13 +183,13 @@ int dvb_usb_fe_init(struct dvb_usb_device* d) | |||
183 | 183 | ||
184 | /* re-assign sleep and wakeup functions */ | 184 | /* re-assign sleep and wakeup functions */ |
185 | if (d->fe != NULL) { | 185 | if (d->fe != NULL) { |
186 | d->fe_init = d->fe->ops->init; d->fe->ops->init = dvb_usb_fe_wakeup; | 186 | d->fe_init = d->fe->ops.init; d->fe->ops.init = dvb_usb_fe_wakeup; |
187 | d->fe_sleep = d->fe->ops->sleep; d->fe->ops->sleep = dvb_usb_fe_sleep; | 187 | d->fe_sleep = d->fe->ops.sleep; d->fe->ops.sleep = dvb_usb_fe_sleep; |
188 | 188 | ||
189 | if (dvb_register_frontend(&d->dvb_adap, d->fe)) { | 189 | if (dvb_register_frontend(&d->dvb_adap, d->fe)) { |
190 | err("Frontend registration failed."); | 190 | err("Frontend registration failed."); |
191 | if (d->fe->ops->release) | 191 | if (d->fe->ops.release) |
192 | d->fe->ops->release(d->fe); | 192 | d->fe->ops.release(d->fe); |
193 | d->fe = NULL; | 193 | d->fe = NULL; |
194 | return -ENODEV; | 194 | return -ENODEV; |
195 | } | 195 | } |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c b/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c index 6c868d667424..6b611a725093 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c | |||
@@ -63,8 +63,8 @@ int dvb_usb_tuner_init_i2c(struct dvb_frontend *fe) | |||
63 | deb_pll("pll-buf: %x %x %x %x\n",d->pll_init[0],d->pll_init[1], | 63 | deb_pll("pll-buf: %x %x %x %x\n",d->pll_init[0],d->pll_init[1], |
64 | d->pll_init[2],d->pll_init[3]); | 64 | d->pll_init[2],d->pll_init[3]); |
65 | 65 | ||
66 | if (fe->ops->i2c_gate_ctrl) | 66 | if (fe->ops.i2c_gate_ctrl) |
67 | fe->ops->i2c_gate_ctrl(fe, 1); | 67 | fe->ops.i2c_gate_ctrl(fe, 1); |
68 | if (i2c_transfer (&d->i2c_adap, &msg, 1) != 1) { | 68 | if (i2c_transfer (&d->i2c_adap, &msg, 1) != 1) { |
69 | err("tuner i2c write failed for pll_init."); | 69 | err("tuner i2c write failed for pll_init."); |
70 | ret = -EREMOTEIO; | 70 | ret = -EREMOTEIO; |
@@ -109,8 +109,8 @@ int dvb_usb_tuner_set_params_i2c(struct dvb_frontend *fe, struct dvb_frontend_pa | |||
109 | if (d->tuner_pass_ctrl) | 109 | if (d->tuner_pass_ctrl) |
110 | d->tuner_pass_ctrl(fe,1,d->pll_addr); | 110 | d->tuner_pass_ctrl(fe,1,d->pll_addr); |
111 | 111 | ||
112 | if (fe->ops->i2c_gate_ctrl) | 112 | if (fe->ops.i2c_gate_ctrl) |
113 | fe->ops->i2c_gate_ctrl(fe, 1); | 113 | fe->ops.i2c_gate_ctrl(fe, 1); |
114 | if (i2c_transfer (&d->i2c_adap, &msg, 1) != 1) { | 114 | if (i2c_transfer (&d->i2c_adap, &msg, 1) != 1) { |
115 | err("tuner i2c write failed for pll_set."); | 115 | err("tuner i2c write failed for pll_set."); |
116 | ret = -EREMOTEIO; | 116 | ret = -EREMOTEIO; |
diff --git a/drivers/media/dvb/dvb-usb/umt-010.c b/drivers/media/dvb/dvb-usb/umt-010.c index 6dbe9dfb03c6..97d74da0dad8 100644 --- a/drivers/media/dvb/dvb-usb/umt-010.c +++ b/drivers/media/dvb/dvb-usb/umt-010.c | |||
@@ -67,7 +67,7 @@ static int umt_tuner_attach (struct dvb_usb_device *d) | |||
67 | { | 67 | { |
68 | d->pll_addr = 0x61; | 68 | d->pll_addr = 0x61; |
69 | d->pll_desc = &dvb_pll_tua6034; | 69 | d->pll_desc = &dvb_pll_tua6034; |
70 | d->fe->ops->tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; | 70 | d->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; |
71 | return 0; | 71 | return 0; |
72 | } | 72 | } |
73 | 73 | ||
diff --git a/drivers/media/dvb/dvb-usb/vp702x-fe.c b/drivers/media/dvb/dvb-usb/vp702x-fe.c index 9d26f46de091..d4da494132ec 100644 --- a/drivers/media/dvb/dvb-usb/vp702x-fe.c +++ b/drivers/media/dvb/dvb-usb/vp702x-fe.c | |||
@@ -287,7 +287,8 @@ struct dvb_frontend * vp702x_fe_attach(struct dvb_usb_device *d) | |||
287 | goto error; | 287 | goto error; |
288 | 288 | ||
289 | s->d = d; | 289 | s->d = d; |
290 | s->fe.ops = &vp702x_fe_ops; | 290 | |
291 | memcpy(&s->fe.ops,&vp702x_fe_ops,sizeof(struct dvb_frontend_ops)); | ||
291 | s->fe.demodulator_priv = s; | 292 | s->fe.demodulator_priv = s; |
292 | 293 | ||
293 | s->lnb_buf[1] = SET_LNB_POWER; | 294 | s->lnb_buf[1] = SET_LNB_POWER; |
diff --git a/drivers/media/dvb/dvb-usb/vp7045-fe.c b/drivers/media/dvb/dvb-usb/vp7045-fe.c index e98e5a517f5a..8452eef90322 100644 --- a/drivers/media/dvb/dvb-usb/vp7045-fe.c +++ b/drivers/media/dvb/dvb-usb/vp7045-fe.c | |||
@@ -23,8 +23,6 @@ | |||
23 | 23 | ||
24 | struct vp7045_fe_state { | 24 | struct vp7045_fe_state { |
25 | struct dvb_frontend fe; | 25 | struct dvb_frontend fe; |
26 | struct dvb_frontend_ops ops; | ||
27 | |||
28 | struct dvb_usb_device *d; | 26 | struct dvb_usb_device *d; |
29 | }; | 27 | }; |
30 | 28 | ||
@@ -151,8 +149,7 @@ struct dvb_frontend * vp7045_fe_attach(struct dvb_usb_device *d) | |||
151 | goto error; | 149 | goto error; |
152 | 150 | ||
153 | s->d = d; | 151 | s->d = d; |
154 | memcpy(&s->ops, &vp7045_fe_ops, sizeof(struct dvb_frontend_ops)); | 152 | memcpy(&s->fe.ops, &vp7045_fe_ops, sizeof(struct dvb_frontend_ops)); |
155 | s->fe.ops = &s->ops; | ||
156 | s->fe.demodulator_priv = s; | 153 | s->fe.demodulator_priv = s; |
157 | 154 | ||
158 | return &s->fe; | 155 | return &s->fe; |