diff options
author | Bo Shen <voice.shen@atmel.com> | 2012-10-15 15:51:17 +0800 |
---|---|---|
committer | Wolfram Sang <w.sang@pengutronix.de> | 2012-11-14 09:56:43 +0100 |
commit | 58a7371a4dd9d03f77265ee2784781fc39096136 (patch) | |
tree | 093d34cfcc66741ea9f5475e88c8c9214e8cdc4c | |
parent | 970d494c323826d8bb21e8ed1796da15082808ec (diff) | |
download | op-kernel-dev-58a7371a4dd9d03f77265ee2784781fc39096136.zip op-kernel-dev-58a7371a4dd9d03f77265ee2784781fc39096136.tar.gz |
i2c: i2c-gpio: fix name issue with multiple i2c gpio nodes
When having multiple i2c-gpio nodes, the name for each is same.
So add the patch to fix it.
The adap->name printing information was added 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---
Signed-off-by: Bo Shen <voice.shen@atmel.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
[wsa: minor fixes to the commit mesage]
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
-rw-r--r-- | drivers/i2c/busses/i2c-gpio.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c index e62d2d9..257299a 100644 --- a/drivers/i2c/busses/i2c-gpio.c +++ b/drivers/i2c/busses/i2c-gpio.c @@ -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; |