diff options
author | Horst Hummel <horst.hummel@de.ibm.com> | 2005-05-01 08:58:59 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-05-01 08:58:59 -0700 |
commit | f24acd4503270ed4c842c8fef0b71105285e0a06 (patch) | |
tree | 9125df60bf98ddcd8197bf479e8a48d22f51af14 /drivers/s390/block/dasd_devmap.c | |
parent | e8f0641ef74eaa71ed9aa9d19c4b741c2143d752 (diff) |
[PATCH] s390: dasd readonly attribute
The independent read-only flags in devmap, dasd_device and gendisk are not
kept in sync. Use one bit per feature in the dasd driver and keep that bit in
sync with the gendisk bit.
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/s390/block/dasd_devmap.c')
-rw-r--r-- | drivers/s390/block/dasd_devmap.c | 59 |
1 files changed, 42 insertions, 17 deletions
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c index ad1841a96c87..1aedc48e5f85 100644 --- a/drivers/s390/block/dasd_devmap.c +++ b/drivers/s390/block/dasd_devmap.c @@ -11,7 +11,7 @@ * functions may not be called from interrupt context. In particular * dasd_get_device is a no-no from interrupt context. * - * $Revision: 1.37 $ + * $Revision: 1.40 $ */ #include <linux/config.h> @@ -513,14 +513,6 @@ dasd_create_device(struct ccw_device *cdev) if (!devmap->device) { devmap->device = device; device->devindex = devmap->devindex; - if (devmap->features & DASD_FEATURE_READONLY) - set_bit(DASD_FLAG_RO, &device->flags); - else - clear_bit(DASD_FLAG_RO, &device->flags); - if (devmap->features & DASD_FEATURE_USEDIAG) - set_bit(DASD_FLAG_USE_DIAG, &device->flags); - else - clear_bit(DASD_FLAG_USE_DIAG, &device->flags); get_device(&cdev->dev); device->cdev = cdev; rc = 0; @@ -651,14 +643,8 @@ dasd_ro_store(struct device *dev, const char *buf, size_t count) devmap->features |= DASD_FEATURE_READONLY; else devmap->features &= ~DASD_FEATURE_READONLY; - if (devmap->device) { - if (devmap->device->gdp) - set_disk_ro(devmap->device->gdp, ro_flag); - if (ro_flag) - set_bit(DASD_FLAG_RO, &devmap->device->flags); - else - clear_bit(DASD_FLAG_RO, &devmap->device->flags); - } + if (devmap->device && devmap->device->gdp) + set_disk_ro(devmap->device->gdp, ro_flag); spin_unlock(&dasd_devmap_lock); return count; } @@ -739,6 +725,45 @@ static struct attribute_group dasd_attr_group = { .attrs = dasd_attrs, }; +/* + * Return value of the specified feature. + */ +int +dasd_get_feature(struct ccw_device *cdev, int feature) +{ + struct dasd_devmap *devmap; + + devmap = dasd_find_busid(cdev->dev.bus_id); + if (IS_ERR(devmap)) + return (int) PTR_ERR(devmap); + + return ((devmap->features & feature) != 0); +} + +/* + * Set / reset given feature. + * Flag indicates wether to set (!=0) or the reset (=0) the feature. + */ +int +dasd_set_feature(struct ccw_device *cdev, int feature, int flag) +{ + struct dasd_devmap *devmap; + + devmap = dasd_find_busid(cdev->dev.bus_id); + if (IS_ERR(devmap)) + return (int) PTR_ERR(devmap); + + spin_lock(&dasd_devmap_lock); + if (flag) + devmap->features |= feature; + else + devmap->features &= ~feature; + + spin_unlock(&dasd_devmap_lock); + return 0; +} + + int dasd_add_sysfs_files(struct ccw_device *cdev) { |