s390/vmlogrdr: cleanup device attribute usage

Let the driver core handle device attribute creation and removal. This
will simplify the code and eliminates races between attribute
availability and userspace notification via uevents.

Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
This commit is contained in:
Sebastian Ott 2012-06-04 19:32:13 +02:00 коммит произвёл Martin Schwidefsky
Родитель 8d4ecfcb6b
Коммит 76e0377b24
1 изменённых файлов: 8 добавлений и 11 удалений

Просмотреть файл

@ -668,6 +668,13 @@ static struct attribute *vmlogrdr_attrs[] = {
&dev_attr_recording.attr, &dev_attr_recording.attr,
NULL, NULL,
}; };
static struct attribute_group vmlogrdr_attr_group = {
.attrs = vmlogrdr_attrs,
};
static const struct attribute_group *vmlogrdr_attr_groups[] = {
&vmlogrdr_attr_group,
NULL,
};
static int vmlogrdr_pm_prepare(struct device *dev) static int vmlogrdr_pm_prepare(struct device *dev)
{ {
@ -692,10 +699,6 @@ static const struct dev_pm_ops vmlogrdr_pm_ops = {
.prepare = vmlogrdr_pm_prepare, .prepare = vmlogrdr_pm_prepare,
}; };
static struct attribute_group vmlogrdr_attr_group = {
.attrs = vmlogrdr_attrs,
};
static struct class *vmlogrdr_class; static struct class *vmlogrdr_class;
static struct device_driver vmlogrdr_driver = { static struct device_driver vmlogrdr_driver = {
.name = "vmlogrdr", .name = "vmlogrdr",
@ -762,6 +765,7 @@ static int vmlogrdr_register_device(struct vmlogrdr_priv_t *priv)
dev->bus = &iucv_bus; dev->bus = &iucv_bus;
dev->parent = iucv_root; dev->parent = iucv_root;
dev->driver = &vmlogrdr_driver; dev->driver = &vmlogrdr_driver;
dev->groups = vmlogrdr_attr_groups;
dev_set_drvdata(dev, priv); dev_set_drvdata(dev, priv);
/* /*
* The release function could be called after the * The release function could be called after the
@ -779,11 +783,6 @@ static int vmlogrdr_register_device(struct vmlogrdr_priv_t *priv)
return ret; return ret;
} }
ret = sysfs_create_group(&dev->kobj, &vmlogrdr_attr_group);
if (ret) {
device_unregister(dev);
return ret;
}
priv->class_device = device_create(vmlogrdr_class, dev, priv->class_device = device_create(vmlogrdr_class, dev,
MKDEV(vmlogrdr_major, MKDEV(vmlogrdr_major,
priv->minor_num), priv->minor_num),
@ -791,7 +790,6 @@ static int vmlogrdr_register_device(struct vmlogrdr_priv_t *priv)
if (IS_ERR(priv->class_device)) { if (IS_ERR(priv->class_device)) {
ret = PTR_ERR(priv->class_device); ret = PTR_ERR(priv->class_device);
priv->class_device=NULL; priv->class_device=NULL;
sysfs_remove_group(&dev->kobj, &vmlogrdr_attr_group);
device_unregister(dev); device_unregister(dev);
return ret; return ret;
} }
@ -804,7 +802,6 @@ static int vmlogrdr_unregister_device(struct vmlogrdr_priv_t *priv)
{ {
device_destroy(vmlogrdr_class, MKDEV(vmlogrdr_major, priv->minor_num)); device_destroy(vmlogrdr_class, MKDEV(vmlogrdr_major, priv->minor_num));
if (priv->device != NULL) { if (priv->device != NULL) {
sysfs_remove_group(&priv->device->kobj, &vmlogrdr_attr_group);
device_unregister(priv->device); device_unregister(priv->device);
priv->device=NULL; priv->device=NULL;
} }