]> err.no Git - linux-2.6/blobdiff - drivers/s390/block/dasd_devmap.c
Merge ssh://master.kernel.org/pub/scm/linux/kernel/git/sam/kbuild
[linux-2.6] / drivers / s390 / block / dasd_devmap.c
index 5943266152f5ec899de2f5a8a98b435328ff8872..0c67258fb9ec07cb6351edb1a4ee307848f4db67 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <asm/debug.h>
 #include <asm/uaccess.h>
+#include <asm/ipl.h>
 
 /* This is ugly... */
 #define PRINTK_HEADER "dasd_devmap:"
@@ -133,14 +134,30 @@ dasd_call_setup(char *str)
 __setup ("dasd=", dasd_call_setup);
 #endif /* #ifndef MODULE */
 
+#define        DASD_IPLDEV     "ipldev"
+
 /*
  * Read a device busid/devno from a string.
  */
-static inline int
+static int
 dasd_busid(char **str, int *id0, int *id1, int *devno)
 {
        int val, old_style;
 
+       /* Interpret ipldev busid */
+       if (strncmp(DASD_IPLDEV, *str, strlen(DASD_IPLDEV)) == 0) {
+               if (ipl_info.type != IPL_TYPE_CCW) {
+                       MESSAGE(KERN_ERR, "%s", "ipl device is not a ccw "
+                               "device");
+                       return -EINVAL;
+               }
+               *id0 = 0;
+               *id1 = ipl_info.data.ccw.dev_id.ssid;
+               *devno = ipl_info.data.ccw.dev_id.devno;
+               *str += strlen(DASD_IPLDEV);
+
+               return 0;
+       }
        /* check for leading '0x' */
        old_style = 0;
        if ((*str)[0] == '0' && (*str)[1] == 'x') {
@@ -182,7 +199,7 @@ dasd_busid(char **str, int *id0, int *id1, int *devno)
  * only one: "ro" for read-only devices. The default feature set
  * is empty (value 0).
  */
-static inline int
+static int
 dasd_feature_list(char *str, char **endp)
 {
        int features, len, rc;
@@ -274,7 +291,7 @@ dasd_parse_keyword( char *parsestring ) {
                dasd_page_cache =
                        kmem_cache_create("dasd_page_cache", PAGE_SIZE,
                                          PAGE_SIZE, SLAB_CACHE_DMA,
-                                         NULL, NULL );
+                                         NULL);
                if (!dasd_page_cache)
                        MESSAGE(KERN_WARNING, "%s", "Failed to create slab, "
                                "fixed buffer mode disabled.");
@@ -341,7 +358,7 @@ dasd_parse_range( char *parsestring ) {
        return ERR_PTR(-EINVAL);
 }
 
-static inline char *
+static char *
 dasd_parse_next_element( char *parsestring ) {
        char * residual_str;
        residual_str = dasd_parse_keyword(parsestring);
@@ -828,6 +845,46 @@ dasd_discipline_show(struct device *dev, struct device_attribute *attr,
 
 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)
 {
@@ -939,6 +996,7 @@ static DEVICE_ATTR(eer_enabled, 0644, dasd_eer_show, dasd_eer_store);
 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,