diff options
author | Lorenzo Bianconi <lorenzo@kernel.org> | 2019-04-30 17:17:23 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2019-05-01 13:04:00 +0200 |
commit | 4d2a6f7b4e17ede86be46013d114d58adaca5631 (patch) | |
tree | a4111825241554212aa2cf48913af68fa7460e73 | |
parent | ae66068f7872872740906cf7699624bfd90516ae (diff) | |
download | linux-4d2a6f7b4e17ede86be46013d114d58adaca5631.tar.gz linux-4d2a6f7b4e17ede86be46013d114d58adaca5631.tar.bz2 linux-4d2a6f7b4e17ede86be46013d114d58adaca5631.zip |
mt76: mt7603: dynamically alloc mcu req in mt7603_mcu_set_eeprom
Do not allocate mcu requests on the stack in mt7603_mcu_set_eeprom
in order to avoid the following warning:
Warning: the frame size of 1032 bytes is larger than 1024 bytes
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r-- | drivers/net/wireless/mediatek/mt76/mt7603/mcu.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7603/mcu.c index 766d968671b3..6357b5658a32 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7603/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7603/mcu.c @@ -354,24 +354,34 @@ int mt7603_mcu_set_eeprom(struct mt7603_dev *dev) u8 buffer_mode; u8 len; u8 pad[2]; - struct req_data data[255]; - } req = { + } req_hdr = { .buffer_mode = 1, .len = ARRAY_SIZE(req_fields) - 1, }; - u8 *eep = (u8 *)dev->mt76.eeprom.data; - int i; + const int size = 0xff * sizeof(struct req_data); + u8 *req, *eep = (u8 *)dev->mt76.eeprom.data; + int i, ret, len = sizeof(req_hdr) + size; + struct req_data *data; - BUILD_BUG_ON(ARRAY_SIZE(req_fields) > ARRAY_SIZE(req.data)); + BUILD_BUG_ON(ARRAY_SIZE(req_fields) * sizeof(*data) > size); + + req = kmalloc(len, GFP_KERNEL); + if (!req) + return -ENOMEM; + memcpy(req, &req_hdr, sizeof(req_hdr)); + data = (struct req_data *)(req + sizeof(req_hdr)); + memset(data, 0, size); for (i = 0; i < ARRAY_SIZE(req_fields); i++) { - req.data[i].addr = cpu_to_le16(req_fields[i]); - req.data[i].val = eep[req_fields[i]]; - req.data[i].pad = 0; + data[i].addr = cpu_to_le16(req_fields[i]); + data[i].val = eep[req_fields[i]]; } - return __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_EFUSE_BUFFER_MODE, - &req, sizeof(req), true); + ret = __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_EFUSE_BUFFER_MODE, + req, len, true); + kfree(req); + + return ret; } static int mt7603_mcu_set_tx_power(struct mt7603_dev *dev) |