[U-Boot] [PATCH] FSL SPI read fix.

The fsl spi engine is non functional when reading from a device. This patch fixes it.
Note that none of the other spi interfaces parse through the datastream looking for 0x0b bytes.
-Dale
diff --git a/drivers/spi/fsl_espi.c b/drivers/spi/fsl_espi.c index a1ebd33..737719b 100644 --- a/drivers/spi/fsl_espi.c +++ b/drivers/spi/fsl_espi.c @@ -291,17 +291,10 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *data_out, debug("***spi_xfer:...%08x readed\n", tmpdin); } } - if (data_in) { - memcpy(data_in, buffer + 2 * cmd_len, tran_len); - if (*buffer == 0x0b) { - data_in += tran_len; - data_len -= tran_len; - *(int *)buffer += tran_len; - } - } spi_cs_deactivate(slave); } - + if (data_in) + memcpy(data_in, buffer + rx_offset, len); free(buffer); return 0; }

Hi,
Can you please update the commit header and logic of the code w.r.t current master tree.
also please use proper commit body.
-- Thanks, Jagan.
On 27-09-2012 02:37, Dale Smith wrote:
The fsl spi engine is non functional when reading from a device. This patch fixes it.
Note that none of the other spi interfaces parse through the datastream looking for 0x0b bytes.
-Dale
}
diff --git a/drivers/spi/fsl_espi.c b/drivers/spi/fsl_espi.c index a1ebd33..737719b 100644 --- a/drivers/spi/fsl_espi.c +++ b/drivers/spi/fsl_espi.c @@ -291,17 +291,10 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *data_out, debug("***spi_xfer:...%08x readed\n", tmpdin); } }
if (data_in) {
memcpy(data_in, buffer + 2 * cmd_len, tran_len);
if (*buffer == 0x0b) {
data_in += tran_len;
data_len -= tran_len;
*(int *)buffer += tran_len;
}
spi_cs_deactivate(slave); }}
- if (data_in)
free(buffer); return 0;memcpy(data_in, buffer + rx_offset, len);

Signed-off-by: Dale P. Smith dsmith@vtiinstruments.com --- drivers/spi/fsl_espi.c | 10 ++-------- 1 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/spi/fsl_espi.c b/drivers/spi/fsl_espi.c index 28609ee..bd9dc64 100644 --- a/drivers/spi/fsl_espi.c +++ b/drivers/spi/fsl_espi.c @@ -287,17 +287,11 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *data_out, debug("***spi_xfer:...%08x readed\n", tmpdin); } } - if (data_in) { - memcpy(data_in, buffer + 2 * cmd_len, tran_len); - if (*buffer == 0x0b) { - data_in += tran_len; - data_len -= tran_len; - *(int *)buffer += tran_len; - } - } spi_cs_deactivate(slave); }
+ if (data_in) + memcpy(data_in, buffer + rx_offset, len); free(buffer); return 0; }

Hi,
Thanks for sending this.
Few comments. 1. Please use subject prefix with version number this case it should be "PATH v3" 2. Commit header should be stand' one as all follows. " spi: fsl_espi: "
On Thu, Jun 13, 2013 at 3:24 AM, Dale P. Smith dsmith@vtiinstruments.com wrote:
Signed-off-by: Dale P. Smith dsmith@vtiinstruments.com
drivers/spi/fsl_espi.c | 10 ++-------- 1 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/spi/fsl_espi.c b/drivers/spi/fsl_espi.c index 28609ee..bd9dc64 100644 --- a/drivers/spi/fsl_espi.c +++ b/drivers/spi/fsl_espi.c @@ -287,17 +287,11 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *data_out, debug("***spi_xfer:...%08x readed\n", tmpdin); } }
if (data_in) {
memcpy(data_in, buffer + 2 * cmd_len, tran_len);
if (*buffer == 0x0b) {
data_in += tran_len;
data_len -= tran_len;
*(int *)buffer += tran_len;
}
} spi_cs_deactivate(slave); }
if (data_in)
memcpy(data_in, buffer + rx_offset, len); free(buffer); return 0;
Have tested this recently?
Thanks, Jagan.

Hi Jagan, Dale,
On Thu, 13 Jun 2013 08:09:04 +0530, Jagan Teki jagannadh.teki@gmail.com wrote:
Hi,
Thanks for sending this.
Few comments.
- Please use subject prefix with version number this case it should
be "PATH v3"
Plus if it is v3, then it should have patch history too.
Amicalement,

On Thu, Jun 13, 2013 at 2:39 PM, Albert ARIBAUD albert.u.boot@aribaud.net wrote:
Hi Jagan, Dale,
On Thu, 13 Jun 2013 08:09:04 +0530, Jagan Teki jagannadh.teki@gmail.com wrote:
Hi,
Thanks for sending this.
Few comments.
- Please use subject prefix with version number this case it should
be "PATH v3"
Plus if it is v3, then it should have patch history too.
Thanks Amicalement,
Hi Dale,
Please refer these 3 points for sending your v3. I am just pointing to a link for sending version patches ignore this if you know it already http://www.denx.de/wiki/view/U-Boot/Patches#Sending_updated_patch_versions
-- Thanks, Jagan.

Signed-off-by: Dale P. Smith dsmith@vtiinstruments.com --- Changes for v2: - First attempt at using git format-patch Changes for v3: - Fix subject. - Add changelog
drivers/spi/fsl_espi.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/spi/fsl_espi.c b/drivers/spi/fsl_espi.c index b1586d1..c84a7ea 100644 --- a/drivers/spi/fsl_espi.c +++ b/drivers/spi/fsl_espi.c @@ -345,17 +345,11 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *data_out, } } } - if (data_in) { - memcpy(data_in, buffer + 2 * cmd_len, tran_len); - if (*buffer == 0x0b) { - data_in += tran_len; - data_len -= tran_len; - *(int *)buffer += tran_len; - } - } spi_cs_deactivate(slave); }
+ if (data_in) + memcpy(data_in, buffer + rx_offset, len); free(buffer); return 0; }

On Fri, 2015-12-11 at 21:19 -0500, Dale P. Smith wrote:
Signed-off-by: Dale P. Smith dsmith@vtiinstruments.com
Changes for v2: - First attempt at using git format-patch Changes for v3: - Fix subject. - Add changelog
While this is a step in the right direction, this driver needs a rewrite. - The malloc/memcpy crap need to go. - TXing 4 bytes a time while while word size is still one byte makes Not full/Not empty HW flags useless. There is no real maintainer of this driver though so I am afraid nobody will do make this happen.
drivers/spi/fsl_espi.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/spi/fsl_espi.c b/drivers/spi/fsl_espi.c index b1586d1..c84a7ea 100644 --- a/drivers/spi/fsl_espi.c +++ b/drivers/spi/fsl_espi.c @@ -345,17 +345,11 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *data_out, } } }
if (data_in) {
memcpy(data_in, buffer + 2 * cmd_len, tran_len);
if (*buffer == 0x0b) {
data_in += tran_len;
data_len -= tran_len;
*(int *)buffer += tran_len;
}
}
spi_cs_deactivate(slave); }
- if (data_in)
memcpy(data_in, buffer + rx_offset, len);
free(buffer); return 0; }

On 12 December 2015 at 22:40, Joakim Tjernlund Joakim.Tjernlund@infinera.com wrote:
On Fri, 2015-12-11 at 21:19 -0500, Dale P. Smith wrote:
Signed-off-by: Dale P. Smith dsmith@vtiinstruments.com
Changes for v2:
- First attempt at using git format-patch
Changes for v3:
- Fix subject.
- Add changelog
While this is a step in the right direction, this driver needs a rewrite.
- The malloc/memcpy crap need to go.
- TXing 4 bytes a time while while word size is still one byte makes Not full/Not empty HW flags useless.
There is no real maintainer of this driver though so I am afraid nobody will do make this happen.
Please try to write it in driver model format, let me know for any help.
thanks!
participants (6)
-
Albert ARIBAUD
-
Dale P. Smith
-
Dale Smith
-
Jagan Teki
-
Jagan Teki
-
Joakim Tjernlund