Commit 215a2efa authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Felix Fietkau

mt76: introduce __mt76_mcu_send_firmware routine

Introduce __mt76_mcu_send_firmware routine to specify mcu message max
length. This is a preliminary patch to support mt7921s driver.
Co-developed-by: default avatarSean Wang <sean.wang@mediatek.com>
Signed-off-by: default avatarSean Wang <sean.wang@mediatek.com>
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
parent a8315b2b
...@@ -106,13 +106,13 @@ int mt76_mcu_skb_send_and_get_msg(struct mt76_dev *dev, struct sk_buff *skb, ...@@ -106,13 +106,13 @@ int mt76_mcu_skb_send_and_get_msg(struct mt76_dev *dev, struct sk_buff *skb,
} }
EXPORT_SYMBOL_GPL(mt76_mcu_skb_send_and_get_msg); EXPORT_SYMBOL_GPL(mt76_mcu_skb_send_and_get_msg);
int mt76_mcu_send_firmware(struct mt76_dev *dev, int cmd, const void *data, int __mt76_mcu_send_firmware(struct mt76_dev *dev, int cmd, const void *data,
int len) int len, int max_len)
{ {
int err, cur_len; int err, cur_len;
while (len > 0) { while (len > 0) {
cur_len = min_t(int, 4096 - dev->mcu_ops->headroom, len); cur_len = min_t(int, max_len - dev->mcu_ops->headroom, len);
err = mt76_mcu_send_msg(dev, cmd, data, cur_len, false); err = mt76_mcu_send_msg(dev, cmd, data, cur_len, false);
if (err) if (err)
...@@ -129,4 +129,4 @@ int mt76_mcu_send_firmware(struct mt76_dev *dev, int cmd, const void *data, ...@@ -129,4 +129,4 @@ int mt76_mcu_send_firmware(struct mt76_dev *dev, int cmd, const void *data,
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(mt76_mcu_send_firmware); EXPORT_SYMBOL_GPL(__mt76_mcu_send_firmware);
...@@ -1258,8 +1258,15 @@ int mt76_mcu_send_and_get_msg(struct mt76_dev *dev, int cmd, const void *data, ...@@ -1258,8 +1258,15 @@ int mt76_mcu_send_and_get_msg(struct mt76_dev *dev, int cmd, const void *data,
int len, bool wait_resp, struct sk_buff **ret); int len, bool wait_resp, struct sk_buff **ret);
int mt76_mcu_skb_send_and_get_msg(struct mt76_dev *dev, struct sk_buff *skb, int mt76_mcu_skb_send_and_get_msg(struct mt76_dev *dev, struct sk_buff *skb,
int cmd, bool wait_resp, struct sk_buff **ret); int cmd, bool wait_resp, struct sk_buff **ret);
int mt76_mcu_send_firmware(struct mt76_dev *dev, int cmd, const void *data, int __mt76_mcu_send_firmware(struct mt76_dev *dev, int cmd, const void *data,
int len); int len, int max_len);
static inline int
mt76_mcu_send_firmware(struct mt76_dev *dev, int cmd, const void *data,
int len)
{
return __mt76_mcu_send_firmware(dev, cmd, data, len, 4096);
}
static inline int static inline int
mt76_mcu_send_msg(struct mt76_dev *dev, int cmd, const void *data, int len, mt76_mcu_send_msg(struct mt76_dev *dev, int cmd, const void *data, int len,
bool wait_resp) bool wait_resp)
......
...@@ -716,8 +716,8 @@ static int mt7921_load_patch(struct mt7921_dev *dev) ...@@ -716,8 +716,8 @@ static int mt7921_load_patch(struct mt7921_dev *dev)
goto out; goto out;
} }
ret = mt76_mcu_send_firmware(&dev->mt76, MCU_CMD_FW_SCATTER, ret = __mt76_mcu_send_firmware(&dev->mt76, MCU_CMD_FW_SCATTER,
dl, len); dl, len, 4096);
if (ret) { if (ret) {
dev_err(dev->mt76.dev, "Failed to send patch\n"); dev_err(dev->mt76.dev, "Failed to send patch\n");
goto out; goto out;
...@@ -788,8 +788,8 @@ mt7921_mcu_send_ram_firmware(struct mt7921_dev *dev, ...@@ -788,8 +788,8 @@ mt7921_mcu_send_ram_firmware(struct mt7921_dev *dev,
return err; return err;
} }
err = mt76_mcu_send_firmware(&dev->mt76, MCU_CMD_FW_SCATTER, err = __mt76_mcu_send_firmware(&dev->mt76, MCU_CMD_FW_SCATTER,
data + offset, len); data + offset, len, 4096);
if (err) { if (err) {
dev_err(dev->mt76.dev, "Failed to send firmware.\n"); dev_err(dev->mt76.dev, "Failed to send firmware.\n");
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment