Patchwork MTD: expose subpage size via sysfs

login
register
mail settings
Submitter Artem Bityutskiy
Date April 17, 2009, 3:11 p.m.
Message ID <1239981096.3390.300.camel@localhost.localdomain>
Download mbox | patch
Permalink /patch/26124/
State New, archived
Headers show

Comments

Artem Bityutskiy - April 17, 2009, 3:11 p.m.
From: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Subject: [PATCH] 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.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
---
 drivers/mtd/mtdcore.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

--
1.6.0.6

Patch

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index fdd6ae8..ae6f15e 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_subpage_size_show(struct device *dev,
+               struct device_attribute *attr, char *buf)
+{
+       struct mtd_info *mtd = dev_to_mtd(dev);
+       unsigned int subpage_size = mtd->writesize >> mtd->subpage_sft;
+
+       return snprintf(buf, PAGE_SIZE, "%u\n", subpage_size);
+
+}
+static DEVICE_ATTR(subpage_size, S_IRUGO, mtd_subpage_size_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_subpage_size.attr,
        &dev_attr_oobsize.attr,
        &dev_attr_numeraseregions.attr,
        &dev_attr_name.attr,