Add --skip-all-ffs option to mtd-utils nandwrite

Marek Vasut marek.vasut at gmail.com
Tue Dec 6 21:01:08 PST 2016


On 12/06/2016 02:19 PM, David Oberhollenzer wrote:
> On 12/06/2016 09:29 AM, Kees Trommel wrote:
>> David,
>>
>> Attached a rebased patch file.
>>
>> Kees.
> Applied to mtd-utils.git.

It'd be great to have the patch posted to the list with git send-email ,
otherwise it's not possible to review it :-(

Also, the code doesn't look awesome, see below:

+               if (skipallffs)
+               {
+                       for (ii = 0; ii < mtd.min_io_size; ii +=
sizeof(uint32_t))
+                       {
+                               if (*(uint32_t*)(writebuf + ii) !=
0xffffffff)
+                                       break;

Is this memcmp()-alike function ?

+                       }
+                       if (ii == mtd.min_io_size)
+                               allffs = 1;
+               }
+               if (!allffs) {

This could be simply turned to:

ret = 0;
if (!memcmp(writebuf, writebuf + 1, mtd.min_io_size - 1)) {
    ret = mtd_write(....);
}

And then you don't need to introduce any new vars (which have weird
names like 'ii' ) either.

+                       /* Write out data */
+                       ret = mtd_write(mtd_desc, &mtd, fd, mtdoffset /
mtd.eb_size,
+                                       mtdoffset % mtd.eb_size,
+                                       onlyoob ? NULL : writebuf,
+                                       onlyoob ? 0 : mtd.min_io_size,
+                                       writeoob ? oobbuf : NULL,
+                                       writeoob ? mtd.oob_size : 0,
+                                       write_mode);
+               } else  {
+                       ret = 0;
+               }

-- 
Best regards,
Marek Vasut



More information about the linux-mtd mailing list