[2.6]
Subsystems (7)
PATCH 1/1 [2.6]
Hello,
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
I think these things are unquestionable and don't make any functional changes to the code, so this should be applied to 2.6 now.
From that point on, we can discuss how to proceed.
Comments?
CU
Michael.
Documentation/i2c/porting-clients +2 -2
@@ -62,9 +62,9 @@ patch to the Documentation/i2c/sysfs-interface file. * [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: - if (!(adapter->class & I2C_ADAP_CLASS_SMBUS)) + if (!(adapter->class & I2C_CLASS_SMBUS)) return 0; ISA-only drivers of course don't need this.
drivers/i2c/busses/i2c-ali1535.c +1 -1
@@ -480,7 +480,7 @@static struct i2c_adapter ali1535_adapter = { .owner =THIS_MODULE , - .class =I2C_ADAP_CLASS_SMBUS , + .class =I2C_CLASS_SMBUS , .algo = &smbus_algorithm, .name ="unset" , };
drivers/i2c/busses/i2c-ali1563.c +1 -1
@@ -357,7 +357,7 @@static struct i2c_adapter ali1563_adapter = { .owner =THIS_MODULE , - .class =I2C_ADAP_CLASS_SMBUS , + .class =I2C_CLASS_SMBUS , .algo = &ali1563_algorithm, };
drivers/i2c/busses/i2c-ali15x3.c +1 -1
@@ -470,7 +470,7 @@static struct i2c_adapter ali15x3_adapter = { .owner =THIS_MODULE , - .class =I2C_ADAP_CLASS_SMBUS , + .class =I2C_CLASS_SMBUS , .algo = &smbus_algorithm, .name ="unset" , };
drivers/i2c/busses/i2c-amd756.c +1 -1
@@ -303,7 +303,7 @@static struct i2c_adapter amd756_adapter = { .owner =THIS_MODULE , - .class =I2C_ADAP_CLASS_SMBUS , + .class =I2C_CLASS_SMBUS , .algo = &smbus_algorithm, .name ="unset" , };
drivers/i2c/busses/i2c-amd8111.c +1 -1
@@ -359,7 +359,7 @@ smbus->adapter.owner =THIS_MODULE ;snprintf (smbus->adapter.name,I2C_NAME_SIZE ,"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_data = smbus;
drivers/i2c/busses/i2c-i801.c +1 -1
@@ -539,7 +539,7 @@static struct i2c_adapter i801_adapter = { .owner =THIS_MODULE , - .class =I2C_ADAP_CLASS_SMBUS , + .class =I2C_CLASS_SMBUS , .algo = &smbus_algorithm, .name ="unset" , };
drivers/i2c/busses/i2c-isa.c +1 -1
@@ -43,7 +43,7 @@/* There can only be one... */ static struct i2c_adapter isa_adapter = { .owner =THIS_MODULE , - .class =I2C_ADAP_CLASS_SMBUS , + .class =I2C_CLASS_SMBUS , .algo = &isa_algorithm, .name ="ISA main adapter" , };
drivers/i2c/busses/i2c-nforce2.c +1 -1
@@ -119,7 +119,7 @@static struct i2c_adapter nforce2_adapter = { .owner =THIS_MODULE , - .class =I2C_ADAP_CLASS_SMBUS , + .class =I2C_CLASS_SMBUS , .algo = &smbus_algorithm, .name ="unset" , };
drivers/i2c/busses/i2c-parport-light.c +1 -1
@@ -112,7 +112,7 @@static struct i2c_adapter parport_adapter = { .owner =THIS_MODULE , - .class =I2C_ADAP_CLASS_SMBUS , + .class =I2C_CLASS_SMBUS , .id =I2C_HW_B_LP , .algo_data = &parport_algo_data, .name ="Parallel port adapter (light)" ,
drivers/i2c/busses/i2c-parport.c +1 -1
@@ -147,7 +147,7 @@static struct i2c_adapter parport_adapter = { .owner =THIS_MODULE , - .class =I2C_ADAP_CLASS_SMBUS , + .class =I2C_CLASS_SMBUS , .id =I2C_HW_B_LP , .name ="Parallel port adapter" , };
drivers/i2c/busses/i2c-piix4.c +1 -1
@@ -410,7 +410,7 @@static struct i2c_adapter piix4_adapter = { .owner =THIS_MODULE , - .class =I2C_ADAP_CLASS_SMBUS , + .class =I2C_CLASS_SMBUS , .algo = &smbus_algorithm, .name ="unset" , };
drivers/i2c/busses/i2c-sis5595.c +1 -1
@@ -360,7 +360,7 @@static struct i2c_adapter sis5595_adapter = { .owner =THIS_MODULE , - .class =I2C_ADAP_CLASS_SMBUS , + .class =I2C_CLASS_SMBUS , .name ="unset" , .algo = &smbus_algorithm, };
drivers/i2c/busses/i2c-sis630.c +1 -1
@@ -456,7 +456,7 @@static struct i2c_adapter sis630_adapter = { .owner =THIS_MODULE , - .class =I2C_ADAP_CLASS_SMBUS , + .class =I2C_CLASS_SMBUS , .name ="unset" , .algo = &smbus_algorithm, };
drivers/i2c/busses/i2c-sis96x.c +1 -1
@@ -260,7 +260,7 @@static struct i2c_adapter sis96x_adapter = { .owner =THIS_MODULE , - .class =I2C_ADAP_CLASS_SMBUS , + .class =I2C_CLASS_SMBUS , .algo = &smbus_algorithm, .name ="unset" , };
drivers/i2c/busses/i2c-via.c +1 -1
@@ -88,7 +88,7 @@static struct i2c_adapter vt586b_adapter = { .owner =THIS_MODULE , - .class =I2C_ADAP_CLASS_SMBUS , + .class =I2C_CLASS_SMBUS , .name ="VIA i2c" , .algo_data = &bit_data, };
drivers/i2c/busses/i2c-viapro.c +1 -1
@@ -289,7 +289,7 @@static struct i2c_adapter vt596_adapter = { .owner =THIS_MODULE , - .class =I2C_ADAP_CLASS_SMBUS , + .class =I2C_CLASS_SMBUS , .algo = &smbus_algorithm, .name ="unset" , };
drivers/i2c/busses/i2c-voodoo3.c +2 -2
@@ -167,7 +167,7 @@static struct i2c_adapter voodoo3_i2c_adapter = { .owner =THIS_MODULE , - .class =I2C_ADAP_CLASS_TV_ANALOG , + .class =I2C_CLASS_TV_ANALOG , .name ="I2C Voodoo3/Banshee adapter" , .algo_data = &voo_i2c_bit_data, };
@@ -184,7 +184,7 @@static struct i2c_adapter voodoo3_ddc_adapter = { .owner =THIS_MODULE , - .class =I2C_ADAP_CLASS_DDC , + .class =I2C_CLASS_DDC , .name ="DDC Voodoo3/Banshee adapter" , .algo_data = &voo_ddc_bit_data, };
drivers/i2c/chips/adm1021.c +1 -1
@@ -200,7 +200,7 @@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 i2c_detect (adapter, &addr_data, adm1021_detect); }
drivers/i2c/chips/asb100.c +1 -1
@@ -609,7 +609,7 @@*/ 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 i2c_detect (adapter, &addr_data, asb100_detect); }
drivers/i2c/chips/fscher.c +1 -1
@@ -293,7 +293,7 @@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 i2c_detect (adapter, &addr_data, fscher_detect); }
drivers/i2c/chips/gl518sm.c +1 -1
@@ -335,7 +335,7 @@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 i2c_detect (adapter, &addr_data, gl518_detect); }
drivers/i2c/chips/it87.c +1 -1
@@ -500,7 +500,7 @@* 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 )) +if (!(adapter->class &I2C_CLASS_SMBUS ))return 0 ;return i2c_detect (adapter, &addr_data, it87_detect); }
drivers/i2c/chips/lm75.c +1 -1
@@ -105,7 +105,7 @@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 i2c_detect (adapter, &addr_data, lm75_detect); }
drivers/i2c/chips/lm78.c +1 -1
@@ -488,7 +488,7 @@* when a new adapter is inserted (and lm78_driver is still present) */ 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 i2c_detect (adapter, &addr_data, lm78_detect); }
drivers/i2c/chips/lm80.c +1 -1
@@ -376,7 +376,7 @@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 i2c_detect (adapter, &addr_data, lm80_detect); }
drivers/i2c/chips/lm83.c +1 -1
@@ -216,7 +216,7 @@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 i2c_detect (adapter, &addr_data, lm83_detect); }
drivers/i2c/chips/lm90.c +1 -1
@@ -261,7 +261,7 @@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 i2c_detect (adapter, &addr_data, lm90_detect); }
drivers/i2c/chips/via686a.c +1 -1
@@ -602,7 +602,7 @@/* This is called when the module is loaded */ 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 i2c_detect (adapter, &addr_data, via686a_detect); }
drivers/i2c/chips/w83781d.c +1 -1
@@ -905,7 +905,7 @@static int w83781d_attach_adapter (struct i2c_adapter *adapter) { -if (!(adapter->class &I2C_ADAP_CLASS_SMBUS )) +if (!(adapter->class &I2C_CLASS_SMBUS ))return 0 ;return i2c_detect (adapter, &addr_data, w83781d_detect); }
drivers/i2c/chips/w83l785ts.c +1 -1
@@ -145,7 +145,7 @@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 i2c_detect (adapter, &addr_data, w83l785ts_detect); }
drivers/media/video/bt832.c +1 -1
@@ -197,7 +197,7 @@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 0 ; }
drivers/media/video/bttv-i2c.c +4 -4
@@ -108,8 +108,8 @@ .inc_use = bttv_inc_use, .dec_use = bttv_dec_use,#endif -#ifdef I2C_ADAP_CLASS_TV_ANALOG - .class = I2C_ADAP_CLASS_TV_ANALOG, +#ifdef I2C_CLASS_TV_ANALOG + .class = I2C_CLASS_TV_ANALOG,#endif I2C_DEVNAME("bt848"), .id = I2C_HW_B_BT848,
@@ -291,8 +291,8 @@ .inc_use = bttv_inc_use, .dec_use = bttv_dec_use,#endif -#ifdef I2C_ADAP_CLASS_TV_ANALOG - .class = I2C_ADAP_CLASS_TV_ANALOG, +#ifdef I2C_CLASS_TV_ANALOG + .class = I2C_CLASS_TV_ANALOG,#endif I2C_DEVNAME("bt878"), .id = I2C_ALGO_BIT | I2C_HW_B_BT848 /* FIXME */,
drivers/media/video/cx88/cx88-i2c.c +2 -2
@@ -128,8 +128,8 @@ .inc_use = cx8800_inc_use, .dec_use = cx8800_dec_use,#endif -#ifdef I2C_ADAP_CLASS_TV_ANALOG - .class = I2C_ADAP_CLASS_TV_ANALOG, +#ifdef I2C_CLASS_TV_ANALOG + .class = I2C_CLASS_TV_ANALOG,#endif I2C_DEVNAME("cx2388x"), .id = I2C_HW_B_BT848,
drivers/media/video/dpc7146.c +1 -1
@@ -106,7 +106,7 @@video port pins should be enabled here ?! */ 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 ) {DEB_S (("cannot register i2c-device. skipping.\n" ));kfree (dpc);
drivers/media/video/hexium_gemini.c +1 -1
@@ -250,7 +250,7 @@/* enable i2c-port pins */ 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 ) {DEB_S (("cannot register i2c-device. skipping.\n" ));kfree (hexium);
drivers/media/video/hexium_orion.c +1 -1
@@ -237,7 +237,7 @@saa7146_write (dev,DD1_STREAM_B ,0x00000000 );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 ) {DEB_S (("cannot register i2c-device. skipping.\n" ));kfree (hexium);
drivers/media/video/msp3400.c +2 -2
@@ -1353,8 +1353,8 @@static int msp_probe (struct i2c_adapter *adap) { -#ifdef I2C_ADAP_CLASS_TV_ANALOG -if (adap->class &I2C_ADAP_CLASS_TV_ANALOG ) +#ifdef I2C_CLASS_TV_ANALOG +if (adap->class &I2C_CLASS_TV_ANALOG )return i2c_probe (adap, &addr_data, msp_attach);#else switch (adap->id) {
drivers/media/video/mxb.c +1 -1
@@ -223,7 +223,7 @@video port pins should be enabled here ?! */ 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 ) {DEB_S (("cannot register i2c-device. skipping.\n" ));kfree (mxb);
drivers/media/video/saa5246a.c +1 -1
@@ -143,7 +143,7 @@*/ 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 0 ; }
drivers/media/video/saa5249.c +1 -1
@@ -219,7 +219,7 @@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 0 ; }
drivers/media/video/saa7134/saa6752hs.c +1 -1
@@ -335,7 +335,7 @@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 0 ;
drivers/media/video/saa7134/saa7134-i2c.c +2 -2
@@ -347,8 +347,8 @@ .inc_use = inc_use, .dec_use = dec_use,#endif -#ifdef I2C_ADAP_CLASS_TV_ANALOG - .class = I2C_ADAP_CLASS_TV_ANALOG, +#ifdef I2C_CLASS_TV_ANALOG + .class = I2C_CLASS_TV_ANALOG,#endif I2C_DEVNAME("saa7134"), .id = I2C_ALGO_SAA7134,
drivers/media/video/tda7432.c +2 -2
@@ -338,8 +338,8 @@static int tda7432_probe (struct i2c_adapter *adap) { -#ifdef I2C_ADAP_CLASS_TV_ANALOG -if (adap->class &I2C_ADAP_CLASS_TV_ANALOG ) +#ifdef I2C_CLASS_TV_ANALOG +if (adap->class &I2C_CLASS_TV_ANALOG )return i2c_probe (adap, &addr_data, tda7432_attach);#else if (adap->id == (I2C_ALGO_BIT |I2C_HW_B_BT848 ))
drivers/media/video/tda9875.c +2 -2
@@ -272,8 +272,8 @@static int tda9875_probe (struct i2c_adapter *adap) { -#ifdef I2C_ADAP_CLASS_TV_ANALOG -if (adap->class &I2C_ADAP_CLASS_TV_ANALOG ) +#ifdef I2C_CLASS_TV_ANALOG +if (adap->class &I2C_CLASS_TV_ANALOG )return i2c_probe (adap, &addr_data, tda9875_attach);#else if (adap->id == (I2C_ALGO_BIT |I2C_HW_B_BT848 ))
drivers/media/video/tda9887.c +2 -2
@@ -370,8 +370,8 @@static int tda9887_probe (struct i2c_adapter *adap) { -#ifdef I2C_ADAP_CLASS_TV_ANALOG -if (adap->class &I2C_ADAP_CLASS_TV_ANALOG ) +#ifdef I2C_CLASS_TV_ANALOG +if (adap->class &I2C_CLASS_TV_ANALOG )return i2c_probe (adap, &addr_data, tda9887_attach);#else switch (adap->id) {
drivers/media/video/tuner.c +2 -2
@@ -1067,8 +1067,8 @@ } this_adap =0 ; -#ifdef I2C_ADAP_CLASS_TV_ANALOG -if (adap->class &I2C_ADAP_CLASS_TV_ANALOG ) +#ifdef I2C_CLASS_TV_ANALOG +if (adap->class &I2C_CLASS_TV_ANALOG )return i2c_probe (adap, &addr_data, tuner_attach);#else switch (adap->id) {
drivers/media/video/tvaudio.c +2 -2
@@ -1497,8 +1497,8 @@static int chip_probe (struct i2c_adapter *adap) { -#ifdef I2C_ADAP_CLASS_TV_ANALOG -if (adap->class &I2C_ADAP_CLASS_TV_ANALOG ) +#ifdef I2C_CLASS_TV_ANALOG +if (adap->class &I2C_CLASS_TV_ANALOG )return i2c_probe (adap, &addr_data, chip_attach);#else switch (adap->id) {
drivers/media/video/tvmixer.c +2 -2
@@ -263,8 +263,8 @@struct video_audio va;int i,minor; -#ifdef I2C_ADAP_CLASS_TV_ANALOG -if (!(client->adapter->class &I2C_ADAP_CLASS_TV_ANALOG )) +#ifdef I2C_CLASS_TV_ANALOG +if (!(client->adapter->class &I2C_CLASS_TV_ANALOG ))return -1 ;#else /* TV card ??? */
drivers/usb/media/w9968cf.c +1 -1
@@ -1578,7 +1578,7 @@static struct i2c_adapter adap = { .id =I2C_ALGO_SMBUS |I2C_HW_SMBUS_W9968CF , - .class =I2C_ADAP_CLASS_CAM_DIGITAL , + .class =I2C_CLASS_CAM_DIGITAL , .owner =THIS_MODULE , .client_register = w9968cf_i2c_attach_inform, .client_unregister = w9968cf_i2c_detach_inform,
include/linux/i2c.h +9 -7
@@ -113,6 +113,7 @@struct module *owner;char name[32 ];int id; +unsigned int class;unsigned int flags;/* div., see below */ /* Notifies the driver that a new bus has appeared. This routine
@@ -237,7 +238,6 @@/* data fields that are valid for all devices */ struct semaphore bus_lock;struct semaphore clist_lock; -unsigned int flags;/* flags specifying div. data */ int timeout;int retries;
@@ -286,12 +286,14 @@/* 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_DIGITAL (1<<2)/* dbv cards */ -#define I2C_ADAP_CLASS_DDC (1<<3)/* i2c-matroxfb ? */ -#define I2C_ADAP_CLASS_CAM_ANALOG (1<<4)/* camera with analog CCD */ -#define I2C_ADAP_CLASS_CAM_DIGITAL (1<<5)/* most webcams */ +#define I2C_CLASS_SMBUS (1<<0)/* lm_sensors, ... */ +#define I2C_CLASS_TV_ANALOG (1<<1)/* bttv + friends */ +#define I2C_CLASS_TV_DIGITAL (1<<2)/* dvb cards */ +#define I2C_CLASS_DDC (1<<3)/* i2c-matroxfb ? */ +#define I2C_CLASS_CAM_ANALOG (1<<4)/* camera with analog CCD */ +#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 * addresses for a driver and for the parameters supplied on the
Quoted 3 lines · Michael Hunold
I think these things are unquestionable and don't make any functional changes to the code, so this should be applied to 2.6 now.
"now" as in 2.6.6-rc3? No.
Now as in I'll add it to my i2c tree, which will get picked up by -mm and let it bake a bit and then pushed to Linus, yes.
I'll look this over and add it to my tree, thanks,
greg k-h
Quoted 8 lines · Michael Hunold
The attached patch does the first step:
- add .class member to structi2c_device
- remove unused .flags member from structi2c_adapter
- renameI2C_ADAP_CLASS_xxxtoI2C_CLASS_xxx(to be used both for drivers and adapters)
- add newI2C_CLASS_ALLandI2C_CLASS_SOUNDclasses
- follow these changes in the existing drivers with copy & paste
Quoted 6 lines
I think these things are unquestionable and don't make any functional changes to the code, so this should be applied to 2.6 now.
From that point on, we can discuss how to proceed.
Comments?
Looks good, I've applied this to my trees, and it will show up in the next -mm release.
thanks,
greg k-h
Hello Greg,
Quoted 4 lines · Greg KH
Quoted 1 line
I think these things are unquestionable and don't make any functional changes to the code, so this should be applied to 2.6 now.
Now as in I'll add it to my i2c tree, which will get picked up by -mm and let it bake a bit and then pushed to Linus, yes.
This is how I meant it.
Quoting your other mail:
Quoted 2 lines
Looks good, I've applied this to my trees, and it will show up in the next -mm release.
Ok, thanks. As my time permits it, I'll prepare patches to add class entries to the i2c adapters and i2c clients.
But I won't be sad if the sensors people make the changes to their drivers themselves. ;-)
(ie. mostly remove
Quoted 2 lines
if (!(adapter->class & I2C_CLASS_SMBUS)) return 0;
from the xxx_attach_adapter() funtion (the check will be done in the i2c-core and add a .class = I2C_CLASS_SMBUS to the xxx_driver static variable)
Quoted 1 line
greg k-h
CU
Michael.
Quoted 4 lines
With the new
I2C_CLASS_ALLflag 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)
Depends. For example the eeprom driver will do that, and this is correct. That said, I agree that this is a collaborative approach and everybody will have to play the game.
Quoted 3 lines
- rename
I2C_ADAP_CLASS_xxxtoI2C_CLASS_xxx(to be used both for drivers and adapters)
- add newI2C_CLASS_ALLandI2C_CLASS_SOUNDclasses
Mmm, I once proposed that I2C_ADAP_CLASS_SMBUS would be better renamed I2C_ADAP_CLASS_SENSORS (so I2C_CLASS_SENSORS now). What about that? I think it would be great to embed that change into your patch, so that the name changes only once.
Now that we come to speak about that, I wonder if we would _also_ need a SMBUS class. SMBus is mostly a subset of I2C, essentially (but not completely) compatible. It may be useful at some point to know if a chip is compliant with SMBus or not. I don't think that i2c-core can make use of this at the moment, nor can I think of concrete examples where this would be needed. It's just a thought at the moment and I mention it here in case anyone has comments ;)
For now we can stick to the classes we have (with the SMBUS->SENSORS change and the new SOUND class). The true SMBUS class can always be added later if needed, I guess.
BTW, if HWMON is prefered to SENSORS, this is fine with me too, I have no strong preference.
Thanks.
Signature · 2 lines
Jean Delvare http://khali.linux-fr.org/
PATCH 1/1 Rename hardware monitoring I2C class
Hi Greg, all,
Quoting myself:
Quoted 7 lines
Mmm, I once proposed that
I2C_ADAP_CLASS_SMBUSwould be better renamedI2C_ADAP_CLASS_SENSORS(soI2C_CLASS_SENSORSnow). What about that? I think it would be great to embed that change into your patch, so that the name changes only once.BTW, if HWMON is prefered to SENSORS, this is fine with me too, I have no strong preference.
Below is a patch that does that. I finally went for HWMON. Yes, it's big, but it's actually nothing more than s/I2C_CLASS_SMBUS/I2C_CLASS_HWMON/ (thanks perl -wip :)).
Greg, can you please apply it on top of Michael's patch?
Thanks.
Documentation/i2c/porting-clients +2 -2
@@ -62,9 +62,9 @@ patch to the Documentation/i2c/sysfs-interface file. * [Attach] For I2C drivers, the attach function should make sure - that the adapter's class has I2C_CLASS_SMBUS, using the + that the adapter's class has I2C_CLASS_HWMON, using the following construct: - if (!(adapter->class & I2C_CLASS_SMBUS)) + if (!(adapter->class & I2C_CLASS_HWMON)) return 0; ISA-only drivers of course don't need this.
drivers/i2c/busses/i2c-ali1535.c +1 -1
@@ -480,7 +480,7 @@static struct i2c_adapter ali1535_adapter = { .owner =THIS_MODULE , - .class =I2C_CLASS_SMBUS , + .class =I2C_CLASS_HWMON , .algo = &smbus_algorithm, .name ="unset" , };
drivers/i2c/busses/i2c-ali1563.c +1 -1
@@ -357,7 +357,7 @@static struct i2c_adapter ali1563_adapter = { .owner =THIS_MODULE , - .class =I2C_CLASS_SMBUS , + .class =I2C_CLASS_HWMON , .algo = &ali1563_algorithm, };
drivers/i2c/busses/i2c-ali15x3.c +1 -1
@@ -470,7 +470,7 @@static struct i2c_adapter ali15x3_adapter = { .owner =THIS_MODULE , - .class =I2C_CLASS_SMBUS , + .class =I2C_CLASS_HWMON , .algo = &smbus_algorithm, .name ="unset" , };
drivers/i2c/busses/i2c-amd756.c +1 -1
@@ -303,7 +303,7 @@static struct i2c_adapter amd756_adapter = { .owner =THIS_MODULE , - .class =I2C_CLASS_SMBUS , + .class =I2C_CLASS_HWMON , .algo = &smbus_algorithm, .name ="unset" , };
drivers/i2c/busses/i2c-amd8111.c +1 -1
@@ -359,7 +359,7 @@ smbus->adapter.owner =THIS_MODULE ;snprintf (smbus->adapter.name,I2C_NAME_SIZE ,"SMBus2 AMD8111 adapter at %04x" , smbus->base); - smbus->adapter.class =I2C_CLASS_SMBUS ; + smbus->adapter.class =I2C_CLASS_HWMON ; smbus->adapter.algo = &smbus_algorithm; smbus->adapter.algo_data = smbus;
drivers/i2c/busses/i2c-i801.c +1 -1
@@ -539,7 +539,7 @@static struct i2c_adapter i801_adapter = { .owner =THIS_MODULE , - .class =I2C_CLASS_SMBUS , + .class =I2C_CLASS_HWMON , .algo = &smbus_algorithm, .name ="unset" , };
drivers/i2c/busses/i2c-isa.c +1 -1
@@ -43,7 +43,7 @@/* There can only be one... */ static struct i2c_adapter isa_adapter = { .owner =THIS_MODULE , - .class =I2C_CLASS_SMBUS , + .class =I2C_CLASS_HWMON , .algo = &isa_algorithm, .name ="ISA main adapter" , };
drivers/i2c/busses/i2c-nforce2.c +1 -1
@@ -119,7 +119,7 @@static struct i2c_adapter nforce2_adapter = { .owner =THIS_MODULE , - .class =I2C_CLASS_SMBUS , + .class =I2C_CLASS_HWMON , .algo = &smbus_algorithm, .name ="unset" , };
drivers/i2c/busses/i2c-parport-light.c +1 -1
@@ -112,7 +112,7 @@static struct i2c_adapter parport_adapter = { .owner =THIS_MODULE , - .class =I2C_CLASS_SMBUS , + .class =I2C_CLASS_HWMON , .id =I2C_HW_B_LP , .algo_data = &parport_algo_data, .name ="Parallel port adapter (light)" ,
drivers/i2c/busses/i2c-parport.c +1 -1
@@ -147,7 +147,7 @@static struct i2c_adapter parport_adapter = { .owner =THIS_MODULE , - .class =I2C_CLASS_SMBUS , + .class =I2C_CLASS_HWMON , .id =I2C_HW_B_LP , .name ="Parallel port adapter" , };
drivers/i2c/busses/i2c-piix4.c +1 -1
@@ -410,7 +410,7 @@static struct i2c_adapter piix4_adapter = { .owner =THIS_MODULE , - .class =I2C_CLASS_SMBUS , + .class =I2C_CLASS_HWMON , .algo = &smbus_algorithm, .name ="unset" , };
drivers/i2c/busses/i2c-sis5595.c +1 -1
@@ -360,7 +360,7 @@static struct i2c_adapter sis5595_adapter = { .owner =THIS_MODULE , - .class =I2C_CLASS_SMBUS , + .class =I2C_CLASS_HWMON , .name ="unset" , .algo = &smbus_algorithm, };
drivers/i2c/busses/i2c-sis630.c +1 -1
@@ -456,7 +456,7 @@static struct i2c_adapter sis630_adapter = { .owner =THIS_MODULE , - .class =I2C_CLASS_SMBUS , + .class =I2C_CLASS_HWMON , .name ="unset" , .algo = &smbus_algorithm, };
drivers/i2c/busses/i2c-sis96x.c +1 -1
@@ -260,7 +260,7 @@static struct i2c_adapter sis96x_adapter = { .owner =THIS_MODULE , - .class =I2C_CLASS_SMBUS , + .class =I2C_CLASS_HWMON , .algo = &smbus_algorithm, .name ="unset" , };
drivers/i2c/busses/i2c-via.c +1 -1
@@ -88,7 +88,7 @@static struct i2c_adapter vt586b_adapter = { .owner =THIS_MODULE , - .class =I2C_CLASS_SMBUS , + .class =I2C_CLASS_HWMON , .name ="VIA i2c" , .algo_data = &bit_data, };
drivers/i2c/busses/i2c-viapro.c +1 -1
@@ -289,7 +289,7 @@static struct i2c_adapter vt596_adapter = { .owner =THIS_MODULE , - .class =I2C_CLASS_SMBUS , + .class =I2C_CLASS_HWMON , .algo = &smbus_algorithm, .name ="unset" , };
drivers/i2c/chips/adm1021.c +1 -1
@@ -200,7 +200,7 @@static int adm1021_attach_adapter (struct i2c_adapter *adapter) { -if (!(adapter->class &I2C_CLASS_SMBUS )) +if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ;return i2c_detect (adapter, &addr_data, adm1021_detect); }
drivers/i2c/chips/asb100.c +1 -1
@@ -609,7 +609,7 @@*/ static int asb100_attach_adapter (struct i2c_adapter *adapter) { -if (!(adapter->class &I2C_CLASS_SMBUS )) +if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ;return i2c_detect (adapter, &addr_data, asb100_detect); }
drivers/i2c/chips/fscher.c +1 -1
@@ -293,7 +293,7 @@static int fscher_attach_adapter (struct i2c_adapter *adapter) { -if (!(adapter->class &I2C_CLASS_SMBUS )) +if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ;return i2c_detect (adapter, &addr_data, fscher_detect); }
drivers/i2c/chips/gl518sm.c +1 -1
@@ -335,7 +335,7 @@static int gl518_attach_adapter (struct i2c_adapter *adapter) { -if (!(adapter->class &I2C_CLASS_SMBUS )) +if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ;return i2c_detect (adapter, &addr_data, gl518_detect); }
drivers/i2c/chips/it87.c +1 -1
@@ -500,7 +500,7 @@* 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_CLASS_SMBUS )) +if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ;return i2c_detect (adapter, &addr_data, it87_detect); }
drivers/i2c/chips/lm75.c +1 -1
@@ -105,7 +105,7 @@static int lm75_attach_adapter (struct i2c_adapter *adapter) { -if (!(adapter->class &I2C_CLASS_SMBUS )) +if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ;return i2c_detect (adapter, &addr_data, lm75_detect); }
drivers/i2c/chips/lm78.c +1 -1
@@ -488,7 +488,7 @@* when a new adapter is inserted (and lm78_driver is still present) */ static int lm78_attach_adapter (struct i2c_adapter *adapter) { -if (!(adapter->class &I2C_CLASS_SMBUS )) +if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ;return i2c_detect (adapter, &addr_data, lm78_detect); }
drivers/i2c/chips/lm80.c +1 -1
@@ -376,7 +376,7 @@static int lm80_attach_adapter (struct i2c_adapter *adapter) { -if (!(adapter->class &I2C_CLASS_SMBUS )) +if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ;return i2c_detect (adapter, &addr_data, lm80_detect); }
drivers/i2c/chips/lm83.c +1 -1
@@ -216,7 +216,7 @@static int lm83_attach_adapter (struct i2c_adapter *adapter) { -if (!(adapter->class &I2C_CLASS_SMBUS )) +if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ;return i2c_detect (adapter, &addr_data, lm83_detect); }
drivers/i2c/chips/lm90.c +1 -1
@@ -274,7 +274,7 @@static int lm90_attach_adapter (struct i2c_adapter *adapter) { -if (!(adapter->class &I2C_CLASS_SMBUS )) +if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ;return i2c_detect (adapter, &addr_data, lm90_detect); }
drivers/i2c/chips/via686a.c +1 -1
@@ -573,7 +573,7 @@/* This is called when the module is loaded */ static int via686a_attach_adapter (struct i2c_adapter *adapter) { -if (!(adapter->class &I2C_CLASS_SMBUS )) +if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ;return i2c_detect (adapter, &addr_data, via686a_detect); }
drivers/i2c/chips/w83781d.c +1 -1
@@ -911,7 +911,7 @@static int w83781d_attach_adapter (struct i2c_adapter *adapter) { -if (!(adapter->class &I2C_CLASS_SMBUS )) +if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ;return i2c_detect (adapter, &addr_data, w83781d_detect); }
drivers/i2c/chips/w83l785ts.c +1 -1
@@ -145,7 +145,7 @@static int w83l785ts_attach_adapter (struct i2c_adapter *adapter) { -if (!(adapter->class &I2C_CLASS_SMBUS )) +if (!(adapter->class &I2C_CLASS_HWMON ))return 0 ;return i2c_detect (adapter, &addr_data, w83l785ts_detect); }
include/linux/i2c.h +1 -1
@@ -286,7 +286,7 @@/* Must equal I2C_M_TEN below */ /* i2c adapter classes (bitmask) */ -#define I2C_CLASS_SMBUS (1<<0)/* lm_sensors, ... */ +#define I2C_CLASS_HWMON (1<<0)/* lm_sensors, ... */ #define I2C_CLASS_TV_ANALOG (1<<1)/* bttv + friends */ #define I2C_CLASS_TV_DIGITAL (1<<2)/* dvb cards */ #define I2C_CLASS_DDC (1<<3)/* i2c-matroxfb ? */
Signature · 2 lines
Jean Delvare http://khali.linux-fr.org/
Greg KH
AppliedRe: [PATCH 2.6] Rename hardware monitoring I2C class
Quoted 9 lines · Jean Delvare
Hi Greg, all,
Quoting myself:
Quoted 5 lines
Mmm, I once proposed that
I2C_ADAP_CLASS_SMBUSwould be better renamedI2C_ADAP_CLASS_SENSORS(soI2C_CLASS_SENSORSnow). What about that? I think it would be great to embed that change into your patch, so that the name changes only once.
Quoted 8 lines
Quoted 2 lines
BTW, if HWMON is prefered to SENSORS, this is fine with me too, I have no strong preference.
Below is a patch that does that. I finally went for HWMON. Yes, it's big, but it's actually nothing more than s/I2C_CLASS_SMBUS/I2C_CLASS_HWMON/ (thanks perl -wip :)).
Greg, can you please apply it on top of Michael's patch?
Applied, thanks.
greg k-h