public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Artem Bityutskiy <dedekind@infradead.org>
To: David Woodhouse <dwmw2@infradead.org>
Cc: David Brownell <david-b@pacbell.net>,
	linux-mtd <linux-mtd@lists.infradead.org>
Subject: [PATCH 2/3] MTD: add sysfs file which shows if the device is writable
Date: Tue, 21 Apr 2009 12:31:56 +0300	[thread overview]
Message-ID: <1240306316.19218.4.camel@localhost.localdomain> (raw)
In-Reply-To: <1240306101.19218.2.camel@localhost.localdomain>

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 (Битюцкий Артём)

  parent reply	other threads:[~2009-04-21  9:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2009-04-21  9:32 ` [PATCH 3/3] MTD: remove the 'flags' sysfs file Artem Bityutskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1240306316.19218.4.camel@localhost.localdomain \
    --to=dedekind@infradead.org \
    --cc=david-b@pacbell.net \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox