aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Bunk <bunk@stusta.de>2006-02-26 22:07:49 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-03-03 12:17:35 -0500
commit805e660ca32ef63b81203a556f29fef262b95cc0 (patch)
tree178c50989edb11f54ea6c1e4c7b82359375f0062
parent2d748ba1669070a12bab11b19d20fd8daf537ef5 (diff)
V4L/DVB (3337): Drivers/media/dvb/frontends/mt312.c: cleanups
This patch contains the following possible cleanups: - update the Kconfig help to mention the VP310 - merge vp310_attach and mt312_attach into a new vp310_mt312_attach to remove some code duplication Signed-off-by: Adrian Bunk <bunk@stusta.de> Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r--drivers/media/dvb/b2c2/flexcop-fe-tuner.c2
-rw-r--r--drivers/media/dvb/frontends/Kconfig2
-rw-r--r--drivers/media/dvb/frontends/mt312.c116
-rw-r--r--drivers/media/dvb/frontends/mt312.h6
4 files changed, 48 insertions, 78 deletions
diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
index 390cc3a99ce6..9c7f122826e0 100644
--- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
+++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
@@ -526,7 +526,7 @@ int flexcop_frontend_init(struct flexcop_device *fc)
526 info("found the stv0297 at i2c address: 0x%02x",alps_tdee4_stv0297_config.demod_address); 526 info("found the stv0297 at i2c address: 0x%02x",alps_tdee4_stv0297_config.demod_address);
527 } else 527 } else
528 /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */ 528 /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */
529 if ((fc->fe = vp310_attach(&skystar23_samsung_tbdu18132_config, &fc->i2c_adap)) != NULL) { 529 if ((fc->fe = vp310_mt312_attach(&skystar23_samsung_tbdu18132_config, &fc->i2c_adap)) != NULL) {
530 ops = fc->fe->ops; 530 ops = fc->fe->ops;
531 531
532 ops->diseqc_send_master_cmd = flexcop_diseqc_send_master_cmd; 532 ops->diseqc_send_master_cmd = flexcop_diseqc_send_master_cmd;
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig
index 76b6a2aef32f..c676b1e23ab0 100644
--- a/drivers/media/dvb/frontends/Kconfig
+++ b/drivers/media/dvb/frontends/Kconfig
@@ -29,7 +29,7 @@ config DVB_TDA8083
29 A DVB-S tuner module. Say Y when you want to support this frontend. 29 A DVB-S tuner module. Say Y when you want to support this frontend.
30 30
31config DVB_MT312 31config DVB_MT312
32 tristate "Zarlink MT312 based" 32 tristate "Zarlink VP310/MT312 based"
33 depends on DVB_CORE 33 depends on DVB_CORE
34 help 34 help
35 A DVB-S tuner module. Say Y when you want to support this frontend. 35 A DVB-S tuner module. Say Y when you want to support this frontend.
diff --git a/drivers/media/dvb/frontends/mt312.c b/drivers/media/dvb/frontends/mt312.c
index ec4e641acc64..d3aea83cf218 100644
--- a/drivers/media/dvb/frontends/mt312.c
+++ b/drivers/media/dvb/frontends/mt312.c
@@ -612,76 +612,6 @@ static void mt312_release(struct dvb_frontend* fe)
612 kfree(state); 612 kfree(state);
613} 613}
614 614
615static struct dvb_frontend_ops vp310_mt312_ops;
616
617struct dvb_frontend* vp310_attach(const struct mt312_config* config,
618 struct i2c_adapter* i2c)
619{
620 struct mt312_state* state = NULL;
621
622 /* allocate memory for the internal state */
623 state = kmalloc(sizeof(struct mt312_state), GFP_KERNEL);
624 if (state == NULL)
625 goto error;
626
627 /* setup the state */
628 state->config = config;
629 state->i2c = i2c;
630 memcpy(&state->ops, &vp310_mt312_ops, sizeof(struct dvb_frontend_ops));
631 strcpy(state->ops.info.name, "Zarlink VP310 DVB-S");
632
633 /* check if the demod is there */
634 if (mt312_readreg(state, ID, &state->id) < 0)
635 goto error;
636 if (state->id != ID_VP310) {
637 goto error;
638 }
639
640 /* create dvb_frontend */
641 state->frequency = 90;
642 state->frontend.ops = &state->ops;
643 state->frontend.demodulator_priv = state;
644 return &state->frontend;
645
646error:
647 kfree(state);
648 return NULL;
649}
650
651struct dvb_frontend* mt312_attach(const struct mt312_config* config,
652 struct i2c_adapter* i2c)
653{
654 struct mt312_state* state = NULL;
655
656 /* allocate memory for the internal state */
657 state = kmalloc(sizeof(struct mt312_state), GFP_KERNEL);
658 if (state == NULL)
659 goto error;
660
661 /* setup the state */
662 state->config = config;
663 state->i2c = i2c;
664 memcpy(&state->ops, &vp310_mt312_ops, sizeof(struct dvb_frontend_ops));
665 strcpy(state->ops.info.name, "Zarlink MT312 DVB-S");
666
667 /* check if the demod is there */
668 if (mt312_readreg(state, ID, &state->id) < 0)
669 goto error;
670 if (state->id != ID_MT312) {
671 goto error;
672 }
673
674 /* create dvb_frontend */
675 state->frequency = 60;
676 state->frontend.ops = &state->ops;
677 state->frontend.demodulator_priv = state;
678 return &state->frontend;
679
680error:
681 kfree(state);
682 return NULL;
683}
684
685static struct dvb_frontend_ops vp310_mt312_ops = { 615static struct dvb_frontend_ops vp310_mt312_ops = {
686 616
687 .info = { 617 .info = {
@@ -720,6 +650,49 @@ static struct dvb_frontend_ops vp310_mt312_ops = {
720 .set_voltage = mt312_set_voltage, 650 .set_voltage = mt312_set_voltage,
721}; 651};
722 652
653struct dvb_frontend* vp310_mt312_attach(const struct mt312_config* config,
654 struct i2c_adapter* i2c)
655{
656 struct mt312_state* state = NULL;
657
658 /* allocate memory for the internal state */
659 state = kmalloc(sizeof(struct mt312_state), GFP_KERNEL);
660 if (state == NULL)
661 goto error;
662
663 /* setup the state */
664 state->config = config;
665 state->i2c = i2c;
666 memcpy(&state->ops, &vp310_mt312_ops, sizeof(struct dvb_frontend_ops));
667
668 /* check if the demod is there */
669 if (mt312_readreg(state, ID, &state->id) < 0)
670 goto error;
671
672 switch (state->id) {
673 case ID_VP310:
674 strcpy(state->ops.info.name, "Zarlink VP310 DVB-S");
675 state->frequency = 90;
676 break;
677 case ID_MT312:
678 strcpy(state->ops.info.name, "Zarlink MT312 DVB-S");
679 state->frequency = 60;
680 break;
681 default:
682 printk (KERN_WARNING "Only Zarlink VP310/MT312 are supported chips.\n");
683 goto error;
684 }
685
686 /* create dvb_frontend */
687 state->frontend.ops = &state->ops;
688 state->frontend.demodulator_priv = state;
689 return &state->frontend;
690
691error:
692 kfree(state);
693 return NULL;
694}
695
723module_param(debug, int, 0644); 696module_param(debug, int, 0644);
724MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); 697MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
725 698
@@ -727,5 +700,4 @@ MODULE_DESCRIPTION("Zarlink VP310/MT312 DVB-S Demodulator driver");
727MODULE_AUTHOR("Andreas Oberritter <obi@linuxtv.org>"); 700MODULE_AUTHOR("Andreas Oberritter <obi@linuxtv.org>");
728MODULE_LICENSE("GPL"); 701MODULE_LICENSE("GPL");
729 702
730EXPORT_SYMBOL(mt312_attach); 703EXPORT_SYMBOL(vp310_mt312_attach);
731EXPORT_SYMBOL(vp310_attach);
diff --git a/drivers/media/dvb/frontends/mt312.h b/drivers/media/dvb/frontends/mt312.h
index b3a53a73a117..074d844f0139 100644
--- a/drivers/media/dvb/frontends/mt312.h
+++ b/drivers/media/dvb/frontends/mt312.h
@@ -38,10 +38,8 @@ struct mt312_config
38 int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); 38 int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
39}; 39};
40 40
41extern struct dvb_frontend* mt312_attach(const struct mt312_config* config, 41struct dvb_frontend* vp310_mt312_attach(const struct mt312_config* config,
42 struct i2c_adapter* i2c); 42 struct i2c_adapter* i2c);
43 43
44extern struct dvb_frontend* vp310_attach(const struct mt312_config* config,
45 struct i2c_adapter* i2c);
46 44
47#endif // MT312_H 45#endif // MT312_H