* [PATCH] [MTD-UTILS] Add support for 4KB page flash devices
@ 2008-09-19 12:41 AYYANARPONNUSAMY GANGHEYAMOORTHY
2008-09-22 6:22 ` Kyungmin Park
0 siblings, 1 reply; 6+ messages in thread
From: AYYANARPONNUSAMY GANGHEYAMOORTHY @ 2008-09-19 12:41 UTC (permalink / raw)
To: linux-mtd; +Cc: David.Woodhouse
We can now use these utilities on 4KB devices.
Signed-off-by: Rohit Hagargundgi <h.rohit@samsung.com>
---
--- a/flash_otp_write.c 2008-06-27 21:51:28.000000000 +0530
+++ b/flash_otp_write.c 2008-07-01 16:04:12.000000000 +0530
@@ -18,7 +18,7 @@ int main(int argc,char *argv[])
int fd, val, ret, size, wrote, len;
mtd_info_t mtdInfo;
off_t offset;
- char *p, buf[2048];
+ char *p, buf[4096];
if (argc != 4 || strcmp(argv[1], "-u")) {
fprintf(stderr, "Usage: %s -u <device> <offset>\n", argv[0]);
--- a/include/mtd/mtd-abi.h 2008-06-27 21:51:28.000000000 +0530
+++ b/include/mtd/mtd-abi.h 2008-06-30 18:51:39.000000000 +0530
@@ -104,7 +104,7 @@ struct nand_oobinfo {
uint32_t useecc;
uint32_t eccbytes;
uint32_t oobfree[8][2];
- uint32_t eccpos[32];
+ uint32_t eccpos[128];
};
struct nand_oobfree {
@@ -119,7 +119,7 @@ struct nand_oobfree {
*/
struct nand_ecclayout {
uint32_t eccbytes;
- uint32_t eccpos[64];
+ uint32_t eccpos[128];
uint32_t oobavail;
struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES];
};
--- a/flashcp.c 2008-06-27 21:51:28.000000000 +0530
+++ b/flashcp.c 2008-07-02 14:49:21.000000000 +0530
@@ -61,7 +62,7 @@ typedef int bool;
#define PERCENTAGE(x,total) (((x) * 100) / (total))
/* size of read/write buffer */
-#define BUFSIZE (10 * 1024)
+#define BUFSIZE (10 * 4096)
/* cmd-line flags */
#define FLAG_NONE 0x00
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] [MTD-UTILS] Add support for 4KB page flash devices 2008-09-19 12:41 [PATCH] [MTD-UTILS] Add support for 4KB page flash devices AYYANARPONNUSAMY GANGHEYAMOORTHY @ 2008-09-22 6:22 ` Kyungmin Park 2008-09-22 9:19 ` Sergei Shtylyov 2008-09-23 11:25 ` apgmoorthy 0 siblings, 2 replies; 6+ messages in thread From: Kyungmin Park @ 2008-09-22 6:22 UTC (permalink / raw) To: moorthy.apg; +Cc: linux-mtd, David.Woodhouse Hi, On Fri, Sep 19, 2008 at 9:41 PM, AYYANARPONNUSAMY GANGHEYAMOORTHY <moorthy.apg@samsung.com> wrote: > We can now use these utilities on 4KB devices. > > Signed-off-by: Rohit Hagargundgi <h.rohit@samsung.com> > --- > --- a/flash_otp_write.c 2008-06-27 21:51:28.000000000 +0530 > +++ b/flash_otp_write.c 2008-07-01 16:04:12.000000000 +0530 > @@ -18,7 +18,7 @@ int main(int argc,char *argv[]) > int fd, val, ret, size, wrote, len; > mtd_info_t mtdInfo; > off_t offset; > - char *p, buf[2048]; > + char *p, buf[4096]; > Is it no problem the stack overflow in application? How about to use malloc & free? Thank you, Kyungmin Park ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [MTD-UTILS] Add support for 4KB page flash devices 2008-09-22 6:22 ` Kyungmin Park @ 2008-09-22 9:19 ` Sergei Shtylyov 2008-09-23 11:25 ` apgmoorthy 1 sibling, 0 replies; 6+ messages in thread From: Sergei Shtylyov @ 2008-09-22 9:19 UTC (permalink / raw) To: Kyungmin Park; +Cc: moorthy.apg, linux-mtd, David.Woodhouse Hello. Kyungmin Park wrote: >> We can now use these utilities on 4KB devices. >> >> Signed-off-by: Rohit Hagargundgi <h.rohit@samsung.com> >> --- >> --- a/flash_otp_write.c 2008-06-27 21:51:28.000000000 +0530 >> +++ b/flash_otp_write.c 2008-07-01 16:04:12.000000000 +0530 >> @@ -18,7 +18,7 @@ int main(int argc,char *argv[]) >> int fd, val, ret, size, wrote, len; >> mtd_info_t mtdInfo; >> off_t offset; >> - char *p, buf[2048]; >> + char *p, buf[4096]; >> >> > > Is it no problem the stack overflow in application? > How about to use malloc & free? > Come on, it's only an extra page of stack for a non-recursive function -- this shouldn't pose any danger. WBR, Sergei ^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH] [MTD-UTILS] Add support for 4KB page flash devices 2008-09-22 6:22 ` Kyungmin Park 2008-09-22 9:19 ` Sergei Shtylyov @ 2008-09-23 11:25 ` apgmoorthy 2008-09-26 0:28 ` Kyungmin Park 1 sibling, 1 reply; 6+ messages in thread From: apgmoorthy @ 2008-09-23 11:25 UTC (permalink / raw) To: 'Kyungmin Park'; +Cc: linux-mtd, David.Woodhouse Hi, I find not much issue with that, but still as a fair practice , I'll absorb your comment in the patch. Have done the memory allocation later in the function to avoid unnecessary freeing code. And malloced with mtdInfo.writesize instead of constants , let us know your comments. We can now use these utilities on 4KB devices. Signed-off-by: Rohit Hagargundgi <h.rohit@samsung.com> --- --- a/flashcp.c 2008-09-23 15:36:26.000000000 +0530 +++ b/flashcp.c 2008-09-23 15:49:42.000000000 +0530 @@ -61,7 +61,7 @@ typedef int bool; #define PERCENTAGE(x,total) (((x) * 100) / (total)) /* size of read/write buffer */ -#define BUFSIZE (10 * 1024) +#define BUFSIZE (10 * 4096) /* cmd-line flags */ #define FLAG_NONE 0x00 --- a/flash_otp_write.c 2008-09-23 15:36:26.000000000 +0530 +++ b/flash_otp_write.c 2008-09-23 16:45:01.000000000 +0530 @@ -18,7 +18,7 @@ int main(int argc,char *argv[]) int fd, val, ret, size, wrote, len; mtd_info_t mtdInfo; off_t offset; - char *p, buf[2048]; + char *p, *buf; if (argc != 4 || strcmp(argv[1], "-u")) { fprintf(stderr, "Usage: %s -u <device> <offset>\n", argv[0]); @@ -64,9 +64,16 @@ int main(int argc,char *argv[]) len = 256; wrote = 0; + + buf = (char *)malloc(mtdInfo.writesize); + if (!buf) { + return -ENOMEM; + } + while ((size = read(0, buf, len))) { if (size < 0) { perror("read()"); + free(buf); return errno; } p = buf; @@ -79,10 +86,12 @@ int main(int argc,char *argv[]) ret = write(fd, p, size); if (ret < 0) { perror("write()"); + free(buf); return errno; } if (ret == 0) { printf("write() returned 0 after writing %d bytes\n", wrote); + free(buf); return 0; } p += ret; @@ -92,5 +101,6 @@ int main(int argc,char *argv[]) } printf("Wrote %d bytes of OTP user data\n", wrote); + free(buf); return 0; } --- a/include/mtd/mtd-abi.h 2008-09-23 15:36:26.000000000 +0530 +++ b/include/mtd/mtd-abi.h 2008-09-23 15:48:48.000000000 +0530 @@ -104,7 +104,7 @@ struct nand_oobinfo { uint32_t useecc; uint32_t eccbytes; uint32_t oobfree[8][2]; - uint32_t eccpos[32]; + uint32_t eccpos[128]; }; struct nand_oobfree { @@ -119,7 +119,7 @@ struct nand_oobfree { */ struct nand_ecclayout { uint32_t eccbytes; - uint32_t eccpos[64]; + uint32_t eccpos[128]; uint32_t oobavail; struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES]; }; -----Original Message----- From: kyungmin78@gmail.com [mailto:kyungmin78@gmail.com] On Behalf Of Kyungmin Park Sent: Monday, September 22, 2008 11:53 AM To: moorthy.apg@samsung.com Cc: linux-mtd@lists.infradead.org; David.Woodhouse@intel.com Subject: Re: [PATCH] [MTD-UTILS] Add support for 4KB page flash devices Hi, On Fri, Sep 19, 2008 at 9:41 PM, AYYANARPONNUSAMY GANGHEYAMOORTHY <moorthy.apg@samsung.com> wrote: > We can now use these utilities on 4KB devices. > > Signed-off-by: Rohit Hagargundgi <h.rohit@samsung.com> > --- > --- a/flash_otp_write.c 2008-06-27 21:51:28.000000000 +0530 > +++ b/flash_otp_write.c 2008-07-01 16:04:12.000000000 +0530 > @@ -18,7 +18,7 @@ int main(int argc,char *argv[]) > int fd, val, ret, size, wrote, len; > mtd_info_t mtdInfo; > off_t offset; > - char *p, buf[2048]; > + char *p, buf[4096]; > Is it no problem the stack overflow in application? How about to use malloc & free? Thank you, Kyungmin Park ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [MTD-UTILS] Add support for 4KB page flash devices 2008-09-23 11:25 ` apgmoorthy @ 2008-09-26 0:28 ` Kyungmin Park 2008-09-26 4:48 ` Artem Bityutskiy 0 siblings, 1 reply; 6+ messages in thread From: Kyungmin Park @ 2008-09-26 0:28 UTC (permalink / raw) To: apgmoorthy; +Cc: linux-mtd, David.Woodhouse > I find not much issue with that, but still as a fair practice , I'll > absorb your comment in the patch. Have done the memory allocation later in > the function to avoid unnecessary freeing code. > And malloced with mtdInfo.writesize instead of constants , let us know > your comments. > > We can now use these utilities on 4KB devices. > > Signed-off-by: Rohit Hagargundgi <h.rohit@samsung.com> > --- Acked-by: Kyungmin Park <kyungmin.park@samsung.com> > } > --- a/include/mtd/mtd-abi.h 2008-09-23 15:36:26.000000000 +0530 > +++ b/include/mtd/mtd-abi.h 2008-09-23 15:48:48.000000000 +0530 > @@ -104,7 +104,7 @@ struct nand_oobinfo { > uint32_t useecc; > uint32_t eccbytes; > uint32_t oobfree[8][2]; > - uint32_t eccpos[32]; > + uint32_t eccpos[128]; > }; > > struct nand_oobfree { > @@ -119,7 +119,7 @@ struct nand_oobfree { > */ > struct nand_ecclayout { > uint32_t eccbytes; > - uint32_t eccpos[64]; > + uint32_t eccpos[128]; > uint32_t oobavail; > struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES]; > }; > > > > > > -----Original Message----- > From: kyungmin78@gmail.com [mailto:kyungmin78@gmail.com] On Behalf Of > Kyungmin Park > Sent: Monday, September 22, 2008 11:53 AM > To: moorthy.apg@samsung.com > Cc: linux-mtd@lists.infradead.org; David.Woodhouse@intel.com > Subject: Re: [PATCH] [MTD-UTILS] Add support for 4KB page flash devices > > Hi, > > On Fri, Sep 19, 2008 at 9:41 PM, AYYANARPONNUSAMY GANGHEYAMOORTHY > <moorthy.apg@samsung.com> wrote: >> We can now use these utilities on 4KB devices. >> >> Signed-off-by: Rohit Hagargundgi <h.rohit@samsung.com> >> --- >> --- a/flash_otp_write.c 2008-06-27 21:51:28.000000000 +0530 >> +++ b/flash_otp_write.c 2008-07-01 16:04:12.000000000 +0530 >> @@ -18,7 +18,7 @@ int main(int argc,char *argv[]) >> int fd, val, ret, size, wrote, len; >> mtd_info_t mtdInfo; >> off_t offset; >> - char *p, buf[2048]; >> + char *p, buf[4096]; >> > > Is it no problem the stack overflow in application? > How about to use malloc & free? > > Thank you, > Kyungmin Park > > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] [MTD-UTILS] Add support for 4KB page flash devices 2008-09-26 0:28 ` Kyungmin Park @ 2008-09-26 4:48 ` Artem Bityutskiy 0 siblings, 0 replies; 6+ messages in thread From: Artem Bityutskiy @ 2008-09-26 4:48 UTC (permalink / raw) To: Kyungmin Park; +Cc: apgmoorthy, linux-mtd, David.Woodhouse Hi, On Fri, 2008-09-26 at 09:28 +0900, Kyungmin Park wrote: > > We can now use these utilities on 4KB devices. > > > > Signed-off-by: Rohit Hagargundgi <h.rohit@samsung.com> > > --- > > Acked-by: Kyungmin Park <kyungmin.park@samsung.com> Err, isn't this ABI change which is going to break backward compatibility and is NO-NO in Linux? > > } > > --- a/include/mtd/mtd-abi.h 2008-09-23 15:36:26.000000000 +0530 > > +++ b/include/mtd/mtd-abi.h 2008-09-23 15:48:48.000000000 +0530 > > @@ -104,7 +104,7 @@ struct nand_oobinfo { > > uint32_t useecc; > > uint32_t eccbytes; > > uint32_t oobfree[8][2]; > > - uint32_t eccpos[32]; > > + uint32_t eccpos[128]; > > }; Err, isn't this ABI change which is going to break backward compatibility and is NO-NO in Linux? -- Best regards, Artem Bityutskiy (Битюцкий Артём) ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-09-26 4:49 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-09-19 12:41 [PATCH] [MTD-UTILS] Add support for 4KB page flash devices AYYANARPONNUSAMY GANGHEYAMOORTHY 2008-09-22 6:22 ` Kyungmin Park 2008-09-22 9:19 ` Sergei Shtylyov 2008-09-23 11:25 ` apgmoorthy 2008-09-26 0:28 ` Kyungmin Park 2008-09-26 4:48 ` Artem Bityutskiy
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox