aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/i2c/busses/i2c-ali1535.c61
-rw-r--r--drivers/i2c/busses/i2c-cpm.c7
-rw-r--r--drivers/i2c/busses/i2c-pxa.c7
-rw-r--r--drivers/i2c/busses/i2c-s6000.c5
-rw-r--r--drivers/i2c/i2c-core.c5
5 files changed, 40 insertions, 45 deletions
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c
index dd364171f9c5..b6807db7b36f 100644
--- a/drivers/i2c/busses/i2c-ali1535.c
+++ b/drivers/i2c/busses/i2c-ali1535.c
@@ -1,23 +1,23 @@
1/* 1/*
2 Copyright (c) 2000 Frodo Looijaard <frodol@dds.nl>, 2 * Copyright (c) 2000 Frodo Looijaard <frodol@dds.nl>,
3 Philip Edelbrock <phil@netroedge.com>, 3 * Philip Edelbrock <phil@netroedge.com>,
4 Mark D. Studebaker <mdsxyz123@yahoo.com>, 4 * Mark D. Studebaker <mdsxyz123@yahoo.com>,
5 Dan Eaton <dan.eaton@rocketlogix.com> and 5 * Dan Eaton <dan.eaton@rocketlogix.com> and
6 Stephen Rousset<stephen.rousset@rocketlogix.com> 6 * Stephen Rousset <stephen.rousset@rocketlogix.com>
7 7 *
8 This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version. 11 * (at your option) any later version.
12 12 *
13 This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 16 * GNU General Public License for more details.
17 17 *
18 You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21*/ 21*/
22 22
23/* 23/*
@@ -254,8 +254,8 @@ static int ali1535_transaction(struct i2c_adapter *adap)
254 if (temp & (ALI1535_STS_ERR | ALI1535_STS_BUSY)) { 254 if (temp & (ALI1535_STS_ERR | ALI1535_STS_BUSY)) {
255 /* do a clear-on-write */ 255 /* do a clear-on-write */
256 outb_p(0xFF, SMBHSTSTS); 256 outb_p(0xFF, SMBHSTSTS);
257 if ((temp = inb_p(SMBHSTSTS)) & 257 temp = inb_p(SMBHSTSTS);
258 (ALI1535_STS_ERR | ALI1535_STS_BUSY)) { 258 if (temp & (ALI1535_STS_ERR | ALI1535_STS_BUSY)) {
259 /* This is probably going to be correctable only by a 259 /* This is probably going to be correctable only by a
260 * power reset as one of the bits now appears to be 260 * power reset as one of the bits now appears to be
261 * stuck */ 261 * stuck */
@@ -267,9 +267,8 @@ static int ali1535_transaction(struct i2c_adapter *adap)
267 } 267 }
268 } else { 268 } else {
269 /* check and clear done bit */ 269 /* check and clear done bit */
270 if (temp & ALI1535_STS_DONE) { 270 if (temp & ALI1535_STS_DONE)
271 outb_p(temp, SMBHSTSTS); 271 outb_p(temp, SMBHSTSTS);
272 }
273 } 272 }
274 273
275 /* start the transaction by writing anything to the start register */ 274 /* start the transaction by writing anything to the start register */
@@ -278,7 +277,7 @@ static int ali1535_transaction(struct i2c_adapter *adap)
278 /* We will always wait for a fraction of a second! */ 277 /* We will always wait for a fraction of a second! */
279 timeout = 0; 278 timeout = 0;
280 do { 279 do {
281 msleep(1); 280 usleep_range(1000, 2000);
282 temp = inb_p(SMBHSTSTS); 281 temp = inb_p(SMBHSTSTS);
283 } while (((temp & ALI1535_STS_BUSY) && !(temp & ALI1535_STS_IDLE)) 282 } while (((temp & ALI1535_STS_BUSY) && !(temp & ALI1535_STS_IDLE))
284 && (timeout++ < MAX_TIMEOUT)); 283 && (timeout++ < MAX_TIMEOUT));
@@ -325,12 +324,12 @@ static int ali1535_transaction(struct i2c_adapter *adap)
325 /* take consequent actions for error conditions */ 324 /* take consequent actions for error conditions */
326 if (!(temp & ALI1535_STS_DONE)) { 325 if (!(temp & ALI1535_STS_DONE)) {
327 /* issue "kill" to reset host controller */ 326 /* issue "kill" to reset host controller */
328 outb_p(ALI1535_KILL,SMBHSTTYP); 327 outb_p(ALI1535_KILL, SMBHSTTYP);
329 outb_p(0xFF,SMBHSTSTS); 328 outb_p(0xFF, SMBHSTSTS);
330 } else if (temp & ALI1535_STS_ERR) { 329 } else if (temp & ALI1535_STS_ERR) {
331 /* issue "timeout" to reset all devices on bus */ 330 /* issue "timeout" to reset all devices on bus */
332 outb_p(ALI1535_T_OUT,SMBHSTTYP); 331 outb_p(ALI1535_T_OUT, SMBHSTTYP);
333 outb_p(0xFF,SMBHSTSTS); 332 outb_p(0xFF, SMBHSTSTS);
334 } 333 }
335 334
336 return result; 335 return result;
@@ -351,7 +350,7 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr,
351 for (timeout = 0; 350 for (timeout = 0;
352 (timeout < MAX_TIMEOUT) && !(temp & ALI1535_STS_IDLE); 351 (timeout < MAX_TIMEOUT) && !(temp & ALI1535_STS_IDLE);
353 timeout++) { 352 timeout++) {
354 msleep(1); 353 usleep_range(1000, 2000);
355 temp = inb_p(SMBHSTSTS); 354 temp = inb_p(SMBHSTSTS);
356 } 355 }
357 if (timeout >= MAX_TIMEOUT) 356 if (timeout >= MAX_TIMEOUT)
@@ -480,12 +479,12 @@ static struct i2c_adapter ali1535_adapter = {
480 .algo = &smbus_algorithm, 479 .algo = &smbus_algorithm,
481}; 480};
482 481
483static const struct pci_device_id ali1535_ids[] = { 482static DEFINE_PCI_DEVICE_TABLE(ali1535_ids) = {
484 { PCI_DEVICE(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101) }, 483 { PCI_DEVICE(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101) },
485 { }, 484 { },
486}; 485};
487 486
488MODULE_DEVICE_TABLE (pci, ali1535_ids); 487MODULE_DEVICE_TABLE(pci, ali1535_ids);
489 488
490static int __devinit ali1535_probe(struct pci_dev *dev, const struct pci_device_id *id) 489static int __devinit ali1535_probe(struct pci_dev *dev, const struct pci_device_id *id)
491{ 490{
diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c
index 3a20961bef1e..b1d9cd28d8da 100644
--- a/drivers/i2c/busses/i2c-cpm.c
+++ b/drivers/i2c/busses/i2c-cpm.c
@@ -662,11 +662,8 @@ static int __devinit cpm_i2c_probe(struct platform_device *ofdev)
662 /* register new adapter to i2c module... */ 662 /* register new adapter to i2c module... */
663 663
664 data = of_get_property(ofdev->dev.of_node, "linux,i2c-index", &len); 664 data = of_get_property(ofdev->dev.of_node, "linux,i2c-index", &len);
665 if (data && len == 4) { 665 cpm->adap.nr = (data && len == 4) ? be32_to_cpup(data) : -1;
666 cpm->adap.nr = *data; 666 result = i2c_add_numbered_adapter(&cpm->adap);
667 result = i2c_add_numbered_adapter(&cpm->adap);
668 } else
669 result = i2c_add_adapter(&cpm->adap);
670 667
671 if (result < 0) { 668 if (result < 0) {
672 dev_err(&ofdev->dev, "Unable to register with I2C\n"); 669 dev_err(&ofdev->dev, "Unable to register with I2C\n");
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index f59224a5c761..d60364650990 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -1079,7 +1079,7 @@ static int i2c_pxa_probe(struct platform_device *dev)
1079 * The reason to do so is to avoid sysfs names that only make 1079 * The reason to do so is to avoid sysfs names that only make
1080 * sense when there are multiple adapters. 1080 * sense when there are multiple adapters.
1081 */ 1081 */
1082 i2c->adap.nr = dev->id != -1 ? dev->id : 0; 1082 i2c->adap.nr = dev->id;
1083 snprintf(i2c->adap.name, sizeof(i2c->adap.name), "pxa_i2c-i2c.%u", 1083 snprintf(i2c->adap.name, sizeof(i2c->adap.name), "pxa_i2c-i2c.%u",
1084 i2c->adap.nr); 1084 i2c->adap.nr);
1085 1085
@@ -1142,10 +1142,7 @@ static int i2c_pxa_probe(struct platform_device *dev)
1142 i2c->adap.dev.of_node = dev->dev.of_node; 1142 i2c->adap.dev.of_node = dev->dev.of_node;
1143#endif 1143#endif
1144 1144
1145 if (i2c_type == REGS_CE4100) 1145 ret = i2c_add_numbered_adapter(&i2c->adap);
1146 ret = i2c_add_adapter(&i2c->adap);
1147 else
1148 ret = i2c_add_numbered_adapter(&i2c->adap);
1149 if (ret < 0) { 1146 if (ret < 0) {
1150 printk(KERN_INFO "I2C: Failed to add bus\n"); 1147 printk(KERN_INFO "I2C: Failed to add bus\n");
1151 goto eadapt; 1148 goto eadapt;
diff --git a/drivers/i2c/busses/i2c-s6000.c b/drivers/i2c/busses/i2c-s6000.c
index cb5d01e279c6..c64ba736f480 100644
--- a/drivers/i2c/busses/i2c-s6000.c
+++ b/drivers/i2c/busses/i2c-s6000.c
@@ -341,10 +341,7 @@ static int __devinit s6i2c_probe(struct platform_device *dev)
341 i2c_wr16(iface, S6_I2C_TXTL, 0); 341 i2c_wr16(iface, S6_I2C_TXTL, 0);
342 342
343 platform_set_drvdata(dev, iface); 343 platform_set_drvdata(dev, iface);
344 if (bus_num < 0) 344 rc = i2c_add_numbered_adapter(p_adap);
345 rc = i2c_add_adapter(p_adap);
346 else
347 rc = i2c_add_numbered_adapter(p_adap);
348 if (rc) 345 if (rc)
349 goto err_irq_free; 346 goto err_irq_free;
350 return 0; 347 return 0;
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 9a58994ff7ea..131079a3e292 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -925,6 +925,9 @@ EXPORT_SYMBOL(i2c_add_adapter);
925 * or otherwise built in to the system's mainboard, and where i2c_board_info 925 * or otherwise built in to the system's mainboard, and where i2c_board_info
926 * is used to properly configure I2C devices. 926 * is used to properly configure I2C devices.
927 * 927 *
928 * If the requested bus number is set to -1, then this function will behave
929 * identically to i2c_add_adapter, and will dynamically assign a bus number.
930 *
928 * If no devices have pre-been declared for this bus, then be sure to 931 * If no devices have pre-been declared for this bus, then be sure to
929 * register the adapter before any dynamically allocated ones. Otherwise 932 * register the adapter before any dynamically allocated ones. Otherwise
930 * the required bus ID may not be available. 933 * the required bus ID may not be available.
@@ -940,6 +943,8 @@ int i2c_add_numbered_adapter(struct i2c_adapter *adap)
940 int id; 943 int id;
941 int status; 944 int status;
942 945
946 if (adap->nr == -1) /* -1 means dynamically assign bus id */
947 return i2c_add_adapter(adap);
943 if (adap->nr & ~MAX_ID_MASK) 948 if (adap->nr & ~MAX_ID_MASK)
944 return -EINVAL; 949 return -EINVAL;
945 950