Commit 0b945293c4fa89347b295ccb355e5faad1585039
Committed by
David S. Miller
1 parent
9fafbd4d5f
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
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>
Showing 1 changed file with 6 additions and 28 deletions Side-by-side Diff
drivers/s390/net/netiucv.c
... | ... | @@ -1854,27 +1854,12 @@ |
1854 | 1854 | .attrs = netiucv_stat_attrs, |
1855 | 1855 | }; |
1856 | 1856 | |
1857 | -static int netiucv_add_files(struct device *dev) | |
1858 | -{ | |
1859 | - int ret; | |
1857 | +static const struct attribute_group *netiucv_attr_groups[] = { | |
1858 | + &netiucv_stat_attr_group, | |
1859 | + &netiucv_attr_group, | |
1860 | + NULL, | |
1861 | +}; | |
1860 | 1862 | |
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 | -} | |
1877 | - | |
1878 | 1863 | static int netiucv_register_device(struct net_device *ndev) |
1879 | 1864 | { |
1880 | 1865 | struct netiucv_priv *priv = netdev_priv(ndev); |
... | ... | @@ -1887,6 +1872,7 @@ |
1887 | 1872 | dev_set_name(dev, "net%s", ndev->name); |
1888 | 1873 | dev->bus = &iucv_bus; |
1889 | 1874 | dev->parent = iucv_root; |
1875 | + dev->groups = netiucv_attr_groups; | |
1890 | 1876 | /* |
1891 | 1877 | * The release function could be called after the |
1892 | 1878 | * module has been unloaded. It's _only_ task is to |
1893 | 1879 | |
1894 | 1880 | |
... | ... | @@ -1904,22 +1890,14 @@ |
1904 | 1890 | put_device(dev); |
1905 | 1891 | return ret; |
1906 | 1892 | } |
1907 | - ret = netiucv_add_files(dev); | |
1908 | - if (ret) | |
1909 | - goto out_unreg; | |
1910 | 1893 | priv->dev = dev; |
1911 | 1894 | dev_set_drvdata(dev, priv); |
1912 | 1895 | return 0; |
1913 | - | |
1914 | -out_unreg: | |
1915 | - device_unregister(dev); | |
1916 | - return ret; | |
1917 | 1896 | } |
1918 | 1897 | |
1919 | 1898 | static void netiucv_unregister_device(struct device *dev) |
1920 | 1899 | { |
1921 | 1900 | IUCV_DBF_TEXT(trace, 3, __func__); |
1922 | - netiucv_remove_files(dev); | |
1923 | 1901 | device_unregister(dev); |
1924 | 1902 | } |
1925 | 1903 |