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/s5h1420.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/s5h1420.c')
-rw-r--r-- | drivers/media/dvb/frontends/s5h1420.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/drivers/media/dvb/frontends/s5h1420.c b/drivers/media/dvb/frontends/s5h1420.c index 5dee511544bf..2c2c344c4c64 100644 --- a/drivers/media/dvb/frontends/s5h1420.c +++ b/drivers/media/dvb/frontends/s5h1420.c | |||
@@ -38,7 +38,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
38 | 38 | ||
39 | struct s5h1420_state { | 39 | struct s5h1420_state { |
40 | struct i2c_adapter* i2c; | 40 | struct i2c_adapter* i2c; |
41 | struct dvb_frontend_ops ops; | ||
42 | const struct s5h1420_config* config; | 41 | const struct s5h1420_config* config; |
43 | struct dvb_frontend frontend; | 42 | struct dvb_frontend frontend; |
44 | 43 | ||
@@ -595,14 +594,14 @@ static int s5h1420_set_frontend(struct dvb_frontend* fe, | |||
595 | (state->fec_inner == p->u.qpsk.fec_inner) && | 594 | (state->fec_inner == p->u.qpsk.fec_inner) && |
596 | (state->symbol_rate == p->u.qpsk.symbol_rate)) { | 595 | (state->symbol_rate == p->u.qpsk.symbol_rate)) { |
597 | 596 | ||
598 | if (fe->ops->tuner_ops.set_params) { | 597 | if (fe->ops.tuner_ops.set_params) { |
599 | fe->ops->tuner_ops.set_params(fe, p); | 598 | fe->ops.tuner_ops.set_params(fe, p); |
600 | if (fe->ops->i2c_gate_ctrl) fe->ops->i2c_gate_ctrl(fe, 0); | 599 | if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); |
601 | } | 600 | } |
602 | if (fe->ops->tuner_ops.get_frequency) { | 601 | if (fe->ops.tuner_ops.get_frequency) { |
603 | u32 tmp; | 602 | u32 tmp; |
604 | fe->ops->tuner_ops.get_frequency(fe, &tmp); | 603 | fe->ops.tuner_ops.get_frequency(fe, &tmp); |
605 | if (fe->ops->i2c_gate_ctrl) fe->ops->i2c_gate_ctrl(fe, 0); | 604 | if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); |
606 | s5h1420_setfreqoffset(state, p->frequency - tmp); | 605 | s5h1420_setfreqoffset(state, p->frequency - tmp); |
607 | } else { | 606 | } else { |
608 | s5h1420_setfreqoffset(state, 0); | 607 | s5h1420_setfreqoffset(state, 0); |
@@ -652,9 +651,9 @@ static int s5h1420_set_frontend(struct dvb_frontend* fe, | |||
652 | s5h1420_writereg(state, 0x05, s5h1420_readreg(state, 0x05) | 1); | 651 | s5h1420_writereg(state, 0x05, s5h1420_readreg(state, 0x05) | 1); |
653 | 652 | ||
654 | /* set tuner PLL */ | 653 | /* set tuner PLL */ |
655 | if (fe->ops->tuner_ops.set_params) { | 654 | if (fe->ops.tuner_ops.set_params) { |
656 | fe->ops->tuner_ops.set_params(fe, p); | 655 | fe->ops.tuner_ops.set_params(fe, p); |
657 | if (fe->ops->i2c_gate_ctrl) fe->ops->i2c_gate_ctrl(fe, 0); | 656 | if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); |
658 | s5h1420_setfreqoffset(state, 0); | 657 | s5h1420_setfreqoffset(state, 0); |
659 | } | 658 | } |
660 | 659 | ||
@@ -766,7 +765,6 @@ struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config, | |||
766 | /* setup the state */ | 765 | /* setup the state */ |
767 | state->config = config; | 766 | state->config = config; |
768 | state->i2c = i2c; | 767 | state->i2c = i2c; |
769 | memcpy(&state->ops, &s5h1420_ops, sizeof(struct dvb_frontend_ops)); | ||
770 | state->postlocked = 0; | 768 | state->postlocked = 0; |
771 | state->fclk = 88000000; | 769 | state->fclk = 88000000; |
772 | state->tunedfreq = 0; | 770 | state->tunedfreq = 0; |
@@ -779,7 +777,7 @@ struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config, | |||
779 | goto error; | 777 | goto error; |
780 | 778 | ||
781 | /* create dvb_frontend */ | 779 | /* create dvb_frontend */ |
782 | state->frontend.ops = &state->ops; | 780 | memcpy(&state->frontend.ops, &s5h1420_ops, sizeof(struct dvb_frontend_ops)); |
783 | state->frontend.demodulator_priv = state; | 781 | state->frontend.demodulator_priv = state; |
784 | return &state->frontend; | 782 | return &state->frontend; |
785 | 783 | ||