linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yadi Hu <yadi.hu@windriver.com>
To: yadi.hu@windriver.com, jdelvare@suse.com, khali@linux-fr.org,
	wsa@the-dreams.de
Cc: linux-i2c@vger.kernel.org
Subject: [PATCH] i2c-eg20t: use dynamically registered adapter number
Date: Tue, 23 Aug 2016 17:05:58 +0800	[thread overview]
Message-ID: <1471943158-21377-1-git-send-email-yadi.hu@windriver.com> (raw)

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(-)

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;
-- 
1.7.5.4

             reply	other threads:[~2016-08-23 15:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-23  9:05 Yadi Hu [this message]
2016-08-26 15:30 ` [PATCH] i2c-eg20t: use dynamically registered adapter number Jean Delvare
2016-09-02  9:44   ` Yadi
2016-09-17 21:49   ` Wolfram Sang
2016-09-19  3:25     ` Yadi
2016-09-19  6:44       ` Wolfram Sang
2016-09-18 19:22   ` Wolfram Sang
2016-09-19  9:02     ` Jean Delvare
2016-09-20 15:48       ` Jean Delvare
  -- strict thread matches above, loose matches on Subject: below --
2016-08-23  8:55 Yadi Hu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1471943158-21377-1-git-send-email-yadi.hu@windriver.com \
    --to=yadi.hu@windriver.com \
    --cc=jdelvare@suse.com \
    --cc=khali@linux-fr.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).