Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Rickard Andersson and committed by
Richard Weinberger
3156ceb2 bdb0ca39

+33
+33
include/uapi/mtd/ubi-user.h
··· 175 175 #define UBI_IOCRPEB _IOW(UBI_IOC_MAGIC, 4, __s32) 176 176 /* Force scrubbing on the specified PEB */ 177 177 #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) 178 180 179 181 /* ioctl commands of the UBI control character device */ 180 182 ··· 413 411 char name[UBI_MAX_VOLUME_NAME + 1]; 414 412 } ents[UBI_MAX_RNVOL]; 415 413 } __packed; 414 + 415 + /** 416 + * struct ubi_ecinfo_req - a data structure used for requesting and receiving 417 + * erase block counter information from a UBI device. 418 + * 419 + * @start: index of first physical erase block to read (in) 420 + * @length: number of erase counters to read (in) 421 + * @read_length: number of erase counters that was actually read (out) 422 + * @padding: reserved for future, not used, has to be zeroed 423 + * @erase_counters: array of erase counter values (out) 424 + * 425 + * This structure is used to retrieve erase counter information for a specified 426 + * range of PEBs on a UBI device. 427 + * Erase counters are read from @start and attempts to read @length number of 428 + * erase counters. 429 + * The retrieved values are stored in the @erase_counters array. It is the 430 + * responsibility of the caller to allocate enough memory for storing @length 431 + * elements in the @erase_counters array. 432 + * If a block is bad or if the erase counter is unknown the corresponding value 433 + * in the array will be set to -1. 434 + * The @read_length field will indicate the number of erase counters actually 435 + * read. Typically @read_length will be limited due to memory or the number of 436 + * PEBs on the UBI device. 437 + */ 438 + struct ubi_ecinfo_req { 439 + __s32 start; 440 + __s32 length; 441 + __s32 read_length; 442 + __s8 padding[16]; 443 + __s32 erase_counters[]; 444 + } __packed; 416 445 417 446 /** 418 447 * struct ubi_leb_change_req - a data structure used in atomic LEB change