linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: spi-mpc512x-psc: don't use obsolet cell-index property
@ 2012-12-21 14:43 Anatolij Gustschin
       [not found] ` <1356100981-18685-1-git-send-email-agust-ynQEQJNshbs@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Anatolij Gustschin @ 2012-12-21 14:43 UTC (permalink / raw)
  To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Use unique PSCx register base offset to obtain the
SPI PSC number used for SPI bus id.

Signed-off-by: Anatolij Gustschin <agust-ynQEQJNshbs@public.gmane.org>
---
 drivers/spi/spi-mpc512x-psc.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c
index 0a1e39e..844d68f 100644
--- a/drivers/spi/spi-mpc512x-psc.c
+++ b/drivers/spi/spi-mpc512x-psc.c
@@ -523,16 +523,21 @@ static int __devinit mpc512x_psc_spi_of_probe(struct platform_device *op)
 
 	/* get PSC id (0..11, used by port_config) */
 	if (op->dev.platform_data == NULL) {
-		const u32 *psc_nump;
+		u32 reg;
+		int err;
 
-		psc_nump = of_get_property(op->dev.of_node, "cell-index", NULL);
-		if (!psc_nump || *psc_nump > 11) {
-			dev_err(&op->dev, "mpc512x_psc_spi: Device node %s "
-				"has invalid cell-index property\n",
+		err =  of_property_read_u32(op->dev.of_node, "reg", &reg);
+		if (err) {
+			dev_err(&op->dev, "Can't read reg property: %d\n", err);
+			return err;
+		}
+
+		id = (reg & 0xf00) >> 8;
+		if (id > 11) {
+			dev_err(&op->dev, "node %s has invalid reg property\n",
 				op->dev.of_node->full_name);
 			return -EINVAL;
 		}
-		id = *psc_nump;
 	}
 
 	return mpc512x_psc_spi_do_probe(&op->dev, (u32) regaddr64, (u32) size64,
-- 
1.7.7.6


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d

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

* Re: [PATCH] spi: spi-mpc512x-psc: don't use obsolet cell-index property
       [not found] ` <1356100981-18685-1-git-send-email-agust-ynQEQJNshbs@public.gmane.org>
@ 2012-12-21 14:48   ` Grant Likely
  2012-12-21 19:29     ` Grant Likely
  0 siblings, 1 reply; 7+ messages in thread
From: Grant Likely @ 2012-12-21 14:48 UTC (permalink / raw)
  To: Anatolij Gustschin; +Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

On Fri, Dec 21, 2012 at 2:43 PM, Anatolij Gustschin <agust-ynQEQJNshbs@public.gmane.org> wrote:
> Use unique PSCx register base offset to obtain the
> SPI PSC number used for SPI bus id.
>
> Signed-off-by: Anatolij Gustschin <agust-ynQEQJNshbs@public.gmane.org>

Don't do this. If you really want to assign a specific bus number,
then use a property in /aliases. cell-index has been deprecated a very
long time ago now.

g.

