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

mtd: Add sysfs attribute for mtd OOB available size

Expose mtd OOB available size by sysfs file. Then users can get available
OOB size by accessing /sys/class/mtd/mtdX/oobavail.

Signed-off-by: Xiaolei Li <xiaolei.li@mediatek.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>

authored by

Xiaolei Li and committed by
Boris Brezillon
7cc9aa66 c3c9a2c4

+18
+8
Documentation/ABI/testing/sysfs-class-mtd
··· 232 232 of the parent (another partition or a flash device) in bytes. 233 233 This attribute is absent on flash devices, so it can be used 234 234 to distinguish them from partitions. 235 + 236 + What: /sys/class/mtd/mtdX/oobavail 237 + Date: April 2018 238 + KernelVersion: 4.16 239 + Contact: linux-mtd@lists.infradead.org 240 + Description: 241 + Number of bytes available for a client to place data into 242 + the out of band area.
+10
drivers/mtd/mtdcore.c
··· 210 210 } 211 211 static DEVICE_ATTR(oobsize, S_IRUGO, mtd_oobsize_show, NULL); 212 212 213 + static ssize_t mtd_oobavail_show(struct device *dev, 214 + struct device_attribute *attr, char *buf) 215 + { 216 + struct mtd_info *mtd = dev_get_drvdata(dev); 217 + 218 + return snprintf(buf, PAGE_SIZE, "%u\n", mtd->oobavail); 219 + } 220 + static DEVICE_ATTR(oobavail, S_IRUGO, mtd_oobavail_show, NULL); 221 + 213 222 static ssize_t mtd_numeraseregions_show(struct device *dev, 214 223 struct device_attribute *attr, char *buf) 215 224 { ··· 336 327 &dev_attr_writesize.attr, 337 328 &dev_attr_subpagesize.attr, 338 329 &dev_attr_oobsize.attr, 330 + &dev_attr_oobavail.attr, 339 331 &dev_attr_numeraseregions.attr, 340 332 &dev_attr_name.attr, 341 333 &dev_attr_ecc_strength.attr,