Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1830820ybl; Thu, 30 Jan 2020 06:48:04 -0800 (PST) X-Google-Smtp-Source: APXvYqwu2topzgWJIAyhiO3Gk0SF1f+ca0EF4SZ9DeZ8sYG+1hv0cTUjSiJ4WoB4vED7HdFU4kiA X-Received: by 2002:a9d:472:: with SMTP id 105mr3524024otc.150.1580395683998; Thu, 30 Jan 2020 06:48:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580395683; cv=none; d=google.com; s=arc-20160816; b=Giw0wJlH3PDJ/U7SY1LrFyT7yJqyw7gk5QATm0byJCYmTHkKv0GaeWV4H0D37pxv8C t6xTyGsbZ9x8Ig66KXxPFphUZCAqmcYSwZ8akA4O4JklaNsi5im2oZIDWZsVp1B1xB1e dXiAxmNXIn89oN0G5wF1lhqUoSVFT7tyYDfNSLHdT1jb4Obzxa5wsK/Kwq3f9Ee0e3N9 MJe8G4dZuUXS+c7eb18RmqF3JYFZSKQuv0w/I4gWNgljIB9HrQ46ww3C/3cFzT9sVYXL PFGtE9z0PHSU4edej+VKBG2GuDIhiShxpDqM3EbYBmwT5TRxzlYa5RC4USfVv4tV4i0J woFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=OdlrI33Ci7s+Vz4HFH/UWnXNQ5ECY+loeEYRx7fVtaM=; b=lMVbZeoynI/Zct9yG7ij/ooVUAUDpgIITmAtcDhQMI0YnwQG2cD67I9uBazs8pUUZD BtacMVFizCccNY7AP8jPJ2qUPi3OIXUOO9lrvN7kyM8d4hXaDGR6ioPHqpf9RFlfnET7 UHFtQhUXzpETrf+dmrO6HkypSlwC8gfpwwSCNyNCgMcl1gxKa5awIg9CuqE04+HByEWP akOwxRkMq/l7I1LiVnhfzmr1/apoeCz37xxj6vFm6DgAfUJwQxmM99VCOKQP9Zw1Q1YK iPxewqyDiUEEXXiouFvx9H9MmdZmQIlf/UyIhUuclNUQxAGp7fDQ3p5AwJzXr99ARN8r Ih7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=txnYJVym; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l17si3200172otk.218.2020.01.30.06.47.50; Thu, 30 Jan 2020 06:48:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=txnYJVym; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727374AbgA3Orc (ORCPT + 99 others); Thu, 30 Jan 2020 09:47:32 -0500 Received: from nbd.name ([46.4.11.11]:57428 "EHLO nbd.name" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727191AbgA3OrV (ORCPT ); Thu, 30 Jan 2020 09:47:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=OdlrI33Ci7s+Vz4HFH/UWnXNQ5ECY+loeEYRx7fVtaM=; b=txnYJVymhkRkDIJ+HeDxi90fV4 2AjxjiL06qF1iASeU1iHgWGobbZcb9izrnLC4DjR56rtWCLGMNge3/aX2OiKgU7MtqGsXKDFyxWz/ BMegmgLP6JMUld1s9Hx4sEIL/ACPAMEoHVAsM1KYAXvmMb9Dx0RmKZPuD8vq8yvvDM8U=; Received: from [178.162.209.135] (helo=maeck.local) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ixB6F-0001VL-Kd for linux-wireless@vger.kernel.org; Thu, 30 Jan 2020 15:47:19 +0100 Received: by maeck.local (Postfix, from userid 501) id EBBAB7AE468B; Thu, 30 Jan 2020 15:47:18 +0100 (CET) From: Felix Fietkau To: linux-wireless@vger.kernel.org Subject: [PATCH 04/15] mt76: mt7615: split up firmware loading functions Date: Thu, 30 Jan 2020 15:47:07 +0100 Message-Id: <20200130144718.14298-4-nbd@nbd.name> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200130144718.14298-1-nbd@nbd.name> References: <20200130144718.14298-1-nbd@nbd.name> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Preparation for adding MT7622 support Signed-off-by: Felix Fietkau --- .../net/wireless/mediatek/mt76/mt7615/mcu.c | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c index cb1de4e1efd0..097d3fc365f7 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c @@ -345,7 +345,7 @@ static int mt7615_driver_own(struct mt7615_dev *dev) return 0; } -static int mt7615_load_patch(struct mt7615_dev *dev) +static int mt7615_load_patch(struct mt7615_dev *dev, const char *name) { const struct mt7615_patch_hdr *hdr; const struct firmware *fw = NULL; @@ -362,7 +362,7 @@ static int mt7615_load_patch(struct mt7615_dev *dev) return -EAGAIN; } - ret = request_firmware(&fw, MT7615_ROM_PATCH, dev->mt76.dev); + ret = request_firmware(&fw, name, dev->mt76.dev); if (ret) goto out; @@ -458,13 +458,13 @@ mt7615_mcu_send_ram_firmware(struct mt7615_dev *dev, return 0; } -static int mt7615_load_ram(struct mt7615_dev *dev) +static int mt7615_load_n9(struct mt7615_dev *dev, const char *name) { const struct mt7615_fw_trailer *hdr; const struct firmware *fw; int ret; - ret = request_firmware(&fw, MT7615_FIRMWARE_N9, dev->mt76.dev); + ret = request_firmware(&fw, name, dev->mt76.dev); if (ret) return ret; @@ -491,9 +491,18 @@ static int mt7615_load_ram(struct mt7615_dev *dev) goto out; } +out: release_firmware(fw); + return ret; +} + +static int mt7615_load_cr4(struct mt7615_dev *dev, const char *name) +{ + const struct mt7615_fw_trailer *hdr; + const struct firmware *fw; + int ret; - ret = request_firmware(&fw, MT7615_FIRMWARE_CR4, dev->mt76.dev); + ret = request_firmware(&fw, name, dev->mt76.dev); if (ret) return ret; @@ -529,6 +538,17 @@ static int mt7615_load_ram(struct mt7615_dev *dev) return ret; } +static int mt7615_load_ram(struct mt7615_dev *dev) +{ + int ret; + + ret = mt7615_load_n9(dev, MT7615_FIRMWARE_N9); + if (ret) + return ret; + + return mt7615_load_cr4(dev, MT7615_FIRMWARE_CR4); +} + static int mt7615_load_firmware(struct mt7615_dev *dev) { int ret; @@ -541,7 +561,7 @@ static int mt7615_load_firmware(struct mt7615_dev *dev) return -EIO; } - ret = mt7615_load_patch(dev); + ret = mt7615_load_patch(dev, MT7615_ROM_PATCH); if (ret) return ret; -- 2.24.0