Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Sebastian Ott and committed by
Martin Schwidefsky
76e0377b 8d4ecfcb

+8 -11
+8 -11
drivers/s390/char/vmlogrdr.c
··· 668 668 &dev_attr_recording.attr, 669 669 NULL, 670 670 }; 671 + static struct attribute_group vmlogrdr_attr_group = { 672 + .attrs = vmlogrdr_attrs, 673 + }; 674 + static const struct attribute_group *vmlogrdr_attr_groups[] = { 675 + &vmlogrdr_attr_group, 676 + NULL, 677 + }; 671 678 672 679 static int vmlogrdr_pm_prepare(struct device *dev) 673 680 { ··· 697 690 698 691 static const struct dev_pm_ops vmlogrdr_pm_ops = { 699 692 .prepare = vmlogrdr_pm_prepare, 700 - }; 701 - 702 - static struct attribute_group vmlogrdr_attr_group = { 703 - .attrs = vmlogrdr_attrs, 704 693 }; 705 694 706 695 static struct class *vmlogrdr_class; ··· 765 762 dev->bus = &iucv_bus; 766 763 dev->parent = iucv_root; 767 764 dev->driver = &vmlogrdr_driver; 765 + dev->groups = vmlogrdr_attr_groups; 768 766 dev_set_drvdata(dev, priv); 769 767 /* 770 768 * The release function could be called after the ··· 783 779 return ret; 784 780 } 785 781 786 - ret = sysfs_create_group(&dev->kobj, &vmlogrdr_attr_group); 787 - if (ret) { 788 - device_unregister(dev); 789 - return ret; 790 - } 791 782 priv->class_device = device_create(vmlogrdr_class, dev, 792 783 MKDEV(vmlogrdr_major, 793 784 priv->minor_num), ··· 790 791 if (IS_ERR(priv->class_device)) { 791 792 ret = PTR_ERR(priv->class_device); 792 793 priv->class_device=NULL; 793 - sysfs_remove_group(&dev->kobj, &vmlogrdr_attr_group); 794 794 device_unregister(dev); 795 795 return ret; 796 796 } ··· 802 804 { 803 805 device_destroy(vmlogrdr_class, MKDEV(vmlogrdr_major, priv->minor_num)); 804 806 if (priv->device != NULL) { 805 - sysfs_remove_group(&priv->device->kobj, &vmlogrdr_attr_group); 806 807 device_unregister(priv->device); 807 808 priv->device=NULL; 808 809 }