* [PATCH 1/2] mtd: sh_flctl: Use memcpy() instead of using a loop
@ 2012-07-05 10:41 Bastian Hecht
2012-07-05 10:41 ` [PATCH 2/2] mtd: sh_flctl: Only copy OOB data if it is required Bastian Hecht
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Bastian Hecht @ 2012-07-05 10:41 UTC (permalink / raw)
To: linux-mtd; +Cc: Bastian Hecht, Linux-SH
Elemets have been copied "manually" in a loop. Better use memcpy().
Signed-off-by: Bastian Hecht <hechtb@gmail.com>
---
drivers/mtd/nand/sh_flctl.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/mtd/nand/sh_flctl.c b/drivers/mtd/nand/sh_flctl.c
index 0d9cce7..e4f31ef 100644
--- a/drivers/mtd/nand/sh_flctl.c
+++ b/drivers/mtd/nand/sh_flctl.c
@@ -29,6 +29,7 @@
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/slab.h>
+#include <linux/string.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
@@ -748,10 +749,9 @@ static void flctl_select_chip(struct mtd_info *mtd, int chipnr)
static void flctl_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
{
struct sh_flctl *flctl = mtd_to_flctl(mtd);
- int i, index = flctl->index;
+ int index = flctl->index;
- for (i = 0; i < len; i++)
- flctl->done_buff[index + i] = buf[i];
+ memcpy(&flctl->done_buff[index], buf, len);
flctl->index += len;
}
@@ -780,10 +780,11 @@ static uint16_t flctl_read_word(struct mtd_info *mtd)
static void flctl_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
{
- int i;
+ struct sh_flctl *flctl = mtd_to_flctl(mtd);
+ int index = flctl->index;
- for (i = 0; i < len; i++)
- buf[i] = flctl_read_byte(mtd);
+ memcpy(buf, &flctl->done_buff[index], len);
+ flctl->index += len;
}
static int flctl_verify_buf(struct mtd_info *mtd, const u_char *buf, int len)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] mtd: sh_flctl: Only copy OOB data if it is required
2012-07-05 10:41 [PATCH 1/2] mtd: sh_flctl: Use memcpy() instead of using a loop Bastian Hecht
@ 2012-07-05 10:41 ` Bastian Hecht
2012-07-06 0:10 ` [PATCH 1/2] mtd: sh_flctl: Use memcpy() instead of using a loop Simon Horman
2012-07-18 12:03 ` Artem Bityutskiy
2 siblings, 0 replies; 4+ messages in thread
From: Bastian Hecht @ 2012-07-05 10:41 UTC (permalink / raw)
To: linux-mtd; +Cc: Bastian Hecht, Linux-SH
Check the new oob_required flag and only copy the OOB data to the internal
buffer if needed.
Signed-off-by: Bastian Hecht <hechtb@gmail.com>
---
I did this only for reading, as for writing the current code would write random data to the non-ECC OOB area when oob_required is false, so I preferred taking the data from the nand_base layer.
drivers/mtd/nand/sh_flctl.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/sh_flctl.c b/drivers/mtd/nand/sh_flctl.c
index e4f31ef..0b798fb 100644
--- a/drivers/mtd/nand/sh_flctl.c
+++ b/drivers/mtd/nand/sh_flctl.c
@@ -398,7 +398,8 @@ static int flctl_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,
uint8_t *buf, int oob_required, int page)
{
chip->read_buf(mtd, buf, mtd->writesize);
- chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
+ if (oob_required)
+ chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
return 0;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] mtd: sh_flctl: Use memcpy() instead of using a loop
2012-07-05 10:41 [PATCH 1/2] mtd: sh_flctl: Use memcpy() instead of using a loop Bastian Hecht
2012-07-05 10:41 ` [PATCH 2/2] mtd: sh_flctl: Only copy OOB data if it is required Bastian Hecht
@ 2012-07-06 0:10 ` Simon Horman
2012-07-18 12:03 ` Artem Bityutskiy
2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2012-07-06 0:10 UTC (permalink / raw)
To: Bastian Hecht; +Cc: Bastian Hecht, linux-mtd, Linux-SH
On Thu, Jul 05, 2012 at 12:41:01PM +0200, Bastian Hecht wrote:
> Elemets have been copied "manually" in a loop. Better use memcpy().
>
> Signed-off-by: Bastian Hecht <hechtb@gmail.com>
Reviewed-by: Simon Horman <horms@verge.net.au>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] mtd: sh_flctl: Use memcpy() instead of using a loop
2012-07-05 10:41 [PATCH 1/2] mtd: sh_flctl: Use memcpy() instead of using a loop Bastian Hecht
2012-07-05 10:41 ` [PATCH 2/2] mtd: sh_flctl: Only copy OOB data if it is required Bastian Hecht
2012-07-06 0:10 ` [PATCH 1/2] mtd: sh_flctl: Use memcpy() instead of using a loop Simon Horman
@ 2012-07-18 12:03 ` Artem Bityutskiy
2 siblings, 0 replies; 4+ messages in thread
From: Artem Bityutskiy @ 2012-07-18 12:03 UTC (permalink / raw)
To: Bastian Hecht; +Cc: Bastian Hecht, linux-mtd, Linux-SH
[-- Attachment #1: Type: text/plain, Size: 261 bytes --]
On Thu, 2012-07-05 at 12:41 +0200, Bastian Hecht wrote:
> Elemets have been copied "manually" in a loop. Better use memcpy().
>
> Signed-off-by: Bastian Hecht <hechtb@gmail.com>
Pushed both to l2-mtd.git, thanks!
--
Best Regards,
Artem Bityutskiy
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-07-18 12:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-05 10:41 [PATCH 1/2] mtd: sh_flctl: Use memcpy() instead of using a loop Bastian Hecht
2012-07-05 10:41 ` [PATCH 2/2] mtd: sh_flctl: Only copy OOB data if it is required Bastian Hecht
2012-07-06 0:10 ` [PATCH 1/2] mtd: sh_flctl: Use memcpy() instead of using a loop Simon Horman
2012-07-18 12:03 ` Artem Bityutskiy
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).