Skip to contentSkip to conversation

i2c: i2c-gpio: fix name issue when i2c gpio node GT 1

PATCH New Bo Shen 3 participants 3 messages Oct 15, 2012 – Nov 14, 2012

Subsystems (2)
lore
Share & tools
lore

Bo Shen

author
#0 lore raw

PATCH v2 1/1 i2c: i2c-gpio: fix name issue when i2c gpio node GT 1

When i2c-gpio node number is greater than 1, the name for each is same So add the patch to fix it.

The adap->name printing information is add by myself

without this patch the log information is as following ---<8---
adap->name = i2c-gpio-1
i2c-gpio i2c.2: using pins 30 (SDA) and 31 (SCL) adap->name = i2c-gpio-1
i2c-gpio i2c.3: using pins 64 (SDA) and 65 (SCL) --->8---

with this patch, the log information is as following ---<8---
adap->name = i2c.2
i2c-gpio i2c.2: using pins 30 (SDA) and 31 (SCL) adap->name = i2c.3
i2c-gpio i2c.3: using pins 64 (SDA) and 65 (SCL) --->8---

---
 drivers/i2c/busses/i2c-gpio.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-gpio.c +5 -1
index e62d2d9..257299a 100644
@@ -184,7 +184,11 @@ static int __devinit i2c_gpio_probe(struct platform_device *pdev)
 	bit_data->data = pdata;
 
 	adap->owner = THIS_MODULE;
-	snprintf(adap->name, sizeof(adap->name), "i2c-gpio%d", pdev->id);
+	if (pdev->dev.of_node)
+		strlcpy(adap->name, dev_name(&pdev->dev), sizeof(adap->name));
+	else
+		snprintf(adap->name, sizeof(adap->name), "i2c-gpio%d", pdev->id);
+
 	adap->algo_data = bit_data;
 	adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
 	adap->dev.parent = &pdev->dev;
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v2 1/1 i2c: i2c-gpio: fix name issue when i2c gpio node GT 1

Quoted 13 lines · Bo Shen

When i2c-gpio node number is greater than 1, the name for each is same So add the patch to fix it.

The adap->name printing information is add by myself

without this patch the log information is as following ---<8---
adap->name = i2c-gpio-1
i2c-gpio i2c.2: using pins 30 (SDA) and 31 (SCL) adap->name = i2c-gpio-1
i2c-gpio i2c.3: using pins 64 (SDA) and 65 (SCL) --->8---

Quoted 7 lines

with this patch, the log information is as following ---<8---
adap->name = i2c.2
i2c-gpio i2c.2: using pins 30 (SDA) and 31 (SCL) adap->name = i2c.3
i2c-gpio i2c.3: using pins 64 (SDA) and 65 (SCL) --->8---

I think this is reasonable, although I imagine this has zero effect on the I2C bus number that's assigned to the device, so I'm not sure how it interacts with or supports the other Atmel patch series you sent, which I didn't really look at in much detail.

Applied
#2 lore raw

PATCH v2 1/1 i2c: i2c-gpio: fix name issue when i2c gpio node GT 1

In reply to Bo Shen
Quoted 21 lines · Bo Shen

When i2c-gpio node number is greater than 1, the name for each is same So add the patch to fix it.

The adap->name printing information is add by myself

without this patch the log information is as following ---<8---
adap->name = i2c-gpio-1
i2c-gpio i2c.2: using pins 30 (SDA) and 31 (SCL) adap->name = i2c-gpio-1
i2c-gpio i2c.3: using pins 64 (SDA) and 65 (SCL) --->8---

with this patch, the log information is as following ---<8---
adap->name = i2c.2
i2c-gpio i2c.2: using pins 30 (SDA) and 31 (SCL) adap->name = i2c.3
i2c-gpio i2c.3: using pins 64 (SDA) and 65 (SCL) --->8---

Quoted 1 line

Applied to for-next, thanks.

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20121114/7bb0cd1e/attachment.sig>