]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: mac80211_hwsim: change hwsim_class to a const struct
authorJori Koolstra <jkoolstra@xs4all.nl>
Tue, 3 Mar 2026 16:59:37 +0000 (17:59 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 4 Mar 2026 10:42:38 +0000 (11:42 +0100)
The class_create() call has been deprecated in favor of class_register()
as the driver core now allows for a struct class to be in read-only
memory. Change hwsim_class to be a const struct class and drop the
class_create() call.

Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jori Koolstra <jkoolstra@xs4all.nl>
Link: https://patch.msgid.link/20260303165938.3773998-1-jkoolstra@xs4all.nl
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/virtual/mac80211_hwsim.c

index 475918ee8132f5df9a99a148f6f5a7fe44052379..32897d88bda3209ed4ca3779280a2aac44baafae 100644 (file)
@@ -337,7 +337,9 @@ static inline void hwsim_net_set_wmediumd(struct net *net, u32 portid)
        hwsim_net->wmediumd = portid;
 }
 
-static struct class *hwsim_class;
+static const struct class hwsim_class = {
+       .name   = "mac80211_hwsim"
+};
 
 static struct net_device *hwsim_mon; /* global monitor netdev */
 
@@ -5524,7 +5526,7 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
        data = hw->priv;
        data->hw = hw;
 
-       data->dev = device_create(hwsim_class, NULL, 0, hw, "hwsim%d", idx);
+       data->dev = device_create(&hwsim_class, NULL, 0, hw, "hwsim%d", idx);
        if (IS_ERR(data->dev)) {
                printk(KERN_DEBUG
                       "mac80211_hwsim: device_create failed (%ld)\n",
@@ -6097,7 +6099,7 @@ static void mac80211_hwsim_free(void)
                spin_lock_bh(&hwsim_radio_lock);
        }
        spin_unlock_bh(&hwsim_radio_lock);
-       class_destroy(hwsim_class);
+       class_unregister(&hwsim_class);
 }
 
 static const struct net_device_ops hwsim_netdev_ops = {
@@ -7205,11 +7207,9 @@ static int __init init_mac80211_hwsim(void)
        if (err)
                goto out_exit_netlink;
 
-       hwsim_class = class_create("mac80211_hwsim");
-       if (IS_ERR(hwsim_class)) {
-               err = PTR_ERR(hwsim_class);
+       err = class_register(&hwsim_class);
+       if (err)
                goto out_exit_virtio;
-       }
 
        hwsim_init_s1g_channels(hwsim_channels_s1g);