s390/cio: cleanup cmb_enable sysfs attr
Ensure that we hold the ccwlock when accessing private data. Return errors that occur during measurement enabling to userspace. Apply some cleanups while at it. Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
This commit is contained in:
parent
3c4aac86cb
commit
279b8f9a0f
1 changed files with 14 additions and 8 deletions
|
@ -1171,23 +1171,28 @@ static ssize_t cmb_enable_show(struct device *dev,
|
||||||
struct device_attribute *attr,
|
struct device_attribute *attr,
|
||||||
char *buf)
|
char *buf)
|
||||||
{
|
{
|
||||||
return sprintf(buf, "%d\n", to_ccwdev(dev)->private->cmb ? 1 : 0);
|
struct ccw_device *cdev = to_ccwdev(dev);
|
||||||
|
int enabled;
|
||||||
|
|
||||||
|
spin_lock_irq(cdev->ccwlock);
|
||||||
|
enabled = !!cdev->private->cmb;
|
||||||
|
spin_unlock_irq(cdev->ccwlock);
|
||||||
|
|
||||||
|
return sprintf(buf, "%d\n", enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t cmb_enable_store(struct device *dev,
|
static ssize_t cmb_enable_store(struct device *dev,
|
||||||
struct device_attribute *attr, const char *buf,
|
struct device_attribute *attr, const char *buf,
|
||||||
size_t c)
|
size_t c)
|
||||||
{
|
{
|
||||||
struct ccw_device *cdev;
|
struct ccw_device *cdev = to_ccwdev(dev);
|
||||||
int ret;
|
|
||||||
unsigned long val;
|
unsigned long val;
|
||||||
|
int ret;
|
||||||
|
|
||||||
ret = kstrtoul(buf, 16, &val);
|
ret = kstrtoul(buf, 16, &val);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
cdev = to_ccwdev(dev);
|
|
||||||
|
|
||||||
switch (val) {
|
switch (val) {
|
||||||
case 0:
|
case 0:
|
||||||
ret = disable_cmf(cdev);
|
ret = disable_cmf(cdev);
|
||||||
|
@ -1195,12 +1200,13 @@ static ssize_t cmb_enable_store(struct device *dev,
|
||||||
case 1:
|
case 1:
|
||||||
ret = enable_cmf(cdev);
|
ret = enable_cmf(cdev);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
ret = -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return c;
|
return ret ? ret : c;
|
||||||
}
|
}
|
||||||
|
DEVICE_ATTR_RW(cmb_enable);
|
||||||
DEVICE_ATTR(cmb_enable, 0644, cmb_enable_show, cmb_enable_store);
|
|
||||||
|
|
||||||
int ccw_set_cmf(struct ccw_device *cdev, int enable)
|
int ccw_set_cmf(struct ccw_device *cdev, int enable)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue