From patchwork Tue Oct 17 19:05:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13425830 X-Patchwork-Delegate: nbd@nbd.name Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F41DCDB483 for ; Tue, 17 Oct 2023 19:27:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235037AbjJQT1y (ORCPT ); Tue, 17 Oct 2023 15:27:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235013AbjJQT1x (ORCPT ); Tue, 17 Oct 2023 15:27:53 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF5CEC6; Tue, 17 Oct 2023 12:27:50 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-323ef9a8b59so5658559f8f.3; Tue, 17 Oct 2023 12:27:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697570869; x=1698175669; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=/WIYTERMpa/hQ3nYRT3WjhR5KvI3DYiqFx8C9H6a/AQ=; b=mN+Kr5BmdVMGY371zJxVibPw+3d31Zy3jAgCCo4GNabPH2fl+7gNrRlr9ORmrgEgpF BLN54B9UlEfuFHVmY9Ynf11/GFUUjxsjeuVxUkxKujgCdSPQGgjT8tdDF5O8XdVD2FS8 Kyvu2YCEANJRPXEbc7sw76VzuXpbHDyEGJDgRP8Tx1PaO930ihKXf3g1QRpV9dumAOFb EWWPEZ65YU7S3CzohLXx9Bu5rqqtQ5keBb0nnIYmEAVhSD9guf/jzxrZJ2LlKe2Y0U6f iOcJxUX92JUzTvHoqJdaLtFzRvJAf62TFA6KsTwriX6o+mF33QHkTFIt0uOdf84MvP6k XdCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697570869; x=1698175669; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/WIYTERMpa/hQ3nYRT3WjhR5KvI3DYiqFx8C9H6a/AQ=; b=hz3clvnV8/cDZXV0hb7E4wGl+uSreKniDYaP+hxL9qKGsljU4OkjfycSQcLDiNogt+ ujFJIZnuPP1DO5AKjU4T+rLnaP5uNjlA+YrZnn1tSUZd8wLbMQmn0zQvhxk157C/c9Q7 S4GoZ23iZHMnQj5i6aqAn5b/iO9NsQpCTfLvTYimfA/Hwy3Rtib7IDYRvlGsfP4SAfNE aUuqcA7Quqk9Kw7ejAV4oPkkpa9IJlk654BcPAmswnppfAt2NYELqd42edT5xAGNS82n W7khQ1hkdp9g1RuttxmYbb7LuMRrq5NGVsG+PPVDWuWl4JSnQgQ89rwtb4eBExeEMk/N SG4w== X-Gm-Message-State: AOJu0YzAScHD0o1XxSMFfbWeP/t4N2OVSaY4R8iyJzh1VcvKIuk8K6CA 9/JsxjDfBCom7LU2LrPqSIsK6e+FZRA= X-Google-Smtp-Source: AGHT+IH1sIJVj6vXFk3PsUqXsDejVqOQyTaC/4Gh2c9aKr1SO/xiGQdSW9KnyI9IseCxWCSAKxk3+A== X-Received: by 2002:adf:f7c3:0:b0:32d:89b5:7fd9 with SMTP id a3-20020adff7c3000000b0032d89b57fd9mr2562686wrq.56.1697570868914; Tue, 17 Oct 2023 12:27:48 -0700 (PDT) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id o2-20020adfeac2000000b0032cc35c2ef7sm435897wrn.29.2023.10.17.12.27.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 12:27:48 -0700 (PDT) From: Christian Marangi To: Felix Fietkau , Lorenzo Bianconi , Ryder Lee , Shayne Chen , Sean Wang , Kalle Valo , Matthias Brugger , AngeloGioacchino Del Regno , Christian Marangi , Simon Horman , Alexander Couzens , Nicolas Cavallari , Daniel Golle , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Cc: stable@vger.kernel.org Subject: [net-next RFC PATCH 1/6] wifi: mt76: fix broken precal loading from MTD for mt7915 Date: Tue, 17 Oct 2023 21:05:05 +0200 Message-Id: <20231017190510.27163-1-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Commit 495184ac91bb ("mt76: mt7915: add support for applying pre-calibration data") was fundamentally broken and never worked. The idea (before NVMEM support) was to expand the MTD function and pass an additional offset. For normal EEPROM load the offset would always be 0. For the purpose of precal loading, an offset was passed that was internally the size of EEPROM, since precal data is right after the EEPROM. Problem is that the offset value passed is never handled and is actually overwrite by offset = be32_to_cpup(list); ret = mtd_read(mtd, offset, len, &retlen, eep); resulting in the passed offset value always ingnored. (and even passing garbage data as precal as the start of the EEPROM is getting read) Fix this by adding to the current offset value, the offset from DT to correctly read the piece of data at the requested location. Cc: stable@vger.kernel.org Fixes: 495184ac91bb ("mt76: mt7915: add support for applying pre-calibration data") Signed-off-by: Christian Marangi --- drivers/net/wireless/mediatek/mt76/eeprom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c index 36564930aef1..2558788f7ffb 100644 --- a/drivers/net/wireless/mediatek/mt76/eeprom.c +++ b/drivers/net/wireless/mediatek/mt76/eeprom.c @@ -67,7 +67,7 @@ static int mt76_get_of_epprom_from_mtd(struct mt76_dev *dev, void *eep, int offs goto out_put_node; } - offset = be32_to_cpup(list); + offset += be32_to_cpup(list); ret = mtd_read(mtd, offset, len, &retlen, eep); put_mtd_device(mtd); if (mtd_is_bitflip(ret)) From patchwork Tue Oct 17 19:05:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13425831 X-Patchwork-Delegate: nbd@nbd.name Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B2F2C41513 for ; Tue, 17 Oct 2023 19:27:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344170AbjJQT1y (ORCPT ); Tue, 17 Oct 2023 15:27:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234988AbjJQT1x (ORCPT ); Tue, 17 Oct 2023 15:27:53 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEC3BC4; Tue, 17 Oct 2023 12:27:51 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-32d834ec222so5544437f8f.0; Tue, 17 Oct 2023 12:27:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697570870; x=1698175670; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=I2HMXOLF5eJrUMENCt8aiW3aj9mFErqyM1uPwOqtdoQ=; b=jF7Fm+ozZZfceySpZ+DlFNpgHhpI04ln+crhE5U9OVziYCzRwYFuIa6g6syjtuz75K +5AC/4zmJSVSQ96Tymvlm9kZBPQO0SjgsxN4DydP6h0pYsGYRsd9gpF8h2BeME8YuaGQ A/sLy7TI1yHDkFgP75o8GKuIYZAAXJKU8XWAohfpXulxJId42A5iqdGX3Lqm3M7Es4cH BiHeqA2EboUYMvAbHC5ZkryUiH4HhMzWTa586SKYfQPoONKp7Hu9esNpdhmDWliSwMuJ gpqbcU2JL4hc6MXFPiMvTONTUOUP9r/NpZpjPdgaoaR8/guxprDW55oXAQ+EqLNtnZAf uOpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697570870; x=1698175670; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I2HMXOLF5eJrUMENCt8aiW3aj9mFErqyM1uPwOqtdoQ=; b=bCMk1euWHV0LM3pVstdi5hpo5BG+7/IZA8cWjFIR0H+9BK/CtzSl7PGiHBlO+wCHnx +OtDEaFisitSFIh1zO7hUTIrE+klMPkTEIWvthze41KehvP4n8WqFIqDiwFhEl5Meyvr 3DqUEJA/74QasFbPKj19J0yOAfcSpLP9aXU9RVB6uCtYRgqHEv6rej235yjkbALR58zY 6Ov/jWxiAjDotaMfCh1F7YizO0pJc++fuCyleZM25yGbm3ZU86+rNm4fA/Fs7XyZoYcs Z5rQNEkvG/IAIYWek7FUC8nExnV8bLd38jhjr016j9naAAWKMxhA8wu9xNL8YO3dLjI+ Zfbg== X-Gm-Message-State: AOJu0YyWIni0Yyrbp6X7Ag8PiE5p9Gf1GE81h8pABraMN+XD0X+w5U0U BI+AH1AiexDaaGN5ADHq+Uw= X-Google-Smtp-Source: AGHT+IHaxYR/ji/TpEeQiKOxetQQnrm2fznjqODcepcXxmiYcoSadf6rAytgEwutDBenrBNoao4Scg== X-Received: by 2002:a05:6000:1375:b0:32d:a98c:aa1f with SMTP id q21-20020a056000137500b0032da98caa1fmr2431879wrz.1.1697570870180; Tue, 17 Oct 2023 12:27:50 -0700 (PDT) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id o2-20020adfeac2000000b0032cc35c2ef7sm435897wrn.29.2023.10.17.12.27.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 12:27:49 -0700 (PDT) From: Christian Marangi To: Felix Fietkau , Lorenzo Bianconi , Ryder Lee , Shayne Chen , Sean Wang , Kalle Valo , Matthias Brugger , AngeloGioacchino Del Regno , Christian Marangi , Simon Horman , Alexander Couzens , Nicolas Cavallari , Daniel Golle , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [net-next RFC PATCH 2/6] wifi: mt76: fix typo in mt76_get_of_eeprom_from_nvmem function Date: Tue, 17 Oct 2023 21:05:06 +0200 Message-Id: <20231017190510.27163-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231017190510.27163-1-ansuelsmth@gmail.com> References: <20231017190510.27163-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Fix typo in mt76_get_of_eeprom_from_nvmem where eeprom was misspelled as epprom. Fixes: 5bef3a406c6e ("wifi: mt76: add support for providing eeprom in nvmem cells") Signed-off-by: Christian Marangi --- drivers/net/wireless/mediatek/mt76/eeprom.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c index 2558788f7ffb..1de3c734e136 100644 --- a/drivers/net/wireless/mediatek/mt76/eeprom.c +++ b/drivers/net/wireless/mediatek/mt76/eeprom.c @@ -106,7 +106,7 @@ static int mt76_get_of_epprom_from_mtd(struct mt76_dev *dev, void *eep, int offs #endif } -static int mt76_get_of_epprom_from_nvmem(struct mt76_dev *dev, void *eep, int len) +static int mt76_get_of_eeprom_from_nvmem(struct mt76_dev *dev, void *eep, int len) { struct device_node *np = dev->dev->of_node; struct nvmem_cell *cell; @@ -153,7 +153,7 @@ int mt76_get_of_eeprom(struct mt76_dev *dev, void *eep, int offset, int len) if (!ret) return 0; - return mt76_get_of_epprom_from_nvmem(dev, eep, len); + return mt76_get_of_eeprom_from_nvmem(dev, eep, len); } EXPORT_SYMBOL_GPL(mt76_get_of_eeprom); From patchwork Tue Oct 17 19:05:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13425832 X-Patchwork-Delegate: nbd@nbd.name Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B3E9CDB474 for ; Tue, 17 Oct 2023 19:27:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344191AbjJQT14 (ORCPT ); Tue, 17 Oct 2023 15:27:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344188AbjJQT1z (ORCPT ); Tue, 17 Oct 2023 15:27:55 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F20EDF1; Tue, 17 Oct 2023 12:27:52 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4064867903cso66256265e9.2; Tue, 17 Oct 2023 12:27:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697570871; x=1698175671; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=+0xHAajk9RnoZnMNxnlpPx/L53pYS94eDmnmY1A3Dok=; b=EN8fPfmvI0AcO1iYEp9D1Ub6rqBvhphV9l8FPRNFmpLI2ThoNyERs9Q9lCSZZWp/kn lNHiDBIi4gXpAAYPd6byKm+Z8JGZy0o0XdixLDoVsbiHVDQEpjfVQ7qhgvG4UP3z8CUm 2I11cWNMhQ2idwDgQajJMFePOwDJcoKM3AdvXjrFM525SV65kIhEy/hkp7UwM7xP0E3I MS0znQjdwvRTXMHY3VYh1zX+NKmzZdz8YoCoVfP3mEhVN+spmfgJ6cvZwVW1DpZGrzDX ygVhOjV0MMgmvfp7pd22fVjkf5CpfY2gA+E4RUL3xGNTp6vbxZFOUzbjWnNoL3AyXdGM FV9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697570871; x=1698175671; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+0xHAajk9RnoZnMNxnlpPx/L53pYS94eDmnmY1A3Dok=; b=uw7jHx8MZ9eISXR2CrXRAyCJujJ+ODogRG2h3Ede7n4Sm9n8V/W9i4BwAxLW9utLcY /OIv/1sdTkb/h0M77dz+gsay3jmquA4z0flwZt2rXyax9IsSJF3oJ+e52XL8TALfjxuG 6iA6qoUM14hzeAA0gkgkizFTIM4soqAu1HgI8vCeHSdV6rb7dS92vD2lKrIatgiJRVeI x6Ojb9D6a7a5FS/mfx0GsPJpsonk3bspUtzNnU/sLooyBD+xNFZcMw3A8zLdSxGtq7XP wrFXXZoh+4ZqRo8shWWqsueBNocMVfXqmCkHxwhxNFhux2qN1FmH4E5DYAD4sKjjFwGD jitA== X-Gm-Message-State: AOJu0Yw/JobiCm61sNzw3VCQFBI/xOBwQB4gaht/5kItgttklhepQpI1 HfqcIfEXU0IVSghVyUM0mgM= X-Google-Smtp-Source: AGHT+IHzX9yaXcV3QWlXu9GSfGAVCIcJ0SoqRGEZUbBLGj/4l7W7+zG+ktg0AVC5pcCKK+R9qYOBXQ== X-Received: by 2002:a5d:5947:0:b0:32d:9e4f:7190 with SMTP id e7-20020a5d5947000000b0032d9e4f7190mr2723978wri.60.1697570871353; Tue, 17 Oct 2023 12:27:51 -0700 (PDT) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id o2-20020adfeac2000000b0032cc35c2ef7sm435897wrn.29.2023.10.17.12.27.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 12:27:51 -0700 (PDT) From: Christian Marangi To: Felix Fietkau , Lorenzo Bianconi , Ryder Lee , Shayne Chen , Sean Wang , Kalle Valo , Matthias Brugger , AngeloGioacchino Del Regno , Christian Marangi , Simon Horman , Alexander Couzens , Nicolas Cavallari , Daniel Golle , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [net-next RFC PATCH 3/6] wifi: mt76: limit support of precal loading for mt7915 to MTD only Date: Tue, 17 Oct 2023 21:05:07 +0200 Message-Id: <20231017190510.27163-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231017190510.27163-1-ansuelsmth@gmail.com> References: <20231017190510.27163-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Limit support for precal loading for mt7915 only to MTD. Passing data from DT doesn't support offset and NVMEM require a different cell name and doesn't support offset hence only MTD way is actually supported. Rename mt76_get_of_eeprom_from_mtd to mt76_get_of_data_from_mtd as it is now used for a more generic purpose and export it. Signed-off-by: Christian Marangi --- drivers/net/wireless/mediatek/mt76/eeprom.c | 5 +++-- drivers/net/wireless/mediatek/mt76/mt76.h | 1 + drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c index 1de3c734e136..817074a5d2fc 100644 --- a/drivers/net/wireless/mediatek/mt76/eeprom.c +++ b/drivers/net/wireless/mediatek/mt76/eeprom.c @@ -28,7 +28,7 @@ static int mt76_get_of_eeprom_data(struct mt76_dev *dev, void *eep, int len) return 0; } -static int mt76_get_of_epprom_from_mtd(struct mt76_dev *dev, void *eep, int offset, int len) +int mt76_get_of_data_from_mtd(struct mt76_dev *dev, void *eep, int offset, int len) { #ifdef CONFIG_MTD struct device_node *np = dev->dev->of_node; @@ -105,6 +105,7 @@ static int mt76_get_of_epprom_from_mtd(struct mt76_dev *dev, void *eep, int offs return -ENOENT; #endif } +EXPORT_SYMBOL_GPL(mt76_get_of_data_from_mtd); static int mt76_get_of_eeprom_from_nvmem(struct mt76_dev *dev, void *eep, int len) { @@ -149,7 +150,7 @@ int mt76_get_of_eeprom(struct mt76_dev *dev, void *eep, int offset, int len) if (!ret) return 0; - ret = mt76_get_of_epprom_from_mtd(dev, eep, offset, len); + ret = mt76_get_of_data_from_mtd(dev, eep, offset, len); if (!ret) return 0; diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index e8757865a3d0..f6c850557447 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -1095,6 +1095,7 @@ void mt76_seq_puts_array(struct seq_file *file, const char *str, int mt76_eeprom_init(struct mt76_dev *dev, int len); void mt76_eeprom_override(struct mt76_phy *phy); +int mt76_get_of_data_from_mtd(struct mt76_dev *dev, void *eep, int offset, int len); int mt76_get_of_eeprom(struct mt76_dev *dev, void *data, int offset, int len); struct mt76_queue * diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c index 76be7308460b..5228f710b3da 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c @@ -25,7 +25,7 @@ static int mt7915_eeprom_load_precal(struct mt7915_dev *dev) offs = is_mt7915(&dev->mt76) ? MT_EE_PRECAL : MT_EE_PRECAL_V2; - return mt76_get_of_eeprom(mdev, dev->cal, offs, val); + return mt76_get_of_data_from_mtd(mdev, dev->cal, offs, val); } static int mt7915_check_eeprom(struct mt7915_dev *dev) From patchwork Tue Oct 17 19:05:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13425833 X-Patchwork-Delegate: nbd@nbd.name Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9942FCDB474 for ; Tue, 17 Oct 2023 19:28:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344230AbjJQT2B (ORCPT ); Tue, 17 Oct 2023 15:28:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344217AbjJQT14 (ORCPT ); Tue, 17 Oct 2023 15:27:56 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9814CC4; Tue, 17 Oct 2023 12:27:54 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-32d9552d765so4721360f8f.2; Tue, 17 Oct 2023 12:27:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697570873; x=1698175673; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=3IL6KY3EzM2BxcqkNoWLsWmWA0zN5X5Kl3affJBzO2c=; b=mIlJcPArnJgQomXy/OLwHjgp6ApElaFgJHcObYMEtxFUgwJOpXYr2JHGHWfHQ08GCC RLN68dcLJMnYlUsSArEQVAenJxuj+uvaVgKqlxsQ87TNQpP81aDPPQklYBnMKwim0nqm r/ZyC5FCVhtwFRtMDjYIwTxlDTozXcRo328GuYQTV6mbqq6kDpeTrLBUcALG1BROc3zk OUPpv67bSS/hvEUlqY+XqeljTk4cIHFZmFqESf+6qv7i6Y9G6pEI1rjEiqoaefRys8HF Z5hD3afBL59x/UsT63BPl912RF3uZ6Zb6lyyCbUy6GQ5+kDfcO2RPvQRTtKovGJswTpS Vfvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697570873; x=1698175673; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3IL6KY3EzM2BxcqkNoWLsWmWA0zN5X5Kl3affJBzO2c=; b=Zq+wIvdpD+/KkMNKwDQLnZttTz3OnFAtd4aTfQNajBBpESmyogLEahs54hvS0BsTQQ +bIha4fiabVACWT/bxOg34pYgpgIikqlOF60DX9B2boAhlD/AQA4x8dGANdb0YTD+ub9 ErjsJ+oDUenOrH3OSpQbj0gdUmjzXNwIq6eAFcDn0xFnhCd545f0Sw7bUQvoskJS4Adu 1Lg1c21kMr+2539ZTnw7TFenIsVgWTwmjFOOHAr9ySxY1tLVOLyVGNgGbPblNyf5ILKp rhsuLr6HMXK3x9+5CfOUVnUXfiqKGhDFps2vRY0Jj82YfucxOVvPtfNV0ihZOmfFw1tA Wkzg== X-Gm-Message-State: AOJu0Yz7edBWlNjr7qmHN87FXZrKlPx0IO7kK7AOb3942q1Ggs9GeUrx x75XpdtNRSleeKGC80VVLHA= X-Google-Smtp-Source: AGHT+IG5U1O8F0WYcC/ShlvOiLSsSiY7RwLNMBcm6vpZV2ouHYIJnXX4mFscSuxO+x0YZ3wBKSLK9Q== X-Received: by 2002:adf:f982:0:b0:32d:b06c:80b2 with SMTP id f2-20020adff982000000b0032db06c80b2mr2969857wrr.0.1697570872715; Tue, 17 Oct 2023 12:27:52 -0700 (PDT) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id o2-20020adfeac2000000b0032cc35c2ef7sm435897wrn.29.2023.10.17.12.27.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 12:27:52 -0700 (PDT) From: Christian Marangi To: Felix Fietkau , Lorenzo Bianconi , Ryder Lee , Shayne Chen , Sean Wang , Kalle Valo , Matthias Brugger , AngeloGioacchino Del Regno , Christian Marangi , Simon Horman , Alexander Couzens , Nicolas Cavallari , Daniel Golle , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [net-next RFC PATCH 4/6] wifi: mt76: make mt76_get_of_eeprom static again Date: Tue, 17 Oct 2023 21:05:08 +0200 Message-Id: <20231017190510.27163-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231017190510.27163-1-ansuelsmth@gmail.com> References: <20231017190510.27163-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Since mt76_get_of_eeprom is not used by mt7915 anymore, unexport it and make it static again. Also drop offset arg as it's only supported for MTD and was always set to 0, hardcode the MTD functio instead. Signed-off-by: Christian Marangi --- drivers/net/wireless/mediatek/mt76/eeprom.c | 7 +++---- drivers/net/wireless/mediatek/mt76/mt76.h | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c index 817074a5d2fc..748f4b643a5e 100644 --- a/drivers/net/wireless/mediatek/mt76/eeprom.c +++ b/drivers/net/wireless/mediatek/mt76/eeprom.c @@ -138,7 +138,7 @@ static int mt76_get_of_eeprom_from_nvmem(struct mt76_dev *dev, void *eep, int le return ret; } -int mt76_get_of_eeprom(struct mt76_dev *dev, void *eep, int offset, int len) +static int mt76_get_of_eeprom(struct mt76_dev *dev, void *eep, int len) { struct device_node *np = dev->dev->of_node; int ret; @@ -150,13 +150,12 @@ int mt76_get_of_eeprom(struct mt76_dev *dev, void *eep, int offset, int len) if (!ret) return 0; - ret = mt76_get_of_data_from_mtd(dev, eep, offset, len); + ret = mt76_get_of_data_from_mtd(dev, eep, 0, len); if (!ret) return 0; return mt76_get_of_eeprom_from_nvmem(dev, eep, len); } -EXPORT_SYMBOL_GPL(mt76_get_of_eeprom); void mt76_eeprom_override(struct mt76_phy *phy) @@ -410,6 +409,6 @@ mt76_eeprom_init(struct mt76_dev *dev, int len) if (!dev->eeprom.data) return -ENOMEM; - return !mt76_get_of_eeprom(dev, dev->eeprom.data, 0, len); + return !mt76_get_of_eeprom(dev, dev->eeprom.data, len); } EXPORT_SYMBOL_GPL(mt76_eeprom_init); diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index f6c850557447..41e4f398083e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -1096,7 +1096,6 @@ void mt76_seq_puts_array(struct seq_file *file, const char *str, int mt76_eeprom_init(struct mt76_dev *dev, int len); void mt76_eeprom_override(struct mt76_phy *phy); int mt76_get_of_data_from_mtd(struct mt76_dev *dev, void *eep, int offset, int len); -int mt76_get_of_eeprom(struct mt76_dev *dev, void *data, int offset, int len); struct mt76_queue * mt76_init_queue(struct mt76_dev *dev, int qid, int idx, int n_desc, From patchwork Tue Oct 17 19:05:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13425834 X-Patchwork-Delegate: nbd@nbd.name Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DF53CDB482 for ; Tue, 17 Oct 2023 19:28:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344269AbjJQT2D (ORCPT ); Tue, 17 Oct 2023 15:28:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344235AbjJQT16 (ORCPT ); Tue, 17 Oct 2023 15:27:58 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81FDDED; Tue, 17 Oct 2023 12:27:55 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4065dea9a33so56105395e9.3; Tue, 17 Oct 2023 12:27:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697570874; x=1698175674; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=g6jQJsBRBLmDkm3I/0qquR/3BJtEfnv9Twl5IETKE8Y=; b=AA7w2xPK5ta5fbCh4NhIrEkL3ITN5j9fXoCY7zsyNPGx8MAISFpqXvAId0BmEshIQB JizZQRRZKpZPhYwOVfyJ9EzB3dD3OINh7fUwV/ZvKVseQ+7TlXxrvG831JOy9DE5nZy6 doGjOg2wqTgvFzPwGARyryLwf+kWuqMsR77RwVX0Fcdj3pVW/721yBweV4c4NDKWQU/b 0bM7p3CzjiXgnbWnFFSocMAVAfHig+R/KY1Tg4FPLsDI95rNX0AcigzxTeAzEnGcIbnh RsHYuoF9+QVoNOZSV84jppnpaJXhG3Y7fs3zcmz6rHiOvpgQ29ErYpbETM1g8fCPv+lj VlAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697570874; x=1698175674; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g6jQJsBRBLmDkm3I/0qquR/3BJtEfnv9Twl5IETKE8Y=; b=h8LcJo6YfK2H6xGjLBHuRBlhfc/UEDUz/00xXTkxVTrnMlp8Qxpld6rHyumpPo8mkn 9+gulP+S42HD26DYs2JbfFVMj/srWUxstxhP+P7Qruq9gF1cP6TDb7W+ujU9vasxXBQ5 cedbsAYRRYpj8PBz3qjaIKSOxZaJjaFfoWJiPh/2qpFQwEACQjdbS57NCdc16OtIqs2O KTOjHHV9SSYPRELLiUB3ZD8W9pJKwypOCbtwaFtpOM/pCe8XPFZRNMiOvE5nDELIslOP tShOs6JYYenXcfwb+ERlxoXB5ovkFBdAkucO76KHUE/ldc07C5mCij0AZ+WH7zhlJFaN aUbQ== X-Gm-Message-State: AOJu0YzH0Os1Uo0hlqbhXDsLhzSX2aZssWjDeV1pUpKIm1+vhPlGHQ9Z A1ZGDXGXxuyzbWiF6KqbuJY= X-Google-Smtp-Source: AGHT+IEnQ5HC+BuPuzufGE10gWuIiTfP965Vnpx9uNXzZJjYccZpAg+E7wcKaRLYSLxC56LOmeRrdA== X-Received: by 2002:a05:6000:8b:b0:31f:a62d:264 with SMTP id m11-20020a056000008b00b0031fa62d0264mr2704276wrx.37.1697570873841; Tue, 17 Oct 2023 12:27:53 -0700 (PDT) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id o2-20020adfeac2000000b0032cc35c2ef7sm435897wrn.29.2023.10.17.12.27.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 12:27:53 -0700 (PDT) From: Christian Marangi To: Felix Fietkau , Lorenzo Bianconi , Ryder Lee , Shayne Chen , Sean Wang , Kalle Valo , Matthias Brugger , AngeloGioacchino Del Regno , Christian Marangi , Simon Horman , Alexander Couzens , Nicolas Cavallari , Daniel Golle , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [net-next RFC PATCH 5/6] wifi: mt76: permit to use alternative cell name to eeprom NVMEM load Date: Tue, 17 Oct 2023 21:05:09 +0200 Message-Id: <20231017190510.27163-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231017190510.27163-1-ansuelsmth@gmail.com> References: <20231017190510.27163-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Generilize mt76_get_of_eeprom_from_nvmem to use alternative cell name by passing the cell name as an arg and expose it. Rename it to mt76_get_of_data_from_nvmem to better reflect the now more generic usage. This is to permit driver to load additional cell, like precal cell. Signed-off-by: Christian Marangi --- drivers/net/wireless/mediatek/mt76/eeprom.c | 8 +++++--- drivers/net/wireless/mediatek/mt76/mt76.h | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c index 748f4b643a5e..ac6c0a0e876f 100644 --- a/drivers/net/wireless/mediatek/mt76/eeprom.c +++ b/drivers/net/wireless/mediatek/mt76/eeprom.c @@ -107,7 +107,8 @@ int mt76_get_of_data_from_mtd(struct mt76_dev *dev, void *eep, int offset, int l } EXPORT_SYMBOL_GPL(mt76_get_of_data_from_mtd); -static int mt76_get_of_eeprom_from_nvmem(struct mt76_dev *dev, void *eep, int len) +int mt76_get_of_data_from_nvmem(struct mt76_dev *dev, void *eep, + const char *cell_name, int len) { struct device_node *np = dev->dev->of_node; struct nvmem_cell *cell; @@ -115,7 +116,7 @@ static int mt76_get_of_eeprom_from_nvmem(struct mt76_dev *dev, void *eep, int le size_t retlen; int ret = 0; - cell = of_nvmem_cell_get(np, "eeprom"); + cell = of_nvmem_cell_get(np, cell_name); if (IS_ERR(cell)) return PTR_ERR(cell); @@ -137,6 +138,7 @@ static int mt76_get_of_eeprom_from_nvmem(struct mt76_dev *dev, void *eep, int le return ret; } +EXPORT_SYMBOL_GPL(mt76_get_of_data_from_nvmem); static int mt76_get_of_eeprom(struct mt76_dev *dev, void *eep, int len) { @@ -154,7 +156,7 @@ static int mt76_get_of_eeprom(struct mt76_dev *dev, void *eep, int len) if (!ret) return 0; - return mt76_get_of_eeprom_from_nvmem(dev, eep, len); + return mt76_get_of_data_from_nvmem(dev, eep, "eeprom", len); } void diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 41e4f398083e..c9934258c49d 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -1096,6 +1096,8 @@ void mt76_seq_puts_array(struct seq_file *file, const char *str, int mt76_eeprom_init(struct mt76_dev *dev, int len); void mt76_eeprom_override(struct mt76_phy *phy); int mt76_get_of_data_from_mtd(struct mt76_dev *dev, void *eep, int offset, int len); +int mt76_get_of_data_from_nvmem(struct mt76_dev *dev, void *eep, + const char *cell_name, int len); struct mt76_queue * mt76_init_queue(struct mt76_dev *dev, int qid, int idx, int n_desc, From patchwork Tue Oct 17 19:05:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13425835 X-Patchwork-Delegate: nbd@nbd.name Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C443CDB486 for ; Tue, 17 Oct 2023 19:28:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344284AbjJQT2E (ORCPT ); Tue, 17 Oct 2023 15:28:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344252AbjJQT2A (ORCPT ); Tue, 17 Oct 2023 15:28:00 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA061FA; Tue, 17 Oct 2023 12:27:56 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-32db8924201so1898917f8f.1; Tue, 17 Oct 2023 12:27:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697570875; x=1698175675; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=mw4sfthIPjM3BfawqG9k28qO9mlhU0PnICKHznmlMio=; b=NIZviTjuruV1qa9Wk70mt8Urg8uDkHAiM+hD3B0sVtTO0A7teqOEIm07xRzjaENQj0 /XhGiyNNG3uSGOpIHKm+XAIHMEY3vvKLvE7NxPyNI100BG27rFG06kL0U07BywL2reWC nhGb3zLKciibGeGE3X1URcO0AitVEI5csZsSY3mCBMuxwInA93+/M6DKGK9GuofEq9+6 aHKDPiPzlV0KBtPPJKN3aml6wn97qMPs18GkzNIe9z+Wo08lRqVlWIKAr7V70oI2V6ol VlsDVYydhOUqIs1VaxZ9X1a118+uh5SZHVkMDosmMP/72GfpYhScsPCMS5pv9x2eewWn yPcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697570875; x=1698175675; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mw4sfthIPjM3BfawqG9k28qO9mlhU0PnICKHznmlMio=; b=VSMwpLypc+BXpOUleL2/HtgIIuEob4ZxoR6C4+7fBUr4RzVpXgIv4eETQDqy9bwv6X R+j/EZhrIZNOPmXROcZOnlRzCC84Uduz6PvOxZpIj2VYsfTeIIns0tRvGSuE5HUXdceZ tVEi7ZyH9NwgjwHjNZcgsFeMerUQOTvyvbsZH/ZFI0ZxfL/FDwWgSRL4mr+6Qfs0acKy wElL1lqqoGrB+cGCoFa7SvfPXnd6XXDzSchQl3Kz1uR+ZY7KMXFVG9tXYAQ1bwXs2oPV aNjSJ82iLQU6Sm8ZUyHQ25RE4qIv2SlyYrzfK8YmQr9JXeLtW76VzhU9mo5qJWoUSZYK b68A== X-Gm-Message-State: AOJu0YwRvnS9ciw4zvdWKJ/bDjSYBA5WRBdoW3Q778G1lUlEqZqKqoOX rEQuVC8ou650ZkPFWCw70Eg= X-Google-Smtp-Source: AGHT+IHglYUm70uW0GVWCXnzNjqxcIopFPc+GSa/J1yUXCB4sfKjA0wso4+1pkjiDF1KQL7RhyLuhg== X-Received: by 2002:adf:e5cb:0:b0:32d:9d3d:3025 with SMTP id a11-20020adfe5cb000000b0032d9d3d3025mr2390702wrn.26.1697570875023; Tue, 17 Oct 2023 12:27:55 -0700 (PDT) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id o2-20020adfeac2000000b0032cc35c2ef7sm435897wrn.29.2023.10.17.12.27.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 12:27:54 -0700 (PDT) From: Christian Marangi To: Felix Fietkau , Lorenzo Bianconi , Ryder Lee , Shayne Chen , Sean Wang , Kalle Valo , Matthias Brugger , AngeloGioacchino Del Regno , Christian Marangi , Simon Horman , Alexander Couzens , Nicolas Cavallari , Daniel Golle , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [net-next RFC PATCH 6/6] wifi: mt76: permit to load precal from NVMEM cell for mt7915 Date: Tue, 17 Oct 2023 21:05:10 +0200 Message-Id: <20231017190510.27163-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231017190510.27163-1-ansuelsmth@gmail.com> References: <20231017190510.27163-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Permit to load precal from NVMEM cell for mt7915. The NVMEM cell must be named "precal" to be correctly loaded. NVMEM cell must already account the correct offset and be placed after the EEPROM as the function expect the data right from the start. Signed-off-by: Christian Marangi --- I would like to have some hint of the cell name... Is it ok to use precal? Should we use "precal-eeprom"? --- drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c index 5228f710b3da..3bb2643d1b26 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/eeprom.c @@ -11,6 +11,7 @@ static int mt7915_eeprom_load_precal(struct mt7915_dev *dev) u8 *eeprom = mdev->eeprom.data; u32 val = eeprom[MT_EE_DO_PRE_CAL]; u32 offs; + int ret; if (!dev->flash_mode) return 0; @@ -25,7 +26,11 @@ static int mt7915_eeprom_load_precal(struct mt7915_dev *dev) offs = is_mt7915(&dev->mt76) ? MT_EE_PRECAL : MT_EE_PRECAL_V2; - return mt76_get_of_data_from_mtd(mdev, dev->cal, offs, val); + ret = mt76_get_of_data_from_mtd(mdev, dev->cal, offs, val); + if (!ret) + return ret; + + return mt76_get_of_data_from_nvmem(mdev, dev->cal, "precal", val); } static int mt7915_check_eeprom(struct mt7915_dev *dev)