summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenzo Bianconi <lorenzo@kernel.org>2022-06-30 14:55:18 +0200
committerFelix Fietkau <nbd@nbd.name>2022-07-11 13:40:03 +0200
commitb146f238d1200f975b5f6d833ef70dab4f4474d4 (patch)
tree6138452f1cf60d2dd39e811e407802cf2de9e5c7
parent7e6ffd5d5da93ee3936402058e12826669849611 (diff)
downloadlwn-b146f238d1200f975b5f6d833ef70dab4f4474d4.tar.gz
lwn-b146f238d1200f975b5f6d833ef70dab4f4474d4.zip
mt76: add len parameter to __mt76_mcu_msg_alloc signature
Introduce len to __mt76_mcu_msg_alloc signature in order to add the capability to specify two different value for allocation and copy length. Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r--drivers/net/wireless/mediatek/mt76/mcu.c10
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt76.h4
-rw-r--r--drivers/net/wireless/mediatek/mt76/mt7921/main.c11
3 files changed, 13 insertions, 12 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/mcu.c b/drivers/net/wireless/mediatek/mt76/mcu.c
index 914ee278e6e2..a8cafa39a56d 100644
--- a/drivers/net/wireless/mediatek/mt76/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mcu.c
@@ -7,17 +7,19 @@
struct sk_buff *
__mt76_mcu_msg_alloc(struct mt76_dev *dev, const void *data,
- int data_len, gfp_t gfp)
+ int len, int data_len, gfp_t gfp)
{
const struct mt76_mcu_ops *ops = dev->mcu_ops;
- int length = ops->headroom + data_len + ops->tailroom;
struct sk_buff *skb;
- skb = alloc_skb(length, gfp);
+ len = max_t(int, len, data_len);
+ len = ops->headroom + len + ops->tailroom;
+
+ skb = alloc_skb(len, gfp);
if (!skb)
return NULL;
- memset(skb->head, 0, length);
+ memset(skb->head, 0, len);
skb_reserve(skb, ops->headroom);
if (data && data_len)
diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index f25f2dad43d8..0a86afbe89db 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -1343,12 +1343,12 @@ int mt76s_rd_rp(struct mt76_dev *dev, u32 base,
struct sk_buff *
__mt76_mcu_msg_alloc(struct mt76_dev *dev, const void *data,
- int data_len, gfp_t gfp);
+ int len, int data_len, gfp_t gfp);
static inline struct sk_buff *
mt76_mcu_msg_alloc(struct mt76_dev *dev, const void *data,
int data_len)
{
- return __mt76_mcu_msg_alloc(dev, data, data_len, GFP_KERNEL);
+ return __mt76_mcu_msg_alloc(dev, data, data_len, data_len, GFP_KERNEL);
}
void mt76_mcu_rx_event(struct mt76_dev *dev, struct sk_buff *skb);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/main.c b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
index 6891d655ab93..7628204a5d99 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/main.c
@@ -1454,15 +1454,14 @@ static void mt7921_ipv6_addr_change(struct ieee80211_hw *hw,
if (!idx)
return;
- skb = __mt76_mcu_msg_alloc(&dev->mt76, NULL, sizeof(req_hdr) +
- idx * sizeof(struct in6_addr), GFP_ATOMIC);
- if (!skb)
- return;
-
req_hdr.arpns.ips_num = idx;
req_hdr.arpns.len = cpu_to_le16(sizeof(struct mt76_connac_arpns_tlv)
+ idx * sizeof(struct in6_addr));
- skb_put_data(skb, &req_hdr, sizeof(req_hdr));
+ skb = __mt76_mcu_msg_alloc(&dev->mt76, &req_hdr,
+ sizeof(req_hdr) + idx * sizeof(struct in6_addr),
+ sizeof(req_hdr), GFP_ATOMIC);
+ if (!skb)
+ return;
for (i = 0; i < idx; i++)
skb_put_data(skb, &ns_addrs[i].in6_u, sizeof(struct in6_addr));