> ---
>  drivers/spi/spi-mpc512x-psc.c |   17 +++++++++++------
>  1 files changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c
> index 0a1e39e..844d68f 100644
> --- a/drivers/spi/spi-mpc512x-psc.c
> +++ b/drivers/spi/spi-mpc512x-psc.c
> @@ -523,16 +523,21 @@ static int __devinit mpc512x_psc_spi_of_probe(struct platform_device *op)
>
>         /* get PSC id (0..11, used by port_config) */
>         if (op->dev.platform_data == NULL) {
> -               const u32 *psc_nump;
> +               u32 reg;
> +               int err;
>
> -               psc_nump = of_get_property(op->dev.of_node, "cell-index", NULL);
> -               if (!psc_nump || *psc_nump > 11) {
> -                       dev_err(&op->dev, "mpc512x_psc_spi: Device node %s "
> -                               "has invalid cell-index property\n",
> +               err =  of_property_read_u32(op->dev.of_node, "reg", &reg);
> +               if (err) {
> +                       dev_err(&op->dev, "Can't read reg property: %d\n", err);
> +                       return err;
> +               }
> +
> +               id = (reg & 0xf00) >> 8;
> +               if (id > 11) {
> +                       dev_err(&op->dev, "node %s has invalid reg property\n",
>                                 op->dev.of_node->full_name);
>                         return -EINVAL;
>                 }
> -               id = *psc_nump;
>         }
>
>         return mpc512x_psc_spi_do_probe(&op->dev, (u32) regaddr64, (u32) size64,
> --
> 1.7.7.6
>



--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d

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

* Re: [PATCH] spi: spi-mpc512x-psc: don't use obsolet cell-index property
  2012-12-21 14:48   ` Grant Likely
@ 2012-12-21 19:29     ` Grant Likely
  2013-01-10 23:12       ` Anatolij Gustschin
                         ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Grant Likely @ 2012-12-21 19:29 UTC (permalink / raw)
  To: Anatolij Gustschin; +Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

On Fri, 21 Dec 2012 14:48:38 +0000, Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> wrote:
> On Fri, Dec 21, 2012 at 2:43 PM, Anatolij Gustschin <agust-ynQEQJNshbs@public.gmane.org> wrote:
> > Use unique PSCx register base offset to obtain the
> > SPI PSC number used for SPI bus id.
> >
> > Signed-off-by: Anatolij Gustschin <agust-ynQEQJNshbs@public.gmane.org>
> 
> Don't do this. If you really want to assign a specific bus number,
> then use a property in /aliases. cell-index has been deprecated a very
> long time ago now.

Ummm.. I really should read patches before I reply to them. I see you're
removing cell-index, not adding it back in. It is fine.

Aliases would be a more generic solution though. Would this following
change work for you? Try it out and let me know.

g.

---
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 84c2861..de9f6ee 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -983,6 +983,9 @@ int spi_register_master(struct spi_master *master)
 	if (master->num_chipselect == 0)
 		return -EINVAL;
 
+	if ((master->bus_num < 0) && master->dev.of_node)
+		master->bus_num = of_alias_get_id(master->dev.of_node, "spi");
+
 	/* convention:  dynamically assigned bus IDs count down from the max */
 	if (master->bus_num < 0) {
 		/* FIXME switch to an IDR based scheme, something like


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d

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

* Re: [PATCH] spi: spi-mpc512x-psc: don't use obsolet cell-index property
  2012-12-21 19:29     ` Grant Likely
@ 2013-01-10 23:12       ` Anatolij Gustschin
  2013-01-10 23:26       ` [PATCH v2] " Anatolij Gustschin
  2013-01-11  0:05       ` Anatolij Gustschin
  2 siblings, 0 replies; 7+ messages in thread
From: Anatolij Gustschin @ 2013-01-10 23:12 UTC (permalink / raw)
  To: Grant Likely; +Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Hi Grant,

On Fri, 21 Dec 2012 19:29:14 +0000
Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> wrote:

> On Fri, 21 Dec 2012 14:48:38 +0000, Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> wrote:
> > On Fri, Dec 21, 2012 at 2:43 PM, Anatolij Gustschin <agust-ynQEQJNshbs@public.gmane.org> wrote:
> > > Use unique PSCx register base offset to obtain the
> > > SPI PSC number used for SPI bus id.
> > >
> > > Signed-off-by: Anatolij Gustschin <agust-ynQEQJNshbs@public.gmane.org>
> > 
> > Don't do this. If you really want to assign a specific bus number,
> > then use a property in /aliases. cell-index has been deprecated a very
> > long time ago now.
> 
> Ummm.. I really should read patches before I reply to them. I see you're
> removing cell-index, not adding it back in. It is fine.
> 
> Aliases would be a more generic solution though. Would this following
> change work for you? Try it out and let me know.

Sorry for delay. I've tried it now, it doesn't work. The mpc5121
psc spi driver also needs to get/enable psc clock of the used psc
controller. It uses psc bus number to generate psc clock name
string and to get and enable this clock, so I need to set
the bus number in the driver. I'll use of_alias_get_id() in the
the psc spi driver.


Thanks,

Anatolij

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712

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

* [PATCH v2] spi: spi-mpc512x-psc: don't use obsolet cell-index property
  2012-12-21 19:29     ` Grant Likely
  2013-01-10 23:12       ` Anatolij Gustschin
@ 2013-01-10 23:26       ` Anatolij Gustschin
  2013-01-11  0:05       ` Anatolij Gustschin
  2 siblings, 0 replies; 7+ messages in thread
From: Anatolij Gustschin @ 2013-01-10 23:26 UTC (permalink / raw)
  To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Remove deprecated cell-index property and use spi alias to
obtain the SPI PSC number used for SPI bus id.

Signed-off-by: Anatolij Gustschin <agust-ynQEQJNshbs@public.gmane.org>
---
v2:
 - use of_alias_get_id() to get spi bus number

 drivers/spi/spi-mpc512x-psc.c |   16 +++++-----------
 1 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c
index cb3a310..88e5441 100644
--- a/drivers/spi/spi-mpc512x-psc.c
+++ b/drivers/spi/spi-mpc512x-psc.c
@@ -522,17 +522,11 @@ static int mpc512x_psc_spi_of_probe(struct platform_device *op)
 	regaddr64 = of_translate_address(op->dev.of_node, regaddr_p);
 
 	/* get PSC id (0..11, used by port_config) */
-	if (op->dev.platform_data == NULL) {
-		const u32 *psc_nump;
-
-		psc_nump = of_get_property(op->dev.of_node, "cell-index", NULL);
-		if (!psc_nump || *psc_nump > 11) {
-			dev_err(&op->dev, "mpc512x_psc_spi: Device node %s "
-				"has invalid cell-index property\n",
-				op->dev.of_node->full_name);
-			return -EINVAL;
-		}
-		id = *psc_nump;
+	id = of_alias_get_id(op->dev.of_node, "spi");
+	if (id < 0) {
+		dev_err(&op->dev, "no alias id for %s\n",
+			op->dev.of_node->full_name);
+		return id;
 	}
 
 	return mpc512x_psc_spi_do_probe(&op->dev, (u32) regaddr64, (u32) size64,
-- 
1.7.5.4


------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712

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

* [PATCH v2] spi: spi-mpc512x-psc: don't use obsolet cell-index property
  2012-12-21 19:29     ` Grant Likely
  2013-01-10 23:12       ` Anatolij Gustschin
  2013-01-10 23:26       ` [PATCH v2] " Anatolij Gustschin
@ 2013-01-11  0:05       ` Anatolij Gustschin
       [not found]         ` <1357862748-14130-1-git-send-email-agust-ynQEQJNshbs@public.gmane.org>
  2 siblings, 1 reply; 7+ messages in thread
From: Anatolij Gustschin @ 2013-01-11  0:05 UTC (permalink / raw)
  To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f; +Cc: Anatolij Gustschin

Remove deprecated cell-index property and use spi alias to
obtain the SPI PSC number used for SPI bus id.

Signed-off-by: Anatolij Gustschin <agust-ynQEQJNshbs@public.gmane.org>
---
v2:
 - use of_alias_get_id() to get spi bus number

 drivers/spi/spi-mpc512x-psc.c |   16 +++++-----------
 1 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c
index cb3a310..88e5441 100644
--- a/drivers/spi/spi-mpc512x-psc.c
+++ b/drivers/spi/spi-mpc512x-psc.c
@@ -522,17 +522,11 @@ static int mpc512x_psc_spi_of_probe(struct platform_device *op)
 	regaddr64 = of_translate_address(op->dev.of_node, regaddr_p);
 
 	/* get PSC id (0..11, used by port_config) */
-	if (op->dev.platform_data == NULL) {
-		const u32 *psc_nump;
-
-		psc_nump = of_get_property(op->dev.of_node, "cell-index", NULL);
-		if (!psc_nump || *psc_nump > 11) {
-			dev_err(&op->dev, "mpc512x_psc_spi: Device node %s "
-				"has invalid cell-index property\n",
-				op->dev.of_node->full_name);
-			return -EINVAL;
-		}
-		id = *psc_nump;
+	id = of_alias_get_id(op->dev.of_node, "spi");
+	if (id < 0) {
+		dev_err(&op->dev, "no alias id for %s\n",
+			op->dev.of_node->full_name);
+		return id;
 	}
 
 	return mpc512x_psc_spi_do_probe(&op->dev, (u32) regaddr64, (u32) size64,
-- 
1.7.5.4


------------------------------------------------------------------------------
Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and
much more. Get web development skills now with LearnDevNow -
350+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122812

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

* Re: [PATCH v2] spi: spi-mpc512x-psc: don't use obsolet cell-index property
       [not found]         ` <1357862748-14130-1-git-send-email-agust-ynQEQJNshbs@public.gmane.org>
@ 2013-02-05 14:09           ` Grant Likely
  0 siblings, 0 replies; 7+ messages in thread
From: Grant Likely @ 2013-02-05 14:09 UTC (permalink / raw)
  To: Anatolij Gustschin,
	spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
  Cc: Anatolij Gustschin

On Fri, 11 Jan 2013 01:05:48 +0100, Anatolij Gustschin <agust-ynQEQJNshbs@public.gmane.org> wrote:
> Remove deprecated cell-index property and use spi alias to
> obtain the SPI PSC number used for SPI bus id.
> 
> Signed-off-by: Anatolij Gustschin <agust-ynQEQJNshbs@public.gmane.org>
> ---
> v2:
>  - use of_alias_get_id() to get spi bus number
> 

Applied, thanks.

g.

>  drivers/spi/spi-mpc512x-psc.c |   16 +++++-----------
>  1 files changed, 5 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c
> index cb3a310..88e5441 100644
> --- a/drivers/spi/spi-mpc512x-psc.c
> +++ b/drivers/spi/spi-mpc512x-psc.c
> @@ -522,17 +522,11 @@ static int mpc512x_psc_spi_of_probe(struct platform_device *op)
>  	regaddr64 = of_translate_address(op->dev.of_node, regaddr_p);
>  
>  	/* get PSC id (0..11, used by port_config) */
> -	if (op->dev.platform_data == NULL) {
> -		const u32 *psc_nump;
> -
> -		psc_nump = of_get_property(op->dev.of_node, "cell-index", NULL);
> -		if (!psc_nump || *psc_nump > 11) {
> -			dev_err(&op->dev, "mpc512x_psc_spi: Device node %s "
> -				"has invalid cell-index property\n",
> -				op->dev.of_node->full_name);
> -			return -EINVAL;
> -		}
> -		id = *psc_nump;
> +	id = of_alias_get_id(op->dev.of_node, "spi");
> +	if (id < 0) {
> +		dev_err(&op->dev, "no alias id for %s\n",
> +			op->dev.of_node->full_name);
> +		return id;
>  	}
>  
>  	return mpc512x_psc_spi_do_probe(&op->dev, (u32) regaddr64, (u32) size64,
> -- 
> 1.7.5.4
> 

-- 
Grant Likely, B.Sc, P.Eng.
Secret Lab Technologies, Ltd.

------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013 
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb

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

end of thread, other threads:[~2013-02-05 14:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-21 14:43 [PATCH] spi: spi-mpc512x-psc: don't use obsolet cell-index property Anatolij Gustschin
     [not found] ` <1356100981-18685-1-git-send-email-agust-ynQEQJNshbs@public.gmane.org>
2012-12-21 14:48   ` Grant Likely
2012-12-21 19:29     ` Grant Likely
2013-01-10 23:12       ` Anatolij Gustschin
2013-01-10 23:26       ` [PATCH v2] " Anatolij Gustschin
2013-01-11  0:05       ` Anatolij Gustschin
     [not found]         ` <1357862748-14130-1-git-send-email-agust-ynQEQJNshbs@public.gmane.org>
2013-02-05 14:09           ` Grant Likely

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