* [PATCH 0/3] amend sysfs mtd sysfs interface
@ 2009-04-21 9:28 Artem Bityutskiy
2009-04-21 9:30 ` [PATCH 1/3] MTD: add sysfs file which tells if bad blocks are allowed Artem Bityutskiy
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Artem Bityutskiy @ 2009-04-21 9:28 UTC (permalink / raw)
To: David Woodhouse; +Cc: David Brownell, linux-mtd
Hi, this patch series improves MTD sysfs interface.
It adds a couple of new useful files which I'm going
to use in UBI utilites. It also removes the 'flags'
file because I believe it is a bad idea to expose
it to userspace via sysfs, just bad API.
David, if you are fine with these, please, make it
go upstream now, because we have just added sysfs
and it is not too late to amend it.
Thanks.
--
Best regards,
Artem Bityutskiy (Битюцкий Артём)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] MTD: add sysfs file which tells if bad blocks are allowed
2009-04-21 9:28 [PATCH 0/3] amend sysfs mtd sysfs interface Artem Bityutskiy
@ 2009-04-21 9:30 ` Artem Bityutskiy
2009-04-21 9:31 ` [PATCH 2/3] MTD: add sysfs file which shows if the device is writable Artem Bityutskiy
2009-04-21 9:32 ` [PATCH 3/3] MTD: remove the 'flags' sysfs file Artem Bityutskiy
2 siblings, 0 replies; 4+ messages in thread
From: Artem Bityutskiy @ 2009-04-21 9:30 UTC (permalink / raw)
To: David Woodhouse; +Cc: David Brownell, linux-mtd
Add a per-mtd device 'bb_allowed' sysfs file which contains 0
if bad blocks are not allowed, and 1 if they are allowed.
This is useful for userspace.
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
---
drivers/mtd/mtdcore.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index bccb4b1..c46f1a9 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -174,6 +174,16 @@ static ssize_t mtd_name_show(struct device *dev,
}
static DEVICE_ATTR(name, S_IRUGO, mtd_name_show, NULL);
+static ssize_t mtd_bb_allowed_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct mtd_info *mtd = dev_to_mtd(dev);
+
+ return snprintf(buf, PAGE_SIZE, "%d\n", !!mtd->block_markbad);
+
+}
+static DEVICE_ATTR(bb_allowed, S_IRUGO, mtd_bb_allowed_show, NULL);
+
static struct attribute *mtd_attrs[] = {
&dev_attr_type.attr,
&dev_attr_flags.attr,
@@ -184,6 +194,7 @@ static struct attribute *mtd_attrs[] = {
&dev_attr_oobsize.attr,
&dev_attr_numeraseregions.attr,
&dev_attr_name.attr,
+ &dev_attr_bb_allowed.attr,
NULL,
};
--
1.6.0.6
--
Best regards,
Artem Bityutskiy (Битюцкий Артём)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] MTD: add sysfs file which shows if the device is writable
2009-04-21 9:28 [PATCH 0/3] amend sysfs mtd sysfs interface Artem Bityutskiy
2009-04-21 9:30 ` [PATCH 1/3] MTD: add sysfs file which tells if bad blocks are allowed Artem Bityutskiy
@ 2009-04-21 9:31 ` Artem Bityutskiy
2009-04-21 9:32 ` [PATCH 3/3] MTD: remove the 'flags' sysfs file Artem Bityutskiy
2 siblings, 0 replies; 4+ messages in thread
From: Artem Bityutskiy @ 2009-04-21 9:31 UTC (permalink / raw)
To: David Woodhouse; +Cc: David Brownell, linux-mtd
Add "writable" per-mtd device file which contains 1 if the
MTD device is writable and 0 if it is not.
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
---
drivers/mtd/mtdcore.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index c46f1a9..07105a8 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -184,6 +184,16 @@ static ssize_t mtd_bb_allowed_show(struct device *dev,
}
static DEVICE_ATTR(bb_allowed, S_IRUGO, mtd_bb_allowed_show, NULL);
+static ssize_t mtd_writable_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct mtd_info *mtd = dev_to_mtd(dev);
+
+ return snprintf(buf, PAGE_SIZE, "%d\n", !!(mtd->flags & MTD_WRITEABLE));
+
+}
+static DEVICE_ATTR(writable, S_IRUGO, mtd_writable_show, NULL);
+
static struct attribute *mtd_attrs[] = {
&dev_attr_type.attr,
&dev_attr_flags.attr,
@@ -195,6 +205,7 @@ static struct attribute *mtd_attrs[] = {
&dev_attr_numeraseregions.attr,
&dev_attr_name.attr,
&dev_attr_bb_allowed.attr,
+ &dev_attr_writable.attr,
NULL,
};
--
1.6.0.6
--
Best regards,
Artem Bityutskiy (Битюцкий Артём)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] MTD: remove the 'flags' sysfs file
2009-04-21 9:28 [PATCH 0/3] amend sysfs mtd sysfs interface Artem Bityutskiy
2009-04-21 9:30 ` [PATCH 1/3] MTD: add sysfs file which tells if bad blocks are allowed Artem Bityutskiy
2009-04-21 9:31 ` [PATCH 2/3] MTD: add sysfs file which shows if the device is writable Artem Bityutskiy
@ 2009-04-21 9:32 ` Artem Bityutskiy
2 siblings, 0 replies; 4+ messages in thread
From: Artem Bityutskiy @ 2009-04-21 9:32 UTC (permalink / raw)
To: David Woodhouse; +Cc: David Brownell, linux-mtd
It is bad idea to export the MTD flags via sysfs. It is much
cleaner to create a per-flag sysfs file which contains 0 or
1. It is difficult for users to parse '0x400'. We have ioctls
which return the flags, no need to add this to sysfs.
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
---
drivers/mtd/mtdcore.c | 11 -----------
1 files changed, 0 insertions(+), 11 deletions(-)
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 07105a8..8067d0c 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -91,16 +91,6 @@ static ssize_t mtd_type_show(struct device *dev,
}
static DEVICE_ATTR(type, S_IRUGO, mtd_type_show, NULL);
-static ssize_t mtd_flags_show(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct mtd_info *mtd = dev_to_mtd(dev);
-
- return snprintf(buf, PAGE_SIZE, "0x%lx\n", (unsigned long)mtd->flags);
-
-}
-static DEVICE_ATTR(flags, S_IRUGO, mtd_flags_show, NULL);
-
static ssize_t mtd_size_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -196,7 +186,6 @@ static DEVICE_ATTR(writable, S_IRUGO, mtd_writable_show, NULL);
static struct attribute *mtd_attrs[] = {
&dev_attr_type.attr,
- &dev_attr_flags.attr,
&dev_attr_size.attr,
&dev_attr_erasesize.attr,
&dev_attr_writesize.attr,
--
1.6.0.6
--
Best regards,
Artem Bityutskiy (Битюцкий Артём)
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-04-21 9:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-21 9:28 [PATCH 0/3] amend sysfs mtd sysfs interface Artem Bityutskiy
2009-04-21 9:30 ` [PATCH 1/3] MTD: add sysfs file which tells if bad blocks are allowed Artem Bityutskiy
2009-04-21 9:31 ` [PATCH 2/3] MTD: add sysfs file which shows if the device is writable Artem Bityutskiy
2009-04-21 9:32 ` [PATCH 3/3] MTD: remove the 'flags' sysfs file Artem Bityutskiy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox