Commit 223f4b75 authored by Michael Hunold's avatar Michael Hunold Committed by Deepak Saxena

[PATCH] I2C: add .class to i2c drivers

in the "[RFC|PATCH][2.6] Additional i2c adapter flags for i2c client
isolation" thread, the i2c people have  agreed that an ".class" field
should be added to struct i2c_driver.

Currently only drivers do checks for plausibility ("Is this an adapter I
can attach to?"), but adapters don't have a chance to keep drivers away
from their bus.

If both drivers and adapters provide a .class entry, the i2c-core can
easily compare them and let devices only probe on busses where they can
really exist.

Real world example: DVB i2c adapters cannot ensure that only known DVB
i2c chipsets probe their busses. Most client drivers probe every bus
they get their hands on. This will confuse some DVB i2c busses.

With the new I2C_CLASS_ALL flag it will be possible that an adapter can
request that really all drivers are probed on the adapter. On the other
hand, drivers can make sure that they get the chance to probe on every
i2c adapter out there (this is not encouraged, though)

The attached patch does the first step:
- add .class member to struct i2c_device
- remove unused .flags member from struct i2c_adapter
- rename I2C_ADAP_CLASS_xxx to I2C_CLASS_xxx (to be used both for
  drivers and adapters)
- add new I2C_CLASS_ALL and I2C_CLASS_SOUND classes
- follow these changes in the existing drivers with copy & paste
parent abfd324f
...@@ -62,9 +62,9 @@ Technical changes: ...@@ -62,9 +62,9 @@ Technical changes:
patch to the Documentation/i2c/sysfs-interface file. patch to the Documentation/i2c/sysfs-interface file.
* [Attach] For I2C drivers, the attach function should make sure * [Attach] For I2C drivers, the attach function should make sure
that the adapter's class has I2C_ADAP_CLASS_SMBUS, using the that the adapter's class has I2C_CLASS_SMBUS, using the
following construct: following construct:
if (!(adapter->class & I2C_ADAP_CLASS_SMBUS)) if (!(adapter->class & I2C_CLASS_SMBUS))
return 0; return 0;
ISA-only drivers of course don't need this. ISA-only drivers of course don't need this.
......
...@@ -480,7 +480,7 @@ static struct i2c_algorithm smbus_algorithm = { ...@@ -480,7 +480,7 @@ static struct i2c_algorithm smbus_algorithm = {
static struct i2c_adapter ali1535_adapter = { static struct i2c_adapter ali1535_adapter = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.class = I2C_ADAP_CLASS_SMBUS, .class = I2C_CLASS_SMBUS,
.algo = &smbus_algorithm, .algo = &smbus_algorithm,
.name = "unset", .name = "unset",
}; };
......
...@@ -357,7 +357,7 @@ static struct i2c_algorithm ali1563_algorithm = { ...@@ -357,7 +357,7 @@ static struct i2c_algorithm ali1563_algorithm = {
static struct i2c_adapter ali1563_adapter = { static struct i2c_adapter ali1563_adapter = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.class = I2C_ADAP_CLASS_SMBUS, .class = I2C_CLASS_SMBUS,
.algo = &ali1563_algorithm, .algo = &ali1563_algorithm,
}; };
......
...@@ -470,7 +470,7 @@ static struct i2c_algorithm smbus_algorithm = { ...@@ -470,7 +470,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,
.class = I2C_ADAP_CLASS_SMBUS, .class = I2C_CLASS_SMBUS,
.algo = &smbus_algorithm, .algo = &smbus_algorithm,
.name = "unset", .name = "unset",
}; };
......
...@@ -303,7 +303,7 @@ static struct i2c_algorithm smbus_algorithm = { ...@@ -303,7 +303,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,
.class = I2C_ADAP_CLASS_SMBUS, .class = I2C_CLASS_SMBUS,
.algo = &smbus_algorithm, .algo = &smbus_algorithm,
.name = "unset", .name = "unset",
}; };
......
...@@ -359,7 +359,7 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_ ...@@ -359,7 +359,7 @@ static int __devinit amd8111_probe(struct pci_dev *dev, const struct pci_device_
smbus->adapter.owner = THIS_MODULE; smbus->adapter.owner = THIS_MODULE;
snprintf(smbus->adapter.name, I2C_NAME_SIZE, snprintf(smbus->adapter.name, I2C_NAME_SIZE,
"SMBus2 AMD8111 adapter at %04x", smbus->base); "SMBus2 AMD8111 adapter at %04x", smbus->base);
smbus->adapter.class = I2C_ADAP_CLASS_SMBUS; smbus->adapter.class = I2C_CLASS_SMBUS;
smbus->adapter.algo = &smbus_algorithm; smbus->adapter.algo = &smbus_algorithm;
smbus->adapter.algo_data = smbus; smbus->adapter.algo_data = smbus;
......
...@@ -539,7 +539,7 @@ static struct i2c_algorithm smbus_algorithm = { ...@@ -539,7 +539,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,
.class = I2C_ADAP_CLASS_SMBUS, .class = I2C_CLASS_SMBUS,
.algo = &smbus_algorithm, .algo = &smbus_algorithm,
.name = "unset", .name = "unset",
}; };
......
...@@ -43,7 +43,7 @@ static struct i2c_algorithm isa_algorithm = { ...@@ -43,7 +43,7 @@ static struct i2c_algorithm isa_algorithm = {
/* There can only be one... */ /* There can only be one... */
static struct i2c_adapter isa_adapter = { static struct i2c_adapter isa_adapter = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.class = I2C_ADAP_CLASS_SMBUS, .class = I2C_CLASS_SMBUS,
.algo = &isa_algorithm, .algo = &isa_algorithm,
.name = "ISA main adapter", .name = "ISA main adapter",
}; };
......
...@@ -119,7 +119,7 @@ static struct i2c_algorithm smbus_algorithm = { ...@@ -119,7 +119,7 @@ static struct i2c_algorithm smbus_algorithm = {
static struct i2c_adapter nforce2_adapter = { static struct i2c_adapter nforce2_adapter = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.class = I2C_ADAP_CLASS_SMBUS, .class = I2C_CLASS_SMBUS,
.algo = &smbus_algorithm, .algo = &smbus_algorithm,
.name = "unset", .name = "unset",
}; };
......
...@@ -112,7 +112,7 @@ static struct i2c_algo_bit_data parport_algo_data = { ...@@ -112,7 +112,7 @@ static struct i2c_algo_bit_data parport_algo_data = {
static struct i2c_adapter parport_adapter = { static struct i2c_adapter parport_adapter = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.class = I2C_ADAP_CLASS_SMBUS, .class = I2C_CLASS_SMBUS,
.id = I2C_HW_B_LP, .id = I2C_HW_B_LP,
.algo_data = &parport_algo_data, .algo_data = &parport_algo_data,
.name = "Parallel port adapter (light)", .name = "Parallel port adapter (light)",
......
...@@ -147,7 +147,7 @@ static struct i2c_algo_bit_data parport_algo_data = { ...@@ -147,7 +147,7 @@ static struct i2c_algo_bit_data parport_algo_data = {
static struct i2c_adapter parport_adapter = { static struct i2c_adapter parport_adapter = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.class = I2C_ADAP_CLASS_SMBUS, .class = I2C_CLASS_SMBUS,
.id = I2C_HW_B_LP, .id = I2C_HW_B_LP,
.name = "Parallel port adapter", .name = "Parallel port adapter",
}; };
......
...@@ -410,7 +410,7 @@ static struct i2c_algorithm smbus_algorithm = { ...@@ -410,7 +410,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,
.class = I2C_ADAP_CLASS_SMBUS, .class = I2C_CLASS_SMBUS,
.algo = &smbus_algorithm, .algo = &smbus_algorithm,
.name = "unset", .name = "unset",
}; };
......
...@@ -360,7 +360,7 @@ static struct i2c_algorithm smbus_algorithm = { ...@@ -360,7 +360,7 @@ static struct i2c_algorithm smbus_algorithm = {
static struct i2c_adapter sis5595_adapter = { static struct i2c_adapter sis5595_adapter = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.class = I2C_ADAP_CLASS_SMBUS, .class = I2C_CLASS_SMBUS,
.name = "unset", .name = "unset",
.algo = &smbus_algorithm, .algo = &smbus_algorithm,
}; };
......
...@@ -456,7 +456,7 @@ static struct i2c_algorithm smbus_algorithm = { ...@@ -456,7 +456,7 @@ static struct i2c_algorithm smbus_algorithm = {
static struct i2c_adapter sis630_adapter = { static struct i2c_adapter sis630_adapter = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.class = I2C_ADAP_CLASS_SMBUS, .class = I2C_CLASS_SMBUS,
.name = "unset", .name = "unset",
.algo = &smbus_algorithm, .algo = &smbus_algorithm,
}; };
......
...@@ -260,7 +260,7 @@ static struct i2c_algorithm smbus_algorithm = { ...@@ -260,7 +260,7 @@ static struct i2c_algorithm smbus_algorithm = {
static struct i2c_adapter sis96x_adapter = { static struct i2c_adapter sis96x_adapter = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.class = I2C_ADAP_CLASS_SMBUS, .class = I2C_CLASS_SMBUS,
.algo = &smbus_algorithm, .algo = &smbus_algorithm,
.name = "unset", .name = "unset",
}; };
......
...@@ -88,7 +88,7 @@ static struct i2c_algo_bit_data bit_data = { ...@@ -88,7 +88,7 @@ static struct i2c_algo_bit_data bit_data = {
static struct i2c_adapter vt586b_adapter = { static struct i2c_adapter vt586b_adapter = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.class = I2C_ADAP_CLASS_SMBUS, .class = I2C_CLASS_SMBUS,
.name = "VIA i2c", .name = "VIA i2c",
.algo_data = &bit_data, .algo_data = &bit_data,
}; };
......
...@@ -289,7 +289,7 @@ static struct i2c_algorithm smbus_algorithm = { ...@@ -289,7 +289,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,
.class = I2C_ADAP_CLASS_SMBUS, .class = I2C_CLASS_SMBUS,
.algo = &smbus_algorithm, .algo = &smbus_algorithm,
.name = "unset", .name = "unset",
}; };
......
...@@ -167,7 +167,7 @@ static struct i2c_algo_bit_data voo_i2c_bit_data = { ...@@ -167,7 +167,7 @@ static struct i2c_algo_bit_data voo_i2c_bit_data = {
static struct i2c_adapter voodoo3_i2c_adapter = { static struct i2c_adapter voodoo3_i2c_adapter = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.class = I2C_ADAP_CLASS_TV_ANALOG, .class = I2C_CLASS_TV_ANALOG,
.name = "I2C Voodoo3/Banshee adapter", .name = "I2C Voodoo3/Banshee adapter",
.algo_data = &voo_i2c_bit_data, .algo_data = &voo_i2c_bit_data,
}; };
...@@ -184,7 +184,7 @@ static struct i2c_algo_bit_data voo_ddc_bit_data = { ...@@ -184,7 +184,7 @@ static struct i2c_algo_bit_data voo_ddc_bit_data = {
static struct i2c_adapter voodoo3_ddc_adapter = { static struct i2c_adapter voodoo3_ddc_adapter = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.class = I2C_ADAP_CLASS_DDC, .class = I2C_CLASS_DDC,
.name = "DDC Voodoo3/Banshee adapter", .name = "DDC Voodoo3/Banshee adapter",
.algo_data = &voo_ddc_bit_data, .algo_data = &voo_ddc_bit_data,
}; };
......
...@@ -200,7 +200,7 @@ static DEVICE_ATTR(die_code, S_IRUGO, show_die_code, NULL); ...@@ -200,7 +200,7 @@ 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)) if (!(adapter->class & I2C_CLASS_SMBUS))
return 0; return 0;
return i2c_detect(adapter, &addr_data, adm1021_detect); return i2c_detect(adapter, &addr_data, adm1021_detect);
} }
......
...@@ -609,7 +609,7 @@ static DEVICE_ATTR(fan1_pwm_enable, S_IRUGO | S_IWUSR, ...@@ -609,7 +609,7 @@ static DEVICE_ATTR(fan1_pwm_enable, S_IRUGO | S_IWUSR,
*/ */
static int asb100_attach_adapter(struct i2c_adapter *adapter) static int asb100_attach_adapter(struct i2c_adapter *adapter)
{ {
if (!(adapter->class & I2C_ADAP_CLASS_SMBUS)) if (!(adapter->class & I2C_CLASS_SMBUS))
return 0; return 0;
return i2c_detect(adapter, &addr_data, asb100_detect); return i2c_detect(adapter, &addr_data, asb100_detect);
} }
......
...@@ -293,7 +293,7 @@ do { \ ...@@ -293,7 +293,7 @@ do { \
static int fscher_attach_adapter(struct i2c_adapter *adapter) static int fscher_attach_adapter(struct i2c_adapter *adapter)
{ {
if (!(adapter->class & I2C_ADAP_CLASS_SMBUS)) if (!(adapter->class & I2C_CLASS_SMBUS))
return 0; return 0;
return i2c_detect(adapter, &addr_data, fscher_detect); return i2c_detect(adapter, &addr_data, fscher_detect);
} }
......
...@@ -335,7 +335,7 @@ static DEVICE_ATTR(beep_mask, S_IWUSR|S_IRUGO, ...@@ -335,7 +335,7 @@ static DEVICE_ATTR(beep_mask, S_IWUSR|S_IRUGO,
static int gl518_attach_adapter(struct i2c_adapter *adapter) static int gl518_attach_adapter(struct i2c_adapter *adapter)
{ {
if (!(adapter->class & I2C_ADAP_CLASS_SMBUS)) if (!(adapter->class & I2C_CLASS_SMBUS))
return 0; return 0;
return i2c_detect(adapter, &addr_data, gl518_detect); return i2c_detect(adapter, &addr_data, gl518_detect);
} }
......
...@@ -500,7 +500,7 @@ static DEVICE_ATTR(alarms, S_IRUGO | S_IWUSR, show_alarms, NULL); ...@@ -500,7 +500,7 @@ static DEVICE_ATTR(alarms, S_IRUGO | S_IWUSR, show_alarms, 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)) if (!(adapter->class & I2C_CLASS_SMBUS))
return 0; return 0;
return i2c_detect(adapter, &addr_data, it87_detect); return i2c_detect(adapter, &addr_data, it87_detect);
} }
......
...@@ -105,7 +105,7 @@ static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input, NULL); ...@@ -105,7 +105,7 @@ static DEVICE_ATTR(temp1_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)) if (!(adapter->class & I2C_CLASS_SMBUS))
return 0; return 0;
return i2c_detect(adapter, &addr_data, lm75_detect); return i2c_detect(adapter, &addr_data, lm75_detect);
} }
......
...@@ -488,7 +488,7 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); ...@@ -488,7 +488,7 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
* when a new adapter is inserted (and lm78_driver is still present) */ * when a new adapter is inserted (and lm78_driver is still present) */
static int lm78_attach_adapter(struct i2c_adapter *adapter) static int lm78_attach_adapter(struct i2c_adapter *adapter)
{ {
if (!(adapter->class & I2C_ADAP_CLASS_SMBUS)) if (!(adapter->class & I2C_CLASS_SMBUS))
return 0; return 0;
return i2c_detect(adapter, &addr_data, lm78_detect); return i2c_detect(adapter, &addr_data, lm78_detect);
} }
......
...@@ -376,7 +376,7 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); ...@@ -376,7 +376,7 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
static int lm80_attach_adapter(struct i2c_adapter *adapter) static int lm80_attach_adapter(struct i2c_adapter *adapter)
{ {
if (!(adapter->class & I2C_ADAP_CLASS_SMBUS)) if (!(adapter->class & I2C_CLASS_SMBUS))
return 0; return 0;
return i2c_detect(adapter, &addr_data, lm80_detect); return i2c_detect(adapter, &addr_data, lm80_detect);
} }
......
...@@ -216,7 +216,7 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); ...@@ -216,7 +216,7 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
static int lm83_attach_adapter(struct i2c_adapter *adapter) static int lm83_attach_adapter(struct i2c_adapter *adapter)
{ {
if (!(adapter->class & I2C_ADAP_CLASS_SMBUS)) if (!(adapter->class & I2C_CLASS_SMBUS))
return 0; return 0;
return i2c_detect(adapter, &addr_data, lm83_detect); return i2c_detect(adapter, &addr_data, lm83_detect);
} }
......
...@@ -274,7 +274,7 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); ...@@ -274,7 +274,7 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
static int lm90_attach_adapter(struct i2c_adapter *adapter) static int lm90_attach_adapter(struct i2c_adapter *adapter)
{ {
if (!(adapter->class & I2C_ADAP_CLASS_SMBUS)) if (!(adapter->class & I2C_CLASS_SMBUS))
return 0; return 0;
return i2c_detect(adapter, &addr_data, lm90_detect); return i2c_detect(adapter, &addr_data, lm90_detect);
} }
......
...@@ -573,7 +573,7 @@ static struct i2c_driver via686a_driver = { ...@@ -573,7 +573,7 @@ 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)) if (!(adapter->class & I2C_CLASS_SMBUS))
return 0; return 0;
return i2c_detect(adapter, &addr_data, via686a_detect); return i2c_detect(adapter, &addr_data, via686a_detect);
} }
......
...@@ -911,7 +911,7 @@ device_create_file(&client->dev, &dev_attr_rt##offset); \ ...@@ -911,7 +911,7 @@ 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)) if (!(adapter->class & I2C_CLASS_SMBUS))
return 0; return 0;
return i2c_detect(adapter, &addr_data, w83781d_detect); return i2c_detect(adapter, &addr_data, w83781d_detect);
} }
......
...@@ -145,7 +145,7 @@ static DEVICE_ATTR(temp1_max, S_IRUGO, show_temp_over, NULL) ...@@ -145,7 +145,7 @@ static DEVICE_ATTR(temp1_max, S_IRUGO, show_temp_over, NULL)
static int w83l785ts_attach_adapter(struct i2c_adapter *adapter) static int w83l785ts_attach_adapter(struct i2c_adapter *adapter)
{ {
if (!(adapter->class & I2C_ADAP_CLASS_SMBUS)) if (!(adapter->class & I2C_CLASS_SMBUS))
return 0; return 0;
return i2c_detect(adapter, &addr_data, w83l785ts_detect); return i2c_detect(adapter, &addr_data, w83l785ts_detect);
} }
......
...@@ -197,7 +197,7 @@ static int bt832_attach(struct i2c_adapter *adap, int addr, ...@@ -197,7 +197,7 @@ 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)
{ {
if (adap->class & I2C_ADAP_CLASS_TV_ANALOG) if (adap->class & I2C_CLASS_TV_ANALOG)
return i2c_probe(adap, &addr_data, bt832_attach); return i2c_probe(adap, &addr_data, bt832_attach);
return 0; return 0;
} }
......
...@@ -108,8 +108,8 @@ static struct i2c_adapter bttv_i2c_adap_sw_template = { ...@@ -108,8 +108,8 @@ static struct i2c_adapter bttv_i2c_adap_sw_template = {
.inc_use = bttv_inc_use, .inc_use = bttv_inc_use,
.dec_use = bttv_dec_use, .dec_use = bttv_dec_use,
#endif #endif
#ifdef I2C_ADAP_CLASS_TV_ANALOG #ifdef I2C_CLASS_TV_ANALOG
.class = I2C_ADAP_CLASS_TV_ANALOG, .class = I2C_CLASS_TV_ANALOG,
#endif #endif
I2C_DEVNAME("bt848"), I2C_DEVNAME("bt848"),
.id = I2C_HW_B_BT848, .id = I2C_HW_B_BT848,
...@@ -291,8 +291,8 @@ static struct i2c_adapter bttv_i2c_adap_hw_template = { ...@@ -291,8 +291,8 @@ static struct i2c_adapter bttv_i2c_adap_hw_template = {
.inc_use = bttv_inc_use, .inc_use = bttv_inc_use,
.dec_use = bttv_dec_use, .dec_use = bttv_dec_use,
#endif #endif
#ifdef I2C_ADAP_CLASS_TV_ANALOG #ifdef I2C_CLASS_TV_ANALOG
.class = I2C_ADAP_CLASS_TV_ANALOG, .class = I2C_CLASS_TV_ANALOG,
#endif #endif
I2C_DEVNAME("bt878"), I2C_DEVNAME("bt878"),
.id = I2C_ALGO_BIT | I2C_HW_B_BT848 /* FIXME */, .id = I2C_ALGO_BIT | I2C_HW_B_BT848 /* FIXME */,
......
...@@ -128,8 +128,8 @@ static struct i2c_adapter cx8800_i2c_adap_template = { ...@@ -128,8 +128,8 @@ static struct i2c_adapter cx8800_i2c_adap_template = {
.inc_use = cx8800_inc_use, .inc_use = cx8800_inc_use,
.dec_use = cx8800_dec_use, .dec_use = cx8800_dec_use,
#endif #endif
#ifdef I2C_ADAP_CLASS_TV_ANALOG #ifdef I2C_CLASS_TV_ANALOG
.class = I2C_ADAP_CLASS_TV_ANALOG, .class = I2C_CLASS_TV_ANALOG,
#endif #endif
I2C_DEVNAME("cx2388x"), I2C_DEVNAME("cx2388x"),
.id = I2C_HW_B_BT848, .id = I2C_HW_B_BT848,
......
...@@ -106,7 +106,7 @@ static int dpc_probe(struct saa7146_dev* dev) ...@@ -106,7 +106,7 @@ static int dpc_probe(struct saa7146_dev* dev)
video port pins should be enabled here ?! */ video port pins should be enabled here ?! */
saa7146_write(dev, MC1, (MASK_08 | MASK_24 | MASK_10 | MASK_26)); saa7146_write(dev, MC1, (MASK_08 | MASK_24 | MASK_10 | MASK_26));
saa7146_i2c_adapter_prepare(dev, &dpc->i2c_adapter, I2C_ADAP_CLASS_TV_ANALOG, SAA7146_I2C_BUS_BIT_RATE_480); saa7146_i2c_adapter_prepare(dev, &dpc->i2c_adapter, I2C_CLASS_TV_ANALOG, SAA7146_I2C_BUS_BIT_RATE_480);
if(i2c_add_adapter(&dpc->i2c_adapter) < 0) { if(i2c_add_adapter(&dpc->i2c_adapter) < 0) {
DEB_S(("cannot register i2c-device. skipping.\n")); DEB_S(("cannot register i2c-device. skipping.\n"));
kfree(dpc); kfree(dpc);
......
...@@ -250,7 +250,7 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d ...@@ -250,7 +250,7 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d
/* enable i2c-port pins */ /* enable i2c-port pins */
saa7146_write(dev, MC1, (MASK_08 | MASK_24 | MASK_10 | MASK_26)); saa7146_write(dev, MC1, (MASK_08 | MASK_24 | MASK_10 | MASK_26));
saa7146_i2c_adapter_prepare(dev, &hexium->i2c_adapter, I2C_ADAP_CLASS_TV_ANALOG, SAA7146_I2C_BUS_BIT_RATE_480); saa7146_i2c_adapter_prepare(dev, &hexium->i2c_adapter, I2C_CLASS_TV_ANALOG, SAA7146_I2C_BUS_BIT_RATE_480);
if (i2c_add_adapter(&hexium->i2c_adapter) < 0) { if (i2c_add_adapter(&hexium->i2c_adapter) < 0) {
DEB_S(("cannot register i2c-device. skipping.\n")); DEB_S(("cannot register i2c-device. skipping.\n"));
kfree(hexium); kfree(hexium);
......
...@@ -237,7 +237,7 @@ static int hexium_probe(struct saa7146_dev *dev) ...@@ -237,7 +237,7 @@ static int hexium_probe(struct saa7146_dev *dev)
saa7146_write(dev, DD1_STREAM_B, 0x00000000); saa7146_write(dev, DD1_STREAM_B, 0x00000000);
saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26)); saa7146_write(dev, MC2, (MASK_09 | MASK_25 | MASK_10 | MASK_26));
saa7146_i2c_adapter_prepare(dev, &hexium->i2c_adapter, I2C_ADAP_CLASS_TV_ANALOG, SAA7146_I2C_BUS_BIT_RATE_480); saa7146_i2c_adapter_prepare(dev, &hexium->i2c_adapter, I2C_CLASS_TV_ANALOG, SAA7146_I2C_BUS_BIT_RATE_480);
if (i2c_add_adapter(&hexium->i2c_adapter) < 0) { if (i2c_add_adapter(&hexium->i2c_adapter) < 0) {
DEB_S(("cannot register i2c-device. skipping.\n")); DEB_S(("cannot register i2c-device. skipping.\n"));
kfree(hexium); kfree(hexium);
......
...@@ -1353,8 +1353,8 @@ static int msp_detach(struct i2c_client *client) ...@@ -1353,8 +1353,8 @@ static int msp_detach(struct i2c_client *client)
static int msp_probe(struct i2c_adapter *adap) static int msp_probe(struct i2c_adapter *adap)
{ {
#ifdef I2C_ADAP_CLASS_TV_ANALOG #ifdef I2C_CLASS_TV_ANALOG
if (adap->class & I2C_ADAP_CLASS_TV_ANALOG) if (adap->class & I2C_CLASS_TV_ANALOG)
return i2c_probe(adap, &addr_data, msp_attach); return i2c_probe(adap, &addr_data, msp_attach);
#else #else
switch (adap->id) { switch (adap->id) {
......
...@@ -223,7 +223,7 @@ static int mxb_probe(struct saa7146_dev* dev) ...@@ -223,7 +223,7 @@ static int mxb_probe(struct saa7146_dev* dev)
video port pins should be enabled here ?! */ video port pins should be enabled here ?! */
saa7146_write(dev, MC1, (MASK_08 | MASK_24 | MASK_10 | MASK_26)); saa7146_write(dev, MC1, (MASK_08 | MASK_24 | MASK_10 | MASK_26));
saa7146_i2c_adapter_prepare(dev, &mxb->i2c_adapter, I2C_ADAP_CLASS_TV_ANALOG, SAA7146_I2C_BUS_BIT_RATE_480); saa7146_i2c_adapter_prepare(dev, &mxb->i2c_adapter, I2C_CLASS_TV_ANALOG, SAA7146_I2C_BUS_BIT_RATE_480);
if(i2c_add_adapter(&mxb->i2c_adapter) < 0) { if(i2c_add_adapter(&mxb->i2c_adapter) < 0) {
DEB_S(("cannot register i2c-device. skipping.\n")); DEB_S(("cannot register i2c-device. skipping.\n"));
kfree(mxb); kfree(mxb);
......
...@@ -143,7 +143,7 @@ static int saa5246a_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -143,7 +143,7 @@ static int saa5246a_attach(struct i2c_adapter *adap, int addr, int kind)
*/ */
static int saa5246a_probe(struct i2c_adapter *adap) static int saa5246a_probe(struct i2c_adapter *adap)
{ {
if (adap->class & I2C_ADAP_CLASS_TV_ANALOG) if (adap->class & I2C_CLASS_TV_ANALOG)
return i2c_probe(adap, &addr_data, saa5246a_attach); return i2c_probe(adap, &addr_data, saa5246a_attach);
return 0; return 0;
} }
......
...@@ -219,7 +219,7 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -219,7 +219,7 @@ 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)
{ {
if (adap->class & I2C_ADAP_CLASS_TV_ANALOG) if (adap->class & I2C_CLASS_TV_ANALOG)
return i2c_probe(adap, &addr_data, saa5249_attach); return i2c_probe(adap, &addr_data, saa5249_attach);
return 0; return 0;
} }
......
...@@ -335,7 +335,7 @@ static int saa6752hs_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -335,7 +335,7 @@ static int saa6752hs_attach(struct i2c_adapter *adap, int addr, int kind)
static int saa6752hs_probe(struct i2c_adapter *adap) static int saa6752hs_probe(struct i2c_adapter *adap)
{ {
if (adap->class & I2C_ADAP_CLASS_TV_ANALOG) if (adap->class & I2C_CLASS_TV_ANALOG)
return i2c_probe(adap, &addr_data, saa6752hs_attach); return i2c_probe(adap, &addr_data, saa6752hs_attach);
return 0; return 0;
......
...@@ -347,8 +347,8 @@ static struct i2c_adapter saa7134_adap_template = { ...@@ -347,8 +347,8 @@ static struct i2c_adapter saa7134_adap_template = {
.inc_use = inc_use, .inc_use = inc_use,
.dec_use = dec_use, .dec_use = dec_use,
#endif #endif
#ifdef I2C_ADAP_CLASS_TV_ANALOG #ifdef I2C_CLASS_TV_ANALOG
.class = I2C_ADAP_CLASS_TV_ANALOG, .class = I2C_CLASS_TV_ANALOG,
#endif #endif
I2C_DEVNAME("saa7134"), I2C_DEVNAME("saa7134"),
.id = I2C_ALGO_SAA7134, .id = I2C_ALGO_SAA7134,
......
...@@ -338,8 +338,8 @@ static int tda7432_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -338,8 +338,8 @@ 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)
{ {
#ifdef I2C_ADAP_CLASS_TV_ANALOG #ifdef I2C_CLASS_TV_ANALOG
if (adap->class & I2C_ADAP_CLASS_TV_ANALOG) if (adap->class & I2C_CLASS_TV_ANALOG)
return i2c_probe(adap, &addr_data, tda7432_attach); return i2c_probe(adap, &addr_data, tda7432_attach);
#else #else
if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848)) if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848))
......
...@@ -272,8 +272,8 @@ static int tda9875_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -272,8 +272,8 @@ 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)
{ {
#ifdef I2C_ADAP_CLASS_TV_ANALOG #ifdef I2C_CLASS_TV_ANALOG
if (adap->class & I2C_ADAP_CLASS_TV_ANALOG) if (adap->class & I2C_CLASS_TV_ANALOG)
return i2c_probe(adap, &addr_data, tda9875_attach); return i2c_probe(adap, &addr_data, tda9875_attach);
#else #else
if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848)) if (adap->id == (I2C_ALGO_BIT | I2C_HW_B_BT848))
......
...@@ -370,8 +370,8 @@ static int tda9887_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -370,8 +370,8 @@ 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)
{ {
#ifdef I2C_ADAP_CLASS_TV_ANALOG #ifdef I2C_CLASS_TV_ANALOG
if (adap->class & I2C_ADAP_CLASS_TV_ANALOG) if (adap->class & I2C_CLASS_TV_ANALOG)
return i2c_probe(adap, &addr_data, tda9887_attach); return i2c_probe(adap, &addr_data, tda9887_attach);
#else #else
switch (adap->id) { switch (adap->id) {
......
...@@ -1067,8 +1067,8 @@ static int tuner_probe(struct i2c_adapter *adap) ...@@ -1067,8 +1067,8 @@ static int tuner_probe(struct i2c_adapter *adap)
} }
this_adap = 0; this_adap = 0;
#ifdef I2C_ADAP_CLASS_TV_ANALOG #ifdef I2C_CLASS_TV_ANALOG
if (adap->class & I2C_ADAP_CLASS_TV_ANALOG) if (adap->class & I2C_CLASS_TV_ANALOG)
return i2c_probe(adap, &addr_data, tuner_attach); return i2c_probe(adap, &addr_data, tuner_attach);
#else #else
switch (adap->id) { switch (adap->id) {
......
...@@ -1497,8 +1497,8 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind) ...@@ -1497,8 +1497,8 @@ 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)
{ {
#ifdef I2C_ADAP_CLASS_TV_ANALOG #ifdef I2C_CLASS_TV_ANALOG
if (adap->class & I2C_ADAP_CLASS_TV_ANALOG) if (adap->class & I2C_CLASS_TV_ANALOG)
return i2c_probe(adap, &addr_data, chip_attach); return i2c_probe(adap, &addr_data, chip_attach);
#else #else
switch (adap->id) { switch (adap->id) {
......
...@@ -263,8 +263,8 @@ static int tvmixer_clients(struct i2c_client *client) ...@@ -263,8 +263,8 @@ static int tvmixer_clients(struct i2c_client *client)
struct video_audio va; struct video_audio va;
int i,minor; int i,minor;
#ifdef I2C_ADAP_CLASS_TV_ANALOG #ifdef I2C_CLASS_TV_ANALOG
if (!(client->adapter->class & I2C_ADAP_CLASS_TV_ANALOG)) if (!(client->adapter->class & I2C_CLASS_TV_ANALOG))
return -1; return -1;
#else #else
/* TV card ??? */ /* TV card ??? */
......
...@@ -1578,7 +1578,7 @@ static int w9968cf_i2c_init(struct w9968cf_device* cam) ...@@ -1578,7 +1578,7 @@ static int w9968cf_i2c_init(struct w9968cf_device* cam)
static struct i2c_adapter adap = { static struct i2c_adapter adap = {
.id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_W9968CF, .id = I2C_ALGO_SMBUS | I2C_HW_SMBUS_W9968CF,
.class = I2C_ADAP_CLASS_CAM_DIGITAL, .class = I2C_CLASS_CAM_DIGITAL,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.client_register = w9968cf_i2c_attach_inform, .client_register = w9968cf_i2c_attach_inform,
.client_unregister = w9968cf_i2c_detach_inform, .client_unregister = w9968cf_i2c_detach_inform,
......
...@@ -113,6 +113,7 @@ struct i2c_driver { ...@@ -113,6 +113,7 @@ struct i2c_driver {
struct module *owner; struct module *owner;
char name[32]; char name[32];
int id; int id;
unsigned int class;
unsigned int flags; /* div., see below */ unsigned int flags; /* div., see below */
/* Notifies the driver that a new bus has appeared. This routine /* Notifies the driver that a new bus has appeared. This routine
...@@ -237,7 +238,6 @@ struct i2c_adapter { ...@@ -237,7 +238,6 @@ struct i2c_adapter {
/* data fields that are valid for all devices */ /* data fields that are valid for all devices */
struct semaphore bus_lock; struct semaphore bus_lock;
struct semaphore clist_lock; struct semaphore clist_lock;
unsigned int flags;/* flags specifying div. data */
int timeout; int timeout;
int retries; int retries;
...@@ -286,12 +286,14 @@ static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data) ...@@ -286,12 +286,14 @@ static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data)
/* Must equal I2C_M_TEN below */ /* Must equal I2C_M_TEN below */
/* i2c adapter classes (bitmask) */ /* i2c adapter classes (bitmask) */
#define I2C_ADAP_CLASS_SMBUS (1<<0) /* lm_sensors, ... */ #define I2C_CLASS_SMBUS (1<<0) /* lm_sensors, ... */
#define I2C_ADAP_CLASS_TV_ANALOG (1<<1) /* bttv + friends */ #define I2C_CLASS_TV_ANALOG (1<<1) /* bttv + friends */
#define I2C_ADAP_CLASS_TV_DIGITAL (1<<2) /* dbv cards */ #define I2C_CLASS_TV_DIGITAL (1<<2) /* dvb cards */
#define I2C_ADAP_CLASS_DDC (1<<3) /* i2c-matroxfb ? */ #define I2C_CLASS_DDC (1<<3) /* i2c-matroxfb ? */
#define I2C_ADAP_CLASS_CAM_ANALOG (1<<4) /* camera with analog CCD */ #define I2C_CLASS_CAM_ANALOG (1<<4) /* camera with analog CCD */
#define I2C_ADAP_CLASS_CAM_DIGITAL (1<<5) /* most webcams */ #define I2C_CLASS_CAM_DIGITAL (1<<5) /* most webcams */
#define I2C_CLASS_SOUND (1<<6) /* sound devices */
#define I2C_CLASS_ALL (UINT_MAX) /* all of the above */
/* 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
......
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