Commit ea1b28a4 authored by Gerd Knorr's avatar Gerd Knorr Committed by Greg Kroah-Hartman

[PATCH] i2c #3/3: add class field to i2c_adapter

This is the last of three patches for i2c.  It introduces a new field
to i2c_adapter which classifies the kind of hardware a i2c adapter
belongs to (analog tv card / dvb card / smbus / gfx card ...).  i2c chip
drivers can use this infomation to decide whenever they want to look for
hardware on that adapter or not.  It doesn't make sense to probe for a
tv tuner on a smbus for example ...
parent 37d7f421
...@@ -475,6 +475,7 @@ static struct i2c_algorithm smbus_algorithm = { ...@@ -475,6 +475,7 @@ static struct i2c_algorithm smbus_algorithm = {
static struct i2c_adapter ali15x3_adapter = { static struct i2c_adapter ali15x3_adapter = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_ALI15X3, .id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_ALI15X3,
.class = I2C_ADAP_CLASS_SMBUS,
.algo = &smbus_algorithm, .algo = &smbus_algorithm,
.dev = { .dev = {
.name = "unset", .name = "unset",
......
...@@ -313,6 +313,7 @@ static struct i2c_algorithm smbus_algorithm = { ...@@ -313,6 +313,7 @@ static struct i2c_algorithm smbus_algorithm = {
static struct i2c_adapter amd756_adapter = { static struct i2c_adapter amd756_adapter = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_AMD756, .id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_AMD756,
.class = I2C_ADAP_CLASS_SMBUS,
.algo = &smbus_algorithm, .algo = &smbus_algorithm,
.dev = { .dev = {
.name = "unset", .name = "unset",
......
...@@ -360,6 +360,7 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_ ...@@ -360,6 +360,7 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_
snprintf(smbus->adapter.dev.name, DEVICE_NAME_SIZE, snprintf(smbus->adapter.dev.name, DEVICE_NAME_SIZE,
"SMBus2 AMD8111 adapter at %04x", smbus->base); "SMBus2 AMD8111 adapter at %04x", smbus->base);
smbus->adapter.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_AMD8111; smbus->adapter.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_AMD8111;
smbus->adapter.class = I2C_ADAP_CLASS_SMBUS;
smbus->adapter.algo = &smbus_algorithm; smbus->adapter.algo = &smbus_algorithm;
smbus->adapter.algo_data = smbus; smbus->adapter.algo_data = smbus;
......
...@@ -547,6 +547,7 @@ static struct i2c_algorithm smbus_algorithm = { ...@@ -547,6 +547,7 @@ static struct i2c_algorithm smbus_algorithm = {
static struct i2c_adapter i801_adapter = { static struct i2c_adapter i801_adapter = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_I801, .id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_I801,
.class = I2C_ADAP_CLASS_SMBUS,
.algo = &smbus_algorithm, .algo = &smbus_algorithm,
.dev = { .dev = {
.name = "unset", .name = "unset",
......
...@@ -40,6 +40,7 @@ static struct i2c_algorithm isa_algorithm = { ...@@ -40,6 +40,7 @@ static struct i2c_algorithm isa_algorithm = {
static struct i2c_adapter isa_adapter = { static struct i2c_adapter isa_adapter = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.id = I2C_ALGO_ISA | I2C_HW_ISA, .id = I2C_ALGO_ISA | I2C_HW_ISA,
.class = I2C_ADAP_CLASS_SMBUS,
.algo = &isa_algorithm, .algo = &isa_algorithm,
.dev = { .dev = {
.name = "ISA main adapter", .name = "ISA main adapter",
......
...@@ -395,6 +395,7 @@ static struct i2c_algorithm smbus_algorithm = { ...@@ -395,6 +395,7 @@ static struct i2c_algorithm smbus_algorithm = {
static struct i2c_adapter piix4_adapter = { static struct i2c_adapter piix4_adapter = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_PIIX4, .id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_PIIX4,
.class = I2C_ADAP_CLASS_SMBUS,
.algo = &smbus_algorithm, .algo = &smbus_algorithm,
.dev = { .dev = {
.name = "unset", .name = "unset",
......
...@@ -295,6 +295,7 @@ static struct i2c_algorithm smbus_algorithm = { ...@@ -295,6 +295,7 @@ static struct i2c_algorithm smbus_algorithm = {
static struct i2c_adapter vt596_adapter = { static struct i2c_adapter vt596_adapter = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_VIA2, .id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_VIA2,
.class = I2C_ADAP_CLASS_SMBUS,
.algo = &smbus_algorithm, .algo = &smbus_algorithm,
.dev = { .dev = {
.name = "unset", .name = "unset",
......
...@@ -203,6 +203,8 @@ static DEVICE_ATTR(die_code, S_IRUGO, show_die_code, NULL); ...@@ -203,6 +203,8 @@ static DEVICE_ATTR(die_code, S_IRUGO, show_die_code, NULL);
static int adm1021_attach_adapter(struct i2c_adapter *adapter) static int adm1021_attach_adapter(struct i2c_adapter *adapter)
{ {
if (!(adapter->class & I2C_ADAP_CLASS_SMBUS))
return 0;
return i2c_detect(adapter, &addr_data, adm1021_detect); return i2c_detect(adapter, &addr_data, adm1021_detect);
} }
......
...@@ -525,6 +525,8 @@ static DEVICE_ATTR(alarm, S_IRUGO | S_IWUSR, show_alarm, NULL); ...@@ -525,6 +525,8 @@ static DEVICE_ATTR(alarm, S_IRUGO | S_IWUSR, show_alarm, NULL);
* when a new adapter is inserted (and it87_driver is still present) */ * when a new adapter is inserted (and it87_driver is still present) */
static int it87_attach_adapter(struct i2c_adapter *adapter) static int it87_attach_adapter(struct i2c_adapter *adapter)
{ {
if (!(adapter->class & I2C_ADAP_CLASS_SMBUS))
return 0;
return i2c_detect(adapter, &addr_data, it87_detect); return i2c_detect(adapter, &addr_data, it87_detect);
} }
......
...@@ -121,6 +121,8 @@ static DEVICE_ATTR(temp_input, S_IRUGO, show_temp_input, NULL); ...@@ -121,6 +121,8 @@ static DEVICE_ATTR(temp_input, S_IRUGO, show_temp_input, NULL);
static int lm75_attach_adapter(struct i2c_adapter *adapter) static int lm75_attach_adapter(struct i2c_adapter *adapter)
{ {
if (!(adapter->class & I2C_ADAP_CLASS_SMBUS))
return 0;
return i2c_detect(adapter, &addr_data, lm75_detect); return i2c_detect(adapter, &addr_data, lm75_detect);
} }
......
...@@ -661,6 +661,8 @@ static struct i2c_driver via686a_driver = { ...@@ -661,6 +661,8 @@ static struct i2c_driver via686a_driver = {
/* This is called when the module is loaded */ /* This is called when the module is loaded */
static int via686a_attach_adapter(struct i2c_adapter *adapter) static int via686a_attach_adapter(struct i2c_adapter *adapter)
{ {
if (!(adapter->class & I2C_ADAP_CLASS_SMBUS))
return 0;
return i2c_detect(adapter, &addr_data, via686a_detect); return i2c_detect(adapter, &addr_data, via686a_detect);
} }
......
...@@ -1026,6 +1026,8 @@ device_create_file(&client->dev, &dev_attr_rt##offset); \ ...@@ -1026,6 +1026,8 @@ device_create_file(&client->dev, &dev_attr_rt##offset); \
static int static int
w83781d_attach_adapter(struct i2c_adapter *adapter) w83781d_attach_adapter(struct i2c_adapter *adapter)
{ {
if (!(adapter->class & I2C_ADAP_CLASS_SMBUS))
return 0;
return i2c_detect(adapter, &addr_data, w83781d_detect); return i2c_detect(adapter, &addr_data, w83781d_detect);
} }
......
...@@ -198,25 +198,9 @@ static int bt832_attach(struct i2c_adapter *adap, int addr, ...@@ -198,25 +198,9 @@ static int bt832_attach(struct i2c_adapter *adap, int addr,
static int bt832_probe(struct i2c_adapter *adap) static int bt832_probe(struct i2c_adapter *adap)
{ {
int rc; if (adap->class & I2C_ADAP_CLASS_TV_ANALOG)
return i2c_probe(adap, &addr_data, bt832_attach);
printk("bt832_probe\n"); return 0;
switch (adap->id) {
case I2C_ALGO_BIT | I2C_HW_B_BT848:
case I2C_ALGO_BIT | I2C_HW_B_RIVA:
case I2C_ALGO_SAA7134:
printk("bt832: probing %s i2c adapter [id=0x%x]\n",
adap->name,adap->id);
rc = i2c_probe(adap, &addr_data, bt832_attach);
break;
default:
printk("bt832: ignoring %s i2c adapter [id=0x%x]\n",
adap->name,adap->id);
rc = 0;
/* nothing */
}
return rc;
} }
static int bt832_detach(struct i2c_client *client) static int bt832_detach(struct i2c_client *client)
......
...@@ -233,6 +233,7 @@ static struct i2c_adapter bttv_i2c_adap_template = { ...@@ -233,6 +233,7 @@ static struct i2c_adapter bttv_i2c_adap_template = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
I2C_DEVNAME("bt848"), I2C_DEVNAME("bt848"),
.id = I2C_HW_B_BT848, .id = I2C_HW_B_BT848,
.class = I2C_ADAP_CLASS_TV_ANALOG,
.client_register = attach_inform, .client_register = attach_inform,
}; };
......
...@@ -1372,7 +1372,7 @@ static int msp_detach(struct i2c_client *client) ...@@ -1372,7 +1372,7 @@ static int msp_detach(struct i2c_client *client)
static int msp_probe(struct i2c_adapter *adap) static int msp_probe(struct i2c_adapter *adap)
{ {
if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848)) if (adap->class & I2C_ADAP_CLASS_TV_ANALOG)
return i2c_probe(adap, &addr_data, msp_attach); return i2c_probe(adap, &addr_data, msp_attach);
return 0; return 0;
} }
......
...@@ -224,12 +224,8 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -224,12 +224,8 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind)
static int saa5249_probe(struct i2c_adapter *adap) static int saa5249_probe(struct i2c_adapter *adap)
{ {
/* Only attach these chips to the BT848 bus for now */ if (adap->class & I2C_ADAP_CLASS_TV_ANALOG)
if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848))
{
return i2c_probe(adap, &addr_data, saa5249_attach); return i2c_probe(adap, &addr_data, saa5249_attach);
}
return 0; return 0;
} }
......
...@@ -336,6 +336,7 @@ static struct i2c_adapter saa7134_adap_template = { ...@@ -336,6 +336,7 @@ static struct i2c_adapter saa7134_adap_template = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
I2C_DEVNAME("saa7134"), I2C_DEVNAME("saa7134"),
.id = I2C_ALGO_SAA7134, .id = I2C_ALGO_SAA7134,
.class = I2C_ADAP_CLASS_TV_ANALOG,
.algo = &saa7134_algo, .algo = &saa7134_algo,
.client_register = attach_inform, .client_register = attach_inform,
}; };
......
...@@ -340,7 +340,7 @@ static int tda7432_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -340,7 +340,7 @@ static int tda7432_attach(struct i2c_adapter *adap, int addr, int kind)
static int tda7432_probe(struct i2c_adapter *adap) static int tda7432_probe(struct i2c_adapter *adap)
{ {
if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848)) if (adap->class & I2C_ADAP_CLASS_TV_ANALOG)
return i2c_probe(adap, &addr_data, tda7432_attach); return i2c_probe(adap, &addr_data, tda7432_attach);
return 0; return 0;
} }
......
...@@ -273,7 +273,7 @@ static int tda9875_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -273,7 +273,7 @@ static int tda9875_attach(struct i2c_adapter *adap, int addr, int kind)
static int tda9875_probe(struct i2c_adapter *adap) static int tda9875_probe(struct i2c_adapter *adap)
{ {
if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848)) if (adap->class & I2C_ADAP_CLASS_TV_ANALOG)
return i2c_probe(adap, &addr_data, tda9875_attach); return i2c_probe(adap, &addr_data, tda9875_attach);
return 0; return 0;
} }
......
...@@ -368,23 +368,9 @@ static int tda9887_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -368,23 +368,9 @@ static int tda9887_attach(struct i2c_adapter *adap, int addr, int kind)
static int tda9887_probe(struct i2c_adapter *adap) static int tda9887_probe(struct i2c_adapter *adap)
{ {
int rc; if (adap->class & I2C_ADAP_CLASS_TV_ANALOG)
return i2c_probe(adap, &addr_data, tda9887_attach);
switch (adap->id) { return 0;
case I2C_ALGO_BIT | I2C_HW_B_BT848:
case I2C_ALGO_BIT | I2C_HW_B_RIVA:
case I2C_ALGO_SAA7134:
printk("tda9887: probing %s i2c adapter [id=0x%x]\n",
adap->dev.name,adap->id);
rc = i2c_probe(adap, &addr_data, tda9887_attach);
break;
default:
printk("tda9887: ignoring %s i2c adapter [id=0x%x]\n",
adap->dev.name,adap->id);
rc = 0;
/* nothing */
}
return rc;
} }
static int tda9887_detach(struct i2c_client *client) static int tda9887_detach(struct i2c_client *client)
......
...@@ -817,29 +817,15 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -817,29 +817,15 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
static int tuner_probe(struct i2c_adapter *adap) static int tuner_probe(struct i2c_adapter *adap)
{ {
int rc;
if (0 != addr) { if (0 != addr) {
normal_i2c_range[0] = addr; normal_i2c_range[0] = addr;
normal_i2c_range[1] = addr; normal_i2c_range[1] = addr;
} }
this_adap = 0; this_adap = 0;
switch (adap->id) {
case I2C_ALGO_BIT | I2C_HW_B_BT848: if (adap->class & I2C_ADAP_CLASS_TV_ANALOG)
case I2C_ALGO_BIT | I2C_HW_B_RIVA: return i2c_probe(adap, &addr_data, tuner_attach);
case I2C_ALGO_SAA7134: return 0;
case I2C_ALGO_SAA7146:
printk("tuner: probing %s i2c adapter [id=0x%x]\n",
adap->dev.name,adap->id);
rc = i2c_probe(adap, &addr_data, tuner_attach);
break;
default:
printk("tuner: ignoring %s i2c adapter [id=0x%x]\n",
adap->dev.name,adap->id);
rc = 0;
/* nothing */
}
return rc;
} }
static int tuner_detach(struct i2c_client *client) static int tuner_detach(struct i2c_client *client)
......
...@@ -1408,14 +1408,9 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -1408,14 +1408,9 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind)
static int chip_probe(struct i2c_adapter *adap) static int chip_probe(struct i2c_adapter *adap)
{ {
switch (adap->id) { if (adap->class & I2C_ADAP_CLASS_TV_ANALOG)
case I2C_ALGO_BIT | I2C_HW_B_BT848:
case I2C_ALGO_BIT | I2C_HW_B_RIVA:
return i2c_probe(adap, &addr_data, chip_attach); return i2c_probe(adap, &addr_data, chip_attach);
default:
/* ignore this i2c bus */
return 0; return 0;
}
} }
static int chip_detach(struct i2c_client *client) static int chip_detach(struct i2c_client *client)
......
...@@ -254,12 +254,7 @@ static int tvmixer_clients(struct i2c_client *client) ...@@ -254,12 +254,7 @@ static int tvmixer_clients(struct i2c_client *client)
int i,minor; int i,minor;
/* TV card ??? */ /* TV card ??? */
switch (client->adapter->id) { if (!(client->adapter->class & I2C_ADAP_CLASS_TV_ANALOG)) {
case I2C_ALGO_BIT | I2C_HW_B_BT848:
case I2C_ALGO_BIT | I2C_HW_B_RIVA:
/* ok, have a look ... */
break;
default:
/* ignore that one */ /* ignore that one */
if (debug) if (debug)
printk("tvmixer: %s is not a tv card\n", printk("tvmixer: %s is not a tv card\n",
......
...@@ -225,6 +225,7 @@ struct i2c_adapter { ...@@ -225,6 +225,7 @@ struct i2c_adapter {
struct module *owner; struct module *owner;
unsigned int id;/* == is algo->id | hwdep.struct->id, */ unsigned int id;/* == is algo->id | hwdep.struct->id, */
/* for registered values see below */ /* for registered values see below */
unsigned int class;
struct i2c_algorithm *algo;/* the algorithm to access the bus */ struct i2c_algorithm *algo;/* the algorithm to access the bus */
void *algo_data; void *algo_data;
...@@ -278,6 +279,12 @@ static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data) ...@@ -278,6 +279,12 @@ static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data)
#define I2C_CLIENT_TEN 0x10 /* we have a ten bit chip address */ #define I2C_CLIENT_TEN 0x10 /* we have a ten bit chip address */
/* Must equal I2C_M_TEN below */ /* Must equal I2C_M_TEN below */
/* i2c adapter classes (bitmask) */
#define I2C_ADAP_CLASS_SMBUS (1<<0) /* lm_sensors, ... */
#define I2C_ADAP_CLASS_TV_ANALOG (1<<1) /* bttv + friends */
#define I2C_ADAP_CLASS_TV_DIGINAL (1<<2) /* dbv cards */
#define I2C_ADAP_CLASS_DDC (1<<3) /* i2c-matroxfb ? */
/* i2c_client_address_data is the struct for holding default client /* i2c_client_address_data is the struct for holding default client
* addresses for a driver and for the parameters supplied on the * addresses for a driver and for the parameters supplied on the
* command line * command line
......
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