Message ID | 20221127231035.17547-2-zajec5@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5330414wrr; Sun, 27 Nov 2022 15:16:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf5KojKt8TEGPUwMcE3drnaZJi9+YVvine9fmHODfUAAG9r5wqvJigyTfyJv6eXrH7FmO4td X-Received: by 2002:a17:906:1b52:b0:7ad:90dc:b7d4 with SMTP id p18-20020a1709061b5200b007ad90dcb7d4mr27344188ejg.278.1669590961557; Sun, 27 Nov 2022 15:16:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669590961; cv=none; d=google.com; s=arc-20160816; b=HkXqKw68aTLx4jn9J071SrQS9wXwuNl+rr+IxpvhHVwOhZLOCb93vWyAtqxLEVvxZo k+QvtBUwqXiumxSCzAiGJDUtRUn5dUGk0wgr2T1fmU8gisL7opvnI5P1cht0ELwVzjav GfsBzy1guOvRP7ccBZKIDIrhhSQ0Yl8EU2XL1q8ebDWI6y8bXx8G/+4Qx5f8Ct9G9VAu tE4i8I50vxIMFINhdz7ILMEU/ZOX6pyppR5eEPps8BOImN/UBwk49FBpWw8R/Yg862Pj wNJwJSdmnMKkdv9LmHZKmKWel1tcHDqWT3dI8WRztDIrz4/L4BuNNRJ3c4ja0v/cql64 x6pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=44xs7cQ6Cza924S+PWNfvtVgJyd+csfrYDPNush93DA=; b=oR8jdvk3dutVERJOWPmtiVob/R4mRiDpJSEpxmeyrmuL0QVzrgAOUifYU93VLywJoc Q8R71uekeC8Ma4Xm0Clung0hT20s3Din1VQY6i/9RncVIytxYNV0rK9q63EniPGCEXm3 vXKEezWgQXCkOvWiauSBPY1XCMj0DZG/1ee4+kxInHU7AuDWcXbcJDUp93RNy/P1FnOB a7vpq9dfuJC6P08VySXCAunpICDTl0uPvdOKB3FkUQoSYFj6OjVbI34H5qPhrHJ7WT44 wzFdA/Cu79s52BMiK4ewVjtihAKGYyJf745SVzEqwXXCIQQAFQ1QOjF0UsXd9FIve5Jr qGTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="dcCRE3/y"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t13-20020a170906178d00b0078356aaeb63si5827746eje.288.2022.11.27.15.15.37; Sun, 27 Nov 2022 15:16:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="dcCRE3/y"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229555AbiK0XLE (ORCPT <rfc822;gah0developer@gmail.com> + 99 others); Sun, 27 Nov 2022 18:11:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229575AbiK0XK7 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 27 Nov 2022 18:10:59 -0500 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 584CEFD22; Sun, 27 Nov 2022 15:10:53 -0800 (PST) Received: by mail-lf1-x12c.google.com with SMTP id d6so14869792lfs.10; Sun, 27 Nov 2022 15:10:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=44xs7cQ6Cza924S+PWNfvtVgJyd+csfrYDPNush93DA=; b=dcCRE3/yjOIPoUAIJRWPvdkLOmTLO/UNEPjAijvzfGDUBgV25ejhUlrihqSjBpRKRs vCk669JGtPhOHwF5GaK12F/FaDY0o8LtOVw3wxejm3AijcTtZoPj1qQtvY49Sjd2N0Z2 quvzUTKkG3tozQVoe/haD35aBci34NXMYeCUduZGWxz20gXH/f0yaagLBAnurPCKzEqM HVtNBJGIyBev0aeVY1eW/7HW1aQDb46npx0NpAN8Et/FFF06HOA8AcvyN2ICOxE0oL8o 5nsGnF26uj1QA+ld5pxcdGBO7Id3cA85kxrxwcGNpS0SkzGJ2GlxgnPzv/KGRojwV+/H XDNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=44xs7cQ6Cza924S+PWNfvtVgJyd+csfrYDPNush93DA=; b=xDaZbNaFQOIvzzAidQxkvLBNq5+cKjCJ8xXjirjdVsbcj/BKjRbkZEQmCG6VGIygZX /oZ/6YMhPY+ulnIIlI3CW/wVPujLDffGdJy21jdmmWD/SSYgy3YyCmqJTRCglKTDaGGs NmTOhvZOWWyTiqih+VNj5wX4Ij0QrUjkL1P+GlXXnX/hCXI3hYgNtGM47iae+uzbnAKz yhXGG91XhgQa+GJVmIZKUkVNPdMBo6eh7p9CpHUU7TBs21wsy9RJyYn4Tyo63XYoP5/x HL2rp797zggLdc3zosW9pqBVz4yney9DBciu/I7ufnrnyQTM/YynnDaJuZFAzDbBrZ+E 0orw== X-Gm-Message-State: ANoB5pn0gpa8Jw4LVn+7xQS3BGMR9M0KFwAV9SX7ph7qCNZ5YzMNAx0p swBrHCYK04e4Shrq4WzLZvA= X-Received: by 2002:ac2:5e26:0:b0:4b1:4602:3f9 with SMTP id o6-20020ac25e26000000b004b1460203f9mr10079217lfg.80.1669590651716; Sun, 27 Nov 2022 15:10:51 -0800 (PST) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id d17-20020a0565123d1100b004b4ea0f4e7fsm1439984lfv.299.2022.11.27.15.10.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Nov 2022 15:10:51 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= <zajec5@gmail.com> To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Cc: Michael Walle <michael@walle.cc>, Miquel Raynal <miquel.raynal@bootlin.com>, Richard Weinberger <richard@nod.at>, Vignesh Raghavendra <vigneshr@ti.com>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Shawn Guo <shawnguo@kernel.org>, linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, u-boot@lists.denx.de, =?utf-8?b?UmFmYcWCIE1p?= =?utf-8?b?xYJlY2tp?= <rafal@milecki.pl> Subject: [PATCH 2/2] nvmem: u-boot-env: reformat MAC in "ethaddr" cell when reading Date: Mon, 28 Nov 2022 00:10:35 +0100 Message-Id: <20221127231035.17547-2-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221127231035.17547-1-zajec5@gmail.com> References: <20221127231035.17547-1-zajec5@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750693012180122574?= X-GMAIL-MSGID: =?utf-8?q?1750693012180122574?= |
Series |
[1/2] nvmem: core: refactor .cell_post_process() CB arguments
|
|
Commit Message
Rafał Miłecki
Nov. 27, 2022, 11:10 p.m. UTC
From: Rafał Miłecki <rafal@milecki.pl> NVMEM consumers expect MAC in a byte-based format (see e.g. nvmem_get_mac_address()). U-Boot environment data stores all values in ASCII form. Add post processing callback detecting "ethaddr" reads and reformat data as expected. This fixes Ethernet drivers reading MAC from NVMEM devices. Signed-off-by: Rafał Miłecki <rafal@milecki.pl> --- drivers/nvmem/u-boot-env.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
Comments
Hi Rafał, I love your patch! Yet something to improve: [auto build test ERROR on shawnguo/for-next] [also build test ERROR on soc/for-next linus/master v6.1-rc7 next-20221125] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Rafa-Mi-ecki/nvmem-core-refactor-cell_post_process-CB-arguments/20221128-071155 base: https://git.kernel.org/pub/scm/linux/kernel/git/shawnguo/linux.git for-next patch link: https://lore.kernel.org/r/20221127231035.17547-2-zajec5%40gmail.com patch subject: [PATCH 2/2] nvmem: u-boot-env: reformat MAC in "ethaddr" cell when reading config: riscv-randconfig-r042-20221127 compiler: riscv64-linux-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/7ed383c8df3e3a2435255360e03171ebdc4437b4 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Rafa-Mi-ecki/nvmem-core-refactor-cell_post_process-CB-arguments/20221128-071155 git checkout 7ed383c8df3e3a2435255360e03171ebdc4437b4 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): riscv64-linux-ld: arch/riscv/kvm/vcpu.o: in function `.L0 ': arch/riscv/kvm/vcpu.c:271: undefined reference to `riscv_cbom_block_size' riscv64-linux-ld: arch/riscv/kvm/vcpu.c:271: undefined reference to `riscv_cbom_block_size' riscv64-linux-ld: drivers/nvmem/u-boot-env.o: in function `.L0 ': >> drivers/nvmem/u-boot-env.c:75: undefined reference to `mac_pton' vim +75 drivers/nvmem/u-boot-env.c 66 67 static int u_boot_env_cell_post_process(void *context, struct nvmem_cell_entry *cell, 68 const char *id, void *buf, size_t *len) 69 { 70 struct u_boot_env *priv = context; 71 72 if (!strcmp(cell->name, "ethaddr")) { 73 u8 mac[ETH_ALEN]; 74 > 75 if (mac_pton(buf, mac)) { 76 ether_addr_copy(buf, mac); 77 if (len) 78 *len = ETH_ALEN; 79 } 80 } 81 82 return 0; 83 } 84
Hi Rafał, I love your patch! Perhaps something to improve: [auto build test WARNING on shawnguo/for-next] [also build test WARNING on soc/for-next linus/master v6.1-rc7 next-20221125] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Rafa-Mi-ecki/nvmem-core-refactor-cell_post_process-CB-arguments/20221128-071155 base: https://git.kernel.org/pub/scm/linux/kernel/git/shawnguo/linux.git for-next patch link: https://lore.kernel.org/r/20221127231035.17547-2-zajec5%40gmail.com patch subject: [PATCH 2/2] nvmem: u-boot-env: reformat MAC in "ethaddr" cell when reading config: x86_64-allyesconfig compiler: gcc-11 (Debian 11.3.0-8) 11.3.0 reproduce (this is a W=1 build): # https://github.com/intel-lab-lkp/linux/commit/7ed383c8df3e3a2435255360e03171ebdc4437b4 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Rafa-Mi-ecki/nvmem-core-refactor-cell_post_process-CB-arguments/20221128-071155 git checkout 7ed383c8df3e3a2435255360e03171ebdc4437b4 # save the config file mkdir build_dir && cp config build_dir/.config make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All warnings (new ones prefixed by >>): drivers/nvmem/u-boot-env.c: In function 'u_boot_env_cell_post_process': >> drivers/nvmem/u-boot-env.c:70:28: warning: unused variable 'priv' [-Wunused-variable] 70 | struct u_boot_env *priv = context; | ^~~~ vim +/priv +70 drivers/nvmem/u-boot-env.c 66 67 static int u_boot_env_cell_post_process(void *context, struct nvmem_cell_entry *cell, 68 const char *id, void *buf, size_t *len) 69 { > 70 struct u_boot_env *priv = context; 71 72 if (!strcmp(cell->name, "ethaddr")) { 73 u8 mac[ETH_ALEN]; 74 75 if (mac_pton(buf, mac)) { 76 ether_addr_copy(buf, mac); 77 if (len) 78 *len = ETH_ALEN; 79 } 80 } 81 82 return 0; 83 } 84
diff --git a/drivers/nvmem/u-boot-env.c b/drivers/nvmem/u-boot-env.c index 2a87dda45188..d103a52e0008 100644 --- a/drivers/nvmem/u-boot-env.c +++ b/drivers/nvmem/u-boot-env.c @@ -4,6 +4,8 @@ */ #include <linux/crc32.h> +#include <linux/etherdevice.h> +#include <linux/if_ether.h> #include <linux/mod_devicetable.h> #include <linux/module.h> #include <linux/mtd/mtd.h> @@ -70,6 +72,24 @@ static int u_boot_env_read(void *context, unsigned int offset, void *val, return 0; } +static int u_boot_env_cell_post_process(void *context, struct nvmem_cell_entry *cell, + const char *id, void *buf, size_t *len) +{ + struct u_boot_env *priv = context; + + if (!strcmp(cell->name, "ethaddr")) { + u8 mac[ETH_ALEN]; + + if (mac_pton(buf, mac)) { + ether_addr_copy(buf, mac); + if (len) + *len = ETH_ALEN; + } + } + + return 0; +} + static int u_boot_env_add_cells(struct u_boot_env *priv, uint8_t *buf, size_t data_offset, size_t data_len) { @@ -179,6 +199,7 @@ static int u_boot_env_probe(struct platform_device *pdev) struct nvmem_config config = { .name = "u-boot-env", .reg_read = u_boot_env_read, + .cell_post_process = u_boot_env_cell_post_process, }; struct device *dev = &pdev->dev; struct device_node *np = dev->of_node;