Skip to contentSkip to conversation

MTD: expose subpage size via sysfs

PATCH In review Artem Bityutskiy 1 participant 3 messages Apr 17, 2009 – Apr 18, 2009 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MTD: expose subpage size via sysfs

From: Artem Bityutskiy <[email protected]>
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.

---
 drivers/mtd/mtdcore.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
drivers/mtd/mtdcore.c +12 -0
index fdd6ae8..ae6f15e 100644
@@ -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,

--
1.6.0.6

Signature · 2 lines
Best regards,
Artem Bityutskiy (Битюцкий Артём)
#1 lore raw

And the same patch with a better commit message.
--

From: Artem Bityutskiy <[email protected]>
Subject: [PATCH v2] 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.

---
 drivers/mtd/mtdcore.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
drivers/mtd/mtdcore.c +12 -0
index fdd6ae8..ae6f15e 100644
@@ -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,
Signature · 5 lines
1.6.0.6

-- 
Best regards,
Artem Bityutskiy (Битюцкий Артём)
#2 lore raw

And yet another version. Make subpage file name "subpagesize", not "subpage_size", just for consistency, because we already have "erasesize" and "writesize" files.
--

From: Artem Bityutskiy <[email protected]>
Subject: [PATCH v3] 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.

---
 drivers/mtd/mtdcore.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
drivers/mtd/mtdcore.c +12 -0
index fdd6ae8..68e3846 100644
@@ -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,
Signature · 5 lines
1.6.0.6

-- 
Best regards,
Artem Bityutskiy (Битюцкий Артём)