On Sat, 2 Jun 2007, Michael Krufky wrote: > This is _not_ the final version of the patch. There is still one caller > of dvb_pll_configure (dvb-usb-i2c), and that must be removed before I > can remove the dvb_pll_configure export, and store the pointer to the > dvb_pll_desc inside the priv structure, instead of storing the id. So, let's get rid of that last dvb_pll_configure user! Here's a patch that does it.
# HG changeset patch # User Trent Piepho <xyzzy@xxxxxxxxxxxxx> # Date 1180812646 25200 # Node ID e92f277e9c25e3d18fa77710217efbeb2bbaee9a # Parent 98e80288b44b34a8bf46a049338c02fcee328829 dvb-pll digitv dvb-usb: Eliminate last user of dvb_pll_configure From: Trent Piepho <xyzzy@xxxxxxxxxxxxx> The last user of dvb_pll_configure was the dvb-usb function dvb_usb_tuner_calc_regs(), which was nothing more than a wrapper around dvb_pll_configure(). It's just a copy of the functionality provided by the tuner_ops calc_regs method, and can be deleted. There were two users of dvb_usb_tuner_calc_regs(). One was dvb_usb_tuner_set_params_i2c(), which is converted to use fe->ops.tuner_ops.calc_regs(). The other was the digitv driver. This driver can use one of two demods, mt352 or nxt6000. For the mt352, the driver would set tuner_ops.calc_regs to dvb_usb_tuner_calc_regs(). We can just attach dvb_pll and use the tuner_ops.calc_regs() provided by that module. For the nxt600, the driver would set tuner_ops.set_params to digitv_nxt6000_tuner_set_params. That function would in turn use dvb_usb_tuner_calc_regs(). We convert it to use tuner_ops.calc_regs() instead, and use dvb_pll_attach. The digitv_tuner_attach() needs to know which frontend was attached by digitv_frontend_attach(), since the nxt6000 needs tuner_ops.set_params() to be overridden with digitv_nxt6000_tuner_set_params(). So to do this a digitv_state that says which frontend was used is added to the dvb_usb_device private state field. Signed-off-by: Trent Piepho <xyzzy@xxxxxxxxxxxxx> diff -r 98e80288b44b -r e92f277e9c25 linux/drivers/media/dvb/dvb-usb/digitv.c --- a/linux/drivers/media/dvb/dvb-usb/digitv.c Fri Jun 01 20:27:57 2007 -0300 +++ b/linux/drivers/media/dvb/dvb-usb/digitv.c Sat Jun 02 12:30:46 2007 -0700 @@ -118,7 +118,8 @@ static int digitv_nxt6000_tuner_set_para { struct dvb_usb_adapter *adap = fe->dvb->priv; u8 b[5]; - dvb_usb_tuner_calc_regs(fe,fep,b, 5); + + fe->ops.tuner_ops.calc_regs(fe, fep, b, sizeof(b)); if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 1); return digitv_ctrl_msg(adap->dev, USB_WRITE_TUNER, 0, &b[1], 4, NULL, 0); @@ -130,21 +131,29 @@ static struct nxt6000_config digitv_nxt6 static int digitv_frontend_attach(struct dvb_usb_adapter *adap) { + struct digitv_state *st = adap->dev->priv; + if ((adap->fe = dvb_attach(mt352_attach, &digitv_mt352_config, &adap->dev->i2c_adap)) != NULL) { - adap->fe->ops.tuner_ops.calc_regs = dvb_usb_tuner_calc_regs; + st->is_nxt6000 = 0; return 0; } if ((adap->fe = dvb_attach(nxt6000_attach, &digitv_nxt6000_config, &adap->dev->i2c_adap)) != NULL) { + st->is_nxt6000 = 1; + return 0; + } + return -EIO; +} + +static int digitv_tuner_attach(struct dvb_usb_adapter *adap) +{ + struct digitv_state *st = adap->dev->priv; + + if (!dvb_attach(dvb_pll_attach, adap->fe, 0x60, NULL, &dvb_pll_tded4)) + return -ENODEV; + + if (st->is_nxt6000) adap->fe->ops.tuner_ops.set_params = digitv_nxt6000_tuner_set_params; - return 0; - } - return -EIO; -} - -static int digitv_tuner_attach(struct dvb_usb_adapter *adap) -{ - adap->pll_addr = 0x60; - adap->pll_desc = &dvb_pll_tded4; + return 0; } @@ -273,6 +282,8 @@ static struct dvb_usb_device_properties .usb_ctrl = CYPRESS_FX2, .firmware = "dvb-usb-digitv-02.fw", + .size_of_priv = sizeof(struct digitv_state), + .num_adapters = 1, .adapter = { { diff -r 98e80288b44b -r e92f277e9c25 linux/drivers/media/dvb/dvb-usb/digitv.h --- a/linux/drivers/media/dvb/dvb-usb/digitv.h Fri Jun 01 20:27:57 2007 -0300 +++ b/linux/drivers/media/dvb/dvb-usb/digitv.h Sat Jun 02 12:30:46 2007 -0700 @@ -3,6 +3,10 @@ #define DVB_USB_LOG_PREFIX "digitv" #include "dvb-usb.h" + +struct digitv_state { + int is_nxt6000; +}; extern int dvb_usb_digitv_debug; #define deb_rc(args...) dprintk(dvb_usb_digitv_debug,0x01,args) diff -r 98e80288b44b -r e92f277e9c25 linux/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c --- a/linux/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c Fri Jun 01 20:27:57 2007 -0300 +++ b/linux/drivers/media/dvb/dvb-usb/dvb-usb-i2c.c Sat Jun 02 12:30:46 2007 -0700 @@ -78,26 +78,6 @@ int dvb_usb_tuner_init_i2c(struct dvb_fr } EXPORT_SYMBOL(dvb_usb_tuner_init_i2c); -int dvb_usb_tuner_calc_regs(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep, u8 *b, int buf_len) -{ - struct dvb_usb_adapter *adap = fe->dvb->priv; - - if (buf_len != 5) - return -EINVAL; - if (adap->pll_desc == NULL) - return 0; - - deb_pll("pll addr: %x, freq: %d %p\n",adap->pll_addr, fep->frequency, adap->pll_desc); - - b[0] = adap->pll_addr; - dvb_pll_configure(adap->pll_desc, &b[1], fep); - - deb_pll("pll-buf: %x %x %x %x %x\n",b[0],b[1],b[2],b[3],b[4]); - - return 5; -} -EXPORT_SYMBOL(dvb_usb_tuner_calc_regs); - int dvb_usb_tuner_set_params_i2c(struct dvb_frontend *fe, struct dvb_frontend_parameters *fep) { struct dvb_usb_adapter *adap = fe->dvb->priv; @@ -105,7 +85,7 @@ int dvb_usb_tuner_set_params_i2c(struct u8 b[5]; struct i2c_msg msg = { .addr = adap->pll_addr, .flags = 0, .buf = &b[1], .len = 4 }; - dvb_usb_tuner_calc_regs(fe,fep,b,5); + fe->ops.tuner_ops.calc_regs(fe, fep, b, sizeof(b)); if (adap->tuner_pass_ctrl) adap->tuner_pass_ctrl(fe, 1, adap->pll_addr); diff -r 98e80288b44b -r e92f277e9c25 linux/drivers/media/dvb/dvb-usb/dvb-usb.h --- a/linux/drivers/media/dvb/dvb-usb/dvb-usb.h Fri Jun 01 20:27:57 2007 -0300 +++ b/linux/drivers/media/dvb/dvb-usb/dvb-usb.h Sat Jun 02 12:30:46 2007 -0700 @@ -405,7 +405,6 @@ extern int dvb_usb_nec_rc_key_to_event(s /* commonly used pll init and set functions */ extern int dvb_usb_tuner_init_i2c(struct dvb_frontend *); -extern int dvb_usb_tuner_calc_regs(struct dvb_frontend *, struct dvb_frontend_parameters *, u8 *buf, int buf_len); extern int dvb_usb_tuner_set_params_i2c(struct dvb_frontend *, struct dvb_frontend_parameters *); /* commonly used firmware download types and function */ diff -r 98e80288b44b -r e92f277e9c25 linux/drivers/media/dvb/frontends/dvb-pll.c --- a/linux/drivers/media/dvb/frontends/dvb-pll.c Fri Jun 01 20:27:57 2007 -0300 +++ b/linux/drivers/media/dvb/frontends/dvb-pll.c Sat Jun 02 12:30:46 2007 -0700 @@ -522,8 +522,8 @@ module_param(debug, int, 0644); module_param(debug, int, 0644); MODULE_PARM_DESC(debug, "enable verbose debug messages"); -int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf, - const struct dvb_frontend_parameters *params) +static int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf, + const struct dvb_frontend_parameters *params) { u32 div; int i; diff -r 98e80288b44b -r e92f277e9c25 linux/drivers/media/dvb/frontends/dvb-pll.h --- a/linux/drivers/media/dvb/frontends/dvb-pll.h Fri Jun 01 20:27:57 2007 -0300 +++ b/linux/drivers/media/dvb/frontends/dvb-pll.h Sat Jun 02 12:30:46 2007 -0700 @@ -50,9 +50,6 @@ extern struct dvb_pll_desc dvb_pll_thoms extern struct dvb_pll_desc dvb_pll_thomson_fe6600; extern struct dvb_pll_desc dvb_pll_opera1; -extern int dvb_pll_configure(struct dvb_pll_desc *desc, u8 *buf, - const struct dvb_frontend_parameters *params); - /** * Attach a dvb-pll to the supplied frontend structure. *
_______________________________________________ linux-dvb mailing list linux-dvb@xxxxxxxxxxx http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb