From: Heiko Carstens <heiko.carstens@de.ibm.com>
To: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>,
Horst Hummel <horst.hummel@de.ibm.com>
Subject: [patch 6/8] dasd: Add sysfs attribute status and generate uevents.
Date: Mon, 26 Mar 2007 23:25:05 +0200 [thread overview]
Message-ID: <20070326212640.095897934@de.ibm.com> (raw)
In-Reply-To: 20070326212459.711271424@de.ibm.com
[-- Attachment #1: 114-dasd-status.diff --]
[-- Type: text/plain, Size: 2872 bytes --]
From: Horst Hummel <horst.hummel@de.ibm.com>
This patch adds a sysfs-attribute 'status' to make the DASD device-status
accessible from user-space. In addition, the DASD driver generates an
uevent(CHANGE) for the ccw-device on each device-status change.
This enables user-space applications (e.g. udev) to do related processing.
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Horst Hummel <horst.hummel@de.ibm.com>
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
---
drivers/s390/block/dasd.c | 3 ++
drivers/s390/block/dasd_devmap.c | 41 +++++++++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+)
Index: linux-2.6/drivers/s390/block/dasd.c
===================================================================
--- linux-2.6.orig/drivers/s390/block/dasd.c
+++ linux-2.6/drivers/s390/block/dasd.c
@@ -398,6 +398,9 @@ dasd_change_state(struct dasd_device *de
if (device->state == device->target)
wake_up(&dasd_init_waitq);
+
+ /* let user-space know that the device status changed */
+ kobject_uevent(&device->cdev->dev.kobj, KOBJ_CHANGE);
}
/*
Index: linux-2.6/drivers/s390/block/dasd_devmap.c
===================================================================
--- linux-2.6.orig/drivers/s390/block/dasd_devmap.c
+++ linux-2.6/drivers/s390/block/dasd_devmap.c
@@ -829,6 +829,46 @@ dasd_discipline_show(struct device *dev,
static DEVICE_ATTR(discipline, 0444, dasd_discipline_show, NULL);
static ssize_t
+dasd_device_status_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct dasd_device *device;
+ ssize_t len;
+
+ device = dasd_device_from_cdev(to_ccwdev(dev));
+ if (!IS_ERR(device)) {
+ switch (device->state) {
+ case DASD_STATE_NEW:
+ len = snprintf(buf, PAGE_SIZE, "new\n");
+ break;
+ case DASD_STATE_KNOWN:
+ len = snprintf(buf, PAGE_SIZE, "detected\n");
+ break;
+ case DASD_STATE_BASIC:
+ len = snprintf(buf, PAGE_SIZE, "basic\n");
+ break;
+ case DASD_STATE_UNFMT:
+ len = snprintf(buf, PAGE_SIZE, "unformatted\n");
+ break;
+ case DASD_STATE_READY:
+ len = snprintf(buf, PAGE_SIZE, "ready\n");
+ break;
+ case DASD_STATE_ONLINE:
+ len = snprintf(buf, PAGE_SIZE, "online\n");
+ break;
+ default:
+ len = snprintf(buf, PAGE_SIZE, "no stat\n");
+ break;
+ }
+ dasd_put_device(device);
+ } else
+ len = snprintf(buf, PAGE_SIZE, "unknown\n");
+ return len;
+}
+
+static DEVICE_ATTR(status, 0444, dasd_device_status_show, NULL);
+
+static ssize_t
dasd_alias_show(struct device *dev, struct device_attribute *attr, char *buf)
{
struct dasd_devmap *devmap;
@@ -939,6 +979,7 @@ static DEVICE_ATTR(eer_enabled, 0644, da
static struct attribute * dasd_attrs[] = {
&dev_attr_readonly.attr,
&dev_attr_discipline.attr,
+ &dev_attr_status.attr,
&dev_attr_alias.attr,
&dev_attr_vendor.attr,
&dev_attr_uid.attr,
--
next prev parent reply other threads:[~2007-03-26 21:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-26 21:24 [patch 0/8] s390 patches for 2.6.22 Heiko Carstens
2007-03-26 21:25 ` [patch 1/8] Processor degredation support Heiko Carstens
2007-03-27 21:35 ` Pavel Machek
2007-03-28 6:54 ` Heiko Carstens
2007-03-28 8:41 ` Pavel Machek
2007-04-02 18:52 ` Heiko Carstens
2007-03-26 21:25 ` [patch 2/8] Get rid of console setup functions Heiko Carstens
2007-03-26 21:25 ` [patch 3/8] Improved kernel stack overflow checking Heiko Carstens
2007-03-26 21:25 ` [patch 4/8] cio: Clean up online_store Heiko Carstens
2007-03-26 21:25 ` [patch 5/8] cio: Channel-path configure function Heiko Carstens
2007-03-26 21:25 ` Heiko Carstens [this message]
2007-03-26 21:25 ` [patch 7/8] dasd: Add ipldev parameter Heiko Carstens
2007-03-26 21:25 ` [patch 8/8] zfcpdump support Heiko Carstens
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=20070326212640.095897934@de.ibm.com \
--to=heiko.carstens@de.ibm.com \
--cc=horst.hummel@de.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=schwidefsky@de.ibm.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.