Add full flash erase support in mtd-utils
Subsystems (2)
PATCH 1/1 Add full flash erase support in mtd-utils
Some flash types support full erase chip command but there was no support for it in mtd-utils. The full erase chip command can reduce the flash erase time significantly. The patch will try first to erase the entire flash and fall back to the old method if the operation fails.
Larisa Ileana Grigore (1):
mtd-utils: flash_erase: Add flash erase chip
include/libmtd.h | 15 +++++++ lib/libmtd.c | 26 ++++++++--- misc-utils/flash_erase.c | 95 ++++++++++++++++++++++++++++++---------- 3 files changed, 106 insertions(+), 30 deletions(-)
Signature · 6 lines
2.17.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH 1/1 mtd-utils: flash_erase: Add flash erase chip
Some flash types support full erase chip command which can reduce the flash erase time. Try first to erase the entire flash and fall back to the old method if the operation fails.
--- include/libmtd.h | 15 +++++++ lib/libmtd.c | 26 ++++++++--- misc-utils/flash_erase.c | 95 ++++++++++++++++++++++++++++++---------- 3 files changed, 106 insertions(+), 30 deletions(-)
include/libmtd.h +15 -0
@@ -1,5 +1,6 @@/* * Copyright (C) 2008, 2009 Nokia Corporation +* Copyright 2021 NXP * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -174,6 +175,20 @@ int mtd_lock(const struct mtd_dev_info *mtd, int fd, int eb);*/ int mtd_unlock (const struct mtd_dev_info *mtd,int fd,int eb); +/** +* mtd_unlock_multi - unlock eraseblocks. +* @desc: MTD library descriptor +* @mtd: MTD device description object +* @fd: MTD device node file descriptor +* @eb: index of first eraseblock to unlock +* @blocks: the number of eraseblocks to unlock +* +* This function unlocks @blocks starting at eraseblock @eb. +* Returns %0 in case of success and %-1 in case of failure. +*/ +int mtd_unlock_multi (const struct mtd_dev_info *mtd,int fd,int eb, +int blocks); +/** * mtd_erase - erase multiple eraseblocks. * @desc: MTD library descriptor
lib/libmtd.c +20 -6
@@ -1,6 +1,7 @@/* * Copyright (c) International Business Machines Corp., 2006 * Copyright (C) 2009 Nokia Corporation +* Copyright 2021 NXP * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -831,8 +832,8 @@ static int mtd_valid_erase_block(const struct mtd_dev_info *mtd, int eb)return 0 ; } -static int mtd_xlock (const struct mtd_dev_info *mtd,int fd,int eb,int req, -const char *sreq) +static int mtd_xlock (const struct mtd_dev_info *mtd,int fd,int eb, +int blocks,int req,const char *sreq) {int ret;struct erase_info_user ei;
@@ -841,8 +842,14 @@ static int mtd_xlock(const struct mtd_dev_info *mtd, int fd, int eb, int req,if (ret)return ret; +if (blocks >1 ) { + ret =mtd_valid_erase_block (mtd, eb + blocks -1 ); +if (ret) +return ret; + } + ei.start = eb * mtd->eb_size; - ei.length = mtd->eb_size; + ei.length = mtd->eb_size * blocks; ret =ioctl (fd, req, &ei);if (ret <0 )
@@ -850,16 +857,23 @@ static int mtd_xlock(const struct mtd_dev_info *mtd, int fd, int eb, int req,return 0 ; } -#define mtd_xlock (mtd, fd, eb, req) mtd_xlock(mtd, fd, eb, req, #req) +#define mtd_xlock (mtd, fd, eb, blocks, req) \ + mtd_xlock(mtd, fd, eb, blocks, req, #req)int mtd_lock (const struct mtd_dev_info *mtd,int fd,int eb) { -return mtd_xlock (mtd, fd, eb,MEMLOCK ); +return mtd_xlock (mtd, fd, eb,1 ,MEMLOCK ); }int mtd_unlock (const struct mtd_dev_info *mtd,int fd,int eb) { -return mtd_xlock (mtd, fd, eb,MEMUNLOCK ); +return mtd_xlock (mtd, fd, eb,1 ,MEMUNLOCK ); +} + +int mtd_unlock_multi (const struct mtd_dev_info *mtd,int fd,int eb, +int blocks) +{ +return mtd_xlock (mtd, fd, eb, blocks,MEMUNLOCK ); } int mtd_erase_multi(libmtd_t desc, const struct mtd_dev_info *mtd,
misc-utils/flash_erase.c +71 -24
140 lines not on this page · raw message
Signature · 6 lines
2.17.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 1/1] mtd-utils: flash_erase: Add flash erase chip
Hi,
Am 2021-04-23 17:07, schrieb Larisa Ileana Grigore:
Quoted 16 lines
Some flash types support full erase chip command which can reduce the flash erase time. Try first to erase the entire flash and fall back to the old method if the operation fails.
Signed-off-by Larisa Ileana Grigore <[email protected]>--- include/libmtd.h | 15 +++++++ lib/libmtd.c | 26 ++++++++--- misc-utils/flash_erase.c | 95 ++++++++++++++++++++++++++++++---------- 3 files changed, 106 insertions(+), 30 deletions(-)include/libmtd.h +0
-0
include/libmtd.h line 3
Quoted 3 lines
include/libmtd.h +1
-0@@ -1,5 +1,6 @@/* * Copyright (C) 2008, 2009 Nokia Corporation +* Copyright 2021 NXP
really? because of one prototype?
Just out of curiousity, is there any incentive that you NXP guys add these copyrights all over the place, even for one line changes.
Quoted 14 lines
include/libmtd.h +0
-0* * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
byinclude/libmtd.h +4
-0@@ -174,6 +175,20 @@ int mtd_lock(const struct mtd_dev_info *mtd, intfd, int eb); */ int mtd_unlock (const struct mtd_dev_info *mtd,int fd,int eb); +/** +* mtd_unlock_multi - unlock eraseblocks. +* @desc: MTD library descriptor +* @mtd: MTD device description object
include/libmtd.h int mtd_lock(const struct mtd_dev_info *mtd, int · line 192
Quoted 10 lines
include/libmtd.h +10
-0+* @fd: MTD device node file descriptor +* @eb: index of first eraseblock to unlock +* @blocks: the number of eraseblocks to unlock +* +* This function unlocks @blocks starting at eraseblock @eb. +* Returns %0 in case of success and %-1 in case of failure. +*/ +int mtd_unlock_multi (const struct mtd_dev_info *mtd,int fd,int eb, +int blocks); +
-michael
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
David Oberhollenzer
AppliedRe: [PATCH 1/1] mtd-utils: flash_erase: Add flash erase chip
In reply to Larisa Ileana GrigoreApplied to mtd-utils.git master.
Thanks,
David
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/