[i2c] [PATCH] i2c: Add support for new-style clients to ibm-iic driver (2nd try)

Stefan Roese sr at denx.de
Wed Aug 29 10:56:06 CEST 2007


Use i2c_bit_add_numbered_bus() if device id specified, so that the
i2c-ibm_iic adapter works well with new-style pre-declared devices.

Signed-off-by: Stefan Roese <sr at denx.de>

---
Fixed a small error in the commit description above spotted by
Eugene.


commit 72daba7753178db457c1414dae1241e64b39f89d
tree f595880e13321b165630ad2b9316346e23548357
parent bcfc8d37d5abb8f60fcc05bccb1f4f118a238962
author Stefan Roese <sr at denx.de> Wed, 29 Aug 2007 10:52:45 +0200
committer Stefan Roese <sr at denx.de> Wed, 29 Aug 2007 10:52:45 +0200

 drivers/i2c/busses/i2c-ibm_iic.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
index b6d2766..aa57c19 100644
--- a/drivers/i2c/busses/i2c-ibm_iic.c
+++ b/drivers/i2c/busses/i2c-ibm_iic.c
@@ -742,7 +742,15 @@ static int __devinit iic_probe(struct ocp_device *ocp){
 	if (adap->dev.parent == NULL) {
 		adap->dev.parent = &platform_bus;
 	}
-	if ((ret = i2c_add_adapter(adap)) != 0){
+
+	/*
+	 * If "dev->idx" is negative we consider it as zero.
+	 * The reason to do so is to avoid sysfs names that only make
+	 * sense when there are multiple adapters.
+	 */
+	adap->nr = dev->idx >= 0 ? dev->idx : 0;
+
+	if ((ret = i2c_add_numbered_adapter(adap)) < 0) {
 		printk(KERN_CRIT "ibm-iic%d: failed to register i2c adapter\n",
 			dev->idx);
 		goto fail;



More information about the i2c mailing list