Commit 1cba97d7 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

V4L/DVB (6471): tuner: i2c_client cannot be part of the tuner struct

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: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMichael Krufky <mkrufky@linuxtv.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent 1a156045
...@@ -608,22 +608,22 @@ static int tda829x_find_tuner(struct dvb_frontend *fe) ...@@ -608,22 +608,22 @@ static int tda829x_find_tuner(struct dvb_frontend *fe)
switch (priv->ver) { switch (priv->ver) {
case TDA8290 | TDA8275: case TDA8290 | TDA8275:
strlcpy(t->i2c.name, "tda8290+75", sizeof(t->i2c.name)); strlcpy(t->i2c->name, "tda8290+75", sizeof(t->i2c->name));
break; break;
case TDA8295 | TDA8275: case TDA8295 | TDA8275:
strlcpy(t->i2c.name, "tda8295+75", sizeof(t->i2c.name)); strlcpy(t->i2c->name, "tda8295+75", sizeof(t->i2c->name));
break; break;
case TDA8290 | TDA8275A: case TDA8290 | TDA8275A:
strlcpy(t->i2c.name, "tda8290+75a", sizeof(t->i2c.name)); strlcpy(t->i2c->name, "tda8290+75a", sizeof(t->i2c->name));
break; break;
case TDA8295 | TDA8275A: case TDA8295 | TDA8275A:
strlcpy(t->i2c.name, "tda8295+75a", sizeof(t->i2c.name)); strlcpy(t->i2c->name, "tda8295+75a", sizeof(t->i2c->name));
break; break;
case TDA8290 | TDA18271: case TDA8290 | TDA18271:
strlcpy(t->i2c.name, "tda8290+18271", sizeof(t->i2c.name)); strlcpy(t->i2c->name, "tda8290+18271", sizeof(t->i2c->name));
break; break;
case TDA8295 | TDA18271: case TDA8295 | TDA18271:
strlcpy(t->i2c.name, "tda8295+18271", sizeof(t->i2c.name)); strlcpy(t->i2c->name, "tda8295+18271", sizeof(t->i2c->name));
break; break;
default: default:
return -EINVAL; return -EINVAL;
...@@ -665,8 +665,8 @@ int tda829x_attach(struct tuner *t) ...@@ -665,8 +665,8 @@ int tda829x_attach(struct tuner *t)
return -ENOMEM; return -ENOMEM;
fe->analog_demod_priv = priv; fe->analog_demod_priv = priv;
priv->i2c_props.addr = t->i2c.addr; priv->i2c_props.addr = t->i2c->addr;
priv->i2c_props.adap = t->i2c.adapter; priv->i2c_props.adap = t->i2c->adapter;
priv->cfg.config = &t->config; priv->cfg.config = &t->config;
priv->cfg.tuner_callback = t->tuner_callback; priv->cfg.tuner_callback = t->tuner_callback;
priv->t = t; priv->t = t;
...@@ -696,7 +696,7 @@ int tda829x_attach(struct tuner *t) ...@@ -696,7 +696,7 @@ int tda829x_attach(struct tuner *t)
} else if (priv->ver & TDA8295) } else if (priv->ver & TDA8295)
tda8295_init_if(fe); 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; t->mode = V4L2_TUNER_ANALOG_TV;
...@@ -707,8 +707,8 @@ EXPORT_SYMBOL_GPL(tda829x_attach); ...@@ -707,8 +707,8 @@ EXPORT_SYMBOL_GPL(tda829x_attach);
int tda8290_probe(struct tuner *t) int tda8290_probe(struct tuner *t)
{ {
struct tuner_i2c_props i2c_props = { struct tuner_i2c_props i2c_props = {
.adap = t->i2c.adapter, .adap = t->i2c->adapter,
.addr = t->i2c.addr .addr = t->i2c->addr
}; };
unsigned char soft_reset[] = { 0x00, 0x00 }; unsigned char soft_reset[] = { 0x00, 0x00 };
......
...@@ -24,14 +24,14 @@ static int tda9887_debug; ...@@ -24,14 +24,14 @@ static int tda9887_debug;
module_param_named(debug, tda9887_debug, int, 0644); module_param_named(debug, tda9887_debug, int, 0644);
#define tda9887_info(fmt, arg...) do {\ #define tda9887_info(fmt, arg...) do {\
printk(KERN_INFO "%s %d-%04x: " fmt, priv->t->i2c.name, \ printk(KERN_INFO "%s %d-%04x: " fmt, priv->t->i2c->name, \
i2c_adapter_id(priv->t->i2c.adapter), \ i2c_adapter_id(priv->t->i2c->adapter), \
priv->t->i2c.addr, ##arg); } while (0) priv->t->i2c->addr, ##arg); } while (0)
#define tda9887_dbg(fmt, arg...) do {\ #define tda9887_dbg(fmt, arg...) do {\
if (tda9887_debug) \ if (tda9887_debug) \
printk(KERN_INFO "%s %d-%04x: " fmt, priv->t->i2c.name, \ printk(KERN_INFO "%s %d-%04x: " fmt, priv->t->i2c->name, \
i2c_adapter_id(priv->t->i2c.adapter), \ i2c_adapter_id(priv->t->i2c->adapter), \
priv->t->i2c.addr, ##arg); } while (0) priv->t->i2c->addr, ##arg); } while (0)
struct tda9887_priv { struct tda9887_priv {
struct tuner_i2c_props i2c_props; struct tuner_i2c_props i2c_props;
...@@ -651,14 +651,14 @@ int tda9887_attach(struct tuner *t) ...@@ -651,14 +651,14 @@ int tda9887_attach(struct tuner *t)
return -ENOMEM; return -ENOMEM;
t->fe.analog_demod_priv = priv; t->fe.analog_demod_priv = priv;
priv->i2c_props.addr = t->i2c.addr; priv->i2c_props.addr = t->i2c->addr;
priv->i2c_props.adap = t->i2c.adapter; priv->i2c_props.adap = t->i2c->adapter;
priv->t = t; 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, tda9887_info("tda988[5/6/7] found @ 0x%x (%s)\n", t->i2c->addr,
t->i2c.driver->driver.name); t->i2c->driver->driver.name);
t->fe.ops.analog_demod_ops = &tda9887_tuner_ops; t->fe.ops.analog_demod_ops = &tda9887_tuner_ops;
......
...@@ -226,20 +226,20 @@ static void set_freq(struct i2c_client *c, unsigned long freq) ...@@ -226,20 +226,20 @@ static void set_freq(struct i2c_client *c, unsigned long freq)
static void tuner_i2c_address_check(struct tuner *t) static void tuner_i2c_address_check(struct tuner *t)
{ {
if ((t->type == UNSET || t->type == TUNER_ABSENT) || 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; return;
tuner_warn("====================== WARNING! ======================\n"); tuner_warn("====================== WARNING! ======================\n");
tuner_warn("Support for tuners in i2c address range 0x64 thru 0x6f\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("will soon be dropped. This message indicates that your\n");
tuner_warn("hardware has a %s tuner at i2c address 0x%02x.\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("To ensure continued support for your device, please\n");
tuner_warn("send a copy of this message, along with full dmesg\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("output to v4l-dvb-maintainer@linuxtv.org\n");
tuner_warn("Please use subject line: \"obsolete tuner i2c address.\"\n"); tuner_warn("Please use subject line: \"obsolete tuner i2c address.\"\n");
tuner_warn("driver: %s, addr: 0x%02x, type: %d (%s)\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); tuners[t->type].name);
tuner_warn("====================== WARNING! ======================\n"); tuner_warn("====================== WARNING! ======================\n");
} }
...@@ -250,7 +250,7 @@ static void attach_simple_tuner(struct tuner *t) ...@@ -250,7 +250,7 @@ static void attach_simple_tuner(struct tuner *t)
.type = t->type, .type = t->type,
.tun = &tuners[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, static void set_type(struct i2c_client *c, unsigned int type,
...@@ -292,7 +292,7 @@ static void set_type(struct i2c_client *c, unsigned int type, ...@@ -292,7 +292,7 @@ static void set_type(struct i2c_client *c, unsigned int type,
switch (t->type) { switch (t->type) {
case TUNER_MT2032: case TUNER_MT2032:
microtune_attach(&t->fe, t->i2c.adapter, t->i2c.addr); microtune_attach(&t->fe, t->i2c->adapter, t->i2c->addr);
break; break;
case TUNER_PHILIPS_TDA8290: case TUNER_PHILIPS_TDA8290:
{ {
...@@ -300,7 +300,7 @@ static void set_type(struct i2c_client *c, unsigned int type, ...@@ -300,7 +300,7 @@ static void set_type(struct i2c_client *c, unsigned int type,
break; break;
} }
case TUNER_TEA5767: 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->type = TUNER_ABSENT;
t->mode_mask = T_UNINITIALIZED; t->mode_mask = T_UNINITIALIZED;
return; return;
...@@ -308,7 +308,7 @@ static void set_type(struct i2c_client *c, unsigned int type, ...@@ -308,7 +308,7 @@ static void set_type(struct i2c_client *c, unsigned int type,
t->mode_mask = T_RADIO; t->mode_mask = T_RADIO;
break; break;
case TUNER_TEA5761: 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->type = TUNER_ABSENT;
t->mode_mask = T_UNINITIALIZED; t->mode_mask = T_UNINITIALIZED;
return; return;
...@@ -348,13 +348,14 @@ static void set_type(struct i2c_client *c, unsigned int type, ...@@ -348,13 +348,14 @@ static void set_type(struct i2c_client *c, unsigned int type,
if (((NULL == ops) || if (((NULL == ops) ||
((NULL == ops->set_tv_freq) && (NULL == ops->set_radio_freq))) && ((NULL == ops->set_tv_freq) && (NULL == ops->set_radio_freq))) &&
(fe_tuner_ops->set_analog_params)) { (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.ops.analog_demod_ops = &tuner_core_ops;
t->fe.analog_demod_priv = t; 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) if (t->mode_mask == T_UNINITIALIZED)
t->mode_mask = new_mode_mask; t->mode_mask = new_mode_mask;
...@@ -579,16 +580,23 @@ static unsigned default_mode_mask; ...@@ -579,16 +580,23 @@ static unsigned default_mode_mask;
*/ */
static int tuner_attach(struct i2c_adapter *adap, int addr, int kind) static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
{ {
struct i2c_client *client;
struct tuner *t; struct tuner *t;
client_template.adapter = adap; client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
client_template.addr = addr; if (NULL == client)
return -ENOMEM;
t = kzalloc(sizeof(struct tuner), GFP_KERNEL); t = kzalloc(sizeof(struct tuner), GFP_KERNEL);
if (NULL == t) if (NULL == t) {
kfree(client);
return -ENOMEM; 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->type = UNSET;
t->audmode = V4L2_TUNER_MODE_STEREO; t->audmode = V4L2_TUNER_MODE_STEREO;
t->mode_mask = T_UNINITIALIZED; t->mode_mask = T_UNINITIALIZED;
...@@ -598,7 +606,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -598,7 +606,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
int i,rc; int i,rc;
memset(buffer, 0, sizeof(buffer)); 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 = "); tuner_info("I2C RECV = ");
for (i=0;i<rc;i++) for (i=0;i<rc;i++)
printk("%02x ",buffer[i]); printk("%02x ",buffer[i]);
...@@ -612,7 +620,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -612,7 +620,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
if (!no_autodetect) { if (!no_autodetect) {
switch (addr) { switch (addr) {
case 0x10: 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->type = TUNER_TEA5761;
t->mode_mask = T_RADIO; t->mode_mask = T_RADIO;
t->mode = T_STANDBY; t->mode = T_STANDBY;
...@@ -639,7 +647,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -639,7 +647,7 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
} }
break; break;
case 0x60: 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->type = TUNER_TEA5767;
t->mode_mask = T_RADIO; t->mode_mask = T_RADIO;
t->mode = T_STANDBY; t->mode = T_STANDBY;
...@@ -664,8 +672,8 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -664,8 +672,8 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
/* Should be just before return */ /* Should be just before return */
register_client: register_client:
tuner_info("chip found @ 0x%x (%s)\n", addr << 1, adap->name); tuner_info("chip found @ 0x%x (%s)\n", addr << 1, adap->name);
i2c_attach_client (&t->i2c); i2c_attach_client (client);
set_type (&t->i2c,t->type, t->mode_mask, t->config, t->tuner_callback); set_type (client,t->type, t->mode_mask, t->config, t->tuner_callback);
return 0; return 0;
} }
...@@ -711,7 +719,7 @@ static int tuner_detach(struct i2c_client *client) ...@@ -711,7 +719,7 @@ static int tuner_detach(struct i2c_client *client)
struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops; struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops;
int err; int err;
err = i2c_detach_client(&t->i2c); err = i2c_detach_client(t->i2c);
if (err) { if (err) {
tuner_warn tuner_warn
("Client deregistration failed, client not detached.\n"); ("Client deregistration failed, client not detached.\n");
...@@ -722,6 +730,7 @@ static int tuner_detach(struct i2c_client *client) ...@@ -722,6 +730,7 @@ static int tuner_detach(struct i2c_client *client)
ops->release(&t->fe); ops->release(&t->fe);
kfree(t); kfree(t);
kfree(client);
return 0; return 0;
} }
...@@ -770,7 +779,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) ...@@ -770,7 +779,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; struct analog_tuner_ops *ops = t->fe.ops.analog_demod_ops;
if (tuner_debug>1) if (tuner_debug>1)
v4l_i2c_print_ioctl(&(t->i2c),cmd); v4l_i2c_print_ioctl(client,cmd);
switch (cmd) { switch (cmd) {
/* --- configuration --- */ /* --- configuration --- */
......
...@@ -45,7 +45,7 @@ struct analog_tuner_ops { ...@@ -45,7 +45,7 @@ struct analog_tuner_ops {
struct tuner { struct tuner {
/* device */ /* device */
struct i2c_client i2c; struct i2c_client *i2c;
unsigned int type; /* chip type */ unsigned int type; /* chip type */
...@@ -71,16 +71,16 @@ struct tuner { ...@@ -71,16 +71,16 @@ struct tuner {
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
#define tuner_warn(fmt, arg...) do {\ #define tuner_warn(fmt, arg...) do {\
printk(KERN_WARNING "%s %d-%04x: " fmt, t->i2c.driver->driver.name, \ printk(KERN_WARNING "%s %d-%04x: " fmt, t->i2c->driver->driver.name, \
i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) i2c_adapter_id(t->i2c->adapter), t->i2c->addr , ##arg); } while (0)
#define tuner_info(fmt, arg...) do {\ #define tuner_info(fmt, arg...) do {\
printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c.driver->driver.name, \ printk(KERN_INFO "%s %d-%04x: " fmt, t->i2c->driver->driver.name, \
i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) i2c_adapter_id(t->i2c->adapter), t->i2c->addr , ##arg); } while (0)
#define tuner_dbg(fmt, arg...) do {\ #define tuner_dbg(fmt, arg...) do {\
extern int tuner_debug; \ extern int tuner_debug; \
if (tuner_debug) \ if (tuner_debug) \
printk(KERN_DEBUG "%s %d-%04x: " fmt, t->i2c.driver->driver.name, \ printk(KERN_DEBUG "%s %d-%04x: " fmt, t->i2c->driver->driver.name, \
i2c_adapter_id(t->i2c.adapter), t->i2c.addr , ##arg); } while (0) i2c_adapter_id(t->i2c->adapter), t->i2c->addr , ##arg); } while (0)
#endif /* __TUNER_DRIVER_H__ */ #endif /* __TUNER_DRIVER_H__ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment