linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4] Lattice ECP3 FPGA: Correct endianness
@ 2014-07-23  9:39 Jean-Michel Hautbois
  2014-07-23 23:58 ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Jean-Michel Hautbois @ 2014-07-23  9:39 UTC (permalink / raw)
  To: linux-kernel, Arnd Bergmann, gregkh, Stefan Roese

This code corrects endianness and avoids a sparse error.
Tested with Lattice ECP3-35 with Freescale i.MX6.
It also sends uevent in order to load it.

Signed-off-by: Jean-Michel Hautbois <jean-michel.hautbois@vodalys.com>
---
 drivers/misc/lattice-ecp3-config.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/misc/lattice-ecp3-config.c
b/drivers/misc/lattice-ecp3-config.c
index bb26f08..2c86319 100644
--- a/drivers/misc/lattice-ecp3-config.c
+++ b/drivers/misc/lattice-ecp3-config.c
@@ -16,6 +16,7 @@
 #include <linux/spi/spi.h>
 #include <linux/platform_device.h>
 #include <linux/delay.h>
+#include <asm/unaligned.h>

 #define FIRMWARE_NAME    "lattice-ecp3.bit"

@@ -92,8 +93,8 @@ static void firmware_load(const struct firmware *fw,
void *context)
     /* Trying to speak with the FPGA via SPI... */
     txbuf[0] = FPGA_CMD_READ_ID;
     ret = spi_write_then_read(spi, txbuf, 8, rxbuf, rx_len);
