diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2007-09-14 10:13:54 +0200 |
---|---|---|
committer | Hans Verkuil <hverkuil@xs4all.nl> | 2007-09-14 10:13:54 +0200 |
commit | ee8841ac8cd3158d3cc78ed87925dbf4768dd2f8 (patch) | |
tree | 6a9f00f7e18a3a85516bceb8c821a712f5aa954a | |
parent | 45d49155305901c4e98c65f2fb47541d59b5bcc5 (diff) | |
download | mediapointer-dvb-s2-ee8841ac8cd3158d3cc78ed87925dbf4768dd2f8.tar.gz mediapointer-dvb-s2-ee8841ac8cd3158d3cc78ed87925dbf4768dd2f8.tar.bz2 |
tuner: i2c_client cannot be part of the tuner struct
From: Hans Verkuil <hverkuil@xs4all.nl>
The bus-based I2C subsystem allocates the i2c_client struct. So if in order to
be able to convert the tuner to the bus-based I2C API the embedded i2c_client
struct must be removed from the tuner struct and replaced with a pointer.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
---
linux/drivers/media/video/tda8290.c | 22 ++++++-------
linux/drivers/media/video/tda9887.c | 22 ++++++-------
linux/drivers/media/video/tuner-core.c | 51 ++++++++++++++++++-------------
linux/drivers/media/video/tuner-driver.h | 26 +++++++--------
4 files changed, 65 insertions(+), 56 deletions(-)
-rw-r--r-- | linux/drivers/media/video/tda8290.c | 22 | ||||
-rw-r--r-- | linux/drivers/media/video/tda9887.c | 22 | ||||
-rw-r--r-- | linux/drivers/media/video/tuner-core.c | 51 | ||||
-rw-r--r-- | linux/drivers/media/video/tuner-driver.h | 26 |
4 files changed, 65 insertions, 56 deletions
diff --git a/linux/drivers/media/video/tda8290.c b/linux/drivers/media/video/tda8290.c index 4e0ed4f57..8026e65a8 100644 --- a/linux/drivers/media/video/tda8290.c +++ b/linux/drivers/media/video/tda8290.c @@ -639,22 +639,22 @@ static int tda829x_find_tuner(struct dvb_frontend *fe) switch (priv->ver) { case TDA8290 | TDA8275: - strlcpy(t->i2c.name, "tda8290+75", sizeof(t->i2c.name)); + strlcpy(t->i2c->name, "tda8290+75", sizeof(t->i2c->name)); break; case TDA8295 | TDA8275: - strlcpy(t->i2c.name, "tda8295+75", sizeof(t->i2c.name)); + strlcpy(t->i2c->name, "tda8295+75", sizeof(t->i2c->name)); break; case TDA8290 | TDA8275A: - strlcpy(t->i2c.name, "tda8290+75a", sizeof(t->i2c.name)); + strlcpy(t->i2c->name, "tda8290+75a", sizeof(t->i2c->name)); break; case TDA8295 | TDA8275A: - strlcpy(t->i2c.name, "tda8295+75a", sizeof(t->i2c.name)); + strlcpy(t->i2c->name, "tda8295+75a", sizeof(t->i2c->name)); break; case TDA8290 | TDA18271: - strlcpy(t->i2c.name, "tda8290+18271", sizeof(t->i2c.name)); + strlcpy(t->i2c->name, "tda8290+18271", sizeof(t->i2c->name)); break; case TDA8295 | TDA18271: - strlcpy(t->i2c.name, "tda8295+18271", sizeof(t->i2c.name)); + strlcpy(t->i2c->name, "tda8295+18271", sizeof(t->i2c->name)); break; default: return -EINVAL; @@ -696,8 +696,8 @@ int tda829x_attach(struct tuner *t) return -ENOMEM; fe->analog_demod_priv = priv; - priv->i2c_props.addr = t->i2c.addr; - priv->i2c_props.adap = t->i2c.adapter; + priv->i2c_props.addr = t->i2c->addr; + priv->i2c_props.adap = t->i2c->adapter; priv->cfg.config = &t->config; priv->cfg.tuner_callback = t->tuner_callback; priv->t = t; @@ -727,7 +727,7 @@ int tda829x_attach(struct tuner *t) } else if (priv->ver & TDA8295) tda8295_init_if(fe); - tuner_info("type set to %s\n", t->i2c.name); + tuner_info("type set to %s\n", t->i2c->name); t->mode = V4L2_TUNER_ANALOG_TV; @@ -738,8 +738,8 @@ EXPORT_SYMBOL_GPL(tda829x_attach); int tda8290_probe(struct tuner *t) { struct tuner_i2c_props i2c_props = { - .adap = t->i2c.adapter, - .addr = t->i2c.addr + .adap = t->i2c->adapter, + .addr = t->i2c->addr }; unsigned char soft_reset[] = { 0x00, 0x00 }; diff --git a/linux/drivers/media/video/tda9887.c b/linux/drivers/media/video/tda9887.c index e21345147..cefba2a14 100644 --- a/linux/drivers/media/video/tda9887.c +++ b/linux/drivers/media/video/tda9887.c @@ -28,14 +28,14 @@ static int tda9887_debug; module_param_named(debug, tda9887_debug, int, 0644); #define tda9887_info(fmt, arg...) do {\ - printk(KERN_INFO "%s %d-%04x: " fmt, priv->t->i2c.name, \ - i2c_adapter_id(priv->t->i2c.adapter), \ - priv->t->i2c.addr, ##arg); } while (0) + printk(KERN_INFO "%s %d-%04x: " fmt, priv->t->i2c->name, \ + i2c_adapter_id(priv->t->i2c->adapter), \ + priv->t->i2c->addr, ##arg); } while (0) #define tda9887_dbg(fmt, arg...) do {\ if (tda9887_debug) \ - printk(KERN_INFO "%s %d-%04x: " fmt, priv->t->i2c.name, \ - i2c_adapter_id(priv->t->i2c.adapter), \ - priv->t->i2c.addr, ##arg); } while (0) + printk(KERN_INFO "%s %d-%04x: " fmt, priv->t->i2c->name, \ + i2c_adapter_id(priv->t->i2c->adapter), \ + priv->t->i2c->addr, ##arg); } while (0) struct tda9887_priv { struct tuner_i2c_props i2c_props; @@ -662,14 +662,14 @@ int tda9887_attach(struct tuner *t) return -ENOMEM; t->fe.analog_demod_priv = priv; - priv->i2c_props.addr = t->i2c.addr; - priv->i2c_props.adap = t->i2c.adapter; + priv->i2c_props.addr = t->i2c->addr; + priv->i2c_props.adap = t->i2c->adapter; priv->t = t; - strlcpy(t->i2c.name, "tda9887", sizeof(t->i2c.name)); + strlcpy(t->i2c->name, "tda9887", sizeof(t->i2c->name)); - tda9887_info("tda988[5/6/7] found @ 0x%x (%s)\n", t->i2c.addr, - t->i2c.driver->driver.name); + tda9887_info("tda988[5/6/7] found @ 0x%x (%s)\n", t->i2c->addr, + t->i2c->driver->driver.name); t->fe.ops.analog_demod_ops = &tda9887_tuner_ops; diff --git a/linux/drivers/media/video/tuner-core.c b/linux/drivers/media/video/tuner-core.c index 969530094..ba05f9630 100644 --- a/linux/drivers/media/video/tuner-core.c +++ b/linux/drivers/media/video/tuner-core.c @@ -251,20 +251,20 @@ static void set_freq(struct i2c_client *c, unsigned long freq) static void tuner_i2c_address_check(struct tuner *t) { if ((t->type == UNSET || t->type == TUNER_ABSENT) || - ((t->i2c.addr < 0x64) || (t->i2c.addr > 0x6f))) + ((t->i2c->addr < 0x64) || (t->i2c->addr > 0x6f))) return; tuner_warn("====================== WARNING! ======================\n"); tuner_warn("Support for tuners in i2c address range 0x64 thru 0x6f\n"); tuner_warn("will soon be dropped. This message indicates that your\n"); tuner_warn("hardware has a %s tuner at i2c address 0x%02x.\n", - t->i2c.name, t->i2c.addr); + t->i2c->name, t->i2c->addr); tuner_warn("To ensure continued support for your device, please\n"); tuner_warn("send a copy of this message, along with full dmesg\n"); tuner_warn("output to v4l-dvb-maintainer@linuxtv.org\n"); tuner_warn("Please use subject line: \"obsolete tuner i2c address.\"\n"); tuner_warn("driver: %s, addr: 0x%02x, type: %d (%s)\n", - t->i2c.adapter->name, t->i2c.addr, t->type, + t->i2c->adapter->name, t->i2c->addr, t->type, tuners[t->type].name); tuner_warn("====================== WARNING! ======================\n"); } @@ -275,7 +275,7 @@ static void attach_simple_tuner(struct tuner *t) .type = t->type, .tun = &tuners[t->type] }; - simple_tuner_attach(&t->fe, t->i2c.adapter, t->i2c.addr, &cfg); + simple_tuner_attach(&t->fe, t->i2c->adapter, t->i2c->addr, &cfg); } static void set_type(struct i2c_client *c, unsigned int type, @@ -319,7 +319,7 @@ static void set_type(struct i2c_client *c, unsigned int type, switch (t->type) { case TUNER_MT2032: - microtune_attach(&t->fe, t->i2c.adapter, t->i2c.addr); + microtune_attach(&t->fe, t->i2c->adapter, t->i2c->addr); break; case TUNER_PHILIPS_TDA8290: { @@ -327,7 +327,7 @@ static void set_type(struct i2c_client *c, unsigned int type, break; } case TUNER_TEA5767: - if (tea5767_attach(&t->fe, t->i2c.adapter, t->i2c.addr) == NULL) { + if (tea5767_attach(&t->fe, t->i2c->adapter, t->i2c->addr) == NULL) { t->type = TUNER_ABSENT; t->mode_mask = T_UNINITIALIZED; return; @@ -335,7 +335,7 @@ static void set_type(struct i2c_client *c, unsigned int type, t->mode_mask = T_RADIO; break; case TUNER_TEA5761: - if (tea5761_attach(&t->fe, t->i2c.adapter, t->i2c.addr) == NULL) { + if (tea5761_attach(&t->fe, t->i2c->adapter, t->i2c->addr) == NULL) { t->type = TUNER_ABSENT; t->mode_mask = T_UNINITIALIZED; return; @@ -389,13 +389,14 @@ static void set_type(struct i2c_client *c, unsigned int type, if (((NULL == ops) || ((NULL == ops->set_tv_freq) && (NULL == ops->set_radio_freq))) && (fe_tuner_ops->set_analog_params)) { - strlcpy(t->i2c.name, fe_tuner_ops->info.name, sizeof(t->i2c.name)); + strlcpy(t->i2c->name, fe_tuner_ops->info.name, + sizeof(t->i2c->name)); t->fe.ops.analog_demod_ops = &tuner_core_ops; t->fe.analog_demod_priv = t; } - tuner_info("type set to %s\n", t->i2c.name); + tuner_info("type set to %s\n", t->i2c->name); if (t->mode_mask == T_UNINITIALIZED) t->mode_mask = new_mode_mask; @@ -634,16 +635,23 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, unsigned short flags, int kind) #endif { + struct i2c_client *client; struct tuner *t; - client_template.adapter = adap; - client_template.addr = addr; + client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL); + if (NULL == client) + return -ENOMEM; t = kzalloc(sizeof(struct tuner), GFP_KERNEL); - if (NULL == t) + if (NULL == t) { + kfree(client); return -ENOMEM; - memcpy(&t->i2c, &client_template, sizeof(struct i2c_client)); - i2c_set_clientdata(&t->i2c, t); + } + t->i2c = client; + client_template.adapter = adap; + client_template.addr = addr; + memcpy(client, &client_template, sizeof(struct i2c_client)); + i2c_set_clientdata(client, t); t->type = UNSET; t->audmode = V4L2_TUNER_MODE_STEREO; t->mode_mask = T_UNINITIALIZED; @@ -653,7 +661,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int i,rc; memset(buffer, 0, sizeof(buffer)); - rc = i2c_master_recv(&t->i2c, buffer, sizeof(buffer)); + rc = i2c_master_recv(client, buffer, sizeof(buffer)); tuner_info("I2C RECV = "); for (i=0;i<rc;i++) printk("%02x ",buffer[i]); @@ -667,7 +675,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, if (!no_autodetect) { switch (addr) { case 0x10: - if (tea5761_autodetection(t->i2c.adapter, t->i2c.addr) != EINVAL) { + if (tea5761_autodetection(t->i2c->adapter, t->i2c->addr) != EINVAL) { t->type = TUNER_TEA5761; t->mode_mask = T_RADIO; t->mode = T_STANDBY; @@ -694,7 +702,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, } break; case 0x60: - if (tea5767_autodetection(t->i2c.adapter, t->i2c.addr) != EINVAL) { + if (tea5767_autodetection(t->i2c->adapter, t->i2c->addr) != EINVAL) { t->type = TUNER_TEA5767; t->mode_mask = T_RADIO; t->mode = T_STANDBY; @@ -719,8 +727,8 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, /* Should be just before return */ register_client: tuner_info("chip found @ 0x%x (%s)\n", addr << 1, adap->name); - i2c_attach_client (&t->i2c); - set_type (&t->i2c,t->type, t->mode_mask, t->config, t->tuner_callback); + i2c_attach_client (client); + set_type (client,t->type, t->mode_mask, t->config, t->tuner_callback); #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) MOD_INC_USE_COUNT; #endif @@ -774,7 +782,7 @@ static int tuner_detach(struct i2c_client *client) struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops; int err; - err = i2c_detach_client(&t->i2c); + err = i2c_detach_client(t->i2c); if (err) { tuner_warn ("Client deregistration failed, client not detached.\n"); @@ -788,6 +796,7 @@ MOD_DEC_USE_COUNT; ops->release(&t->fe); kfree(t); + kfree(client); return 0; } @@ -842,7 +851,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops; if (tuner_debug>1) - v4l_i2c_print_ioctl(&(t->i2c),cmd); + v4l_i2c_print_ioctl(client,cmd); switch (cmd) { /* --- configuration --- */ diff --git a/linux/drivers/media/video/tuner-driver.h b/linux/drivers/media/video/tuner-driver.h index ad2d57dfb..d5acacebd 100644 --- a/linux/drivers/media/video/tuner-driver.h +++ b/linux/drivers/media/video/tuner-driver.h @@ -45,7 +45,7 @@ struct analog_tuner_ops { struct tuner { /* device */ - struct i2c_client i2c; + struct i2c_client *i2c; unsigned int type; /* chip type */ @@ -72,28 +72,28 @@ struct tuner { #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,15) #define tuner_warn(fmt, arg...) do {\ - printk(KERN_WARNING "%s %d-%04x: " fmt, t->i2c.driver->name, \ - i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) + printk(KERN_WARNING "%s %d-%04x: " fmt, t->i2c->driver->name, \ + i2c_adapter_id(t->i2c->adapter), t->i2c->addr , ##arg); } while (0) #define tuner_info(fmt, arg...) do {\ - printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.driver->name, \ - i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) + printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c->driver->name, \ + i2c_adapter_id(t->i2c->adapter), t->i2c->addr , ##arg); } while (0) #define tuner_dbg(fmt, arg...) do {\ extern int tuner_debug; \ if (tuner_debug) \ - printk(KERN_DEBUG "%s %d-%04x: " fmt, t->i2c.driver->name, \ - i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) + printk(KERN_DEBUG "%s %d-%04x: " fmt, t->i2c->driver->name, \ + i2c_adapter_id(t->i2c->adapter), t->i2c->addr , ##arg); } while (0) #else #define tuner_warn(fmt, arg...) do {\ - printk(KERN_WARNING "%s %d-%04x: " fmt, t->i2c.driver->driver.name, \ - i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) + printk(KERN_WARNING "%s %d-%04x: " fmt, t->i2c->driver->driver.name, \ + i2c_adapter_id(t->i2c->adapter), t->i2c->addr , ##arg); } while (0) #define tuner_info(fmt, arg...) do {\ - printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.driver->driver.name, \ - i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) + printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c->driver->driver.name, \ + i2c_adapter_id(t->i2c->adapter), t->i2c->addr , ##arg); } while (0) #define tuner_dbg(fmt, arg...) do {\ extern int tuner_debug; \ if (tuner_debug) \ - printk(KERN_DEBUG "%s %d-%04x: " fmt, t->i2c.driver->driver.name, \ - i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) + printk(KERN_DEBUG "%s %d-%04x: " fmt, t->i2c->driver->driver.name, \ + i2c_adapter_id(t->i2c->adapter), t->i2c->addr , ##arg); } while (0) #endif #endif /* __TUNER_DRIVER_H__ */ |