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
No related merge requests found
......@@ -475,6 +475,7 @@ static struct i2c_algorithm smbus_algorithm = {
static struct i2c_adapter ali15x3_adapter = {
.owner = THIS_MODULE,
.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_ALI15X3,
.class = I2C_ADAP_CLASS_SMBUS,
.algo = &smbus_algorithm,
.dev = {
.name = "unset",
......
......@@ -313,6 +313,7 @@ static struct i2c_algorithm smbus_algorithm = {
static struct i2c_adapter amd756_adapter = {
.owner = THIS_MODULE,
.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_AMD756,
.class = I2C_ADAP_CLASS_SMBUS,
.algo = &smbus_algorithm,
.dev = {
.name = "unset",
......
......@@ -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,
"SMBus2 AMD8111 adapter at %04x", smbus->base);
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_data = smbus;
......
......@@ -547,6 +547,7 @@ static struct i2c_algorithm smbus_algorithm = {
static struct i2c_adapter i801_adapter = {
.owner = THIS_MODULE,
.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_I801,
.class = I2C_ADAP_CLASS_SMBUS,
.algo = &smbus_algorithm,
.dev = {
.name = "unset",
......
......@@ -40,6 +40,7 @@ static struct i2c_algorithm isa_algorithm = {
static struct i2c_adapter isa_adapter = {
.owner = THIS_MODULE,
.id = I2C_ALGO_ISA | I2C_HW_ISA,
.class = I2C_ADAP_CLASS_SMBUS,
.algo = &isa_algorithm,
.dev = {
.name = "ISA main adapter",
......
......@@ -395,6 +395,7 @@ static struct i2c_algorithm smbus_algorithm = {
static struct i2c_adapter piix4_adapter = {
.owner = THIS_MODULE,
.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_PIIX4,
.class = I2C_ADAP_CLASS_SMBUS,
.algo = &smbus_algorithm,
.dev = {
.name = "unset",
......
......@@ -295,6 +295,7 @@ static struct i2c_algorithm smbus_algorithm = {
static struct i2c_adapter vt596_adapter = {
.owner = THIS_MODULE,
.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_VIA2,
.class = I2C_ADAP_CLASS_SMBUS,
.algo = &smbus_algorithm,
.dev = {
.name = "unset",
......
......@@ -203,6 +203,8 @@ static DEVICE_ATTR(die_code, S_IRUGO, show_die_code, NULL);
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);
}
......
......@@ -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) */
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);
}
......
......@@ -121,6 +121,8 @@ static DEVICE_ATTR(temp_input, S_IRUGO, show_temp_input, NULL);
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);
}
......
......@@ -661,6 +661,8 @@ static struct i2c_driver via686a_driver = {
/* This is called when the module is loaded */
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);
}
......
......@@ -1026,6 +1026,8 @@ device_create_file(&client->dev, &dev_attr_rt##offset); \
static int
w83781d_attach_adapter(struct i2c_adapter *adapter)
{
if (!(adapter->class & I2C_ADAP_CLASS_SMBUS))
return 0;
return i2c_detect(adapter, &addr_data, w83781d_detect);
}
......
......@@ -198,25 +198,9 @@ static int bt832_attach(struct i2c_adapter *adap, int addr,
static int bt832_probe(struct i2c_adapter *adap)
{
int rc;
printk("bt832_probe\n");
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;
if (adap->class & I2C_ADAP_CLASS_TV_ANALOG)
return i2c_probe(adap, &addr_data, bt832_attach);
return 0;
}
static int bt832_detach(struct i2c_client *client)
......
......@@ -233,6 +233,7 @@ static struct i2c_adapter bttv_i2c_adap_template = {
.owner = THIS_MODULE,
I2C_DEVNAME("bt848"),
.id = I2C_HW_B_BT848,
.class = I2C_ADAP_CLASS_TV_ANALOG,
.client_register = attach_inform,
};
......
......@@ -1372,7 +1372,7 @@ static int msp_detach(struct i2c_client *client)
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 0;
}
......
......@@ -224,12 +224,8 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind)
static int saa5249_probe(struct i2c_adapter *adap)
{
/* Only attach these chips to the BT848 bus for now */
if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848))
{
if (adap->class & I2C_ADAP_CLASS_TV_ANALOG)
return i2c_probe(adap, &addr_data, saa5249_attach);
}
return 0;
}
......
......@@ -336,6 +336,7 @@ static struct i2c_adapter saa7134_adap_template = {
.owner = THIS_MODULE,
I2C_DEVNAME("saa7134"),
.id = I2C_ALGO_SAA7134,
.class = I2C_ADAP_CLASS_TV_ANALOG,
.algo = &saa7134_algo,
.client_register = attach_inform,
};
......
......@@ -340,7 +340,7 @@ static int tda7432_attach(struct i2c_adapter *adap, int addr, int kind)
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 0;
}
......
......@@ -273,7 +273,7 @@ static int tda9875_attach(struct i2c_adapter *adap, int addr, int kind)
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 0;
}
......
......@@ -368,23 +368,9 @@ static int tda9887_attach(struct i2c_adapter *adap, int addr, int kind)
static int tda9887_probe(struct i2c_adapter *adap)
{
int rc;
switch (adap->id) {
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;
if (adap->class & I2C_ADAP_CLASS_TV_ANALOG)
return i2c_probe(adap, &addr_data, tda9887_attach);
return 0;
}
static int tda9887_detach(struct i2c_client *client)
......
......@@ -817,29 +817,15 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
static int tuner_probe(struct i2c_adapter *adap)
{
int rc;
if (0 != addr) {
normal_i2c_range[0] = addr;
normal_i2c_range[1] = addr;
}
this_adap = 0;
switch (adap->id) {
case I2C_ALGO_BIT | I2C_HW_B_BT848:
case I2C_ALGO_BIT | I2C_HW_B_RIVA:
case I2C_ALGO_SAA7134:
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;
if (adap->class & I2C_ADAP_CLASS_TV_ANALOG)
return i2c_probe(adap, &addr_data, tuner_attach);
return 0;
}
static int tuner_detach(struct i2c_client *client)
......
......@@ -1408,14 +1408,9 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind)
static int chip_probe(struct i2c_adapter *adap)
{
switch (adap->id) {
case I2C_ALGO_BIT | I2C_HW_B_BT848:
case I2C_ALGO_BIT | I2C_HW_B_RIVA:
if (adap->class & I2C_ADAP_CLASS_TV_ANALOG)
return i2c_probe(adap, &addr_data, chip_attach);
default:
/* ignore this i2c bus */
return 0;
}
}
static int chip_detach(struct i2c_client *client)
......
......@@ -254,12 +254,7 @@ static int tvmixer_clients(struct i2c_client *client)
int i,minor;
/* TV card ??? */
switch (client->adapter->id) {
case I2C_ALGO_BIT | I2C_HW_B_BT848:
case I2C_ALGO_BIT | I2C_HW_B_RIVA:
/* ok, have a look ... */
break;
default:
if (!(client->adapter->class & I2C_ADAP_CLASS_TV_ANALOG)) {
/* ignore that one */
if (debug)
printk("tvmixer: %s is not a tv card\n",
......
......@@ -225,6 +225,7 @@ struct i2c_adapter {
struct module *owner;
unsigned int id;/* == is algo->id | hwdep.struct->id, */
/* for registered values see below */
unsigned int class;
struct i2c_algorithm *algo;/* the algorithm to access the bus */
void *algo_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 */
/* 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
* addresses for a driver and for the parameters supplied on the
* 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