i2c-eg20t: use dynamically registered adapter number

Submitted by Yadi Hu on Aug. 23, 2016, 8:55 a.m.

Details

Message ID 1471942515-21278-1-git-send-email-yadi.hu@windriver.com
State New
Headers show

Commit Message

Yadi Hu Aug. 23, 2016, 8:55 a.m.
From: Hu Yadi <Yadi.hu@windriver.com>

The eg20t driver uses i2c_add_numbered_adapter() to register adapter:

    pch_adap->nr = i;
    ret = i2c_add_numbered_adapter(pch_adap);

Variable i is assigned to 0, it means that i2c_eg20t is the first adapter
by default. if another adapter registers before eg20t, above code return
error for index conflict:

    i2c_eg20t 0000:05:0c.2: pch_i2c_probe :i2c_add_adapter[ch:0] FAILED
    i2c_eg20t: probe of 0000:05:0c.2 failed with error -16

So, we can replace i2c_add_numbered_adapter() with i2c_add_adapter()
interface.since it dynamically allocates the index number.

Signed-off-by: Hu Yadi <Yadi.hu@windriver.com>
---
 drivers/i2c/busses/i2c-eg20t.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/i2c/busses/i2c-eg20t.c b/drivers/i2c/busses/i2c-eg20t.c
index 7a51ddc..2f4c2af 100644
--- a/drivers/i2c/busses/i2c-eg20t.c
+++ b/drivers/i2c/busses/i2c-eg20t.c
@@ -913,8 +913,7 @@  static int __devinit pch_i2c_probe(struct pci_dev *pdev,
 
 		pch_i2c_init(&adap_info->pch_data[i]);
 
-		pch_adap->nr = i;
-		ret = i2c_add_numbered_adapter(pch_adap);
+               ret = i2c_add_adapter(pch_adap);
 		if (ret) {
 			pch_pci_err(pdev, "i2c_add_adapter[ch:%d] FAILED\n", i);
 			goto err_add_adapter;