mtd: expose subpage size via sysfs

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Sun Apr 19 04:59:02 EDT 2009


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=e7693548950ea5801d5d8b00414aed37033cf972
Commit:     e7693548950ea5801d5d8b00414aed37033cf972
Parent:     2fdb11449ca82f4f1907fce4929df4e0bd267c50
Author:     Artem Bityutskiy <dedekind at infradead.org>
AuthorDate: Sat Apr 18 12:29:42 2009 +0300
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Sun Apr 19 09:12:49 2009 +0100

    mtd: expose subpage size via sysfs
    
    MTD has got sysfs support in 2.6.30-rc1. But subpage size is not
    exposed there - do this.
    
    UBI utilities badly need this parameter. At the moment there is
    no way to get subpage size - ioctls do not return it. And we
    just got sysfs support, so we can easilly extend it with this
    additional parameter.
    
    This can be merged late in the development cycle because:
    1. sysfs support has been just added - there are no users for
       it so far, even.
    2. UBI utilities really need this parameter, and it is better
       not to delay this.
    
    Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/mtdcore.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 051b4d4..bccb4b1 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -132,6 +132,17 @@ static ssize_t mtd_writesize_show(struct device *dev,
 }
 static DEVICE_ATTR(writesize, S_IRUGO, mtd_writesize_show, NULL);
 
+static ssize_t mtd_subpagesize_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct mtd_info *mtd = dev_to_mtd(dev);
+	unsigned int subpagesize = mtd->writesize >> mtd->subpage_sft;
+
+	return snprintf(buf, PAGE_SIZE, "%u\n", subpagesize);
+
+}
+static DEVICE_ATTR(subpagesize, S_IRUGO, mtd_subpagesize_show, NULL);
+
 static ssize_t mtd_oobsize_show(struct device *dev,
 		struct device_attribute *attr, char *buf)
 {
@@ -169,6 +180,7 @@ static struct attribute *mtd_attrs[] = {
 	&dev_attr_size.attr,
 	&dev_attr_erasesize.attr,
 	&dev_attr_writesize.attr,
+	&dev_attr_subpagesize.attr,
 	&dev_attr_oobsize.attr,
 	&dev_attr_numeraseregions.attr,
 	&dev_attr_name.attr,



More information about the linux-mtd-cvs mailing list