diff options
Diffstat (limited to 'drivers/s390/block/dasd_devmap.c')
-rw-r--r-- | drivers/s390/block/dasd_devmap.c | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c index 91cf971f0652..17fdd8c9f740 100644 --- a/drivers/s390/block/dasd_devmap.c +++ b/drivers/s390/block/dasd_devmap.c | |||
@@ -684,21 +684,26 @@ dasd_ro_store(struct device *dev, struct device_attribute *attr, | |||
684 | const char *buf, size_t count) | 684 | const char *buf, size_t count) |
685 | { | 685 | { |
686 | struct dasd_devmap *devmap; | 686 | struct dasd_devmap *devmap; |
687 | int ro_flag; | 687 | int val; |
688 | char *endp; | ||
688 | 689 | ||
689 | devmap = dasd_devmap_from_cdev(to_ccwdev(dev)); | 690 | devmap = dasd_devmap_from_cdev(to_ccwdev(dev)); |
690 | if (IS_ERR(devmap)) | 691 | if (IS_ERR(devmap)) |
691 | return PTR_ERR(devmap); | 692 | return PTR_ERR(devmap); |
692 | ro_flag = buf[0] == '1'; | 693 | |
694 | val = simple_strtoul(buf, &endp, 0); | ||
695 | if (((endp + 1) < (buf + count)) || (val > 1)) | ||
696 | return -EINVAL; | ||
697 | |||
693 | spin_lock(&dasd_devmap_lock); | 698 | spin_lock(&dasd_devmap_lock); |
694 | if (ro_flag) | 699 | if (val) |
695 | devmap->features |= DASD_FEATURE_READONLY; | 700 | devmap->features |= DASD_FEATURE_READONLY; |
696 | else | 701 | else |
697 | devmap->features &= ~DASD_FEATURE_READONLY; | 702 | devmap->features &= ~DASD_FEATURE_READONLY; |
698 | if (devmap->device) | 703 | if (devmap->device) |
699 | devmap->device->features = devmap->features; | 704 | devmap->device->features = devmap->features; |
700 | if (devmap->device && devmap->device->gdp) | 705 | if (devmap->device && devmap->device->gdp) |
701 | set_disk_ro(devmap->device->gdp, ro_flag); | 706 | set_disk_ro(devmap->device->gdp, val); |
702 | spin_unlock(&dasd_devmap_lock); | 707 | spin_unlock(&dasd_devmap_lock); |
703 | return count; | 708 | return count; |
704 | } | 709 | } |
@@ -729,17 +734,22 @@ dasd_use_diag_store(struct device *dev, struct device_attribute *attr, | |||
729 | { | 734 | { |
730 | struct dasd_devmap *devmap; | 735 | struct dasd_devmap *devmap; |
731 | ssize_t rc; | 736 | ssize_t rc; |
732 | int use_diag; | 737 | int val; |
738 | char *endp; | ||
733 | 739 | ||
734 | devmap = dasd_devmap_from_cdev(to_ccwdev(dev)); | 740 | devmap = dasd_devmap_from_cdev(to_ccwdev(dev)); |
735 | if (IS_ERR(devmap)) | 741 | if (IS_ERR(devmap)) |
736 | return PTR_ERR(devmap); | 742 | return PTR_ERR(devmap); |
737 | use_diag = buf[0] == '1'; | 743 | |
744 | val = simple_strtoul(buf, &endp, 0); | ||
745 | if (((endp + 1) < (buf + count)) || (val > 1)) | ||
746 | return -EINVAL; | ||
747 | |||
738 | spin_lock(&dasd_devmap_lock); | 748 | spin_lock(&dasd_devmap_lock); |
739 | /* Changing diag discipline flag is only allowed in offline state. */ | 749 | /* Changing diag discipline flag is only allowed in offline state. */ |
740 | rc = count; | 750 | rc = count; |
741 | if (!devmap->device) { | 751 | if (!devmap->device) { |
742 | if (use_diag) | 752 | if (val) |
743 | devmap->features |= DASD_FEATURE_USEDIAG; | 753 | devmap->features |= DASD_FEATURE_USEDIAG; |
744 | else | 754 | else |
745 | devmap->features &= ~DASD_FEATURE_USEDIAG; | 755 | devmap->features &= ~DASD_FEATURE_USEDIAG; |
@@ -854,14 +864,20 @@ dasd_eer_store(struct device *dev, struct device_attribute *attr, | |||
854 | const char *buf, size_t count) | 864 | const char *buf, size_t count) |
855 | { | 865 | { |
856 | struct dasd_devmap *devmap; | 866 | struct dasd_devmap *devmap; |
857 | int rc; | 867 | int val, rc; |
868 | char *endp; | ||
858 | 869 | ||
859 | devmap = dasd_devmap_from_cdev(to_ccwdev(dev)); | 870 | devmap = dasd_devmap_from_cdev(to_ccwdev(dev)); |
860 | if (IS_ERR(devmap)) | 871 | if (IS_ERR(devmap)) |
861 | return PTR_ERR(devmap); | 872 | return PTR_ERR(devmap); |
862 | if (!devmap->device) | 873 | if (!devmap->device) |
863 | return count; | 874 | return -ENODEV; |
864 | if (buf[0] == '1') { | 875 | |
876 | val = simple_strtoul(buf, &endp, 0); | ||
877 | if (((endp + 1) < (buf + count)) || (val > 1)) | ||
878 | return -EINVAL; | ||
879 | |||
880 | if (val) { | ||
865 | rc = dasd_eer_enable(devmap->device); | 881 | rc = dasd_eer_enable(devmap->device); |
866 | if (rc) | 882 | if (rc) |
867 | return rc; | 883 | return rc; |