]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: b43: kzalloc + kcalloc to kzalloc_flex
authorRosen Penev <rosenp@gmail.com>
Wed, 11 Mar 2026 00:47:36 +0000 (17:47 -0700)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 24 Mar 2026 15:32:45 +0000 (16:32 +0100)
Simplifies allocation and allows using __counted_by for extra runtime
analysis.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://patch.msgid.link/20260311004736.32730-1-rosenp@gmail.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/broadcom/b43/dma.c
drivers/net/wireless/broadcom/b43/dma.h

index 3a8df7a180427a40612ffad0119af7a2e024ae11..05da6987a845076895fa2a80f409a1e583fad05e 100644 (file)
@@ -837,18 +837,19 @@ struct b43_dmaring *b43_setup_dmaring(struct b43_wldev *dev,
        struct b43_dmaring *ring;
        int i, err;
        dma_addr_t dma_test;
+       size_t nr_slots;
 
-       ring = kzalloc_obj(*ring);
+       if (for_tx)
+               nr_slots = B43_TXRING_SLOTS;
+       else
+               nr_slots = B43_RXRING_SLOTS;
+
+       ring = kzalloc_flex(*ring, meta, nr_slots);
        if (!ring)
                goto out;
 
-       ring->nr_slots = B43_RXRING_SLOTS;
-       if (for_tx)
-               ring->nr_slots = B43_TXRING_SLOTS;
+       ring->nr_slots = nr_slots;
 
-       ring->meta = kzalloc_objs(struct b43_dmadesc_meta, ring->nr_slots);
-       if (!ring->meta)
-               goto err_kfree_ring;
        for (i = 0; i < ring->nr_slots; i++)
                ring->meta->skb = B43_DMA_PTR_POISON;
 
@@ -943,8 +944,6 @@ struct b43_dmaring *b43_setup_dmaring(struct b43_wldev *dev,
       err_kfree_txhdr_cache:
        kfree(ring->txhdr_cache);
       err_kfree_meta:
-       kfree(ring->meta);
-      err_kfree_ring:
        kfree(ring);
        ring = NULL;
        goto out;
@@ -1004,7 +1003,6 @@ static void b43_destroy_dmaring(struct b43_dmaring *ring,
        free_ringmemory(ring);
 
        kfree(ring->txhdr_cache);
-       kfree(ring->meta);
        kfree(ring);
 }
 
index c2a357219d4b87774e1e9fbbb705de9f5b4ed082..f9f65bbe2d768f20e84d7834c2f296ba1b73faa7 100644 (file)
@@ -228,8 +228,6 @@ struct b43_dmaring {
        const struct b43_dma_ops *ops;
        /* Kernel virtual base address of the ring memory. */
        void *descbase;
-       /* Meta data about all descriptors. */
-       struct b43_dmadesc_meta *meta;
        /* Cache of TX headers for each TX frame.
         * This is to avoid an allocation on each TX.
         * This is NULL for an RX ring.
@@ -273,6 +271,8 @@ struct b43_dmaring {
        /* Statistics: Total number of TX plus all retries. */
        u64 nr_total_packet_tries;
 #endif /* CONFIG_B43_DEBUG */
+       /* Meta data about all descriptors. */
+       struct b43_dmadesc_meta meta[] __counted_by(nr_slots);
 };
 
 static inline u32 b43_dma_read(struct b43_dmaring *ring, u16 offset)