All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Hesselbarth <sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Thomas Petazzoni
	<thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
	Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Shadi Ammouri <shadi-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	Jason Cooper <jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org>,
	Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org>,
	Gregory Clement
	<gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
	Tawfik Bayouk <tawfik-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>,
	Nadav Haklai <nadavh-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>,
	Lior Amsalem <alior-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>,
	Ezequiel Garcia
	<ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
	stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 1/2] spi: orion: fix incorrect handling of cell-index DT property
Date: Mon, 28 Jul 2014 08:27:28 +0200	[thread overview]
Message-ID: <53D5ED50.2070809@gmail.com> (raw)
In-Reply-To: <1406498000-13079-2-git-send-email-thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

On 07/27/2014 11:53 PM, Thomas Petazzoni wrote:
> In commit f814f9ac5a81 ("spi/orion: add device tree binding"), Device
> Tree support was added to the spi-orion driver. However, this commit
> reads the "cell-index" property, without taking into account the fact
> that DT properties are big-endian encoded.
> 
> Since most of the platforms using spi-orion with DT have apparently
> not used anything but cell-index = <0>, the problem was not
> visible. But as soon as one starts using cell-index = <1>, the problem
> becomes clearly visible, as the master->bus_num gets a wrong value
> (actually it gets the value 0, which conflicts with the first bus that
> has cell-index = <0>).
> 
> This commit fixes that by using of_property_read_u32() to read the
> property value, which does the appropriate endianness conversion when
> needed.
> 
> Fixes: f814f9ac5a81 ("spi/orion: add device tree binding")
> Cc: <stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org> # v3.6+
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>

For MVEBU,

Acked-by: Sebastian Hesselbarth <sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

> ---
>  drivers/spi/spi-orion.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
> index d018a4a..c206a4a 100644
> --- a/drivers/spi/spi-orion.c
> +++ b/drivers/spi/spi-orion.c
> @@ -346,8 +346,6 @@ static int orion_spi_probe(struct platform_device *pdev)
>  	struct resource *r;
>  	unsigned long tclk_hz;
>  	int status = 0;
> -	const u32 *iprop;
> -	int size;
>  
>  	master = spi_alloc_master(&pdev->dev, sizeof(*spi));
>  	if (master == NULL) {
> @@ -358,10 +356,10 @@ static int orion_spi_probe(struct platform_device *pdev)
>  	if (pdev->id != -1)
>  		master->bus_num = pdev->id;
>  	if (pdev->dev.of_node) {
> -		iprop = of_get_property(pdev->dev.of_node, "cell-index",
> -					&size);
> -		if (iprop && size == sizeof(*iprop))
> -			master->bus_num = *iprop;
> +		u32 cell_index;
> +		if (!of_property_read_u32(pdev->dev.of_node, "cell-index",
> +					  &cell_index))
> +			master->bus_num = cell_index;
>  	}
>  
>  	/* we support only mode 0, and no options */
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: sebastian.hesselbarth@gmail.com (Sebastian Hesselbarth)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] spi: orion: fix incorrect handling of cell-index DT property
Date: Mon, 28 Jul 2014 08:27:28 +0200	[thread overview]
Message-ID: <53D5ED50.2070809@gmail.com> (raw)
In-Reply-To: <1406498000-13079-2-git-send-email-thomas.petazzoni@free-electrons.com>

On 07/27/2014 11:53 PM, Thomas Petazzoni wrote:
> In commit f814f9ac5a81 ("spi/orion: add device tree binding"), Device
> Tree support was added to the spi-orion driver. However, this commit
> reads the "cell-index" property, without taking into account the fact
> that DT properties are big-endian encoded.
> 
> Since most of the platforms using spi-orion with DT have apparently
> not used anything but cell-index = <0>, the problem was not
> visible. But as soon as one starts using cell-index = <1>, the problem
> becomes clearly visible, as the master->bus_num gets a wrong value
> (actually it gets the value 0, which conflicts with the first bus that
> has cell-index = <0>).
> 
> This commit fixes that by using of_property_read_u32() to read the
> property value, which does the appropriate endianness conversion when
> needed.
> 
> Fixes: f814f9ac5a81 ("spi/orion: add device tree binding")
> Cc: <stable@vger.kernel.org> # v3.6+
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

For MVEBU,

Acked-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>

> ---
>  drivers/spi/spi-orion.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/spi/spi-orion.c b/drivers/spi/spi-orion.c
> index d018a4a..c206a4a 100644
> --- a/drivers/spi/spi-orion.c
> +++ b/drivers/spi/spi-orion.c
> @@ -346,8 +346,6 @@ static int orion_spi_probe(struct platform_device *pdev)
>  	struct resource *r;
>  	unsigned long tclk_hz;
>  	int status = 0;
> -	const u32 *iprop;
> -	int size;
>  
>  	master = spi_alloc_master(&pdev->dev, sizeof(*spi));
>  	if (master == NULL) {
> @@ -358,10 +356,10 @@ static int orion_spi_probe(struct platform_device *pdev)
>  	if (pdev->id != -1)
>  		master->bus_num = pdev->id;
>  	if (pdev->dev.of_node) {
> -		iprop = of_get_property(pdev->dev.of_node, "cell-index",
> -					&size);
> -		if (iprop && size == sizeof(*iprop))
> -			master->bus_num = *iprop;
> +		u32 cell_index;
> +		if (!of_property_read_u32(pdev->dev.of_node, "cell-index",
> +					  &cell_index))
> +			master->bus_num = cell_index;
>  	}
>  
>  	/* we support only mode 0, and no options */
> 

  parent reply	other threads:[~2014-07-28  6:27 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-27 21:53 [PATCH 0/2] spi-orion: one fix and one improvement Thomas Petazzoni
2014-07-27 21:53 ` Thomas Petazzoni
     [not found] ` <1406498000-13079-1-git-send-email-thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-07-27 21:53   ` [PATCH 1/2] spi: orion: fix incorrect handling of cell-index DT property Thomas Petazzoni
2014-07-27 21:53     ` Thomas Petazzoni
     [not found]     ` <1406498000-13079-2-git-send-email-thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-07-28  6:27       ` Sebastian Hesselbarth [this message]
2014-07-28  6:27         ` Sebastian Hesselbarth
2014-07-28 21:30     ` Mark Brown
2014-07-28 21:30       ` Mark Brown
2014-07-27 21:53   ` [PATCH 2/2] spi: orion: add support for multiple chip selects Thomas Petazzoni
2014-07-27 21:53     ` Thomas Petazzoni
     [not found]     ` <1406498000-13079-3-git-send-email-thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-07-28  6:25       ` Sebastian Hesselbarth
2014-07-28  6:25         ` Sebastian Hesselbarth
     [not found]         ` <53D5ECCA.7030806-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-07-28 21:48           ` Mark Brown
2014-07-28 21:48             ` Mark Brown
2014-07-28 21:52       ` Mark Brown
2014-07-28 21:52         ` Mark Brown

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=53D5ED50.2070809@gmail.com \
    --to=sebastian.hesselbarth-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=alior-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org \
    --cc=andrew-g2DYL2Zd6BY@public.gmane.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=nadavh-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org \
    --cc=shadi-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org \
    --cc=stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=tawfik-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org \
    --cc=thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.