From: Benoit Cousson <b-cousson-l0cyMroinI0@public.gmane.org>
To: Florian Vaussard <florian.vaussard-p8DiymsW2f8@public.gmane.org>
Cc: "Tony Lindgren" <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>,
linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
"Ben Dooks" <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>,
"Wolfram Sang" <w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
"Philippe Rétornaz"
<philippe.retornaz-p8DiymsW2f8@public.gmane.org>
Subject: Re: [PATCH 1/2] i2c-omap: Fix incorrect adapter id when booting from a device tree
Date: Fri, 31 Aug 2012 11:14:20 +0200 [thread overview]
Message-ID: <5040806C.9080003@ti.com> (raw)
In-Reply-To: <1346399575-7285-2-git-send-email-florian.vaussard-p8DiymsW2f8@public.gmane.org>
Hi Florian,
On 08/31/2012 09:52 AM, Florian Vaussard wrote:
> When booting from a device tree, the omap driver is using pdev->id,
> which is incorrect.
Not really, see below...
> The proposed patch uses aliases, as done in omap-serial.
Mmm, but is it really needed?
In the case of serial the id is important because of the tty number used
as device interface.
In the case of I2C, the id is mostly irrelevant.
In fact, using the pdev->id = -1 was used on purpose to have a dynamic
assignment:
int i2c_add_numbered_adapter(struct i2c_adapter *adap)
...
if (adap->nr == -1) /* -1 means dynamically assign bus id */
return i2c_add_adapter(adap);
> Signed-off-by: Florian Vaussard <florian.vaussard-p8DiymsW2f8@public.gmane.org>
> ---
> drivers/i2c/busses/i2c-omap.c | 19 +++++++++++++++----
> 1 files changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
> index 5d19a49..9445d1f 100644
> --- a/drivers/i2c/busses/i2c-omap.c
> +++ b/drivers/i2c/busses/i2c-omap.c
> @@ -1064,9 +1064,6 @@ omap_i2c_probe(struct platform_device *pdev)
> goto err_unuse_clocks;
> }
>
> - dev_info(dev->dev, "bus %d rev%d.%d.%d at %d kHz\n", pdev->id,
> - dev->dtrev, dev->rev >> 4, dev->rev & 0xf, dev->speed);
> -
[ 0.658843] omap_i2c i2c.15: bus -1 rev2.4.0 at 400 kHz
[ 0.760192] omap_i2c i2c.16: bus -1 rev2.4.0 at 400 kHz
[ 0.775817] omap_i2c i2c.17: bus -1 rev2.4.0 at 400 kHz
[ 0.791442] omap_i2c i2c.18: bus -1 rev2.4.0 at 400 kHz
OK, it is true that the current log is not that nice with bus -1, but
maybe we should just remove that.
Or we can potentially retrieve the i2c adapter number assign later, and
delay the log.
> r = i2c_add_numbered_adapter(adap);
> if (r) {
> dev_err(dev->dev, "failure adding adapter\n");
Regards,
Benoit
> adap = &dev->adapter;
> i2c_set_adapdata(adap, dev);
> adap->owner = THIS_MODULE;
> @@ -1076,8 +1073,22 @@ omap_i2c_probe(struct platform_device *pdev)
> adap->dev.parent = &pdev->dev;
> adap->dev.of_node = pdev->dev.of_node;
>
> + if (adap->dev.of_node)
> + adap->nr = of_alias_get_id(adap->dev.of_node, "i2c");
> + else
> + adap->nr = pdev->id;
> +
> + if (adap->nr < 0) {
> + dev_err(&pdev->dev, "failed to get alias/pdev id, errno %d\n",
> + adap->nr);
> + r = -ENODEV;
> + goto err_free_irq;
> + }
> +
> + dev_info(dev->dev, "bus %d rev%d.%d.%d at %d kHz\n", adap->nr,
> + dev->dtrev, dev->rev >> 4, dev->rev & 0xf, dev->speed);
> +
> /* i2c device drivers may be active on return from add_adapter() */
> - adap->nr = pdev->id;
> r = i2c_add_numbered_adapter(adap);
> if (r) {
> dev_err(dev->dev, "failure adding adapter\n");
>
next prev parent reply other threads:[~2012-08-31 9:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-31 7:52 [PATCH 0/2] dts for i2c-omap: fix incorrect adapter id Florian Vaussard
2012-08-31 7:52 ` [PATCH 1/2] i2c-omap: Fix incorrect adapter id when booting from a device tree Florian Vaussard
[not found] ` <1346399575-7285-2-git-send-email-florian.vaussard-p8DiymsW2f8@public.gmane.org>
2012-08-31 9:14 ` Benoit Cousson [this message]
2012-08-31 9:53 ` Florian Vaussard
2012-08-31 7:52 ` [PATCH 2/2] arm/dts: Add i2c aliases for OMAP3 and OMAP4/AM33xx Florian Vaussard
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=5040806C.9080003@ti.com \
--to=b-cousson-l0cymroini0@public.gmane.org \
--cc=ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org \
--cc=florian.vaussard-p8DiymsW2f8@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=philippe.retornaz-p8DiymsW2f8@public.gmane.org \
--cc=tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org \
--cc=w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
/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).