[S390] ccwgroup: move attributes to attribute group
Put sysfs attributes of ccwgroup devices in an attribute group to ensure that these attributes are actually present when userspace is notified via uevents. Cc: stable@kernel.org Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
This commit is contained in:
committed by
Martin Schwidefsky
parent
d4e81b35b8
commit
dbdf1afcaa
@@ -87,6 +87,12 @@ static void __ccwgroup_remove_cdev_refs(struct ccwgroup_device *gdev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ssize_t ccwgroup_online_store(struct device *dev,
|
||||||
|
struct device_attribute *attr,
|
||||||
|
const char *buf, size_t count);
|
||||||
|
static ssize_t ccwgroup_online_show(struct device *dev,
|
||||||
|
struct device_attribute *attr,
|
||||||
|
char *buf);
|
||||||
/*
|
/*
|
||||||
* Provide an 'ungroup' attribute so the user can remove group devices no
|
* Provide an 'ungroup' attribute so the user can remove group devices no
|
||||||
* longer needed or accidentially created. Saves memory :)
|
* longer needed or accidentially created. Saves memory :)
|
||||||
@@ -134,6 +140,20 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static DEVICE_ATTR(ungroup, 0200, NULL, ccwgroup_ungroup_store);
|
static DEVICE_ATTR(ungroup, 0200, NULL, ccwgroup_ungroup_store);
|
||||||
|
static DEVICE_ATTR(online, 0644, ccwgroup_online_show, ccwgroup_online_store);
|
||||||
|
|
||||||
|
static struct attribute *ccwgroup_attrs[] = {
|
||||||
|
&dev_attr_online.attr,
|
||||||
|
&dev_attr_ungroup.attr,
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
static struct attribute_group ccwgroup_attr_group = {
|
||||||
|
.attrs = ccwgroup_attrs,
|
||||||
|
};
|
||||||
|
static const struct attribute_group *ccwgroup_attr_groups[] = {
|
||||||
|
&ccwgroup_attr_group,
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ccwgroup_release (struct device *dev)
|
ccwgroup_release (struct device *dev)
|
||||||
@@ -293,25 +313,17 @@ int ccwgroup_create_from_string(struct device *root, unsigned int creator_id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
dev_set_name(&gdev->dev, "%s", dev_name(&gdev->cdev[0]->dev));
|
dev_set_name(&gdev->dev, "%s", dev_name(&gdev->cdev[0]->dev));
|
||||||
|
gdev->dev.groups = ccwgroup_attr_groups;
|
||||||
rc = device_add(&gdev->dev);
|
rc = device_add(&gdev->dev);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto error;
|
goto error;
|
||||||
get_device(&gdev->dev);
|
get_device(&gdev->dev);
|
||||||
rc = device_create_file(&gdev->dev, &dev_attr_ungroup);
|
|
||||||
|
|
||||||
if (rc) {
|
|
||||||
device_unregister(&gdev->dev);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = __ccwgroup_create_symlinks(gdev);
|
rc = __ccwgroup_create_symlinks(gdev);
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
mutex_unlock(&gdev->reg_mutex);
|
mutex_unlock(&gdev->reg_mutex);
|
||||||
put_device(&gdev->dev);
|
put_device(&gdev->dev);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
device_remove_file(&gdev->dev, &dev_attr_ungroup);
|
|
||||||
device_unregister(&gdev->dev);
|
device_unregister(&gdev->dev);
|
||||||
error:
|
error:
|
||||||
for (i = 0; i < num_devices; i++)
|
for (i = 0; i < num_devices; i++)
|
||||||
@@ -423,7 +435,7 @@ ccwgroup_online_store (struct device *dev, struct device_attribute *attr, const
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!dev->driver)
|
if (!dev->driver)
|
||||||
return -ENODEV;
|
return -EINVAL;
|
||||||
|
|
||||||
gdev = to_ccwgroupdev(dev);
|
gdev = to_ccwgroupdev(dev);
|
||||||
gdrv = to_ccwgroupdrv(dev->driver);
|
gdrv = to_ccwgroupdrv(dev->driver);
|
||||||
@@ -456,8 +468,6 @@ ccwgroup_online_show (struct device *dev, struct device_attribute *attr, char *b
|
|||||||
return sprintf(buf, online ? "1\n" : "0\n");
|
return sprintf(buf, online ? "1\n" : "0\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static DEVICE_ATTR(online, 0644, ccwgroup_online_show, ccwgroup_online_store);
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ccwgroup_probe (struct device *dev)
|
ccwgroup_probe (struct device *dev)
|
||||||
{
|
{
|
||||||
@@ -469,12 +479,7 @@ ccwgroup_probe (struct device *dev)
|
|||||||
gdev = to_ccwgroupdev(dev);
|
gdev = to_ccwgroupdev(dev);
|
||||||
gdrv = to_ccwgroupdrv(dev->driver);
|
gdrv = to_ccwgroupdrv(dev->driver);
|
||||||
|
|
||||||
if ((ret = device_create_file(dev, &dev_attr_online)))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
ret = gdrv->probe ? gdrv->probe(gdev) : -ENODEV;
|
ret = gdrv->probe ? gdrv->probe(gdev) : -ENODEV;
|
||||||
if (ret)
|
|
||||||
device_remove_file(dev, &dev_attr_online);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -485,9 +490,6 @@ ccwgroup_remove (struct device *dev)
|
|||||||
struct ccwgroup_device *gdev;
|
struct ccwgroup_device *gdev;
|
||||||
struct ccwgroup_driver *gdrv;
|
struct ccwgroup_driver *gdrv;
|
||||||
|
|
||||||
device_remove_file(dev, &dev_attr_online);
|
|
||||||
device_remove_file(dev, &dev_attr_ungroup);
|
|
||||||
|
|
||||||
if (!dev->driver)
|
if (!dev->driver)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user