* [PATCH] mtd: devices: fix mchp23k256 read and write
@ 2019-10-30 11:39 Angelo Dureghello
2019-11-05 18:41 ` Miquel Raynal
2019-11-12 14:19 ` Miquel Raynal
0 siblings, 2 replies; 6+ messages in thread
From: Angelo Dureghello @ 2019-10-30 11:39 UTC (permalink / raw)
To: vigneshr, richard, miquel.raynal; +Cc: linux-mtd, angelo.dureghello
Due to the use of sizeof(), command size set for the spi transfer
was wrong. Driver was sending and receiving always 1 byte less
and especially on write, it was hanging.
echo -n -e "\\x1\\x2\\x3\\x4" > /dev/mtd1
And read part too now works as expected.
hexdump -C -n16 /dev/mtd1
00000000 01 02 03 04 ab f3 ad c2 ab e3 f4 36 dd 38 04 15
00000010
Signed-off-by: Angelo Dureghello <angelo.dureghello@timesys.com>
---
drivers/mtd/devices/mchp23k256.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/drivers/mtd/devices/mchp23k256.c b/drivers/mtd/devices/mchp23k256.c
index b20d02b4f830..77c872fd3d83 100644
--- a/drivers/mtd/devices/mchp23k256.c
+++ b/drivers/mtd/devices/mchp23k256.c
@@ -64,15 +64,17 @@ static int mchp23k256_write(struct mtd_info *mtd, loff_t to, size_t len,
struct spi_transfer transfer[2] = {};
struct spi_message message;
unsigned char command[MAX_CMD_SIZE];
- int ret;
+ int ret, cmd_len;
spi_message_init(&message);
+ cmd_len = mchp23k256_cmdsz(flash);
+
command[0] = MCHP23K256_CMD_WRITE;
mchp23k256_addr2cmd(flash, to, command);
transfer[0].tx_buf = command;
- transfer[0].len = mchp23k256_cmdsz(flash);
+ transfer[0].len = cmd_len;
spi_message_add_tail(&transfer[0], &message);
transfer[1].tx_buf = buf;
@@ -88,8 +90,8 @@ static int mchp23k256_write(struct mtd_info *mtd, loff_t to, size_t len,
if (ret)
return ret;
- if (retlen && message.actual_length > sizeof(command))
- *retlen += message.actual_length - sizeof(command);
+ if (retlen && message.actual_length > cmd_len)
+ *retlen += message.actual_length - cmd_len;
return 0;
}
@@ -101,16 +103,18 @@ static int mchp23k256_read(struct mtd_info *mtd, loff_t from, size_t len,
struct spi_transfer transfer[2] = {};
struct spi_message message;
unsigned char command[MAX_CMD_SIZE];
- int ret;
+ int ret, cmd_len;
spi_message_init(&message);
+ cmd_len = mchp23k256_cmdsz(flash);
+
memset(&transfer, 0, sizeof(transfer));
command[0] = MCHP23K256_CMD_READ;
mchp23k256_addr2cmd(flash, from, command);
transfer[0].tx_buf = command;
- transfer[0].len = mchp23k256_cmdsz(flash);
+ transfer[0].len = cmd_len;
spi_message_add_tail(&transfer[0], &message);
transfer[1].rx_buf = buf;
@@ -126,8 +130,8 @@ static int mchp23k256_read(struct mtd_info *mtd, loff_t from, size_t len,
if (ret)
return ret;
- if (retlen && message.actual_length > sizeof(command))
- *retlen += message.actual_length - sizeof(command);
+ if (retlen && message.actual_length > cmd_len)
+ *retlen += message.actual_length - cmd_len;
return 0;
}
--
2.23.0
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] mtd: devices: fix mchp23k256 read and write
2019-10-30 11:39 [PATCH] mtd: devices: fix mchp23k256 read and write Angelo Dureghello
@ 2019-11-05 18:41 ` Miquel Raynal
2019-11-05 23:17 ` Andrew Lunn
2019-11-12 14:19 ` Miquel Raynal
1 sibling, 1 reply; 6+ messages in thread
From: Miquel Raynal @ 2019-11-05 18:41 UTC (permalink / raw)
To: Angelo Dureghello; +Cc: richard, linux-mtd, vigneshr, andrew
Hi Angelo,
+ Andrew
Angelo Dureghello <angelo.dureghello@timesys.com> wrote on Wed, 30 Oct
2019 12:39:57 +0100:
> Due to the use of sizeof(), command size set for the spi transfer
> was wrong. Driver was sending and receiving always 1 byte less
> and especially on write, it was hanging.
>
> echo -n -e "\\x1\\x2\\x3\\x4" > /dev/mtd1
>
> And read part too now works as expected.
>
> hexdump -C -n16 /dev/mtd1
> 00000000 01 02 03 04 ab f3 ad c2 ab e3 f4 36 dd 38 04 15
> 00000010
>
Looks fine by me, just added Andrew in case he wants to review the
patch as he was the original committer.
Anyway you're missing a Cc: stable and Fixes tag on
5dc17fa6fb70 ("mtd: mchp23k256: Add driver for this SPI SRAM device")
Thanks,
Miquèl
> Signed-off-by: Angelo Dureghello <angelo.dureghello@timesys.com>
> ---
> drivers/mtd/devices/mchp23k256.c | 20 ++++++++++++--------
> 1 file changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/mtd/devices/mchp23k256.c b/drivers/mtd/devices/mchp23k256.c
> index b20d02b4f830..77c872fd3d83 100644
> --- a/drivers/mtd/devices/mchp23k256.c
> +++ b/drivers/mtd/devices/mchp23k256.c
> @@ -64,15 +64,17 @@ static int mchp23k256_write(struct mtd_info *mtd, loff_t to, size_t len,
> struct spi_transfer transfer[2] = {};
> struct spi_message message;
> unsigned char command[MAX_CMD_SIZE];
> - int ret;
> + int ret, cmd_len;
>
> spi_message_init(&message);
>
> + cmd_len = mchp23k256_cmdsz(flash);
> +
> command[0] = MCHP23K256_CMD_WRITE;
> mchp23k256_addr2cmd(flash, to, command);
>
> transfer[0].tx_buf = command;
> - transfer[0].len = mchp23k256_cmdsz(flash);
> + transfer[0].len = cmd_len;
> spi_message_add_tail(&transfer[0], &message);
>
> transfer[1].tx_buf = buf;
> @@ -88,8 +90,8 @@ static int mchp23k256_write(struct mtd_info *mtd, loff_t to, size_t len,
> if (ret)
> return ret;
>
> - if (retlen && message.actual_length > sizeof(command))
> - *retlen += message.actual_length - sizeof(command);
> + if (retlen && message.actual_length > cmd_len)
> + *retlen += message.actual_length - cmd_len;
>
> return 0;
> }
> @@ -101,16 +103,18 @@ static int mchp23k256_read(struct mtd_info *mtd, loff_t from, size_t len,
> struct spi_transfer transfer[2] = {};
> struct spi_message message;
> unsigned char command[MAX_CMD_SIZE];
> - int ret;
> + int ret, cmd_len;
>
> spi_message_init(&message);
>
> + cmd_len = mchp23k256_cmdsz(flash);
> +
> memset(&transfer, 0, sizeof(transfer));
> command[0] = MCHP23K256_CMD_READ;
> mchp23k256_addr2cmd(flash, from, command);
>
> transfer[0].tx_buf = command;
> - transfer[0].len = mchp23k256_cmdsz(flash);
> + transfer[0].len = cmd_len;
> spi_message_add_tail(&transfer[0], &message);
>
> transfer[1].rx_buf = buf;
> @@ -126,8 +130,8 @@ static int mchp23k256_read(struct mtd_info *mtd, loff_t from, size_t len,
> if (ret)
> return ret;
>
> - if (retlen && message.actual_length > sizeof(command))
> - *retlen += message.actual_length - sizeof(command);
> + if (retlen && message.actual_length > cmd_len)
> + *retlen += message.actual_length - cmd_len;
>
> return 0;
> }
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mtd: devices: fix mchp23k256 read and write
2019-11-05 18:41 ` Miquel Raynal
@ 2019-11-05 23:17 ` Andrew Lunn
2019-11-05 23:39 ` Miquel Raynal
[not found] ` <CALJHbkDoiireW8iNqGgqRRQdQcKjiLVnxUcFBGkgzE=qsba7-A@mail.gmail.com>
0 siblings, 2 replies; 6+ messages in thread
From: Andrew Lunn @ 2019-11-05 23:17 UTC (permalink / raw)
To: Miquel Raynal; +Cc: richard, linux-mtd, Angelo Dureghello, vigneshr
On Tue, Nov 05, 2019 at 07:41:22PM +0100, Miquel Raynal wrote:
> Hi Angelo,
>
> + Andrew
>
> Angelo Dureghello <angelo.dureghello@timesys.com> wrote on Wed, 30 Oct
> 2019 12:39:57 +0100:
>
> > Due to the use of sizeof(), command size set for the spi transfer
> > was wrong. Driver was sending and receiving always 1 byte less
> > and especially on write, it was hanging.
> >
> > echo -n -e "\\x1\\x2\\x3\\x4" > /dev/mtd1
> >
> > And read part too now works as expected.
> >
> > hexdump -C -n16 /dev/mtd1
> > 00000000 01 02 03 04 ab f3 ad c2 ab e3 f4 36 dd 38 04 15
> > 00000010
> >
>
> Looks fine by me, just added Andrew in case he wants to review the
> patch as he was the original committer.
>
> Anyway you're missing a Cc: stable and Fixes tag on
> 5dc17fa6fb70 ("mtd: mchp23k256: Add driver for this SPI SRAM device")
Hi Miquèl
This is the wrong fixes tag. The correct one is
Fixes: 4379075a870b ("mtd: mchp23k256: Add support for mchp23lcv1024")
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mtd: devices: fix mchp23k256 read and write
2019-11-05 23:17 ` Andrew Lunn
@ 2019-11-05 23:39 ` Miquel Raynal
[not found] ` <CALJHbkDoiireW8iNqGgqRRQdQcKjiLVnxUcFBGkgzE=qsba7-A@mail.gmail.com>
1 sibling, 0 replies; 6+ messages in thread
From: Miquel Raynal @ 2019-11-05 23:39 UTC (permalink / raw)
To: Andrew Lunn; +Cc: richard, linux-mtd, Angelo Dureghello, vigneshr
Hi Andrew,
Andrew Lunn <andrew@lunn.ch> wrote on Wed, 6 Nov 2019 00:17:09 +0100:
> On Tue, Nov 05, 2019 at 07:41:22PM +0100, Miquel Raynal wrote:
> > Hi Angelo,
> >
> > + Andrew
> >
> > Angelo Dureghello <angelo.dureghello@timesys.com> wrote on Wed, 30 Oct
> > 2019 12:39:57 +0100:
> >
> > > Due to the use of sizeof(), command size set for the spi transfer
> > > was wrong. Driver was sending and receiving always 1 byte less
> > > and especially on write, it was hanging.
> > >
> > > echo -n -e "\\x1\\x2\\x3\\x4" > /dev/mtd1
> > >
> > > And read part too now works as expected.
> > >
> > > hexdump -C -n16 /dev/mtd1
> > > 00000000 01 02 03 04 ab f3 ad c2 ab e3 f4 36 dd 38 04 15
> > > 00000010
> > >
> >
> > Looks fine by me, just added Andrew in case he wants to review the
> > patch as he was the original committer.
> >
> > Anyway you're missing a Cc: stable and Fixes tag on
> > 5dc17fa6fb70 ("mtd: mchp23k256: Add driver for this SPI SRAM device")
>
> Hi Miquèl
>
> This is the wrong fixes tag. The correct one is
>
> Fixes: 4379075a870b ("mtd: mchp23k256: Add support for mchp23lcv1024")
Oh crap, you're right, thanks for the correction!
>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
>
> Andrew
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <CALJHbkDoiireW8iNqGgqRRQdQcKjiLVnxUcFBGkgzE=qsba7-A@mail.gmail.com>]
* Re: [PATCH] mtd: devices: fix mchp23k256 read and write
[not found] ` <CALJHbkDoiireW8iNqGgqRRQdQcKjiLVnxUcFBGkgzE=qsba7-A@mail.gmail.com>
@ 2019-11-11 16:56 ` Angelo Dureghello
0 siblings, 0 replies; 6+ messages in thread
From: Angelo Dureghello @ 2019-11-11 16:56 UTC (permalink / raw)
Cc: linux-mtd
Hi all,
many thanks.
Let me know if i need to prepare a v1 with proper tags in case.
Regards,
Angelo
On Wed, Nov 6, 2019 at 12:17 AM Andrew Lunn <andrew@lunn.ch> wrote:
>
> On Tue, Nov 05, 2019 at 07:41:22PM +0100, Miquel Raynal wrote:
> > Hi Angelo,
> >
> > + Andrew
> >
> > Angelo Dureghello <angelo.dureghello@timesys.com> wrote on Wed, 30 Oct
> > 2019 12:39:57 +0100:
> >
> > > Due to the use of sizeof(), command size set for the spi transfer
> > > was wrong. Driver was sending and receiving always 1 byte less
> > > and especially on write, it was hanging.
> > >
> > > echo -n -e "\\x1\\x2\\x3\\x4" > /dev/mtd1
> > >
> > > And read part too now works as expected.
> > >
> > > hexdump -C -n16 /dev/mtd1
> > > 00000000 01 02 03 04 ab f3 ad c2 ab e3 f4 36 dd 38 04 15
> > > 00000010
> > >
> >
> > Looks fine by me, just added Andrew in case he wants to review the
> > patch as he was the original committer.
> >
> > Anyway you're missing a Cc: stable and Fixes tag on
> > 5dc17fa6fb70 ("mtd: mchp23k256: Add driver for this SPI SRAM device")
>
> Hi Miqučl
>
> This is the wrong fixes tag. The correct one is
>
> Fixes: 4379075a870b ("mtd: mchp23k256: Add support for mchp23lcv1024")
>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
>
> Andrew
--
Angelo Dureghello
Timesys
email: angelo.dureghello@timesys.com
cell.: +39 388 8550663
--
Angelo Dureghello
Timesys
email: angelo.dureghello@timesys.com
cell.: +39 388 8550663
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mtd: devices: fix mchp23k256 read and write
2019-10-30 11:39 [PATCH] mtd: devices: fix mchp23k256 read and write Angelo Dureghello
2019-11-05 18:41 ` Miquel Raynal
@ 2019-11-12 14:19 ` Miquel Raynal
1 sibling, 0 replies; 6+ messages in thread
From: Miquel Raynal @ 2019-11-12 14:19 UTC (permalink / raw)
To: Angelo Dureghello, vigneshr, richard, miquel.raynal; +Cc: linux-mtd
On Wed, 2019-10-30 at 11:39:57 UTC, Angelo Dureghello wrote:
> Due to the use of sizeof(), command size set for the spi transfer
> was wrong. Driver was sending and receiving always 1 byte less
> and especially on write, it was hanging.
>
> echo -n -e "\\x1\\x2\\x3\\x4" > /dev/mtd1
>
> And read part too now works as expected.
>
> hexdump -C -n16 /dev/mtd1
> 00000000 01 02 03 04 ab f3 ad c2 ab e3 f4 36 dd 38 04 15
> 00000010
>
> Signed-off-by: Angelo Dureghello <angelo.dureghello@timesys.com>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.
Miquel
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-11-12 14:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-30 11:39 [PATCH] mtd: devices: fix mchp23k256 read and write Angelo Dureghello
2019-11-05 18:41 ` Miquel Raynal
2019-11-05 23:17 ` Andrew Lunn
2019-11-05 23:39 ` Miquel Raynal
[not found] ` <CALJHbkDoiireW8iNqGgqRRQdQcKjiLVnxUcFBGkgzE=qsba7-A@mail.gmail.com>
2019-11-11 16:56 ` Angelo Dureghello
2019-11-12 14:19 ` Miquel Raynal
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.