Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ar5523: use container_of

If we want to shrink skb->cb then we'd have to see about
reducing struct ieee80211_tx_info, which gets embedded inside
skb->cb[].

It provides a scratch space to be used by wireless drivers.
ar5523 uses the maximum space available today (40 bytes), but it seems
we don't need this -- data->skb pointer seems to always point back to the
skb whose cb buffer the data structure resides, iow, given a pointer to the
embedded control buffer we can infer the skb address.

Tested-by: Pontus Fuchs <pontus.fuchs@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>

authored by

Florian Westphal and committed by
Kalle Valo
6faf22d9 dd295112

+5 -5
+5 -4
drivers/net/wireless/ath/ar5523/ar5523.c
··· 779 779 ieee80211_stop_queues(hw); 780 780 } 781 781 782 - data->skb = skb; 783 - 784 782 spin_lock_irqsave(&ar->tx_data_list_lock, flags); 785 783 list_add_tail(&data->list, &ar->tx_queue_pending); 786 784 spin_unlock_irqrestore(&ar->tx_data_list_lock, flags); ··· 815 817 if (!data) 816 818 break; 817 819 818 - skb = data->skb; 820 + txi = container_of((void *)data, struct ieee80211_tx_info, 821 + driver_data); 819 822 txqid = 0; 820 - txi = IEEE80211_SKB_CB(skb); 823 + 824 + skb = container_of((void *)txi, struct sk_buff, cb); 821 825 paylen = skb->len; 826 + 822 827 urb = usb_alloc_urb(0, GFP_KERNEL); 823 828 if (!urb) { 824 829 ar5523_err(ar, "Failed to allocate TX urb\n");
-1
drivers/net/wireless/ath/ar5523/ar5523.h
··· 74 74 struct ar5523_tx_data { 75 75 struct list_head list; 76 76 struct ar5523 *ar; 77 - struct sk_buff *skb; 78 77 struct urb *urb; 79 78 }; 80 79