[2/2] isp1760: Fix endianness-sensitivity in of_isp1760_probe()

Message ID 1316008633-31009-3-git-send-email-dave.martin@linaro.org
State Superseded
Headers show

Commit Message

Dave Martin Sept. 14, 2011, 1:57 p.m.
Data read direct from device tree properties will be in the device
tree's native endianness (i.e., big-endian).

This patch uses of_property_read_u32() to read the bus-width
property in host byte order instead.

Signed-off-by: Dave Martin <dave.martin@linaro.org>
Acked-by: Pawel Moll <pawel.moll@arm.com>
---
 drivers/usb/host/isp1760-if.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

Comments

Grant Likely Sept. 14, 2011, 3:46 p.m. | #1
On Wed, Sep 14, 2011 at 02:57:13PM +0100, Dave Martin wrote:
> Data read direct from device tree properties will be in the device
> tree's native endianness (i.e., big-endian).
> 
> This patch uses of_property_read_u32() to read the bus-width
> property in host byte order instead.
> 
> Signed-off-by: Dave Martin <dave.martin@linaro.org>
> Acked-by: Pawel Moll <pawel.moll@arm.com>
> ---
>  drivers/usb/host/isp1760-if.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c
> index 69ee32c..fa99c27 100644
> --- a/drivers/usb/host/isp1760-if.c
> +++ b/drivers/usb/host/isp1760-if.c
> @@ -39,8 +39,8 @@ static int of_isp1760_probe(struct platform_device *dev)
>  	int virq;
>  	resource_size_t res_len;
>  	int ret;
> -	const unsigned int *prop;
>  	unsigned int devflags = 0;
> +	u32 bus_width = 0;
>  
>  	ret = of_address_to_resource(dp, 0, &memory);
>  	if (ret)
> @@ -64,8 +64,8 @@ static int of_isp1760_probe(struct platform_device *dev)
>  		devflags |= ISP1760_FLAG_ISP1761;
>  
>  	/* Some systems wire up only 16 of the 32 data lines */
> -	prop = of_get_property(dp, "bus-width", NULL);
> -	if (prop && *prop == 16)
> +	of_property_read_u32(dp, "bus-width", bus_width);

Shouldn't this be '&bus_width'?

g.

> +	if (bus_width == 16)
>  		devflags |= ISP1760_FLAG_BUS_WIDTH_16;
>  
>  	if (of_get_property(dp, "port1-otg", NULL) != NULL)
> -- 
> 1.7.4.1
>
Sergei Shtylyov Sept. 14, 2011, 7:12 p.m. | #2
Hello.

On 09/14/2011 05:57 PM, Dave Martin wrote:

> Data read direct from device tree properties will be in the device
> tree's native endianness (i.e., big-endian).

> This patch uses of_property_read_u32() to read the bus-width
> property in host byte order instead.

> Signed-off-by: Dave Martin<dave.martin@linaro.org>
> Acked-by: Pawel Moll<pawel.moll@arm.com>
> ---
>   drivers/usb/host/isp1760-if.c |    6 +++---
>   1 files changed, 3 insertions(+), 3 deletions(-)

> diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c
> index 69ee32c..fa99c27 100644
> --- a/drivers/usb/host/isp1760-if.c
> +++ b/drivers/usb/host/isp1760-if.c
[...]
> @@ -64,8 +64,8 @@ static int of_isp1760_probe(struct platform_device *dev)
>   		devflags |= ISP1760_FLAG_ISP1761;
>
>   	/* Some systems wire up only 16 of the 32 data lines */
> -	prop = of_get_property(dp, "bus-width", NULL);
> -	if (prop&&  *prop == 16)
> +	of_property_read_u32(dp, "bus-width", bus_width);

    You probably mean '&bus_width'?

> +	if (bus_width == 16)
>   		devflags |= ISP1760_FLAG_BUS_WIDTH_16;
>
>   	if (of_get_property(dp, "port1-otg", NULL) != NULL)

WBR, Sergei
Dave Martin Sept. 15, 2011, 8:53 a.m. | #3
Hi,

On Wed, Sep 14, 2011 at 09:46:29AM -0600, Grant Likely wrote:
> On Wed, Sep 14, 2011 at 02:57:13PM +0100, Dave Martin wrote:

[...]

> > +   of_property_read_u32(dp, "bus-width", bus_width);
>
> Shouldn't this be '&bus_width'?


On Wed, Sep 14, 2011 at 11:12:57PM +0400, Sergei Shtylyov wrote:
[...]

> On 09/14/2011 05:57 PM, Dave Martin wrote:
[...]

> >+	of_property_read_u32(dp, "bus-width", bus_width);
> 
>    You probably mean '&bus_width'?

Yes, it should -- quite right.

Cheers
---Dave

Patch

diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c
index 69ee32c..fa99c27 100644
--- a/drivers/usb/host/isp1760-if.c
+++ b/drivers/usb/host/isp1760-if.c
@@ -39,8 +39,8 @@  static int of_isp1760_probe(struct platform_device *dev)
 	int virq;
 	resource_size_t res_len;
 	int ret;
-	const unsigned int *prop;
 	unsigned int devflags = 0;
+	u32 bus_width = 0;
 
 	ret = of_address_to_resource(dp, 0, &memory);
 	if (ret)
@@ -64,8 +64,8 @@  static int of_isp1760_probe(struct platform_device *dev)
 		devflags |= ISP1760_FLAG_ISP1761;
 
 	/* Some systems wire up only 16 of the 32 data lines */
-	prop = of_get_property(dp, "bus-width", NULL);
-	if (prop && *prop == 16)
+	of_property_read_u32(dp, "bus-width", bus_width);
+	if (bus_width == 16)
 		devflags |= ISP1760_FLAG_BUS_WIDTH_16;
 
 	if (of_get_property(dp, "port1-otg", NULL) != NULL)