From patchwork Tue Mar 17 16:41:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 216270 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBEC0C2BB1D for ; Tue, 17 Mar 2020 16:42:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C0A7120738 for ; Tue, 17 Mar 2020 16:42:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584463332; bh=OIDV7xOwK4cL9i/DBOwXG2DvG5Kqko1qEZiH/mXmJz4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=TD/KkNpS+qqDEHZWjZwM6eYrUGyjEKLULsyyNt5N3vGRTX9QB9Z7HLNKsrBY1Z+X6 OfwUZQwvM8YVsGoJn8hsM5DIRWRyuPHrSlT42NMeqfET7N8Fp3GVhswBjjbRNVw7LS NBHFW/Y48RdR05IabWRCrsnRypUahQrbxzjtMjHw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726766AbgCQQmM (ORCPT ); Tue, 17 Mar 2020 12:42:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:47194 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726019AbgCQQmL (ORCPT ); Tue, 17 Mar 2020 12:42:11 -0400 Received: from lore-desk-wlan.redhat.com (unknown [151.48.128.122]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E4AD020735; Tue, 17 Mar 2020 16:42:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584463331; bh=OIDV7xOwK4cL9i/DBOwXG2DvG5Kqko1qEZiH/mXmJz4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=it7h+xwJiWIRN73eQ9nHzFwTFmcLLJvvmLtAjXYGI3rtKDsFednveCGiFDm9MfTJT dPem/S2iuPpCnalt4A1bpkwvPtzaS1RgwYSFNpdRP+kEpLEjc2qXU3Namh4tJA3VOz YGCgQiHBJ+5fUvRRQHwSwyL/8G+0v+pB1ReTqom0= From: Lorenzo Bianconi To: nbd@nbd.name Cc: lorenzo.bianconi@redhat.com, sean.wang@mediatek.com, ryder.lee@mediatek.com, linux-wireless@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH v4 10/25] mt76: mt7615: rely on skb API for mt7615_mcu_set_eeprom Date: Tue, 17 Mar 2020 17:41:17 +0100 Message-Id: <3696d88f8ef0e2a58979d7bb8ba4ce5d9cadbfb1.1584463004.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Rely on skb API and avoid kmalloc the buffer in mt7615_mcu_set_eeprom routine Signed-off-by: Lorenzo Bianconi --- .../net/wireless/mediatek/mt76/mt7615/mcu.c | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c index 2ad8173f95ef..73ec31b20d21 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c @@ -1262,28 +1262,26 @@ int mt7615_mcu_set_eeprom(struct mt7615_dev *dev) } __packed req_hdr = { .buffer_mode = 1, }; - int ret, len, eep_len; - u8 *req, *eep = (u8 *)dev->mt76.eeprom.data; + u8 *eep = (u8 *)dev->mt76.eeprom.data; + struct sk_buff *skb; + int eep_len; if (is_mt7622(&dev->mt76)) eep_len = MT7622_EE_MAX - MT_EE_NIC_CONF_0; else eep_len = MT7615_EE_MAX - MT_EE_NIC_CONF_0; - len = sizeof(req_hdr) + eep_len; - req = kzalloc(len, GFP_KERNEL); - if (!req) - return -ENOMEM; - req_hdr.len = cpu_to_le16(eep_len); - memcpy(req, &req_hdr, sizeof(req_hdr)); - memcpy(req + sizeof(req_hdr), eep + MT_EE_NIC_CONF_0, eep_len); - ret = __mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD_EFUSE_BUFFER_MODE, - req, len, true); - kfree(req); + skb = mt7615_mcu_msg_alloc(NULL, sizeof(req_hdr) + eep_len); + if (!skb) + return -ENOMEM; + + skb_put_data(skb, &req_hdr, sizeof(req_hdr)); + skb_put_data(skb, eep + MT_EE_NIC_CONF_0, eep_len); - return ret; + return __mt76_mcu_skb_send_msg(&dev->mt76, skb, + MCU_EXT_CMD_EFUSE_BUFFER_MODE, true); } int mt7615_mcu_set_mac_enable(struct mt7615_dev *dev, int band, bool enable)