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/frontends/sp8870.c | |
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/frontends/sp8870.c')
-rw-r--r-- | drivers/media/dvb/frontends/sp8870.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/drivers/media/dvb/frontends/sp8870.c b/drivers/media/dvb/frontends/sp8870.c index 4d553c0dabb3..44ec5b9a4695 100644 --- a/drivers/media/dvb/frontends/sp8870.c +++ b/drivers/media/dvb/frontends/sp8870.c | |||
@@ -44,8 +44,6 @@ struct sp8870_state { | |||
44 | 44 | ||
45 | struct i2c_adapter* i2c; | 45 | struct i2c_adapter* i2c; |
46 | 46 | ||
47 | struct dvb_frontend_ops ops; | ||
48 | |||
49 | const struct sp8870_config* config; | 47 | const struct sp8870_config* config; |
50 | 48 | ||
51 | struct dvb_frontend frontend; | 49 | struct dvb_frontend frontend; |
@@ -262,9 +260,9 @@ static int sp8870_set_frontend_parameters (struct dvb_frontend* fe, | |||
262 | sp8870_microcontroller_stop(state); | 260 | sp8870_microcontroller_stop(state); |
263 | 261 | ||
264 | // set tuner parameters | 262 | // set tuner parameters |
265 | if (fe->ops->tuner_ops.set_params) { | 263 | if (fe->ops.tuner_ops.set_params) { |
266 | fe->ops->tuner_ops.set_params(fe, p); | 264 | fe->ops.tuner_ops.set_params(fe, p); |
267 | if (fe->ops->i2c_gate_ctrl) fe->ops->i2c_gate_ctrl(fe, 0); | 265 | if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); |
268 | } | 266 | } |
269 | 267 | ||
270 | // sample rate correction bit [23..17] | 268 | // sample rate correction bit [23..17] |
@@ -566,14 +564,13 @@ struct dvb_frontend* sp8870_attach(const struct sp8870_config* config, | |||
566 | /* setup the state */ | 564 | /* setup the state */ |
567 | state->config = config; | 565 | state->config = config; |
568 | state->i2c = i2c; | 566 | state->i2c = i2c; |
569 | memcpy(&state->ops, &sp8870_ops, sizeof(struct dvb_frontend_ops)); | ||
570 | state->initialised = 0; | 567 | state->initialised = 0; |
571 | 568 | ||
572 | /* check if the demod is there */ | 569 | /* check if the demod is there */ |
573 | if (sp8870_readreg(state, 0x0200) < 0) goto error; | 570 | if (sp8870_readreg(state, 0x0200) < 0) goto error; |
574 | 571 | ||
575 | /* create dvb_frontend */ | 572 | /* create dvb_frontend */ |
576 | state->frontend.ops = &state->ops; | 573 | memcpy(&state->frontend.ops, &sp8870_ops, sizeof(struct dvb_frontend_ops)); |
577 | state->frontend.demodulator_priv = state; | 574 | state->frontend.demodulator_priv = state; |
578 | return &state->frontend; | 575 | return &state->frontend; |
579 | 576 | ||