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

netiucv: cleanup 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: Frank Blaschka <frank.blaschka@de.ibm.com>
Acked-by: Ursula Braun <ursula.braun@de.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

frank.blaschka@de.ibm.com and committed by
David S. Miller
0b945293 9fafbd4d

+6 -28
+6 -28
drivers/s390/net/netiucv.c
··· 1854 1854 .attrs = netiucv_stat_attrs, 1855 1855 }; 1856 1856 1857 - static int netiucv_add_files(struct device *dev) 1858 - { 1859 - int ret; 1860 - 1861 - IUCV_DBF_TEXT(trace, 3, __func__); 1862 - ret = sysfs_create_group(&dev->kobj, &netiucv_attr_group); 1863 - if (ret) 1864 - return ret; 1865 - ret = sysfs_create_group(&dev->kobj, &netiucv_stat_attr_group); 1866 - if (ret) 1867 - sysfs_remove_group(&dev->kobj, &netiucv_attr_group); 1868 - return ret; 1869 - } 1870 - 1871 - static void netiucv_remove_files(struct device *dev) 1872 - { 1873 - IUCV_DBF_TEXT(trace, 3, __func__); 1874 - sysfs_remove_group(&dev->kobj, &netiucv_stat_attr_group); 1875 - sysfs_remove_group(&dev->kobj, &netiucv_attr_group); 1876 - } 1857 + static const struct attribute_group *netiucv_attr_groups[] = { 1858 + &netiucv_stat_attr_group, 1859 + &netiucv_attr_group, 1860 + NULL, 1861 + }; 1877 1862 1878 1863 static int netiucv_register_device(struct net_device *ndev) 1879 1864 { ··· 1872 1887 dev_set_name(dev, "net%s", ndev->name); 1873 1888 dev->bus = &iucv_bus; 1874 1889 dev->parent = iucv_root; 1890 + dev->groups = netiucv_attr_groups; 1875 1891 /* 1876 1892 * The release function could be called after the 1877 1893 * module has been unloaded. It's _only_ task is to ··· 1890 1904 put_device(dev); 1891 1905 return ret; 1892 1906 } 1893 - ret = netiucv_add_files(dev); 1894 - if (ret) 1895 - goto out_unreg; 1896 1907 priv->dev = dev; 1897 1908 dev_set_drvdata(dev, priv); 1898 1909 return 0; 1899 - 1900 - out_unreg: 1901 - device_unregister(dev); 1902 - return ret; 1903 1910 } 1904 1911 1905 1912 static void netiucv_unregister_device(struct device *dev) 1906 1913 { 1907 1914 IUCV_DBF_TEXT(trace, 3, __func__); 1908 - netiucv_remove_files(dev); 1909 1915 device_unregister(dev); 1910 1916 } 1911 1917