aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390
diff options
context:
space:
mode:
authorSebastian Ott <sebott@linux.vnet.ibm.com>2013-12-16 04:54:13 -0500
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2013-12-16 08:38:02 -0500
commit00381eeb47ef6b3b70d2a17c89a8205b6f1aa00a (patch)
treea801b13badc66a26abae11f4ee48823e62f076e0 /drivers/s390
parent74bd0d859dc3536b01c892abfa9f87620e4bca2f (diff)
s390/cio: use device_lock to synchronize calls to the ccw driver
When calling set_{on,off}line of a ccw device driver we hold the module reference of the owner. This is pretty useless - we don't want to prevent module unloading but driver unbinding. Use the driver core's device_lock instead. Reviewed-by: Peter Oberparleiter <oberpar@linux.vnet.ibm.com> Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers/s390')
-rw-r--r--drivers/s390/cio/device.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index 4a0734fcc83c..e9d783563cbb 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -549,17 +549,12 @@ static ssize_t online_store (struct device *dev, struct device_attribute *attr,
549 if (!dev_fsm_final_state(cdev) && 549 if (!dev_fsm_final_state(cdev) &&
550 cdev->private->state != DEV_STATE_DISCONNECTED) { 550 cdev->private->state != DEV_STATE_DISCONNECTED) {
551 ret = -EAGAIN; 551 ret = -EAGAIN;
552 goto out_onoff; 552 goto out;
553 } 553 }
554 /* Prevent conflict between pending work and on-/offline processing.*/ 554 /* Prevent conflict between pending work and on-/offline processing.*/
555 if (work_pending(&cdev->private->todo_work)) { 555 if (work_pending(&cdev->private->todo_work)) {
556 ret = -EAGAIN; 556 ret = -EAGAIN;
557 goto out_onoff; 557 goto out;
558 }
559
560 if (cdev->drv && !try_module_get(cdev->drv->driver.owner)) {
561 ret = -EINVAL;
562 goto out_onoff;
563 } 558 }
564 if (!strncmp(buf, "force\n", count)) { 559 if (!strncmp(buf, "force\n", count)) {
565 force = 1; 560 force = 1;
@@ -571,6 +566,8 @@ static ssize_t online_store (struct device *dev, struct device_attribute *attr,
571 } 566 }
572 if (ret) 567 if (ret)
573 goto out; 568 goto out;
569
570 device_lock(dev);
574 switch (i) { 571 switch (i) {
575 case 0: 572 case 0:
576 ret = online_store_handle_offline(cdev); 573 ret = online_store_handle_offline(cdev);
@@ -581,10 +578,9 @@ static ssize_t online_store (struct device *dev, struct device_attribute *attr,
581 default: 578 default:
582 ret = -EINVAL; 579 ret = -EINVAL;
583 } 580 }
581 device_unlock(dev);
582
584out: 583out:
585 if (cdev->drv)
586 module_put(cdev->drv->driver.owner);
587out_onoff:
588 atomic_set(&cdev->private->onoff, 0); 584 atomic_set(&cdev->private->onoff, 0);
589 return (ret < 0) ? ret : count; 585 return (ret < 0) ? ret : count;
590} 586}