Skip to contentSkip to conversation

drivers/media/dvb/frontends/mt312.c: possible cleanups

PATCH In review Adrian Bunk 3 participants 5 messages Feb 4, 2006 – Feb 10, 2006 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/media/dvb/frontends/mt312.c: possible 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

---

This patch was already sent on:
- 28 Jan 2006

 drivers/media/dvb/b2c2/flexcop-fe-tuner.c |    2 
 drivers/media/dvb/frontends/Kconfig       |    2 
 drivers/media/dvb/frontends/mt312.c       |  111 +++++++---------------
 drivers/media/dvb/frontends/mt312.h       |    6 -
 4 files changed, 43 insertions(+), 78 deletions(-)
drivers/media/dvb/frontends/Kconfig renamed from drivers/media/dvb/frontends/Kconfig.old +1 -1
@@ -29,7 +29,7 @@
 	  A DVB-S tuner module. Say Y when you want to support this frontend.
 
 config DVB_MT312
-	tristate "Zarlink MT312 based"
+	tristate "Zarlink VP310/MT312 based"
 	depends on DVB_CORE
 	help
 	  A DVB-S tuner module. Say Y when you want to support this frontend.
drivers/media/dvb/frontends/mt312.h renamed from drivers/media/dvb/frontends/mt312.h.old +2 -4
@@ -38,10 +38,8 @@
 	int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
 };
 
-extern struct dvb_frontend* mt312_attach(const struct mt312_config* config,
-					 struct i2c_adapter* i2c);
+struct dvb_frontend* vp310_mt312_attach(const struct mt312_config* config,
+					struct i2c_adapter* i2c);
 
-extern struct dvb_frontend* vp310_attach(const struct mt312_config* config,
-					 struct i2c_adapter* i2c);
 
 #endif // MT312_H
drivers/media/dvb/frontends/mt312.c renamed from drivers/media/dvb/frontends/mt312.c.old +39 -72

126 lines not on this page · raw message

drivers/media/dvb/b2c2/flexcop-fe-tuner.c renamed from drivers/media/dvb/b2c2/flexcop-fe-tuner.c.old +1 -1
@@ -526,7 +526,7 @@
 		info("found the stv0297 at i2c address: 0x%02x",alps_tdee4_stv0297_config.demod_address);
 	} else
 	/* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */
-	if ((fc->fe = vp310_attach(&skystar23_samsung_tbdu18132_config, &fc->i2c_adap)) != NULL) {
+	if ((fc->fe = vp310_mt312_attach(&skystar23_samsung_tbdu18132_config, &fc->i2c_adap)) != NULL) {
 		ops = fc->fe->ops;
 
 		ops->diseqc_send_master_cmd = flexcop_diseqc_send_master_cmd;
#1 lore raw
Quoted 51 lines · Adrian Bunk

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

---

This patch was already sent on:
- 28 Jan 2006

 drivers/media/dvb/b2c2/flexcop-fe-tuner.c |    2 
 drivers/media/dvb/frontends/Kconfig       |    2 
 drivers/media/dvb/frontends/mt312.c       |  111 +++++++---------------
 drivers/media/dvb/frontends/mt312.h       |    6 -
 4 files changed, 43 insertions(+), 78 deletions(-)
drivers/media/dvb/frontends/Kconfig renamed from drivers/media/dvb/frontends/Kconfig.old +1 -1
@@ -29,7 +29,7 @@
 	  A DVB-S tuner module. Say Y when you want to support this frontend.
 
 config DVB_MT312
-	tristate "Zarlink MT312 based"
+	tristate "Zarlink VP310/MT312 based"
 	depends on DVB_CORE
 	help
 	  A DVB-S tuner module. Say Y when you want to support this frontend.
drivers/media/dvb/frontends/mt312.h renamed from drivers/media/dvb/frontends/mt312.h.old +2 -4
@@ -38,10 +38,8 @@
 	int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
 };
 
-extern struct dvb_frontend* mt312_attach(const struct mt312_config* config,
-					 struct i2c_adapter* i2c);
+struct dvb_frontend* vp310_mt312_attach(const struct mt312_config* config,
+					struct i2c_adapter* i2c);
 
-extern struct dvb_frontend* vp310_attach(const struct mt312_config* config,
-					 struct i2c_adapter* i2c);
 
 #endif // MT312_H
drivers/media/dvb/frontends/mt312.c renamed from drivers/media/dvb/frontends/mt312.c.old +0 -0
@@ -612,76 +612,6 @@
 	kfree(state);
 }
 

[snip]

Quoted 24 lines

