diff mbox

spi: spi-mpc512x-psc: don't use obsolet cell-index property

Message ID 1356100981-18685-1-git-send-email-agust@denx.de (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Anatolij Gustschin Dec. 21, 2012, 2:43 p.m. UTC
Use unique PSCx register base offset to obtain the
SPI PSC number used for SPI bus id.

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

Comments

Grant Likely Dec. 21, 2012, 2:48 p.m. UTC | #1
On Fri, Dec 21, 2012 at 2:43 PM, Anatolij Gustschin <agust@denx.de> wrote:
> Use unique PSCx register base offset to obtain the
> SPI PSC number used for SPI bus id.
>
> Signed-off-by: Anatolij Gustschin <agust@denx.de>

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
diff mbox

Patch

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,