[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>
This commit is contained in:
Horst Hummel
2005-05-01 08:58:59 -07:00
committed by Linus Torvalds
parent e8f0641ef7
commit f24acd4503
6 changed files with 93 additions and 42 deletions

View File

@@ -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)
{