[S390] cio: disallow online setting of device in transient state
authorSebastian Ott <sebott@linux.vnet.ibm.com>
Tue, 31 Mar 2009 17:16:06 +0000 (19:16 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Tue, 31 Mar 2009 17:17:06 +0000 (19:17 +0200)
Return -EAGAIN on writes to sysfs online attribute if the corresponding
ccw device is in transient state.

Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
drivers/s390/cio/device.c

index 868f8c6..e47aa3f 100644 (file)
@@ -515,7 +515,11 @@ static ssize_t online_store (struct device *dev, struct device_attribute *attr,
        int force, ret;
        unsigned long i;
 
-       if (atomic_cmpxchg(&cdev->private->onoff, 0, 1) != 0)
+       if ((cdev->private->state != DEV_STATE_OFFLINE &&
+            cdev->private->state != DEV_STATE_ONLINE &&
+            cdev->private->state != DEV_STATE_BOXED &&
+            cdev->private->state != DEV_STATE_DISCONNECTED) ||
+           atomic_cmpxchg(&cdev->private->onoff, 0, 1) != 0)
                return -EAGAIN;
 
        if (cdev->drv && !try_module_get(cdev->drv->owner)) {