Skip to content

Commit 3156ceb

Browse files
Rickard Anderssonrichardweinberger
authored andcommitted
ubi: Expose interface for detailed erase counters
Using the ioctl command 'UBI_IOCECNFO' user space can obtain detailed erase counter information of all blocks of a device. Signed-off-by: Rickard Andersson <rickard.andersson@axis.com> Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: Richard Weinberger <richard@nod.at>
1 parent bdb0ca3 commit 3156ceb

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

include/uapi/mtd/ubi-user.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@
175175
#define UBI_IOCRPEB _IOW(UBI_IOC_MAGIC, 4, __s32)
176176
/* Force scrubbing on the specified PEB */
177177
#define UBI_IOCSPEB _IOW(UBI_IOC_MAGIC, 5, __s32)
178+
/* Read detailed device erase counter information */
179+
#define UBI_IOCECNFO _IOWR(UBI_IOC_MAGIC, 6, struct ubi_ecinfo_req)
178180

179181
/* ioctl commands of the UBI control character device */
180182

@@ -412,6 +414,37 @@ struct ubi_rnvol_req {
412414
} ents[UBI_MAX_RNVOL];
413415
} __packed;
414416

417+
/**
418+
* struct ubi_ecinfo_req - a data structure used for requesting and receiving
419+
* erase block counter information from a UBI device.
420+
*
421+
* @start: index of first physical erase block to read (in)
422+
* @length: number of erase counters to read (in)
423+
* @read_length: number of erase counters that was actually read (out)
424+
* @padding: reserved for future, not used, has to be zeroed
425+
* @erase_counters: array of erase counter values (out)
426+
*
427+
* This structure is used to retrieve erase counter information for a specified
428+
* range of PEBs on a UBI device.
429+
* Erase counters are read from @start and attempts to read @length number of
430+
* erase counters.
431+
* The retrieved values are stored in the @erase_counters array. It is the
432+
* responsibility of the caller to allocate enough memory for storing @length
433+
* elements in the @erase_counters array.
434+
* If a block is bad or if the erase counter is unknown the corresponding value
435+
* in the array will be set to -1.
436+
* The @read_length field will indicate the number of erase counters actually
437+
* read. Typically @read_length will be limited due to memory or the number of
438+
* PEBs on the UBI device.
439+
*/
440+
struct ubi_ecinfo_req {
441+
__s32 start;
442+
__s32 length;
443+
__s32 read_length;
444+
__s8 padding[16];
445+
__s32 erase_counters[];
446+
} __packed;
447+
415448
/**
416449
* struct ubi_leb_change_req - a data structure used in atomic LEB change
417450
* requests.

0 commit comments

Comments
 (0)