Skip to content

Commit e769354

Browse files
dedekindDavid Woodhouse
authored andcommitted
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@nokia.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
1 parent 2fdb114 commit e769354

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎drivers/mtd/mtdcore.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,17 @@ static ssize_t mtd_writesize_show(struct device *dev,
132132
}
133133
static DEVICE_ATTR(writesize, S_IRUGO, mtd_writesize_show, NULL);
134134

135+
static ssize_t mtd_subpagesize_show(struct device *dev,
136+
struct device_attribute *attr, char *buf)
137+
{
138+
struct mtd_info *mtd = dev_to_mtd(dev);
139+
unsigned int subpagesize = mtd->writesize >> mtd->subpage_sft;
140+
141+
return snprintf(buf, PAGE_SIZE, "%u\n", subpagesize);
142+
143+
}
144+
static DEVICE_ATTR(subpagesize, S_IRUGO, mtd_subpagesize_show, NULL);
145+
135146
static ssize_t mtd_oobsize_show(struct device *dev,
136147
struct device_attribute *attr, char *buf)
137148
{
@@ -169,6 +180,7 @@ static struct attribute *mtd_attrs[] = {
169180
&dev_attr_size.attr,
170181
&dev_attr_erasesize.attr,
171182
&dev_attr_writesize.attr,
183+
&dev_attr_subpagesize.attr,
172184
&dev_attr_oobsize.attr,
173185
&dev_attr_numeraseregions.attr,
174186
&dev_attr_name.attr,

0 commit comments

Comments
 (0)