diff options
| author | Gerd Knorr <kraxel@bytesex.org> | 2003-05-06 03:16:36 -0700 |
|---|---|---|
| committer | Greg Kroah-Hartman <greg@kroah.com> | 2003-05-06 03:16:36 -0700 |
| commit | ea1b28a4d66b08082242670e717d92b86b52b46d (patch) | |
| tree | 90848a68130552a90c6033007e45057e57defed5 | |
| parent | 37d7f421ce2d3ff357ecbed85d20e62bd2e7afcf (diff) | |
[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 ...
| -rw-r--r-- | drivers/i2c/busses/i2c-ali15x3.c | 1 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-amd756.c | 1 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-amd8111.c | 1 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-i801.c | 1 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-isa.c | 1 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-piix4.c | 1 | ||||
| -rw-r--r-- | drivers/i2c/busses/i2c-viapro.c | 1 | ||||
| -rw-r--r-- | drivers/i2c/chips/adm1021.c | 2 | ||||
| -rw-r--r-- | drivers/i2c/chips/it87.c | 2 | ||||
| -rw-r--r-- | drivers/i2c/chips/lm75.c | 2 | ||||
| -rw-r--r-- | drivers/i2c/chips/via686a.c | 2 | ||||
| -rw-r--r-- | drivers/i2c/chips/w83781d.c | 2 | ||||
| -rw-r--r-- | drivers/media/video/bt832.c | 22 | ||||
| -rw-r--r-- | drivers/media/video/bttv-if.c | 1 | ||||
| -rw-r--r-- | drivers/media/video/msp3400.c | 2 | ||||
| -rw-r--r-- | drivers/media/video/saa5249.c | 6 | ||||
| -rw-r--r-- | drivers/media/video/saa7134/saa7134-i2c.c | 1 | ||||
| -rw-r--r-- | drivers/media/video/tda7432.c | 2 | ||||
| -rw-r--r-- | drivers/media/video/tda9875.c | 2 | ||||
| -rw-r--r-- | drivers/media/video/tda9887.c | 20 | ||||
| -rw-r--r-- | drivers/media/video/tuner.c | 22 | ||||
| -rw-r--r-- | drivers/media/video/tvaudio.c | 9 | ||||
| -rw-r--r-- | drivers/media/video/tvmixer.c | 7 | ||||
| -rw-r--r-- | include/linux/i2c.h | 7 |
24 files changed, 43 insertions, 75 deletions
diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c index e431e9fb3f68..1ca200036209 100644 --- a/drivers/i2c/busses/i2c-ali15x3.c +++ b/drivers/i2c/busses/i2c-ali15x3.c @@ -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", diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c index 8515937334a7..61f1ad0c86ae 100644 --- a/drivers/i2c/busses/i2c-amd756.c +++ b/drivers/i2c/busses/i2c-amd756.c @@ -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", diff --git a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c index f852936a8291..a87dc0b40c5a 100644 --- a/drivers/i2c/busses/i2c-amd8111.c +++ b/drivers/i2c/busses/i2c-amd8111.c @@ -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; diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 7a208e66d006..701520b0c86f 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c @@ -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", diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c index 851da94882ab..c49a874764e5 100644 --- a/drivers/i2c/busses/i2c-isa.c +++ b/drivers/i2c/busses/i2c-isa.c @@ -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", diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c index d7e0f720a9ec..a7bd53bfb10c 100644 --- a/drivers/i2c/busses/i2c-piix4.c +++ b/drivers/i2c/busses/i2c-piix4.c @@ -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", diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c index 05b54382d6c1..12742967bfec 100644 --- a/drivers/i2c/busses/i2c-viapro.c +++ b/drivers/i2c/busses/i2c-viapro.c @@ -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", diff --git a/drivers/i2c/chips/adm1021.c b/drivers/i2c/chips/adm1021.c index f7afe0b4b4ea..2db50c2a2ad4 100644 --- a/drivers/i2c/chips/adm1021.c +++ b/drivers/i2c/chips/adm1021.c @@ -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); } diff --git a/drivers/i2c/chips/it87.c b/drivers/i2c/chips/it87.c index 73f8ec4433c9..b853e8233d8f 100644 --- a/drivers/i2c/chips/it87.c +++ b/drivers/i2c/chips/it87.c @@ -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); } diff --git a/drivers/i2c/chips/lm75.c b/drivers/i2c/chips/lm75.c index f4acc1649917..1214ab3f4ca5 100644 --- a/drivers/i2c/chips/lm75.c +++ b/drivers/i2c/chips/lm75.c @@ -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); } diff --git a/drivers/i2c/chips/via686a.c b/drivers/i2c/chips/via686a.c index 83859fead850..664e521a6d61 100644 --- a/drivers/i2c/chips/via686a.c +++ b/drivers/i2c/chips/via686a.c @@ -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); } diff --git a/drivers/i2c/chips/w83781d.c b/drivers/i2c/chips/w83781d.c index c1fbf4c72873..5da55f2acdfc 100644 --- a/drivers/i2c/chips/w83781d.c +++ b/drivers/i2c/chips/w83781d.c @@ -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); } diff --git a/drivers/media/video/bt832.c b/drivers/media/video/bt832.c index 6faa2abec3ae..70ef06611498 100644 --- a/drivers/media/video/bt832.c +++ b/drivers/media/video/bt832.c @@ -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) diff --git a/drivers/media/video/bttv-if.c b/drivers/media/video/bttv-if.c index 52b1daa077ba..a4a462ecb2fa 100644 --- a/drivers/media/video/bttv-if.c +++ b/drivers/media/video/bttv-if.c @@ -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, }; diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c index d81070e1b156..65403235f802 100644 --- a/drivers/media/video/msp3400.c +++ b/drivers/media/video/msp3400.c @@ -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; } diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c index df511ae63a8c..97c3990e02ae 100644 --- a/drivers/media/video/saa5249.c +++ b/drivers/media/video/saa5249.c @@ -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; } diff --git a/drivers/media/video/saa7134/saa7134-i2c.c b/drivers/media/video/saa7134/saa7134-i2c.c index 0aa4292d4a51..b1249c3aca96 100644 --- a/drivers/media/video/saa7134/saa7134-i2c.c +++ b/drivers/media/video/saa7134/saa7134-i2c.c @@ -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, }; diff --git a/drivers/media/video/tda7432.c b/drivers/media/video/tda7432.c index eaf5f5c8eef2..61454f84ff7f 100644 --- a/drivers/media/video/tda7432.c +++ b/drivers/media/video/tda7432.c @@ -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; } diff --git a/drivers/media/video/tda9875.c b/drivers/media/video/tda9875.c index 0e97185a9b68..bcb44135bef2 100644 --- a/drivers/media/video/tda9875.c +++ b/drivers/media/video/tda9875.c @@ -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; } diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c index a674ff9f15c5..d8aecd8acb44 100644 --- a/drivers/media/video/tda9887.c +++ b/drivers/media/video/tda9887.c @@ -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) diff --git a/drivers/media/video/tuner.c b/drivers/media/video/tuner.c index 93de9a356f21..b193c4c195bc 100644 --- a/drivers/media/video/tuner.c +++ b/drivers/media/video/tuner.c @@ -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) diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index d546d6d72a14..0aaba6c19bb8 100644 --- a/drivers/media/video/tvaudio.c +++ b/drivers/media/video/tvaudio.c @@ -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; - } + return 0; } static int chip_detach(struct i2c_client *client) diff --git a/drivers/media/video/tvmixer.c b/drivers/media/video/tvmixer.c index 100159f3c7e9..7f244b001cb6 100644 --- a/drivers/media/video/tvmixer.c +++ b/drivers/media/video/tvmixer.c @@ -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", diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 15c94caeba74..6876a6705bb8 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -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 |
