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>

authored by Adrian Bunk and committed by Mauro Carvalho Chehab 805e660c 2d748ba1

+48 -78
+1 -1
drivers/media/dvb/b2c2/flexcop-fe-tuner.c
··· 526 526 info("found the stv0297 at i2c address: 0x%02x",alps_tdee4_stv0297_config.demod_address); 527 527 } else 528 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 530 ops = fc->fe->ops; 531 531 532 532 ops->diseqc_send_master_cmd = flexcop_diseqc_send_master_cmd;
+1 -1
drivers/media/dvb/frontends/Kconfig
··· 29 29 A DVB-S tuner module. Say Y when you want to support this frontend. 30 30 31 31 config DVB_MT312 32 - tristate "Zarlink MT312 based" 32 + tristate "Zarlink VP310/MT312 based" 33 33 depends on DVB_CORE 34 34 help 35 35 A DVB-S tuner module. Say Y when you want to support this frontend.
+44 -72
drivers/media/dvb/frontends/mt312.c
··· 612 612 kfree(state); 613 613 } 614 614 615 - static struct dvb_frontend_ops vp310_mt312_ops; 616 - 617 - struct 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 - 646 - error: 647 - kfree(state); 648 - return NULL; 649 - } 650 - 651 - struct 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 - 680 - error: 681 - kfree(state); 682 - return NULL; 683 - } 684 - 685 615 static struct dvb_frontend_ops vp310_mt312_ops = { 686 616 687 617 .info = { ··· 650 720 .set_voltage = mt312_set_voltage, 651 721 }; 652 722 723 + struct dvb_frontend* vp310_mt312_attach(const struct mt312_config* config, 724 + struct i2c_adapter* i2c) 725 + { 726 + struct mt312_state* state = NULL; 727 + 728 + /* allocate memory for the internal state */ 729 + state = kmalloc(sizeof(struct mt312_state), GFP_KERNEL); 730 + if (state == NULL) 731 + goto error; 732 + 733 + /* setup the state */ 734 + state->config = config; 735 + state->i2c = i2c; 736 + memcpy(&state->ops, &vp310_mt312_ops, sizeof(struct dvb_frontend_ops)); 737 + 738 + /* check if the demod is there */ 739 + if (mt312_readreg(state, ID, &state->id) < 0) 740 + goto error; 741 + 742 + switch (state->id) { 743 + case ID_VP310: 744 + strcpy(state->ops.info.name, "Zarlink VP310 DVB-S"); 745 + state->frequency = 90; 746 + break; 747 + case ID_MT312: 748 + strcpy(state->ops.info.name, "Zarlink MT312 DVB-S"); 749 + state->frequency = 60; 750 + break; 751 + default: 752 + printk (KERN_WARNING "Only Zarlink VP310/MT312 are supported chips.\n"); 753 + goto error; 754 + } 755 + 756 + /* create dvb_frontend */ 757 + state->frontend.ops = &state->ops; 758 + state->frontend.demodulator_priv = state; 759 + return &state->frontend; 760 + 761 + error: 762 + kfree(state); 763 + return NULL; 764 + } 765 + 653 766 module_param(debug, int, 0644); 654 767 MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); 655 768 ··· 700 727 MODULE_AUTHOR("Andreas Oberritter <obi@linuxtv.org>"); 701 728 MODULE_LICENSE("GPL"); 702 729 703 - EXPORT_SYMBOL(mt312_attach); 704 - EXPORT_SYMBOL(vp310_attach); 730 + EXPORT_SYMBOL(vp310_mt312_attach);
+2 -4
drivers/media/dvb/frontends/mt312.h
··· 38 38 int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); 39 39 }; 40 40 41 - extern struct dvb_frontend* mt312_attach(const struct mt312_config* config, 42 - struct i2c_adapter* i2c); 41 + struct dvb_frontend* vp310_mt312_attach(const struct mt312_config* config, 42 + struct i2c_adapter* i2c); 43 43 44 - extern struct dvb_frontend* vp310_attach(const struct mt312_config* config, 45 - struct i2c_adapter* i2c); 46 44 47 45 #endif // MT312_H