static struct dvb_frontend_ops vp310_mt312_ops = {

drivers/media/dvb/frontends/mt312.c renamed from drivers/media/dvb/frontends/mt312.c.old +17 -0
 	.info = {
@@ -720,6 +650,44 @@
 	.set_voltage = mt312_set_voltage,
 };
 
+struct dvb_frontend* vp310_mt312_attach(const struct mt312_config* config,
+					struct i2c_adapter* i2c)
+{
+	struct mt312_state* state = NULL;
+
+	/* allocate memory for the internal state */
+	state = kmalloc(sizeof(struct mt312_state), GFP_KERNEL);
+	if (state == NULL)
+		goto error;
+
+	/* setup the state */
+	state->config = config;
+	state->i2c = i2c;
+	memcpy(&state->ops, &vp310_mt312_ops, sizeof(struct dvb_frontend_ops));
+
+	/* check if the demod is there */
+	if (mt312_readreg(state, ID, &state->id) < 0)

drivers/media/dvb/frontends/mt312.c line 679

Quoted 10 lines
drivers/media/dvb/frontends/mt312.c renamed from drivers/media/dvb/frontends/mt312.c.old +10 -0
+		goto error;
+
+	if (state->id == ID_VP310){
+		strcpy(state->ops.info.name, "Zarlink VP310 DVB-S");
+		state->frequency = 90;
+	} else if (state->id == ID_MT312) {
+		strcpy(state->ops.info.name, "Zarlink MT312 DVB-S");
+		state->frequency = 60;
+	} else
+		goto error;

^^^ I would prefer to see this as a switch..case block, in the spirit of nxt200x and lgdt330x.

Quoted 15 lines
drivers/media/dvb/frontends/mt312.c renamed from drivers/media/dvb/frontends/mt312.c.old +11 -0
+
+	/* create dvb_frontend */
+	state->frontend.ops = &state->ops;
+	state->frontend.demodulator_priv = state;
+	return &state->frontend;
+
+error:
+	kfree(state);
+	return NULL;
+}
+
 module_param(debug, int, 0644);
 MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
 

drivers/media/dvb/frontends/mt312.c line 698

Quoted 6 lines
drivers/media/dvb/frontends/mt312.c renamed from drivers/media/dvb/frontends/mt312.c.old +1 -2
@@ -727,5 +695,4 @@
 MODULE_AUTHOR("Andreas Oberritter <[email protected]>");
 MODULE_LICENSE("GPL");
 
-EXPORT_SYMBOL(mt312_attach);
-EXPORT_SYMBOL(vp310_attach);
+EXPORT_SYMBOL(vp310_mt312_attach);

^^^ I think vp310_mt312_attach is starting to get long, maybe even ugly.
Isn't mt312_attach enough, considering that it is the name of the
module? I think just mt312_attach would be nicer, unless someone thinks otherwise?

drivers/media/dvb/b2c2/flexcop-fe-tuner.c line 532

Quoted 11 lines
drivers/media/dvb/b2c2/flexcop-fe-tuner.c renamed from drivers/media/dvb/b2c2/flexcop-fe-tuner.c.old +1 -1
@@ -526,7 +526,7 @@
 		info("found the stv0297 at i2c address: 0x%02x",alps_tdee4_stv0297_config.demod_address);
 	} else
 	/* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */
-	if ((fc->fe = vp310_attach(&skystar23_samsung_tbdu18132_config, &fc->i2c_adap)) != NULL) {
+	if ((fc->fe = vp310_mt312_attach(&skystar23_samsung_tbdu18132_config, &fc->i2c_adap)) != NULL) {
 		ops = fc->fe->ops;
 
 		ops->diseqc_send_master_cmd = flexcop_diseqc_send_master_cmd;

Besides my comments above, the patch looks okay to me, by eye, although I lack the hardware to test...

-Michael Krufky

#2 lore raw
Quoted 2 lines · Michael Krufky

drivers/media/dvb/frontends/mt312.c line 672

Quoted 1 line · Adrian Bunk
drivers/media/dvb/frontends/mt312.c renamed from drivers/media/dvb/frontends/mt312.c.old +1 -0
+	if (state->id == ID_VP310){

lacks a space

Quoted 8 lines

drivers/media/dvb/frontends/mt312.c line 698

Quoted 3 lines
drivers/media/dvb/frontends/mt312.c renamed from drivers/media/dvb/frontends/mt312.c.old +1 -2
-EXPORT_SYMBOL(mt312_attach);
-EXPORT_SYMBOL(vp310_attach);
+EXPORT_SYMBOL(vp310_mt312_attach);

^^^ I think vp310_mt312_attach is starting to get long, maybe even ugly.
Isn't mt312_attach enough, considering that it is the name of the
module? I think just mt312_attach would be nicer, unless someone thinks otherwise?

...

Quoted 5 lines
Quoted 5 lines
(quoted diff) +0 -1
-	if ((fc->fe = vp310_attach(&skystar23_samsung_tbdu18132_config, 

&fc->i2c_adap)) != NULL) {

(quoted diff) +1 -0
+	if ((fc->fe = 

vp310_mt312_attach(&skystar23_samsung_tbdu18132_config, &fc->i2c_adap)) != NULL) {

mt312_attach() isn't used by any driver, so it looks like a bad choice for a name. IMHO vp310_mt312_attach() is fine.

Johannes

#3 lore raw

PATCH 1/1 drivers/media/dvb/frontends/mt312.c: cleanups

In reply to Michael Krufky
Quoted 13 lines · Michael Krufky

Adrian Bunk wrote:
...

Review

Quoted 8 lines
(quoted diff) +8 -0
+	if (state->id == ID_VP310){
+		strcpy(state->ops.info.name, "Zarlink VP310 DVB-S");
+		state->frequency = 90;
+	} else if (state->id == ID_MT312) {
+		strcpy(state->ops.info.name, "Zarlink MT312 DVB-S");
+		state->frequency = 60;
+	} else
+		goto error;

^^^ I would prefer to see this as a switch..case block, in the spirit of nxt200x and lgdt330x.

Updated patch below.

Quoted 10 lines

...

Review

Quoted 3 lines
(quoted diff) +1 -2
-EXPORT_SYMBOL(mt312_attach);
-EXPORT_SYMBOL(vp310_attach);
+EXPORT_SYMBOL(vp310_mt312_attach);

^^^ I think vp310_mt312_attach is starting to get long, maybe even ugly.
Isn't mt312_attach enough, considering that it is the name of the
module? I think just mt312_attach would be nicer, unless someone thinks otherwise?
...

I kept it based on Johannes' comment.

Quoted 1 line

-Michael Krufky

cu
Adrian

<-- snip -->

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

---

 drivers/media/dvb/b2c2/flexcop-fe-tuner.c |    2 
 drivers/media/dvb/frontends/Kconfig       |    2 
 drivers/media/dvb/frontends/mt312.c       |  116 ++++++++--------------
 drivers/media/dvb/frontends/mt312.h       |    6 -
 4 files changed, 48 insertions(+), 78 deletions(-)
drivers/media/dvb/frontends/Kconfig renamed from drivers/media/dvb/frontends/Kconfig.old +1 -1
@@ -29,7 +29,7 @@
 	  A DVB-S tuner module. Say Y when you want to support this frontend.
 
 config DVB_MT312
-	tristate "Zarlink MT312 based"
+	tristate "Zarlink VP310/MT312 based"
 	depends on DVB_CORE
 	help
 	  A DVB-S tuner module. Say Y when you want to support this frontend.
drivers/media/dvb/frontends/mt312.h renamed from drivers/media/dvb/frontends/mt312.h.old +2 -4
@@ -38,10 +38,8 @@
 	int (*pll_set)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
 };
 
-extern struct dvb_frontend* mt312_attach(const struct mt312_config* config,
-					 struct i2c_adapter* i2c);
+struct dvb_frontend* vp310_mt312_attach(const struct mt312_config* config,
+					struct i2c_adapter* i2c);
 
-extern struct dvb_frontend* vp310_attach(const struct mt312_config* config,
-					 struct i2c_adapter* i2c);
 
 #endif // MT312_H
drivers/media/dvb/b2c2/flexcop-fe-tuner.c renamed from drivers/media/dvb/b2c2/flexcop-fe-tuner.c.old +1 -1
@@ -526,7 +526,7 @@
 		info("found the stv0297 at i2c address: 0x%02x",alps_tdee4_stv0297_config.demod_address);
 	} else
 	/* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */
-	if ((fc->fe = vp310_attach(&skystar23_samsung_tbdu18132_config, &fc->i2c_adap)) != NULL) {
+	if ((fc->fe = vp310_mt312_attach(&skystar23_samsung_tbdu18132_config, &fc->i2c_adap)) != NULL) {
 		ops = fc->fe->ops;
 
 		ops->diseqc_send_master_cmd = flexcop_diseqc_send_master_cmd;
drivers/media/dvb/frontends/mt312.c renamed from drivers/media/dvb/frontends/mt312.c.old +44 -72

131 lines not on this page · raw message

#4 lore raw

Re: [2.6 patch] drivers/media/dvb/frontends/mt312.c: cleanups

Quoted 8 lines · Adrian Bunk

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

Quoted 7 lines

---

 drivers/media/dvb/b2c2/flexcop-fe-tuner.c |    2 
 drivers/media/dvb/frontends/Kconfig       |    2 
 drivers/media/dvb/frontends/mt312.c       |  116 ++++++++--------------
 drivers/media/dvb/frontends/mt312.h       |    6 -
 4 files changed, 48 insertions(+), 78 deletions(-)

Thanks, Adrian. I've applied this to my tree.

Regards,

Michael Krufky