]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: rt2x00: allocate anchor with rt2x00dev
authorRosen Penev <rosenp@gmail.com>
Thu, 30 Apr 2026 23:22:06 +0000 (16:22 -0700)
committerJohannes Berg <johannes.berg@intel.com>
Wed, 20 May 2026 09:57:35 +0000 (11:57 +0200)
Instead of being creative with devm, allocate with rt2x00dev by using a
flexible array member. Simplifies code slightly.

It's worth noting that in 25369b22223d1c56e42a0cd4ac9137349d5a898e , the
proper device was set to the devm call as it seems there was confusion
there.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
Link: https://patch.msgid.link/20260430232206.141461-1-rosenp@gmail.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/ralink/rt2x00/rt2x00.h
drivers/net/wireless/ralink/rt2x00/rt2x00usb.c

index 665887e9b118bf4c33db6804a0a750d52efc7e6d..7d313e86d3f2016ded0bf20f37cbc12fc73bca2f 100644 (file)
@@ -1009,11 +1009,12 @@ struct rt2x00_dev {
        /* Extra TX headroom required for alignment purposes. */
        unsigned int extra_tx_headroom;
 
-       struct usb_anchor *anchor;
        unsigned int num_proto_errs;
 
        /* Clock for System On Chip devices. */
        struct clk *clk;
+
+       struct usb_anchor anchor[];
 };
 
 struct rt2x00_bar_list_entry {
index 174d89b0b1d77b3835f2ed91b54a1d616cde8550..47e427ea86221a92a984db503c1fe096366290a4 100644 (file)
@@ -804,7 +804,7 @@ int rt2x00usb_probe(struct usb_interface *usb_intf,
 
        usb_reset_device(usb_dev);
 
-       hw = ieee80211_alloc_hw(sizeof(struct rt2x00_dev), ops->hw);
+       hw = ieee80211_alloc_hw(struct_size(rt2x00dev, anchor, 1), ops->hw);
        if (!hw) {
                rt2x00_probe_err("Failed to allocate hardware\n");
                return -ENOMEM;
@@ -826,13 +826,6 @@ int rt2x00usb_probe(struct usb_interface *usb_intf,
        if (retval)
                goto exit_free_device;
 
-       rt2x00dev->anchor = devm_kmalloc(&usb_intf->dev,
-                                       sizeof(struct usb_anchor),
-                                       GFP_KERNEL);
-       if (!rt2x00dev->anchor) {
-               retval = -ENOMEM;
-               goto exit_free_reg;
-       }
        init_usb_anchor(rt2x00dev->anchor);
 
        retval = rt2x00lib_probe_dev(rt2x00dev);
@@ -843,8 +836,6 @@ int rt2x00usb_probe(struct usb_interface *usb_intf,
 
 exit_free_anchor:
        usb_kill_anchored_urbs(rt2x00dev->anchor);
-
-exit_free_reg:
        rt2x00usb_free_reg(rt2x00dev);
 
 exit_free_device: