linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: imx: use of_alias_get_id to order i2c devices
@ 2013-04-09 17:09 Philipp Zabel
       [not found] ` <1365527379-17786-1-git-send-email-p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Philipp Zabel @ 2013-04-09 17:09 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: Ben Dooks, Wolfram Sang, Shawn Guo, Philipp Zabel

This allows to order i2c character devices as they are numbered
in the reference manual, instead of ordering them by register
base address.

Signed-off-by: Philipp Zabel <p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
---
 drivers/i2c/busses/i2c-imx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 82f20c6..e5a3f08 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -488,6 +488,7 @@ static struct i2c_algorithm i2c_imx_algo = {
 
 static int __init i2c_imx_probe(struct platform_device *pdev)
 {
+	struct device_node *np = pdev->dev.of_node;
 	const struct of_device_id *of_id = of_match_device(i2c_imx_dt_ids,
 							   &pdev->dev);
 	struct imx_i2c_struct *i2c_imx;
@@ -531,7 +532,7 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
 	i2c_imx->adapter.owner		= THIS_MODULE;
 	i2c_imx->adapter.algo		= &i2c_imx_algo;
 	i2c_imx->adapter.dev.parent	= &pdev->dev;
-	i2c_imx->adapter.nr 		= pdev->id;
+	i2c_imx->adapter.nr		= (pdev->id < 0) ? of_alias_get_id(np, "i2c") : pdev->id;
 	i2c_imx->adapter.dev.of_node	= pdev->dev.of_node;
 	i2c_imx->base			= base;
 
-- 
1.8.2.rc2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] i2c: imx: use of_alias_get_id to order i2c devices
       [not found] ` <1365527379-17786-1-git-send-email-p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2013-04-12  1:49   ` Shawn Guo
  2013-04-16  9:17   ` Wolfram Sang
  1 sibling, 0 replies; 4+ messages in thread
From: Shawn Guo @ 2013-04-12  1:49 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Ben Dooks, Wolfram Sang,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Grant Likely,
	Rob Herring

On Tue, Apr 09, 2013 at 07:09:39PM +0200, Philipp Zabel wrote:
> This allows to order i2c character devices as they are numbered
> in the reference manual, instead of ordering them by register
> base address.
> 
> Signed-off-by: Philipp Zabel <p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

I'm fine with the patch, but let's see if DT maintainers have an
opinion.

Shawn

> ---
>  drivers/i2c/busses/i2c-imx.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index 82f20c6..e5a3f08 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -488,6 +488,7 @@ static struct i2c_algorithm i2c_imx_algo = {
>  
>  static int __init i2c_imx_probe(struct platform_device *pdev)
>  {
> +	struct device_node *np = pdev->dev.of_node;
>  	const struct of_device_id *of_id = of_match_device(i2c_imx_dt_ids,
>  							   &pdev->dev);
>  	struct imx_i2c_struct *i2c_imx;
> @@ -531,7 +532,7 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
>  	i2c_imx->adapter.owner		= THIS_MODULE;
>  	i2c_imx->adapter.algo		= &i2c_imx_algo;
>  	i2c_imx->adapter.dev.parent	= &pdev->dev;
> -	i2c_imx->adapter.nr 		= pdev->id;
> +	i2c_imx->adapter.nr		= (pdev->id < 0) ? of_alias_get_id(np, "i2c") : pdev->id;
>  	i2c_imx->adapter.dev.of_node	= pdev->dev.of_node;
>  	i2c_imx->base			= base;
>  
> -- 
> 1.8.2.rc2
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] i2c: imx: use of_alias_get_id to order i2c devices
       [not found] ` <1365527379-17786-1-git-send-email-p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  2013-04-12  1:49   ` Shawn Guo
@ 2013-04-16  9:17   ` Wolfram Sang
       [not found]     ` <20130416091359.GB16978-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
  1 sibling, 1 reply; 4+ messages in thread
From: Wolfram Sang @ 2013-04-16  9:17 UTC (permalink / raw)
  To: Philipp Zabel; +Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Ben Dooks, Shawn Guo

On Tue, Apr 09, 2013 at 07:09:39PM +0200, Philipp Zabel wrote:
> This allows to order i2c character devices as they are numbered
> in the reference manual, instead of ordering them by register
> base address.
> 
> Signed-off-by: Philipp Zabel <p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

ee5c27440cc24d62ec463cce4c000bb32c5692c7 in i2c/for-next does this on
core level.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] i2c: imx: use of_alias_get_id to order i2c devices
       [not found]     ` <20130416091359.GB16978-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
@ 2013-04-16  9:25       ` Philipp Zabel
  0 siblings, 0 replies; 4+ messages in thread
From: Philipp Zabel @ 2013-04-16  9:25 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Ben Dooks, Shawn Guo

Am Dienstag, den 16.04.2013, 11:17 +0200 schrieb Wolfram Sang:
> On Tue, Apr 09, 2013 at 07:09:39PM +0200, Philipp Zabel wrote:
> > This allows to order i2c character devices as they are numbered
> > in the reference manual, instead of ordering them by register
> > base address.
> > 
> > Signed-off-by: Philipp Zabel <p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> 
> ee5c27440cc24d62ec463cce4c000bb32c5692c7 in i2c/for-next does this on
> core level.

Excellent, thanks!

regards
Philipp

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-04-16  9:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-09 17:09 [PATCH] i2c: imx: use of_alias_get_id to order i2c devices Philipp Zabel
     [not found] ` <1365527379-17786-1-git-send-email-p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-04-12  1:49   ` Shawn Guo
2013-04-16  9:17   ` Wolfram Sang
     [not found]     ` <20130416091359.GB16978-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
2013-04-16  9:25       ` Philipp Zabel

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