mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 01:32:21 +02:00
wifi: brcmfmac: flowring: simplify flow allocation
Use a flexible array member and kzalloc_flex to combine allocations. Simplifies code slightly. Add __counted_by for extra runtime analysis. Signed-off-by: Rosen Penev <rosenp@gmail.com> Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com> Link: https://patch.msgid.link/20260608051102.6698-1-rosenp@gmail.com Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
parent
2fd1926686
commit
201dd93a17
|
|
@ -360,20 +360,15 @@ struct brcmf_flowring *brcmf_flowring_attach(struct device *dev, u16 nrofrings)
|
|||
struct brcmf_flowring *flow;
|
||||
u32 i;
|
||||
|
||||
flow = kzalloc_obj(*flow);
|
||||
flow = kzalloc_flex(*flow, rings, nrofrings);
|
||||
if (flow) {
|
||||
flow->dev = dev;
|
||||
flow->nrofrings = nrofrings;
|
||||
flow->dev = dev;
|
||||
spin_lock_init(&flow->block_lock);
|
||||
for (i = 0; i < ARRAY_SIZE(flow->addr_mode); i++)
|
||||
flow->addr_mode[i] = ADDR_INDIRECT;
|
||||
for (i = 0; i < ARRAY_SIZE(flow->hash); i++)
|
||||
flow->hash[i].ifidx = BRCMF_FLOWRING_INVALID_IFIDX;
|
||||
flow->rings = kzalloc_objs(*flow->rings, nrofrings);
|
||||
if (!flow->rings) {
|
||||
kfree(flow);
|
||||
flow = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return flow;
|
||||
|
|
@ -399,7 +394,6 @@ void brcmf_flowring_detach(struct brcmf_flowring *flow)
|
|||
search = search->next;
|
||||
kfree(remove);
|
||||
}
|
||||
kfree(flow->rings);
|
||||
kfree(flow);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,12 +38,12 @@ struct brcmf_flowring_tdls_entry {
|
|||
struct brcmf_flowring {
|
||||
struct device *dev;
|
||||
struct brcmf_flowring_hash hash[BRCMF_FLOWRING_HASHSIZE];
|
||||
struct brcmf_flowring_ring **rings;
|
||||
spinlock_t block_lock;
|
||||
enum proto_addr_mode addr_mode[BRCMF_MAX_IFS];
|
||||
u16 nrofrings;
|
||||
bool tdls_active;
|
||||
struct brcmf_flowring_tdls_entry *tdls_entry;
|
||||
struct brcmf_flowring_ring *rings[] __counted_by(nrofrings);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user