[PATCH] I2C: Kill i2c_algorithm.id (6/7)
authorJean Delvare <khali@linux-fr.org>
Thu, 11 Aug 2005 21:51:10 +0000 (23:51 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 5 Sep 2005 16:14:32 +0000 (09:14 -0700)
In theory, there should be no more users of I2C_ALGO_* at this point.
However, it happens that several drivers were using I2C_ALGO_* for
adapter ids, so we need to correct these before we can get rid of all
the I2C_ALGO_* definitions.

Note that this also fixes a bug in media/video/tvaudio.c:

/* don't attach on saa7146 based cards,
   because dedicated drivers are used */
if ((adap->id & I2C_ALGO_SAA7146))
return 0;

This test was plain broken, as it would succeed for many more adapters
than just the saa7146: any those id would share at least one bit with
the saa7146 id. We are really lucky that the few other adapters we want
this driver to work with did not fulfill that condition.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
20 files changed:
drivers/i2c/busses/i2c-keywest.c
drivers/i2c/busses/scx200_acb.c
drivers/media/common/saa7146_i2c.c
drivers/media/dvb/b2c2/flexcop-i2c.c
drivers/media/dvb/dvb-usb/dvb-usb-i2c.c
drivers/media/dvb/pluto2/pluto2.c
drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
drivers/media/video/ir-kbd-i2c.c
drivers/media/video/saa7134/saa7134-i2c.c
drivers/media/video/tda9840.c
drivers/media/video/tda9887.c
drivers/media/video/tea6415c.c
drivers/media/video/tea6420.c
drivers/media/video/tvaudio.c
drivers/video/aty/radeon_i2c.c
drivers/video/nvidia/nv_i2c.c
drivers/video/riva/rivafb-i2c.c
drivers/video/savage/savagefb-i2c.c
include/linux/i2c-id.h
include/media/id.h

index 5254d2d..e60ed6f 100644 (file)
@@ -619,7 +619,6 @@ create_iface(struct device_node *np, struct device *dev)
                sprintf(chan->adapter.name, "%s %d", np->parent->name, i);
                chan->iface = iface;
                chan->chan_no = i;
-               chan->adapter.id = I2C_ALGO_SMBUS;
                chan->adapter.algo = &keywest_algorithm;
                chan->adapter.algo_data = NULL;
                chan->adapter.client_register = NULL;
index 46b9a75..a1d580e 100644 (file)
@@ -454,7 +454,7 @@ static int  __init scx200_acb_create(int base, int index)
        i2c_set_adapdata(adapter, iface);
        snprintf(adapter->name, I2C_NAME_SIZE, "SCx200 ACB%d", index);
        adapter->owner = THIS_MODULE;
-       adapter->id = I2C_ALGO_SMBUS;
+       adapter->id = I2C_HW_SMBUS_SCX200;
        adapter->algo = &scx200_acb_algorithm;
        adapter->class = I2C_CLASS_HWMON;
 
index e413ee7..6284894 100644 (file)
@@ -410,7 +410,7 @@ int saa7146_i2c_adapter_prepare(struct saa7146_dev *dev, struct i2c_adapter *i2c
 #endif
                i2c_adapter->algo          = &saa7146_algo;
                i2c_adapter->algo_data     = NULL;
-               i2c_adapter->id            = I2C_ALGO_SAA7146;
+               i2c_adapter->id            = I2C_HW_SAA7146;
                i2c_adapter->timeout = SAA7146_I2C_TIMEOUT;
                i2c_adapter->retries = SAA7146_I2C_RETRIES;
        }
index 848910f..56495cb 100644 (file)
@@ -190,7 +190,6 @@ int flexcop_i2c_init(struct flexcop_device *fc)
        fc->i2c_adap.class          = I2C_CLASS_TV_DIGITAL;
        fc->i2c_adap.algo       = &flexcop_algo;
        fc->i2c_adap.algo_data  = NULL;
-       fc->i2c_adap.id         = I2C_ALGO_BIT;
 
        if ((ret = i2c_add_adapter(&fc->i2c_adap)) < 0)
                return ret;
index 9f0a8d9..da97094 100644 (file)
@@ -27,7 +27,6 @@ int dvb_usb_i2c_init(struct dvb_usb_device *d)
 #endif
        d->i2c_adap.algo      = d->props.i2c_algo;
        d->i2c_adap.algo_data = NULL;
-       d->i2c_adap.id        = I2C_ALGO_BIT;
 
        i2c_set_adapdata(&d->i2c_adap, d);
 
index 706e0bc..85b437b 100644 (file)
@@ -633,7 +633,6 @@ static int __devinit pluto2_probe(struct pci_dev *pdev,
        i2c_set_adapdata(&pluto->i2c_adap, pluto);
        strcpy(pluto->i2c_adap.name, DRIVER_NAME);
        pluto->i2c_adap.owner = THIS_MODULE;
-       pluto->i2c_adap.id = I2C_ALGO_BIT;
        pluto->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
        pluto->i2c_adap.dev.parent = &pdev->dev;
        pluto->i2c_adap.algo_data = &pluto->i2c_bit;
index 11afec5..7daf7b1 100644 (file)
@@ -1523,7 +1523,6 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i
 #endif
        ttusb->i2c_adap.algo              = &ttusb_dec_algo;
        ttusb->i2c_adap.algo_data         = NULL;
-       ttusb->i2c_adap.id                = I2C_ALGO_BIT;
 
        result = i2c_add_adapter(&ttusb->i2c_adap);
        if (result) {
index c2f32d5..feccf08 100644 (file)
@@ -432,7 +432,7 @@ static int ir_probe(struct i2c_adapter *adap)
        case I2C_HW_B_BT848:
                probe = probe_bttv;
                break;
-       case I2C_ALGO_SAA7134:
+       case I2C_HW_SAA7134:
                probe = probe_saa7134;
                break;
        }
index 0bb1073..238ac3f 100644 (file)
@@ -381,7 +381,7 @@ static struct i2c_adapter saa7134_adap_template = {
        .class         = I2C_CLASS_TV_ANALOG,
 #endif
        I2C_DEVNAME("saa7134"),
-       .id            = I2C_ALGO_SAA7134,
+       .id            = I2C_HW_SAA7134,
        .algo          = &saa7134_algo,
        .client_register = attach_inform,
 };
index c29bdfc..c0594e0 100644 (file)
@@ -205,7 +205,7 @@ static int detect(struct i2c_adapter *adapter, int address, int kind)
 static int attach(struct i2c_adapter *adapter)
 {
        /* let's see whether this is a know adapter we can attach to */
-       if (adapter->id != I2C_ALGO_SAA7146) {
+       if (adapter->id != I2C_HW_SAA7146) {
                dprintk("refusing to probe on unknown adapter [name='%s',id=0x%x]\n", adapter->name, adapter->id);
                return -ENODEV;
        }
index f1b1bb5..abb96ce 100644 (file)
@@ -620,7 +620,7 @@ static int tda9887_probe(struct i2c_adapter *adap)
        switch (adap->id) {
        case I2C_HW_B_BT848:
        case I2C_HW_B_RIVA:
-       case I2C_ALGO_SAA7134:
+       case I2C_HW_SAA7134:
                return i2c_probe(adap, &addr_data, tda9887_attach);
                break;
        }
index b44db8a..8334d6c 100644 (file)
@@ -86,7 +86,7 @@ static int detect(struct i2c_adapter *adapter, int address, int kind)
 static int attach(struct i2c_adapter *adapter)
 {
        /* let's see whether this is a know adapter we can attach to */
-       if (adapter->id != I2C_ALGO_SAA7146) {
+       if (adapter->id != I2C_HW_SAA7146) {
                dprintk("refusing to probe on unknown adapter [name='%s',id=0x%x]\n", adapter->name, adapter->id);
                return -ENODEV;
        }
index 48d4db7..9d09d2d 100644 (file)
@@ -135,7 +135,7 @@ static int tea6420_detect(struct i2c_adapter *adapter, int address, int kind)
 static int attach(struct i2c_adapter *adapter)
 {
        /* let's see whether this is a know adapter we can attach to */
-       if (adapter->id != I2C_ALGO_SAA7146) {
+       if (adapter->id != I2C_HW_SAA7146) {
                dprintk("refusing to probe on unknown adapter [name='%s',id=0x%x]\n", adapter->name, adapter->id);
                return -ENODEV;
        }
index 9420b5f..f6aab89 100644 (file)
@@ -1548,7 +1548,7 @@ static int chip_probe(struct i2c_adapter *adap)
 {
        /* don't attach on saa7146 based cards,
           because dedicated drivers are used */
-       if ((adap->id & I2C_ALGO_SAA7146))
+       if (adap->id == I2C_HW_SAA7146)
                return 0;
 #ifdef I2C_CLASS_TV_ANALOG
        if (adap->class & I2C_CLASS_TV_ANALOG)
@@ -1557,7 +1557,7 @@ static int chip_probe(struct i2c_adapter *adap)
        switch (adap->id) {
        case I2C_HW_B_BT848:
        case I2C_HW_B_RIVA:
-       case I2C_ALGO_SAA7134:
+       case I2C_HW_SAA7134:
                return i2c_probe(adap, &addr_data, chip_attach);
        }
 #endif
index 7622441..a9d0414 100644 (file)
@@ -75,7 +75,7 @@ static int radeon_setup_i2c_bus(struct radeon_i2c_chan *chan, const char *name)
 
        strcpy(chan->adapter.name, name);
        chan->adapter.owner             = THIS_MODULE;
-       chan->adapter.id                = I2C_ALGO_ATI;
+       chan->adapter.id                = I2C_HW_B_RADEON;
        chan->adapter.algo_data         = &chan->algo;
        chan->adapter.dev.parent        = &chan->rinfo->pdev->dev;
        chan->algo.setsda               = radeon_gpio_setsda;
index 3757c14..1a91bff 100644 (file)
@@ -90,14 +90,13 @@ static int nvidia_gpio_getsda(void *data)
        return val;
 }
 
-#define I2C_ALGO_NVIDIA   0x0e0000
 static int nvidia_setup_i2c_bus(struct nvidia_i2c_chan *chan, const char *name)
 {
        int rc;
 
        strcpy(chan->adapter.name, name);
        chan->adapter.owner = THIS_MODULE;
-       chan->adapter.id = I2C_ALGO_NVIDIA;
+       chan->adapter.id = I2C_HW_B_NVIDIA;
        chan->adapter.algo_data = &chan->algo;
        chan->adapter.dev.parent = &chan->par->pci_dev->dev;
        chan->algo.setsda = nvidia_gpio_setsda;
index da1334d..77151d8 100644 (file)
@@ -92,14 +92,13 @@ static int riva_gpio_getsda(void* data)
        return val;
 }
 
-#define I2C_ALGO_RIVA   0x0e0000
 static int riva_setup_i2c_bus(struct riva_i2c_chan *chan, const char *name)
 {
        int rc;
 
        strcpy(chan->adapter.name, name);
        chan->adapter.owner             = THIS_MODULE;
-       chan->adapter.id                = I2C_ALGO_RIVA;
+       chan->adapter.id                = I2C_HW_B_RIVA;
        chan->adapter.algo_data         = &chan->algo;
        chan->adapter.dev.parent        = &chan->par->pdev->dev;
        chan->algo.setsda               = riva_gpio_setsda;
index 024a0ce..847698b 100644 (file)
@@ -137,7 +137,6 @@ static int prosavage_gpio_getsda(void* data)
        return (0 != (GET_CR_DATA(chan->ioaddr) & PROSAVAGE_I2C_SDA_IN));
 }
 
-#define I2C_ALGO_SAVAGE   0x0f0000
 static int savage_setup_i2c_bus(struct savagefb_i2c_chan *chan,
                                const char *name)
 {
@@ -147,7 +146,7 @@ static int savage_setup_i2c_bus(struct savagefb_i2c_chan *chan,
        if (add_bus && chan->par) {
                strcpy(chan->adapter.name, name);
                chan->adapter.owner             = THIS_MODULE;
-               chan->adapter.id                = I2C_ALGO_SAVAGE;
+               chan->adapter.id                = I2C_HW_B_SAVAGE;
                chan->adapter.algo_data         = &chan->algo;
                chan->adapter.dev.parent        = &chan->par->pcidev->dev;
                chan->algo.udelay               = 40;
index 5b72f66..d044e73 100644 (file)
 #define I2C_HW_B_ZR36067       0x010019 /* Zoran-36057/36067 based boards */
 #define I2C_HW_B_PCILYNX       0x01001a /* TI PCILynx I2C adapter */
 #define I2C_HW_B_CX2388x       0x01001b /* connexant 2388x based tv cards */
+#define I2C_HW_B_NVIDIA                0x01001c /* nvidia framebuffer driver */
+#define I2C_HW_B_SAVAGE                0x01001d /* savage framebuffer driver */
+#define I2C_HW_B_RADEON                0x01001e /* radeon framebuffer driver */
 
 /* --- PCF 8584 based algorithms                                       */
 #define I2C_HW_P_LP            0x020000 /* Parallel port interface */
 /* --- Marvell mv64xxx i2c adapter */
 #define I2C_HW_MV64XXX         0x190000
 
+/* --- Miscellaneous adapters */
+#define I2C_HW_SAA7146         0x060000 /* SAA7146 video decoder bus */
+#define I2C_HW_SAA7134         0x090000 /* SAA7134 video decoder bus */
+
 #endif /* LINUX_I2C_ID_H */
index a39a642..801ddef 100644 (file)
@@ -34,8 +34,3 @@
 #ifndef  I2C_DRIVERID_SAA6752HS
 # define I2C_DRIVERID_SAA6752HS I2C_DRIVERID_EXP0+8
 #endif
-
-/* algorithms */
-#ifndef I2C_ALGO_SAA7134
-# define I2C_ALGO_SAA7134 0x090000
-#endif