mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] SPI: i.MX: Fix incorrect bus number in case of DT probe.
@ 2013-10-28  8:26 Alexander Shiyan
  2013-10-28 12:45 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Shiyan @ 2013-10-28  8:26 UTC (permalink / raw)
  To: barebox

The SPI bus number is not assigned in DT case, so the device can
be attached to the wrong SPI bus.

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
 drivers/spi/imx_spi.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/imx_spi.c b/drivers/spi/imx_spi.c
index 6f942bf..5975dd6 100644
--- a/drivers/spi/imx_spi.c
+++ b/drivers/spi/imx_spi.c
@@ -534,17 +534,20 @@ static int imx_spi_probe(struct device_d *dev)
 
 	master = &imx->master;
 	master->dev = dev;
-	master->bus_num = dev->id;
 
 	master->setup = imx_spi_setup;
 	master->transfer = imx_spi_transfer;
 
 	if (pdata) {
+		master->bus_num = dev->id;
 		master->num_chipselect = pdata->num_chipselect;
 		imx->cs_array = pdata->chipselect;
 	} else {
-		if (IS_ENABLED(CONFIG_OFDEVICE))
-			imx_spi_dt_probe(imx);
+		ret = of_alias_get_id(dev->device_node, "spi");
+		if (ret < 0)
+			goto err_free;
+		master->bus_num = ret;
+		imx_spi_dt_probe(imx);
 	}
 
 	imx->clk = clk_get(dev, NULL);
-- 
1.8.1.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] SPI: i.MX: Fix incorrect bus number in case of DT probe.
  2013-10-28  8:26 [PATCH] SPI: i.MX: Fix incorrect bus number in case of DT probe Alexander Shiyan
@ 2013-10-28 12:45 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2013-10-28 12:45 UTC (permalink / raw)
  To: Alexander Shiyan; +Cc: barebox

Hi Alexander,

On Mon, Oct 28, 2013 at 12:26:50PM +0400, Alexander Shiyan wrote:
> The SPI bus number is not assigned in DT case, so the device can
> be attached to the wrong SPI bus.

I stumbled upon the same problem just this morning. I fixed it by doing
what you did, but in the SPI core to make it available to all drivers.

Sascha

> 
> Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
> ---
>  drivers/spi/imx_spi.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/spi/imx_spi.c b/drivers/spi/imx_spi.c
> index 6f942bf..5975dd6 100644
> --- a/drivers/spi/imx_spi.c
> +++ b/drivers/spi/imx_spi.c
> @@ -534,17 +534,20 @@ static int imx_spi_probe(struct device_d *dev)
>  
>  	master = &imx->master;
>  	master->dev = dev;
> -	master->bus_num = dev->id;
>  
>  	master->setup = imx_spi_setup;
>  	master->transfer = imx_spi_transfer;
>  
>  	if (pdata) {
> +		master->bus_num = dev->id;
>  		master->num_chipselect = pdata->num_chipselect;
>  		imx->cs_array = pdata->chipselect;
>  	} else {
> -		if (IS_ENABLED(CONFIG_OFDEVICE))
> -			imx_spi_dt_probe(imx);
> +		ret = of_alias_get_id(dev->device_node, "spi");
> +		if (ret < 0)
> +			goto err_free;
> +		master->bus_num = ret;
> +		imx_spi_dt_probe(imx);
>  	}
>  
>  	imx->clk = clk_get(dev, NULL);
> -- 
> 1.8.1.5
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2013-10-28 12:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-28  8:26 [PATCH] SPI: i.MX: Fix incorrect bus number in case of DT probe Alexander Shiyan
2013-10-28 12:45 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox