diff options
author | Xiaolei Li <xiaolei.li@mediatek.com> | 2018-04-02 16:20:10 +0800 |
---|---|---|
committer | Boris Brezillon <boris.brezillon@bootlin.com> | 2018-04-22 20:07:06 +0200 |
commit | 7cc9aa669a5119a8d70b22c57779d1decd4d0d62 (patch) | |
tree | c48b958a576e6193061c2aa9b2a6400ecf1c35aa /drivers/mtd/mtdcore.c | |
parent | c3c9a2c4b94f2c92132298b705a6f5f9dc1ccd3f (diff) | |
download | op-kernel-dev-7cc9aa669a5119a8d70b22c57779d1decd4d0d62.zip op-kernel-dev-7cc9aa669a5119a8d70b22c57779d1decd4d0d62.tar.gz |
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>
Diffstat (limited to 'drivers/mtd/mtdcore.c')
-rw-r--r-- | drivers/mtd/mtdcore.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 807d17d..adf18b0 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -210,6 +210,15 @@ static ssize_t mtd_oobsize_show(struct device *dev, } static DEVICE_ATTR(oobsize, S_IRUGO, mtd_oobsize_show, NULL); +static ssize_t mtd_oobavail_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct mtd_info *mtd = dev_get_drvdata(dev); + + return snprintf(buf, PAGE_SIZE, "%u\n", mtd->oobavail); +} +static DEVICE_ATTR(oobavail, S_IRUGO, mtd_oobavail_show, NULL); + static ssize_t mtd_numeraseregions_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -327,6 +336,7 @@ static struct attribute *mtd_attrs[] = { &dev_attr_writesize.attr, &dev_attr_subpagesize.attr, &dev_attr_oobsize.attr, + &dev_attr_oobavail.attr, &dev_attr_numeraseregions.attr, &dev_attr_name.attr, &dev_attr_ecc_strength.attr, |