-    dev_dbg(&spi->dev, "FPGA JTAG ID=%08x\n", *(u32 *)&rxbuf[4]);
-    jedec_id = *(u32 *)&rxbuf[4];
+    jedec_id = get_unaligned_be32(&rxbuf[4]);
+    dev_dbg(&spi->dev, "FPGA JTAG ID=%08x\n", jedec_id);

     for (i = 0; i < ARRAY_SIZE(ecp3_dev); i++) {
         if (jedec_id == ecp3_dev[i].jedec_id)
@@ -110,7 +111,8 @@ static void firmware_load(const struct firmware
*fw, void *context)

     txbuf[0] = FPGA_CMD_READ_STATUS;
     ret = spi_write_then_read(spi, txbuf, 8, rxbuf, rx_len);
-    dev_dbg(&spi->dev, "FPGA Status=%08x\n", *(u32 *)&rxbuf[4]);
+    status = get_unaligned_be32(&rxbuf[4]);
+    dev_dbg(&spi->dev, "FPGA Status=%08x\n", status);

     buffer = kzalloc(fw->size + 8, GFP_KERNEL);
     if (!buffer) {
@@ -142,7 +144,7 @@ static void firmware_load(const struct firmware
*fw, void *context)
     for (i = 0; i < FPGA_CLEAR_LOOP_COUNT; i++) {
         txbuf[0] = FPGA_CMD_READ_STATUS;
         ret = spi_write_then_read(spi, txbuf, 8, rxbuf, rx_len);
-        status = *(u32 *)&rxbuf[4];
+        status = get_unaligned_be32(&rxbuf[4]);
         if (status == FPGA_STATUS_CLEARED)
             break;

@@ -165,8 +167,8 @@ static void firmware_load(const struct firmware
*fw, void *context)

     txbuf[0] = FPGA_CMD_READ_STATUS;
     ret = spi_write_then_read(spi, txbuf, 8, rxbuf, rx_len);
-    dev_dbg(&spi->dev, "FPGA Status=%08x\n", *(u32 *)&rxbuf[4]);
-    status = *(u32 *)&rxbuf[4];
+    status = get_unaligned_be32(&rxbuf[4]);
+    dev_dbg(&spi->dev, "FPGA Status=%08x\n", status);

     /* Check result */
     if (status & FPGA_STATUS_DONE)
@@ -197,7 +199,7 @@ static int lattice_ecp3_probe(struct spi_device *spi)
     spi_set_drvdata(spi, data);

     init_completion(&data->fw_loaded);
-    err = request_firmware_nowait(THIS_MODULE, FW_ACTION_NOHOTPLUG,
+    err = request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG,
                       FIRMWARE_NAME, &spi->dev,
                       GFP_KERNEL, spi, firmware_load);
     if (err) {
-- 
2.0.0

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

* Re: [PATCH v4] Lattice ECP3 FPGA: Correct endianness
  2014-07-23  9:39 [PATCH v4] Lattice ECP3 FPGA: Correct endianness Jean-Michel Hautbois
@ 2014-07-23 23:58 ` Greg KH
  2014-07-24  6:53   ` Jean-Michel Hautbois
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2014-07-23 23:58 UTC (permalink / raw)
  To: Jean-Michel Hautbois; +Cc: linux-kernel, Arnd Bergmann, Stefan Roese

On Wed, Jul 23, 2014 at 11:39:35AM +0200, Jean-Michel Hautbois wrote:
> This code corrects endianness and avoids a sparse error.
> Tested with Lattice ECP3-35 with Freescale i.MX6.
> It also sends uevent in order to load it.
> 
> Signed-off-by: Jean-Michel Hautbois <jean-michel.hautbois@vodalys.com>
> ---
>  drivers/misc/lattice-ecp3-config.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/misc/lattice-ecp3-config.c
> b/drivers/misc/lattice-ecp3-config.c
> index bb26f08..2c86319 100644
> --- a/drivers/misc/lattice-ecp3-config.c
> +++ b/drivers/misc/lattice-ecp3-config.c
> @@ -16,6 +16,7 @@
>  #include <linux/spi/spi.h>
>  #include <linux/platform_device.h>
>  #include <linux/delay.h>
> +#include <asm/unaligned.h>
> 
>  #define FIRMWARE_NAME    "lattice-ecp3.bit"
> 
> @@ -92,8 +93,8 @@ static void firmware_load(const struct firmware *fw,
> void *context)
>      /* Trying to speak with the FPGA via SPI... */
>      txbuf[0] = FPGA_CMD_READ_ID;
>      ret = spi_write_then_read(spi, txbuf, 8, rxbuf, rx_len);
> -    dev_dbg(&spi->dev, "FPGA JTAG ID=%08x\n", *(u32 *)&rxbuf[4]);
> -    jedec_id = *(u32 *)&rxbuf[4];
> +    jedec_id = get_unaligned_be32(&rxbuf[4]);
> +    dev_dbg(&spi->dev, "FPGA JTAG ID=%08x\n", jedec_id);

Your email client ate all the tabs and spit out spaces and then
line-wrapped the patch, making it impossible to apply :(

Can you fix it up and resend it in a format we can use?

thanks,

greg k-h

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

* Re: [PATCH v4] Lattice ECP3 FPGA: Correct endianness
  2014-07-23 23:58 ` Greg KH
@ 2014-07-24  6:53   ` Jean-Michel Hautbois
  2014-07-24  7:37     ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Jean-Michel Hautbois @ 2014-07-24  6:53 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, Arnd Bergmann, Stefan Roese

> Your email client ate all the tabs and spit out spaces and then
> line-wrapped the patch, making it impossible to apply :(
>
> Can you fix it up and resend it in a format we can use?
>
> thanks,
>
> greg k-h

GMail GUI is a nightmare, I can't find an option to tell it to let me
send whatever I want... :(
I will use Thunderbird then !

JM

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

* Re: [PATCH v4] Lattice ECP3 FPGA: Correct endianness
  2014-07-24  6:53   ` Jean-Michel Hautbois
@ 2014-07-24  7:37     ` Greg KH
  2014-07-24  8:21       ` Jean-Michel Hautbois
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2014-07-24  7:37 UTC (permalink / raw)
  To: Jean-Michel Hautbois; +Cc: linux-kernel, Arnd Bergmann, Stefan Roese

On Thu, Jul 24, 2014 at 08:53:30AM +0200, Jean-Michel Hautbois wrote:
> > Your email client ate all the tabs and spit out spaces and then
> > line-wrapped the patch, making it impossible to apply :(
> >
> > Can you fix it up and resend it in a format we can use?
> >
> > thanks,
> >
> > greg k-h
> 
> GMail GUI is a nightmare, I can't find an option to tell it to let me
> send whatever I want... :(
> I will use Thunderbird then !

Please see Documentation/email-clients.txt for help with this.

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

* Re: [PATCH v4] Lattice ECP3 FPGA: Correct endianness
  2014-07-24  7:37     ` Greg KH
@ 2014-07-24  8:21       ` Jean-Michel Hautbois
  0 siblings, 0 replies; 5+ messages in thread
From: Jean-Michel Hautbois @ 2014-07-24  8:21 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, Arnd Bergmann, Stefan Roese

2014-07-24 9:37 GMT+02:00 Greg KH <gregkh@linuxfoundation.org>:
> On Thu, Jul 24, 2014 at 08:53:30AM +0200, Jean-Michel Hautbois wrote:
>> > Your email client ate all the tabs and spit out spaces and then
>> > line-wrapped the patch, making it impossible to apply :(
>> >
>> > Can you fix it up and resend it in a format we can use?
>> >
>> > thanks,
>> >
>> > greg k-h
>>
>> GMail GUI is a nightmare, I can't find an option to tell it to let me
>> send whatever I want... :(
>> I will use Thunderbird then !
>
> Please see Documentation/email-clients.txt for help with this.

Thanks, as expected, GMail is a crap :).
Do I resend this patch as [PATCH v5] or as a reply to this mail ?

JM

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

end of thread, other threads:[~2014-07-24  8:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-23  9:39 [PATCH v4] Lattice ECP3 FPGA: Correct endianness Jean-Michel Hautbois
2014-07-23 23:58 ` Greg KH
2014-07-24  6:53   ` Jean-Michel Hautbois
2014-07-24  7:37     ` Greg KH
2014-07-24  8:21       ` Jean-Michel Hautbois

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