From nobody Thu Apr 16 03:45:22 2026 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 D2EEEC3A59F for ; Wed, 23 Nov 2022 18:03:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239500AbiKWSDO (ORCPT ); Wed, 23 Nov 2022 13:03:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239365AbiKWSCV (ORCPT ); Wed, 23 Nov 2022 13:02:21 -0500 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4B1E93700; Wed, 23 Nov 2022 10:02:20 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id 59D7C27B2; Wed, 23 Nov 2022 19:02:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1669226538; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8sjjk67lYXsbZ+8cTcOR9HPiqjFzaTQLO5gq3X9c4IA=; b=zeAXKIkh1NfD6yON6Wk9huqk9GL/RNNI0wcW3b+xZN/jZNrEJoLcYjTEq9j4Ei5Q8OHFU8 H/a+SvAyy9EIJtraA9MccxRXjPdez1bvmYjbK0qoUTnfBjtC+nTKjVg26J022Nzn7lLD3o t1ZSX8SOaqfRgO6+D+DZB8XHvNSMGp3Vc/QdG4DP8kwEHHvLh8yElLsp8DN82kS7XmzLW3 Nfe2yxX2UAR7Z+7vV8GfV6dv24MeKJr/CyEeg0lLrF4HQJ9xhreMlvdcOpTt9r0olAMoMM J7C5evjwohYhc8R7fAUtXjczWJNuOzCB5YJAQ7eyIKZ87Tl9o2QpK/Rz+V3c9w== From: Michael Walle To: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand , Sascha Hauer Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle , Andrew Lunn , Jakub Kicinski Subject: [PATCH v4 01/20] net: add helper eth_addr_add() Date: Wed, 23 Nov 2022 19:01:32 +0100 Message-Id: <20221123180151.2160033-2-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123180151.2160033-1-michael@walle.cc> References: <20221123180151.2160033-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add a helper to add an offset to a ethernet address. This comes in handy if you have a base ethernet address for multiple interfaces. Signed-off-by: Michael Walle Reviewed-by: Andrew Lunn Acked-by: Jakub Kicinski --- changes since v3: - fix typo s/and/an/ changes since v2: - none changes since v1: - none include/linux/etherdevice.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h index a541f0c4f146..224645f17c33 100644 --- a/include/linux/etherdevice.h +++ b/include/linux/etherdevice.h @@ -507,6 +507,20 @@ static inline void eth_addr_inc(u8 *addr) u64_to_ether_addr(u, addr); } =20 +/** + * eth_addr_add() - Add (or subtract) an offset to/from the given MAC addr= ess. + * + * @offset: Offset to add. + * @addr: Pointer to a six-byte array containing Ethernet address to incre= ment. + */ +static inline void eth_addr_add(u8 *addr, long offset) +{ + u64 u =3D ether_addr_to_u64(addr); + + u +=3D offset; + u64_to_ether_addr(u, addr); +} + /** * is_etherdev_addr - Tell if given Ethernet address belongs to the device. * @dev: Pointer to a device structure --=20 2.30.2 From nobody Thu Apr 16 03:45:22 2026 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 A9F67C4332F for ; Wed, 23 Nov 2022 18:03:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239519AbiKWSDZ (ORCPT ); Wed, 23 Nov 2022 13:03:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239367AbiKWSCW (ORCPT ); Wed, 23 Nov 2022 13:02:22 -0500 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44A7D9371F; Wed, 23 Nov 2022 10:02:21 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id 23F7927BF; Wed, 23 Nov 2022 19:02:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1669226539; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6/o1ZODrnXgixeRc40M5DiB6qZMv+p5qkZBjlK/B2Jo=; b=XkpNhRW6GPSZcUMEQAclXA8ulS7pIcJhe4QcBvaZQWhN/eTsw8xVRx02TqAqYdDUIrgXlx hcC1/44PtAw0iD/Iq0+fk6mrk4kO0QKlnaRtm/3JfM26ntp2UMyo95/8Mk/hzdegdpKv+L LD/3De6Sx3swD0vWOQsfnDtd5aAJx5LmWJ7q9BFnfBPwe+2RC8JTmBj5YHXNZX6YvyMYrz hzZ9CWqFcS9xSBA/HBsGZCQDoGOdsMcEWZ3tiQ+BwW3HGDAUvG54+yrCNosn3nnSVx8Skq roLYh3rML5odQoPI96zxLVlksDdybaPmAXWx52FkTZBIGAaoiDu3mJJXwMidxA== From: Michael Walle To: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand , Sascha Hauer Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle , Rob Herring Subject: [PATCH v4 02/20] of: base: add of_parse_phandle_with_optional_args() Date: Wed, 23 Nov 2022 19:01:33 +0100 Message-Id: <20221123180151.2160033-3-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123180151.2160033-1-michael@walle.cc> References: <20221123180151.2160033-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add a new variant of the of_parse_phandle_with_args() which treats the cells name as optional. If it's missing, it is assumed that the phandle has no arguments. Up until now, a nvmem node didn't have any arguments, so all the device trees haven't any '#*-cells' property. But there is a need for an additional argument for the phandle, for which we need a '#*-cells' property. Therefore, we need to support nvmem nodes with and without this property. Signed-off-by: Michael Walle Reviewed-by: Rob Herring --- changes since v3: - none changes since v2: - none changes since v1: - none include/linux/of.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/include/linux/of.h b/include/linux/of.h index 8b9f94386dc3..98c252d2d851 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -1008,6 +1008,31 @@ static inline int of_parse_phandle_with_fixed_args(c= onst struct device_node *np, index, out_args); } =20 +/** + * of_parse_phandle_with_optional_args() - Find a node pointed by phandle = in a list + * @np: pointer to a device tree node containing a list + * @list_name: property name that contains a list + * @cells_name: property name that specifies phandles' arguments count + * @index: index of a phandle to parse out + * @out_args: optional pointer to output arguments structure (will be fill= ed) + * + * Same as of_parse_phandle_with_args() except that if the cells_name prop= erty + * is not found, cell_count of 0 is assumed. + * + * This is used to useful, if you have a phandle which didn't have argumen= ts + * before and thus doesn't have a '#*-cells' property but is now migrated = to + * having arguments while retaining backwards compatibility. + */ +static inline int of_parse_phandle_with_optional_args(const struct device_= node *np, + const char *list_name, + const char *cells_name, + int index, + struct of_phandle_args *out_args) +{ + return __of_parse_phandle_with_args(np, list_name, cells_name, + 0, index, out_args); +} + /** * of_property_count_u8_elems - Count the number of u8 elements in a prope= rty * --=20 2.30.2 From nobody Thu Apr 16 03:45:22 2026 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 72A49C4332F for ; Wed, 23 Nov 2022 18:03:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239509AbiKWSDR (ORCPT ); Wed, 23 Nov 2022 13:03:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239370AbiKWSCW (ORCPT ); Wed, 23 Nov 2022 13:02:22 -0500 Received: from mail.3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8E9197358; Wed, 23 Nov 2022 10:02:21 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id AACAA31FF; Wed, 23 Nov 2022 19:02:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1669226539; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XAy6w8gmcdBCGB2WqwHd4YD9OIJ2+H3z5Lml3ZnuA1g=; b=Jk8A2EV9KEcSNasbByjuQt4+++GQ/KW67C5/I+Tf74dT/Y9tJd0oBWBzVfadSmgmsDjArL AwzGAodXnZxJGtF/OXmHxDbXMVcO2nlIfqe+EGYtKNX5MUpeUR9FjTiqx3hnu+lG0D6IpL z3Pu8ymOvfx9YDxHRfql5QvX8DH3r2dTAD0TLg+NFpRNEbvvULeFZQPUDaHtPy6g4KRywO 2pLEPltOCEFDDv108Kdxli/pBN+sIAuvezSL5OsBqQ9u0Ld2A9pSqTBNmJIUIta5ofYhZg 6aqrcvjZlb6tUa25OXK9vii2aF+Ptl+J9YuYCRii3iSsJ0FvMHRhc3XiunlkVw== From: Michael Walle To: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand , Sascha Hauer Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle Subject: [PATCH v4 03/20] of: property: make #.*-cells optional for simple props Date: Wed, 23 Nov 2022 19:01:34 +0100 Message-Id: <20221123180151.2160033-4-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123180151.2160033-1-michael@walle.cc> References: <20221123180151.2160033-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Sometimes, future bindings for phandles will get additional arguments. Thus the target node of the phandle will need a new #.*-cells property. To be backwards compatible, this needs to be optional. Prepare the DEFINE_SIMPLE_PROPS() to handle the cells name as optional. Signed-off-by: Michael Walle Tested-by: Miquel Raynal Reviewed-by: Rob Herring --- changes since v3: - new patch drivers/of/property.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/of/property.c b/drivers/of/property.c index 967f79b59016..9773bfeaed9f 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1254,8 +1254,8 @@ static struct device_node *parse_suffix_prop_cells(st= ruct device_node *np, if (strcmp_suffix(prop_name, suffix)) return NULL; =20 - if (of_parse_phandle_with_args(np, prop_name, cells_name, index, - &sup_args)) + if (__of_parse_phandle_with_args(np, prop_name, cells_name, 0, index, + &sup_args)) return NULL; =20 return sup_args.np; --=20 2.30.2 From nobody Thu Apr 16 03:45:22 2026 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 10CC0C4332F for ; Wed, 23 Nov 2022 18:03:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239344AbiKWSDg (ORCPT ); Wed, 23 Nov 2022 13:03:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239168AbiKWSCZ (ORCPT ); Wed, 23 Nov 2022 13:02:25 -0500 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A2AF2D741; Wed, 23 Nov 2022 10:02:22 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id 42CFA322F; Wed, 23 Nov 2022 19:02:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1669226540; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bQO4p8yYKQXJsXFHB0RdTY77pOrPELcS4Lfg139SYHo=; b=uVzBA4B+zBhLOBzQlnjDwdk5Yebf5vsK0n25923nVLEvyvC6MhJaOFMV/OBJUUl2hZQOZ8 yRGhURRCux6SaIh07BJVlPXG8YV8IsfMEIyNTYdYNu0iJQ9orTJB7sJrB+DkV9NlBOuP3a YdTTexUQvY+yKQTO4Mma8w8k3UBNrpB9dG7+qcz0f7LJbfY7Mo/kW4LppMwuMU+UMQcjNt 4RO5RRbOe0jVQsrwIZ41e/Ez+T2o2HEhdOIU0ziFXZ2a94GmYIaW+vs8ZfZWmVaSQhF8GV F021R8tntSAF+nCN004o9/kO1iNuSt25kEVzqY7qo4IwDspDQqJo9WZ2pMSpBw== From: Michael Walle To: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand , Sascha Hauer Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle Subject: [PATCH v4 04/20] of: property: add #nvmem-cell-cells property Date: Wed, 23 Nov 2022 19:01:35 +0100 Message-Id: <20221123180151.2160033-5-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123180151.2160033-1-michael@walle.cc> References: <20221123180151.2160033-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Bindings describe the new '#nvmem-cell-cells' property. Now that the arguments count property is optional, we just add this property to the nvmem-cells. Signed-off-by: Michael Walle Tested-by: Miquel Raynal Reviewed-by: Rob Herring --- changes since v3: - new patch drivers/of/property.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/of/property.c b/drivers/of/property.c index 9773bfeaed9f..f60ac02e9dec 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1305,7 +1305,7 @@ DEFINE_SIMPLE_PROP(dmas, "dmas", "#dma-cells") DEFINE_SIMPLE_PROP(power_domains, "power-domains", "#power-domain-cells") DEFINE_SIMPLE_PROP(hwlocks, "hwlocks", "#hwlock-cells") DEFINE_SIMPLE_PROP(extcon, "extcon", NULL) -DEFINE_SIMPLE_PROP(nvmem_cells, "nvmem-cells", NULL) +DEFINE_SIMPLE_PROP(nvmem_cells, "nvmem-cells", "#nvmem-cell-cells") DEFINE_SIMPLE_PROP(phys, "phys", "#phy-cells") DEFINE_SIMPLE_PROP(wakeup_parent, "wakeup-parent", NULL) DEFINE_SIMPLE_PROP(pinctrl0, "pinctrl-0", NULL) --=20 2.30.2 From nobody Thu Apr 16 03:45:22 2026 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 C7FA7C4332F for ; Wed, 23 Nov 2022 18:03:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237931AbiKWSDq (ORCPT ); Wed, 23 Nov 2022 13:03:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239183AbiKWSCZ (ORCPT ); Wed, 23 Nov 2022 13:02:25 -0500 Received: from mail.3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E81FA93700; Wed, 23 Nov 2022 10:02:22 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id C83B93A7F; Wed, 23 Nov 2022 19:02:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1669226540; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1Q1MoPTERuwNbtl93gSheDb+IydkaPiCC1imB+guf7A=; b=O40PtDLf1PHHYXCdyXG0dEe/l1T4hU/5ZadCAMY9NuJx9Nz4/lYbJnzCO1AtiW05WhVzwf a55BRAkXHsw8LnQkXpMUwGXTZ2PL3RwDGxxhgAEGyaNjkfvPfJf0DHYORI2G0yI4/J9P/S eucSBEC02A58rfUCU4Pr4K19BXqwQgoHoojCGzY1/8tVFy9AvbF8Bst8W7BwL7aoLr+Exc id2EZlndNwiSPCAP689VEAzrmPxcm3q5XfDLEX7wXgcvyQYmngmhlmNlOu0Rxd3jlsejnt 0YbRN7zF3K2JCHHqlNCZZbVoye7hdxAyL9ue7eVxDhxx6uzLxnjRjZwiCGWYdw== From: Michael Walle To: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand , Sascha Hauer Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle Subject: [PATCH v4 05/20] nvmem: core: fix device node refcounting Date: Wed, 23 Nov 2022 19:01:36 +0100 Message-Id: <20221123180151.2160033-6-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123180151.2160033-1-michael@walle.cc> References: <20221123180151.2160033-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In of_nvmem_cell_get(), of_get_next_parent() is used on cell_np. This will decrement the refcount on cell_np, but cell_np is still used later in the code. Use of_get_parent() instead and of_node_put() in the appropriate places. Signed-off-by: Michael Walle --- changes since v3: - none changes since v2: - new patch drivers/nvmem/core.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 321d7d63e068..205a427f564d 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -1242,16 +1242,21 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_= node *np, const char *id) if (!cell_np) return ERR_PTR(-ENOENT); =20 - nvmem_np =3D of_get_next_parent(cell_np); - if (!nvmem_np) + nvmem_np =3D of_get_parent(cell_np); + if (!nvmem_np) { + of_node_put(cell_np); return ERR_PTR(-EINVAL); + } =20 nvmem =3D __nvmem_device_get(nvmem_np, device_match_of_node); of_node_put(nvmem_np); - if (IS_ERR(nvmem)) + if (IS_ERR(nvmem)) { + of_node_put(cell_np); return ERR_CAST(nvmem); + } =20 cell_entry =3D nvmem_find_cell_entry_by_node(nvmem, cell_np); + of_node_put(cell_np); if (!cell_entry) { __nvmem_device_put(nvmem); return ERR_PTR(-ENOENT); --=20 2.30.2 From nobody Thu Apr 16 03:45:22 2026 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 D7758C4332F for ; Wed, 23 Nov 2022 18:03:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238968AbiKWSDm (ORCPT ); Wed, 23 Nov 2022 13:03:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239207AbiKWSCZ (ORCPT ); Wed, 23 Nov 2022 13:02:25 -0500 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3503797364; Wed, 23 Nov 2022 10:02:23 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id 22DDC3B18; Wed, 23 Nov 2022 19:02:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1669226541; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MYiFNEuKVdNaBDsNXMlXbzjfWQYDtr067TKicS/QZv4=; b=Q6YDH4HZEQNbOvFFPE8rTEiaWiyy0F4V8vP/dW1v5e+NE4TvBLINdEH7NEuBoXAtWdZxbF czJ6bPH65ya+Ag7dmmbHMw1uf8oGsBVprvAOBjwrw0cCx2EuGDRItw8pJKUpieFkxjDWCP Q0h9CMA2OufgtN6sQ7I8WH2hwLLXu3zNDS1wXK14BedVvXdNZtfPhTeBe3JzJu6LNDHsjT 4eNW0EnG4ui17CX6QHLDJKIYlPjLo4oOM6Y+yLrlqoniGtRHzozx91on433kM2k9+n6zpx 54yEX3r6bM2nS+f9/lw1fruCPEDKb3GFvQMNklIlfjwQSExwO6bqE2sih4ItPQ== From: Michael Walle To: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand , Sascha Hauer Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle Subject: [PATCH v4 06/20] nvmem: core: add an index parameter to the cell Date: Wed, 23 Nov 2022 19:01:37 +0100 Message-Id: <20221123180151.2160033-7-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123180151.2160033-1-michael@walle.cc> References: <20221123180151.2160033-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Sometimes a cell can represend multiple values. For example, a base ethernet address stored in the NVMEM can be expanded into multiple discreet ones by adding an offset. For this use case, introduce an index parameter which is then used to distiguish between values. This parameter will then be passed to the post process hook which can then use it to create different values during reading. At the moment, there is only support for the device tree path. You can add the index to the phandle, e.g. &net { nvmem-cells =3D <&base_mac_address 2>; nvmem-cell-names =3D "mac-address"; }; &nvmem_provider { base_mac_address: base-mac-address@0 { #nvmem-cell-cells =3D <1>; reg =3D <0 6>; }; }; Signed-off-by: Michael Walle --- changes since v3: - none changes since v2: - none changes since v1: - none drivers/nvmem/core.c | 37 ++++++++++++++++++++++++---------- drivers/nvmem/imx-ocotp.c | 4 ++-- include/linux/nvmem-provider.h | 4 ++-- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 205a427f564d..24573e63e5a9 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -60,6 +60,7 @@ struct nvmem_cell_entry { struct nvmem_cell { struct nvmem_cell_entry *entry; const char *id; + int index; }; =20 static DEFINE_MUTEX(nvmem_mutex); @@ -1127,7 +1128,8 @@ struct nvmem_device *devm_nvmem_device_get(struct dev= ice *dev, const char *id) } EXPORT_SYMBOL_GPL(devm_nvmem_device_get); =20 -static struct nvmem_cell *nvmem_create_cell(struct nvmem_cell_entry *entry= , const char *id) +static struct nvmem_cell *nvmem_create_cell(struct nvmem_cell_entry *entry, + const char *id, int index) { struct nvmem_cell *cell; const char *name =3D NULL; @@ -1146,6 +1148,7 @@ static struct nvmem_cell *nvmem_create_cell(struct nv= mem_cell_entry *entry, cons =20 cell->id =3D name; cell->entry =3D entry; + cell->index =3D index; =20 return cell; } @@ -1184,7 +1187,7 @@ nvmem_cell_get_from_lookup(struct device *dev, const = char *con_id) __nvmem_device_put(nvmem); cell =3D ERR_PTR(-ENOENT); } else { - cell =3D nvmem_create_cell(cell_entry, con_id); + cell =3D nvmem_create_cell(cell_entry, con_id, 0); if (IS_ERR(cell)) __nvmem_device_put(nvmem); } @@ -1232,15 +1235,27 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_= node *np, const char *id) struct nvmem_device *nvmem; struct nvmem_cell_entry *cell_entry; struct nvmem_cell *cell; + struct of_phandle_args cell_spec; int index =3D 0; + int cell_index =3D 0; + int ret; =20 /* if cell name exists, find index to the name */ if (id) index =3D of_property_match_string(np, "nvmem-cell-names", id); =20 - cell_np =3D of_parse_phandle(np, "nvmem-cells", index); - if (!cell_np) - return ERR_PTR(-ENOENT); + ret =3D of_parse_phandle_with_optional_args(np, "nvmem-cells", + "#nvmem-cell-cells", + index, &cell_spec); + if (ret) + return ERR_PTR(ret); + + if (cell_spec.args_count > 1) + return ERR_PTR(-EINVAL); + + cell_np =3D cell_spec.np; + if (cell_spec.args_count) + cell_index =3D cell_spec.args[0]; =20 nvmem_np =3D of_get_parent(cell_np); if (!nvmem_np) { @@ -1262,7 +1277,7 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_no= de *np, const char *id) return ERR_PTR(-ENOENT); } =20 - cell =3D nvmem_create_cell(cell_entry, id); + cell =3D nvmem_create_cell(cell_entry, id, cell_index); if (IS_ERR(cell)) __nvmem_device_put(nvmem); =20 @@ -1415,8 +1430,8 @@ static void nvmem_shift_read_buffer_in_place(struct n= vmem_cell_entry *cell, void } =20 static int __nvmem_cell_read(struct nvmem_device *nvmem, - struct nvmem_cell_entry *cell, - void *buf, size_t *len, const char *id) + struct nvmem_cell_entry *cell, + void *buf, size_t *len, const char *id, int index) { int rc; =20 @@ -1430,7 +1445,7 @@ static int __nvmem_cell_read(struct nvmem_device *nvm= em, nvmem_shift_read_buffer_in_place(cell, buf); =20 if (nvmem->cell_post_process) { - rc =3D nvmem->cell_post_process(nvmem->priv, id, + rc =3D nvmem->cell_post_process(nvmem->priv, id, index, cell->offset, buf, cell->bytes); if (rc) return rc; @@ -1465,7 +1480,7 @@ void *nvmem_cell_read(struct nvmem_cell *cell, size_t= *len) if (!buf) return ERR_PTR(-ENOMEM); =20 - rc =3D __nvmem_cell_read(nvmem, cell->entry, buf, len, cell->id); + rc =3D __nvmem_cell_read(nvmem, cell->entry, buf, len, cell->id, cell->in= dex); if (rc) { kfree(buf); return ERR_PTR(rc); @@ -1778,7 +1793,7 @@ ssize_t nvmem_device_cell_read(struct nvmem_device *n= vmem, if (rc) return rc; =20 - rc =3D __nvmem_cell_read(nvmem, &cell, buf, &len, NULL); + rc =3D __nvmem_cell_read(nvmem, &cell, buf, &len, NULL, 0); if (rc) return rc; =20 diff --git a/drivers/nvmem/imx-ocotp.c b/drivers/nvmem/imx-ocotp.c index 14284e866f26..e9b52ecb3f72 100644 --- a/drivers/nvmem/imx-ocotp.c +++ b/drivers/nvmem/imx-ocotp.c @@ -222,8 +222,8 @@ static int imx_ocotp_read(void *context, unsigned int o= ffset, return ret; } =20 -static int imx_ocotp_cell_pp(void *context, const char *id, unsigned int o= ffset, - void *data, size_t bytes) +static int imx_ocotp_cell_pp(void *context, const char *id, int index, + unsigned int offset, void *data, size_t bytes) { struct ocotp_priv *priv =3D context; =20 diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h index 50caa117cb62..8f964b394292 100644 --- a/include/linux/nvmem-provider.h +++ b/include/linux/nvmem-provider.h @@ -20,8 +20,8 @@ typedef int (*nvmem_reg_read_t)(void *priv, unsigned int = offset, typedef int (*nvmem_reg_write_t)(void *priv, unsigned int offset, void *val, size_t bytes); /* used for vendor specific post processing of cell data */ -typedef int (*nvmem_cell_post_process_t)(void *priv, const char *id, unsig= ned int offset, - void *buf, size_t bytes); +typedef int (*nvmem_cell_post_process_t)(void *priv, const char *id, int i= ndex, + unsigned int offset, void *buf, size_t bytes); =20 enum nvmem_type { NVMEM_TYPE_UNKNOWN =3D 0, --=20 2.30.2 From nobody Thu Apr 16 03:45:22 2026 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 ABE01C433FE for ; Wed, 23 Nov 2022 18:04:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239380AbiKWSEJ (ORCPT ); Wed, 23 Nov 2022 13:04:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239253AbiKWSCZ (ORCPT ); Wed, 23 Nov 2022 13:02:25 -0500 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B28D160F9; Wed, 23 Nov 2022 10:02:23 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id B41AF3B1C; Wed, 23 Nov 2022 19:02:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1669226541; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GlKtoulrQImwZ0J+jmUcVt5fZ5o3JIoWsQTVPvtUMg0=; b=zl7B4JwpgH+/znHNfGRB+U6ZMhMZywwF7gL+2fNTVCyqzw2iTKu7eWrbOa5taU0KQgXM3C FQmd4G+Jb46q9XYoBtZtXZjgZhbtKAh/o1Xm5yajU9TEcUs8yQXhd/hEhycCDXYf1tk8cq ePC3DBiIcsjN8QufETNg8AJAUGA1AXFmtRzMFbBYsoHRqHG6k+L4/yTVv65ogK3fv7/Xwf VYsMVmVgHOOfP4MKFR1i/KYUF/m3JHkMr4xmzt0BiidlmNKNU59XTXlGUUfZZXb3pi4+ey LlKYARQaqNXZVhTZUVdFBykWQgMDU0BrpL9PjOdLIvUL0inP1dMCdMvmWPV7cQ== From: Michael Walle To: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand , Sascha Hauer Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle Subject: [PATCH v4 07/20] nvmem: core: move struct nvmem_cell_info to nvmem-provider.h Date: Wed, 23 Nov 2022 19:01:38 +0100 Message-Id: <20221123180151.2160033-8-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123180151.2160033-1-michael@walle.cc> References: <20221123180151.2160033-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" struct nvmem_cell_info is used to describe a cell. Thus this should really be in the nvmem-provider's header. There are two (unused) nvmem access methods which use the nvmem_cell_info to describe the cell to be accesses. One can argue, that they will create a cell before accessing, thus they are both a provider and a consumer. struct nvmem_cell_info will get used more and more by nvmem-providers, don't force them to also include the consumer header, although they are not. Signed-off-by: Michael Walle --- changes since v3: - none changes since v2: - none changes since v1: - new patch include/linux/nvmem-consumer.h | 10 +--------- include/linux/nvmem-provider.h | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h index 980f9c9ac0bc..1f62f7ba71ca 100644 --- a/include/linux/nvmem-consumer.h +++ b/include/linux/nvmem-consumer.h @@ -18,15 +18,7 @@ struct device_node; /* consumer cookie */ struct nvmem_cell; struct nvmem_device; - -struct nvmem_cell_info { - const char *name; - unsigned int offset; - unsigned int bytes; - unsigned int bit_offset; - unsigned int nbits; - struct device_node *np; -}; +struct nvmem_cell_info; =20 /** * struct nvmem_cell_lookup - cell lookup entry diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h index 8f964b394292..14a32a1bc249 100644 --- a/include/linux/nvmem-provider.h +++ b/include/linux/nvmem-provider.h @@ -14,7 +14,6 @@ #include =20 struct nvmem_device; -struct nvmem_cell_info; typedef int (*nvmem_reg_read_t)(void *priv, unsigned int offset, void *val, size_t bytes); typedef int (*nvmem_reg_write_t)(void *priv, unsigned int offset, @@ -47,6 +46,24 @@ struct nvmem_keepout { unsigned char value; }; =20 +/** + * struct nvmem_cell_info - NVMEM cell description + * @name: Name. + * @offset: Offset within the NVMEM device. + * @bytes: Length of the cell. + * @bit_offset: Bit offset if cell is smaller than a byte. + * @nbits: Number of bits. + * @np: Optional device_node pointer. + */ +struct nvmem_cell_info { + const char *name; + unsigned int offset; + unsigned int bytes; + unsigned int bit_offset; + unsigned int nbits; + struct device_node *np; +}; + /** * struct nvmem_config - NVMEM device configuration * --=20 2.30.2 From nobody Thu Apr 16 03:45:22 2026 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 C7B43C4332F for ; Wed, 23 Nov 2022 18:03:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239269AbiKWSDv (ORCPT ); Wed, 23 Nov 2022 13:03:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239227AbiKWSCZ (ORCPT ); Wed, 23 Nov 2022 13:02:25 -0500 Received: from mail.3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3ECF8C7AC; Wed, 23 Nov 2022 10:02:23 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id 0CFBA3B1D; Wed, 23 Nov 2022 19:02:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1669226542; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dbqJAngAnCItu/kQhrmwoKdD13Z1Ky8qwmXbY0PTXSA=; b=v/5RSiS+j5rt3w7kJZACxzGmYamX7vbD6+QyoLb9F0wfekJVPshLPUfL8jQ7PVLYQx4/1j djfiU2DV47D29uxfvw4BMdtCxpcuiuaDkAPIIYfayKTlmghBR8FxRP/cUQPu9+B9PXeg96 4vQueLE3pnYbPuvjAMbutoxAFzXu8FWnZQ4MRgeJWBxE7coja3R20STwIJwE09zG9C91I4 0WfBZiPn3jpbhY2dotC5oW/O4WuagisAZgsCShQYbwHYM9fJZf1FNhNuQHdOuhFE0bz7kv iKaENYpuqLt4rB4kxYCjNAQUzOipujW49nGSSwvjv18izu7vZpJR38I3idkWkg== From: Michael Walle To: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand , Sascha Hauer Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle Subject: [PATCH v4 08/20] nvmem: core: drop the removal of the cells in nvmem_add_cells() Date: Wed, 23 Nov 2022 19:01:39 +0100 Message-Id: <20221123180151.2160033-9-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123180151.2160033-1-michael@walle.cc> References: <20221123180151.2160033-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" If nvmem_add_cells() fails, the whole nvmem_register() will fail and the cells will then be removed anyway. This is a preparation to introduce a nvmem_add_one_cell() which can then be used by nvmem_add_cells(). This is then the same to what nvmem_add_cells_from_table() and nvmem_add_cells_from_of() do. Signed-off-by: Michael Walle --- changes since v3: - fix typo, s/prepartion/preparation/ changes since v2: - none changes since v1: - none drivers/nvmem/core.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 24573e63e5a9..7c76e0e0072e 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -515,7 +515,7 @@ static int nvmem_add_cells(struct nvmem_device *nvmem, int ncells) { struct nvmem_cell_entry **cells; - int i, rval; + int i, rval =3D 0; =20 cells =3D kcalloc(ncells, sizeof(*cells), GFP_KERNEL); if (!cells) @@ -525,28 +525,22 @@ static int nvmem_add_cells(struct nvmem_device *nvmem, cells[i] =3D kzalloc(sizeof(**cells), GFP_KERNEL); if (!cells[i]) { rval =3D -ENOMEM; - goto err; + goto out; } =20 rval =3D nvmem_cell_info_to_nvmem_cell_entry(nvmem, &info[i], cells[i]); if (rval) { kfree(cells[i]); - goto err; + goto out; } =20 nvmem_cell_entry_add(cells[i]); } =20 +out: /* remove tmp array */ kfree(cells); =20 - return 0; -err: - while (i--) - nvmem_cell_entry_drop(cells[i]); - - kfree(cells); - return rval; } =20 --=20 2.30.2 From nobody Thu Apr 16 03:45:22 2026 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 05E90C4332F for ; Wed, 23 Nov 2022 18:04:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239475AbiKWSEP (ORCPT ); Wed, 23 Nov 2022 13:04:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239295AbiKWSCZ (ORCPT ); Wed, 23 Nov 2022 13:02:25 -0500 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A9F193715; Wed, 23 Nov 2022 10:02:24 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id 5A7923B28; Wed, 23 Nov 2022 19:02:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1669226542; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v/eOHqJ1LIauQnre0RUshOABMUFVK1bneA370Wreibw=; b=UKN6v0DpI83iFSVut+UHaRNSPZUjTnT07PYOJuVNNkKuDAQjAhL+fImT1g0y1Mt7By9NUi p/Qz5V3FaoZrEG/5g7DTvWJPwJLuQEMWB2OT6yhy0ZPEQp5ZL6cf6oKipY0VO0ZwdnBqHx wYltn3J73Ntx3ENBsvvO7FIhdyWUL4F2v7OrkdIBjMs2wOk/JwNJPjRxHgbmK1POUX+/Ty nxLg4CQMpqOC+UqCeN9VFZwA+hCKa+vcRumqZDf2gliFlEDmj5px8pojST5m8X8k3+NvDD krJJ6fBthCP3qW/3vrbPagy8HoHRxzAIT7qdrZUJfphqcStvnDmqFL90+sk1RA== From: Michael Walle To: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand , Sascha Hauer Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle Subject: [PATCH v4 09/20] nvmem: core: add nvmem_add_one_cell() Date: Wed, 23 Nov 2022 19:01:40 +0100 Message-Id: <20221123180151.2160033-10-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123180151.2160033-1-michael@walle.cc> References: <20221123180151.2160033-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add a new function to add exactly one cell. This will be used by the nvmem layout drivers to add custom cells. In contrast to the nvmem_add_cells(), this has the advantage that we don't have to assemble a list of cells on runtime. Signed-off-by: Michael Walle --- changes since v3: - none changes since v2: - add EXPORT_SYMBOL_GPL() changes since v1: - none drivers/nvmem/core.c | 59 ++++++++++++++++++++-------------- include/linux/nvmem-provider.h | 8 +++++ 2 files changed, 43 insertions(+), 24 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 7c76e0e0072e..cb25bf29dea7 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -501,6 +501,36 @@ static int nvmem_cell_info_to_nvmem_cell_entry(struct = nvmem_device *nvmem, return 0; } =20 +/** + * nvmem_add_one_cell() - Add one cell information to an nvmem device + * + * @nvmem: nvmem device to add cells to. + * @info: nvmem cell info to add to the device + * + * Return: 0 or negative error code on failure. + */ +int nvmem_add_one_cell(struct nvmem_device *nvmem, + const struct nvmem_cell_info *info) +{ + struct nvmem_cell_entry *cell; + int rval; + + cell =3D kzalloc(sizeof(*cell), GFP_KERNEL); + if (!cell) + return -ENOMEM; + + rval =3D nvmem_cell_info_to_nvmem_cell_entry(nvmem, info, cell); + if (rval) { + kfree(cell); + return rval; + } + + nvmem_cell_entry_add(cell); + + return 0; +} +EXPORT_SYMBOL_GPL(nvmem_add_one_cell); + /** * nvmem_add_cells() - Add cell information to an nvmem device * @@ -514,34 +544,15 @@ static int nvmem_add_cells(struct nvmem_device *nvmem, const struct nvmem_cell_info *info, int ncells) { - struct nvmem_cell_entry **cells; - int i, rval =3D 0; - - cells =3D kcalloc(ncells, sizeof(*cells), GFP_KERNEL); - if (!cells) - return -ENOMEM; + int i, rval; =20 for (i =3D 0; i < ncells; i++) { - cells[i] =3D kzalloc(sizeof(**cells), GFP_KERNEL); - if (!cells[i]) { - rval =3D -ENOMEM; - goto out; - } - - rval =3D nvmem_cell_info_to_nvmem_cell_entry(nvmem, &info[i], cells[i]); - if (rval) { - kfree(cells[i]); - goto out; - } - - nvmem_cell_entry_add(cells[i]); + rval =3D nvmem_add_one_cell(nvmem, &info[i]); + if (rval) + return rval; } =20 -out: - /* remove tmp array */ - kfree(cells); - - return rval; + return 0; } =20 /** diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h index 14a32a1bc249..385d29168008 100644 --- a/include/linux/nvmem-provider.h +++ b/include/linux/nvmem-provider.h @@ -155,6 +155,9 @@ struct nvmem_device *devm_nvmem_register(struct device = *dev, void nvmem_add_cell_table(struct nvmem_cell_table *table); void nvmem_del_cell_table(struct nvmem_cell_table *table); =20 +int nvmem_add_one_cell(struct nvmem_device *nvmem, + const struct nvmem_cell_info *info); + #else =20 static inline struct nvmem_device *nvmem_register(const struct nvmem_confi= g *c) @@ -172,6 +175,11 @@ devm_nvmem_register(struct device *dev, const struct n= vmem_config *c) =20 static inline void nvmem_add_cell_table(struct nvmem_cell_table *table) {} static inline void nvmem_del_cell_table(struct nvmem_cell_table *table) {} +static inline int nvmem_add_one_cell(struct nvmem_device *nvmem, + const struct nvmem_cell_info *info) +{ + return -EOPNOTSUPP; +} =20 #endif /* CONFIG_NVMEM */ #endif /* ifndef _LINUX_NVMEM_PROVIDER_H */ --=20 2.30.2 From nobody Thu Apr 16 03:45:22 2026 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 B149CC433FE for ; Wed, 23 Nov 2022 18:04:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239320AbiKWSD7 (ORCPT ); Wed, 23 Nov 2022 13:03:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239380AbiKWSC0 (ORCPT ); Wed, 23 Nov 2022 13:02:26 -0500 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF88397350; Wed, 23 Nov 2022 10:02:24 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id E74BF3B2D; Wed, 23 Nov 2022 19:02:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1669226543; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WXol5tT/oIFKZhTAd0NDm/tufouMejDDn5FNjp75nXI=; b=d42jT60xZRu6OI92S9R0pgqZ5Rr5mDmN1r2cDlA5DFBC/iHLLLHyRclbVm8cYR4xzuC5M/ /RrCXHVcHLquLp3ENBOUklnFAAeKR/JHo/45/aqFdslL+tvMuIOERwy07yIt3QF2GWHZuL jNy9w9lDPAUg1OeLH+PWhXFYuMsw93b5DsfaxQjxt+++qedSmLFhpiOemn6yoK4xXGBc9e dc+ttW6spRW5F3gwoCffA9tDACTKV1WxXLBEPfmo0GNYi/GCCai6Xi/4N5Pjj+TBGlDOSM Xl84Rkcgn3zzUfN7UK648yWPEqJV73G37UaB7y76QugAB4rhL+7VyJBvk91Osw== From: Michael Walle To: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand , Sascha Hauer Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle Subject: [PATCH v4 10/20] nvmem: core: use nvmem_add_one_cell() in nvmem_add_cells_from_of() Date: Wed, 23 Nov 2022 19:01:41 +0100 Message-Id: <20221123180151.2160033-11-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123180151.2160033-1-michael@walle.cc> References: <20221123180151.2160033-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Convert nvmem_add_cells_from_of() to use the new nvmem_add_one_cell(). This will remove duplicate code and it will make it possible to add a hook to a nvmem layout in between, which can change fields before the cell is finally added. Signed-off-by: Michael Walle --- changes since v3: - none changes since v2: - none changes since v1: - new patch drivers/nvmem/core.c | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index cb25bf29dea7..26459d582e99 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -688,15 +688,15 @@ static int nvmem_validate_keepouts(struct nvmem_devic= e *nvmem) =20 static int nvmem_add_cells_from_of(struct nvmem_device *nvmem) { - struct device_node *parent, *child; struct device *dev =3D &nvmem->dev; struct nvmem_cell_entry *cell; + struct device_node *child; const __be32 *addr; - int len; + int len, ret; =20 - parent =3D dev->of_node; + for_each_child_of_node(dev->of_node, child) { + struct nvmem_cell_info info =3D {0}; =20 - for_each_child_of_node(parent, child) { addr =3D of_get_property(child, "reg", &len); if (!addr) continue; @@ -712,34 +712,24 @@ static int nvmem_add_cells_from_of(struct nvmem_devic= e *nvmem) return -ENOMEM; } =20 - cell->nvmem =3D nvmem; - cell->offset =3D be32_to_cpup(addr++); - cell->bytes =3D be32_to_cpup(addr); - cell->name =3D kasprintf(GFP_KERNEL, "%pOFn", child); + info.offset =3D be32_to_cpup(addr++); + info.bytes =3D be32_to_cpup(addr); + info.name =3D kasprintf(GFP_KERNEL, "%pOFn", child); =20 addr =3D of_get_property(child, "bits", &len); if (addr && len =3D=3D (2 * sizeof(u32))) { - cell->bit_offset =3D be32_to_cpup(addr++); - cell->nbits =3D be32_to_cpup(addr); + info.bit_offset =3D be32_to_cpup(addr++); + info.nbits =3D be32_to_cpup(addr); } =20 - if (cell->nbits) - cell->bytes =3D DIV_ROUND_UP( - cell->nbits + cell->bit_offset, - BITS_PER_BYTE); + info.np =3D of_node_get(child); =20 - if (!IS_ALIGNED(cell->offset, nvmem->stride)) { - dev_err(dev, "cell %s unaligned to nvmem stride %d\n", - cell->name, nvmem->stride); - /* Cells already added will be freed later. */ - kfree_const(cell->name); - kfree(cell); + ret =3D nvmem_add_one_cell(nvmem, &info); + kfree(info.name); + if (ret) { of_node_put(child); - return -EINVAL; + return ret; } - - cell->np =3D of_node_get(child); - nvmem_cell_entry_add(cell); } =20 return 0; --=20 2.30.2 From nobody Thu Apr 16 03:45:22 2026 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 46828C4332F for ; Wed, 23 Nov 2022 18:04:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239348AbiKWSEE (ORCPT ); Wed, 23 Nov 2022 13:04:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239386AbiKWSC1 (ORCPT ); Wed, 23 Nov 2022 13:02:27 -0500 Received: from mail.3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FD0697358; Wed, 23 Nov 2022 10:02:25 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id 476423B2F; Wed, 23 Nov 2022 19:02:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1669226543; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gZunGWAs/GGCOS5lVXRvCoyL5WreR7oe/miR4YQALN4=; b=LujOKYy6vUuVIvSYP0AJtYtD7qpMLGQhJMUXc4rulFkhtnoJYUaSaer0VDHxiuLJd1j25e Fl31tR6/4C8/1Zed7CgJzMY/FzFxhR5Vuq3GyRwXZWzTy07ig+LZPRhrJaKm1lYsxzSZ3N 8rKQKj8fHPUpTqgOh1pL8mJiV1CrpBjN773ogci5eynuDRRLf52sfePcD9khTPI0/ccGTx XJdh6qLKUEIYthgCA+vhcdIL56rO45W0Frx91v3KvTVF8xTTGRQNfGPbKBDVlHQH/u0Wkj OJ2Io9j3ngvdawPFneZbvFGpp+Nx99r27xgBdeiswYYI8HbZkhMkHVqeagpsIQ== From: Michael Walle To: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand , Sascha Hauer Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle Subject: [PATCH v4 11/20] nvmem: core: introduce NVMEM layouts Date: Wed, 23 Nov 2022 19:01:42 +0100 Message-Id: <20221123180151.2160033-12-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123180151.2160033-1-michael@walle.cc> References: <20221123180151.2160033-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" NVMEM layouts are used to generate NVMEM cells during runtime. Think of an EEPROM with a well-defined conent. For now, the content can be described by a device tree or a board file. But this only works if the offsets and lengths are static and don't change. One could also argue that putting the layout of the EEPROM in the device tree is the wrong place. Instead, the device tree should just have a specific compatible string. Right now there are two use cases: (1) The NVMEM cell needs special processing. E.g. if it only specifies a base MAC address offset and you need to add an offset, or it needs to parse a MAC from ASCII format or some proprietary format. (Post processing of cells is added in a later commit). (2) u-boot environment parsing. The cells don't have a particular offset but it needs parsing the content to determine the offsets and length. Co-developed-by: Miquel Raynal Signed-off-by: Miquel Raynal Signed-off-by: Michael Walle --- changes since v3: - check return code of .add_cells() changes since v2: - look for "nvmem-layout" node and its compatible - add of_nvmem_layout_get_container() - special handling in of_nvmem_cell_get() changes since v1: - add documentation in nvmem.rst - add nvmem_layout_unregister() + necessary module tracking - make it possible to supply a layout via nvmem_register() - check add_cells, before calling Documentation/driver-api/nvmem.rst | 15 ++++ drivers/nvmem/Kconfig | 4 + drivers/nvmem/Makefile | 1 + drivers/nvmem/core.c | 118 +++++++++++++++++++++++++++++ drivers/nvmem/layouts/Kconfig | 5 ++ drivers/nvmem/layouts/Makefile | 4 + include/linux/nvmem-consumer.h | 7 ++ include/linux/nvmem-provider.h | 51 +++++++++++++ 8 files changed, 205 insertions(+) create mode 100644 drivers/nvmem/layouts/Kconfig create mode 100644 drivers/nvmem/layouts/Makefile diff --git a/Documentation/driver-api/nvmem.rst b/Documentation/driver-api/= nvmem.rst index e3366322d46c..de221e91c8e3 100644 --- a/Documentation/driver-api/nvmem.rst +++ b/Documentation/driver-api/nvmem.rst @@ -185,3 +185,18 @@ ex:: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 See Documentation/devicetree/bindings/nvmem/nvmem.txt + +8. NVMEM layouts +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +NVMEM layouts are yet another mechanism to create cells. With the device +tree binding it is possible to specify simple cells by using an offset +and a length. Sometimes, the cells doesn't have a static offset, but +the content is still well defined, e.g. tag-length-values. In this case, +the NVMEM device content has to be first parsed and the cells need to +be added accordingly. Layouts let you read the content of the NVMEM device +and let you add cells dynamically. + +Another use case for layouts is the post processing of cells. With layouts, +it is possible to associate a custom post processing hook to a cell. It +even possible to add this hook to cells not created by the layout itself. diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index 755f551426b5..0e10b5b094b9 100644 --- a/drivers/nvmem/Kconfig +++ b/drivers/nvmem/Kconfig @@ -21,6 +21,10 @@ config NVMEM_SYSFS This interface is mostly used by userspace applications to read/write directly into nvmem. =20 +# Layouts + +source "drivers/nvmem/layouts/Kconfig" + # Devices =20 config NVMEM_APPLE_EFUSES diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile index fa80fe17e567..4cf87ef6c24d 100644 --- a/drivers/nvmem/Makefile +++ b/drivers/nvmem/Makefile @@ -5,6 +5,7 @@ =20 obj-$(CONFIG_NVMEM) +=3D nvmem_core.o nvmem_core-y :=3D core.o +obj-y +=3D layouts/ =20 # Devices obj-$(CONFIG_NVMEM_APPLE_EFUSES) +=3D nvmem-apple-efuses.o diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 26459d582e99..87ba1e3a5bd4 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -40,6 +40,7 @@ struct nvmem_device { nvmem_reg_write_t reg_write; nvmem_cell_post_process_t cell_post_process; struct gpio_desc *wp_gpio; + struct nvmem_layout *layout; void *priv; }; =20 @@ -74,6 +75,9 @@ static LIST_HEAD(nvmem_lookup_list); =20 static BLOCKING_NOTIFIER_HEAD(nvmem_notifier); =20 +static DEFINE_SPINLOCK(nvmem_layout_lock); +static LIST_HEAD(nvmem_layouts); + static int __nvmem_reg_read(struct nvmem_device *nvmem, unsigned int offse= t, void *val, size_t bytes) { @@ -735,6 +739,99 @@ static int nvmem_add_cells_from_of(struct nvmem_device= *nvmem) return 0; } =20 +int __nvmem_layout_register(struct nvmem_layout *layout, struct module *ow= ner) +{ + layout->owner =3D owner; + + spin_lock(&nvmem_layout_lock); + list_add(&layout->node, &nvmem_layouts); + spin_unlock(&nvmem_layout_lock); + + return 0; +} +EXPORT_SYMBOL_GPL(__nvmem_layout_register); + +void nvmem_layout_unregister(struct nvmem_layout *layout) +{ + spin_lock(&nvmem_layout_lock); + list_del(&layout->node); + spin_unlock(&nvmem_layout_lock); +} +EXPORT_SYMBOL_GPL(nvmem_layout_unregister); + +static struct nvmem_layout *nvmem_layout_get(struct nvmem_device *nvmem) +{ + struct device_node *layout_np, *np =3D nvmem->dev.of_node; + struct nvmem_layout *l, *layout =3D NULL; + + layout_np =3D of_get_child_by_name(np, "nvmem-layout"); + if (!layout_np) + return NULL; + + spin_lock(&nvmem_layout_lock); + + list_for_each_entry(l, &nvmem_layouts, node) { + if (of_match_node(l->of_match_table, layout_np)) { + if (try_module_get(l->owner)) + layout =3D l; + + break; + } + } + + spin_unlock(&nvmem_layout_lock); + of_node_put(layout_np); + + return layout; +} + +static void nvmem_layout_put(struct nvmem_layout *layout) +{ + if (layout) + module_put(layout->owner); +} + +static int nvmem_add_cells_from_layout(struct nvmem_device *nvmem) +{ + struct nvmem_layout *layout =3D nvmem->layout; + int ret; + + if (layout && layout->add_cells) { + ret =3D layout->add_cells(&nvmem->dev, nvmem, layout); + if (ret) + return ret; + } + + return 0; +} + +#if IS_ENABLED(CONFIG_OF) +/** + * of_nvmem_layout_get_container() - Get OF node to layout container. + * + * @nvmem: nvmem device. + * + * Return: a node pointer with refcount incremented or NULL if no + * container exists. Use of_node_put() on it when done. + */ +struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvm= em) +{ + return of_get_child_by_name(nvmem->dev.of_node, "nvmem-layout"); +} +EXPORT_SYMBOL_GPL(of_nvmem_layout_get_container); +#endif + +const void *nvmem_layout_get_match_data(struct nvmem_device *nvmem, + struct nvmem_layout *layout) +{ + const struct of_device_id *match; + + match =3D of_match_node(layout->of_match_table, nvmem->dev.of_node); + + return match ? match->data : NULL; +} +EXPORT_SYMBOL_GPL(nvmem_layout_get_match_data); + /** * nvmem_register() - Register a nvmem device for given nvmem_config. * Also creates a binary entry in /sys/bus/nvmem/devices/dev-name/nvmem @@ -849,6 +946,12 @@ struct nvmem_device *nvmem_register(const struct nvmem= _config *config) goto err_device_del; } =20 + /* + * If the driver supplied a layout by config->layout, the module + * pointer will be NULL and nvmem_layout_put() will be a noop. + */ + nvmem->layout =3D config->layout ?: nvmem_layout_get(nvmem); + if (config->cells) { rval =3D nvmem_add_cells(nvmem, config->cells, config->ncells); if (rval) @@ -863,6 +966,10 @@ struct nvmem_device *nvmem_register(const struct nvmem= _config *config) if (rval) goto err_remove_cells; =20 + rval =3D nvmem_add_cells_from_layout(nvmem); + if (rval) + goto err_remove_cells; + blocking_notifier_call_chain(&nvmem_notifier, NVMEM_ADD, nvmem); =20 return nvmem; @@ -872,6 +979,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_= config *config) err_teardown_compat: if (config->compat) nvmem_sysfs_remove_compat(nvmem, config); + nvmem_layout_put(nvmem->layout); err_device_del: device_del(&nvmem->dev); err_put_device: @@ -893,6 +1001,7 @@ static void nvmem_device_release(struct kref *kref) device_remove_bin_file(nvmem->base_dev, &nvmem->eeprom); =20 nvmem_device_remove_all_cells(nvmem); + nvmem_layout_put(nvmem->layout); device_unregister(&nvmem->dev); } =20 @@ -1258,6 +1367,15 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_n= ode *np, const char *id) return ERR_PTR(-EINVAL); } =20 + /* nvmem layouts produce cells within the nvmem-layout container */ + if (of_node_name_eq(nvmem_np, "nvmem-layout")) { + nvmem_np =3D of_get_next_parent(nvmem_np); + if (!nvmem_np) { + of_node_put(cell_np); + return ERR_PTR(-EINVAL); + } + } + nvmem =3D __nvmem_device_get(nvmem_np, device_match_of_node); of_node_put(nvmem_np); if (IS_ERR(nvmem)) { diff --git a/drivers/nvmem/layouts/Kconfig b/drivers/nvmem/layouts/Kconfig new file mode 100644 index 000000000000..9ad3911d1605 --- /dev/null +++ b/drivers/nvmem/layouts/Kconfig @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0 + +menu "Layout Types" + +endmenu diff --git a/drivers/nvmem/layouts/Makefile b/drivers/nvmem/layouts/Makefile new file mode 100644 index 000000000000..6fdb3c60a4fa --- /dev/null +++ b/drivers/nvmem/layouts/Makefile @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for nvmem layouts. +# diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h index 1f62f7ba71ca..fa030d93b768 100644 --- a/include/linux/nvmem-consumer.h +++ b/include/linux/nvmem-consumer.h @@ -239,6 +239,7 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_node= *np, const char *id); struct nvmem_device *of_nvmem_device_get(struct device_node *np, const char *name); +struct device_node *of_nvmem_layout_get_container(struct nvmem_device *nvm= em); #else static inline struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, const char *id) @@ -251,6 +252,12 @@ static inline struct nvmem_device *of_nvmem_device_get= (struct device_node *np, { return ERR_PTR(-EOPNOTSUPP); } + +static inline struct device_node * +of_nvmem_layout_get_container(struct nvmem_device *nvmem) +{ + return ERR_PTR(-EOPNOTSUPP); +} #endif /* CONFIG_NVMEM && CONFIG_OF */ =20 #endif /* ifndef _LINUX_NVMEM_CONSUMER_H */ diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h index 385d29168008..4185767c114f 100644 --- a/include/linux/nvmem-provider.h +++ b/include/linux/nvmem-provider.h @@ -89,6 +89,7 @@ struct nvmem_cell_info { * @priv: User context passed to read/write callbacks. * @wp-gpio: Write protect pin * @ignore_wp: Write Protect pin is managed by the provider. + * @layout: Fixed layout associated with this nvmem device. * * Note: A default "nvmem" name will be assigned to the device if * no name is specified in its configuration. In such case "" is @@ -111,6 +112,7 @@ struct nvmem_config { bool read_only; bool root_only; bool ignore_wp; + struct nvmem_layout *layout; struct device_node *of_node; bool no_of_node; nvmem_reg_read_t reg_read; @@ -144,6 +146,33 @@ struct nvmem_cell_table { struct list_head node; }; =20 +/** + * struct nvmem_layout - NVMEM layout definitions + * + * @name: Layout name. + * @of_match_table: Open firmware match table. + * @add_cells: Will be called if a nvmem device is found which + * has this layout. The function will add layout + * specific cells with nvmem_add_one_cell(). + * @owner: Pointer to struct module. + * @node: List node. + * + * A nvmem device can hold a well defined structure which can just be + * evaluated during runtime. For example a TLV list, or a list of "name=3D= val" + * pairs. A nvmem layout can parse the nvmem device and add appropriate + * cells. + */ +struct nvmem_layout { + const char *name; + const struct of_device_id *of_match_table; + int (*add_cells)(struct device *dev, struct nvmem_device *nvmem, + struct nvmem_layout *layout); + + /* private */ + struct module *owner; + struct list_head node; +}; + #if IS_ENABLED(CONFIG_NVMEM) =20 struct nvmem_device *nvmem_register(const struct nvmem_config *cfg); @@ -158,6 +187,14 @@ void nvmem_del_cell_table(struct nvmem_cell_table *tab= le); int nvmem_add_one_cell(struct nvmem_device *nvmem, const struct nvmem_cell_info *info); =20 +int __nvmem_layout_register(struct nvmem_layout *layout, struct module *ow= ner); +#define nvmem_layout_register(layout) \ + __nvmem_layout_register(layout, THIS_MODULE) +void nvmem_layout_unregister(struct nvmem_layout *layout); + +const void *nvmem_layout_get_match_data(struct nvmem_device *nvmem, + struct nvmem_layout *layout); + #else =20 static inline struct nvmem_device *nvmem_register(const struct nvmem_confi= g *c) @@ -181,5 +218,19 @@ static inline int nvmem_add_one_cell(struct nvmem_devi= ce *nvmem, return -EOPNOTSUPP; } =20 +static inline int nvmem_layout_register(struct nvmem_layout *layout) +{ + return -EOPNOTSUPP; +} + +static inline void nvmem_layout_unregister(struct nvmem_layout *layout) {} + +static inline const void * +nvmem_layout_get_match_data(struct nvmem_device *nvmem, + struct nvmem_layout *layout) +{ + return NULL; +} + #endif /* CONFIG_NVMEM */ #endif /* ifndef _LINUX_NVMEM_PROVIDER_H */ --=20 2.30.2 From nobody Thu Apr 16 03:45:22 2026 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 EF4A6C433FE for ; Wed, 23 Nov 2022 18:03:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239026AbiKWSD4 (ORCPT ); Wed, 23 Nov 2022 13:03:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239388AbiKWSC1 (ORCPT ); Wed, 23 Nov 2022 13:02:27 -0500 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B18CF97087; Wed, 23 Nov 2022 10:02:25 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id D9EA63B33; Wed, 23 Nov 2022 19:02:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1669226544; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QnWNBJBre5MF1HKaKc5jyQ5wsfU873yuhAWeFwHDAUw=; b=11RGxVtEEkh4n2edyM3mYZ90vfHfq0Ss9Lf39FclnHzf1Eg8lX8TpHzkOz+0G/vCO5Xmd+ JBzH6sXy4vc4DlfM9MKYqjme4jF+d4SFj1FrFEZWYoTgdHxD88tBT/iDqRHq+Md1I6eM+f blWHEv99fzIPxvvMcUXVx9C/Cx9ZWBxFy0eVTP1TFqmVY2sXIF3LHLY6hnmcbBNkdx7xW+ TNLw4ZC/QCZoNbKsF8jYm3xeYJjmrHRUtRSjKNKVgD8oVQB+jSXXHY9p6TiYnOIG909ZTo zpXdBS376uuvgLldFwjunkphICoWTZkz7uLl3Zg51ZCTK/1BFRUmHn10fu10SA== From: Michael Walle To: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand , Sascha Hauer Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle Subject: [PATCH v4 12/20] nvmem: core: add per-cell post processing Date: Wed, 23 Nov 2022 19:01:43 +0100 Message-Id: <20221123180151.2160033-13-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123180151.2160033-1-michael@walle.cc> References: <20221123180151.2160033-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Instead of relying on the name the consumer is using for the cell, like it is done for the nvmem .cell_post_process configuration parameter, provide a per-cell post processing hook. This can then be populated by the NVMEM provider (or the NVMEM layout) when adding the cell. Signed-off-by: Michael Walle --- changes since v3: - none changes since v2: - none changes since v1: - rename hook to read_post_process drivers/nvmem/core.c | 17 +++++++++++++++++ include/linux/nvmem-provider.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 87ba1e3a5bd4..e75642a675ae 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -53,6 +53,7 @@ struct nvmem_cell_entry { int bytes; int bit_offset; int nbits; + nvmem_cell_post_process_t read_post_process; struct device_node *np; struct nvmem_device *nvmem; struct list_head node; @@ -469,6 +470,7 @@ static int nvmem_cell_info_to_nvmem_cell_entry_nodup(st= ruct nvmem_device *nvmem, cell->offset =3D info->offset; cell->bytes =3D info->bytes; cell->name =3D info->name; + cell->read_post_process =3D info->read_post_process; =20 cell->bit_offset =3D info->bit_offset; cell->nbits =3D info->nbits; @@ -1557,6 +1559,13 @@ static int __nvmem_cell_read(struct nvmem_device *nv= mem, if (cell->bit_offset || cell->nbits) nvmem_shift_read_buffer_in_place(cell, buf); =20 + if (cell->read_post_process) { + rc =3D cell->read_post_process(nvmem->priv, id, index, + cell->offset, buf, cell->bytes); + if (rc) + return rc; + } + if (nvmem->cell_post_process) { rc =3D nvmem->cell_post_process(nvmem->priv, id, index, cell->offset, buf, cell->bytes); @@ -1665,6 +1674,14 @@ static int __nvmem_cell_entry_write(struct nvmem_cel= l_entry *cell, void *buf, si (cell->bit_offset =3D=3D 0 && len !=3D cell->bytes)) return -EINVAL; =20 + /* + * Any cells which have a read_post_process hook are read-only because + * we cannot reverse the operation and it might affect other cells, + * too. + */ + if (cell->read_post_process) + return -EINVAL; + if (cell->bit_offset || cell->nbits) { buf =3D nvmem_cell_prepare_write_buffer(cell, buf, len); if (IS_ERR(buf)) diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h index 4185767c114f..1930496d8854 100644 --- a/include/linux/nvmem-provider.h +++ b/include/linux/nvmem-provider.h @@ -54,6 +54,8 @@ struct nvmem_keepout { * @bit_offset: Bit offset if cell is smaller than a byte. * @nbits: Number of bits. * @np: Optional device_node pointer. + * @read_post_process: Callback for optional post processing of cell data + * on reads. */ struct nvmem_cell_info { const char *name; @@ -62,6 +64,7 @@ struct nvmem_cell_info { unsigned int bit_offset; unsigned int nbits; struct device_node *np; + nvmem_cell_post_process_t read_post_process; }; =20 /** --=20 2.30.2 From nobody Thu Apr 16 03:45:22 2026 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 5404AC4332F for ; Wed, 23 Nov 2022 18:04:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239486AbiKWSE2 (ORCPT ); Wed, 23 Nov 2022 13:04:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239418AbiKWSCa (ORCPT ); Wed, 23 Nov 2022 13:02:30 -0500 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14810B9C; Wed, 23 Nov 2022 10:02:26 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id 39A373B37; Wed, 23 Nov 2022 19:02:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1669226544; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FGdZLi8Kaekagprvtmjt1fkHx30M/b/xsvMTa000JA0=; b=to6F88I7laehj/GAVEm1nFLFl+6bEbL7zo0aV8deuodaX9dYLOe4+ZvrJN2bn3kxaNhxM6 Kl8/R6oZ80LnJ3UXIo+JpLWdgJlNt6Sv/LPbhAT/IyDSi4VOfKvvZebrWg5SI/fD+y3N4b HWIYepJ+tJ8zEdHTyYlu44Xdwukz93ADIj85MHfWDNOKg0GfURP/qAgkgUE2UHv2QPuPDW GZ462oSpw2A95r8dFqzfBrNyla8iY0RsPqf4j07261N1z5hPVM02QhAvVWytZziPpKixQ3 Wd2HyxU5giNltKUbVqeTcxFLCqbJHLvRl4AEcin7Aw48Ytipno0HaEqWFjO7AQ== From: Michael Walle To: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand , Sascha Hauer Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle Subject: [PATCH v4 13/20] nvmem: core: allow to modify a cell before adding it Date: Wed, 23 Nov 2022 19:01:44 +0100 Message-Id: <20221123180151.2160033-14-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123180151.2160033-1-michael@walle.cc> References: <20221123180151.2160033-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Provide a way to modify a cell before it will get added. This is useful to attach a custom post processing hook via a layout. Signed-off-by: Michael Walle --- changes since v3: - none changes since v2: - none changes since v1: - new patch drivers/nvmem/core.c | 4 ++++ include/linux/nvmem-provider.h | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index e75642a675ae..ccbde9629f7f 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -694,6 +694,7 @@ static int nvmem_validate_keepouts(struct nvmem_device = *nvmem) =20 static int nvmem_add_cells_from_of(struct nvmem_device *nvmem) { + struct nvmem_layout *layout =3D nvmem->layout; struct device *dev =3D &nvmem->dev; struct nvmem_cell_entry *cell; struct device_node *child; @@ -730,6 +731,9 @@ static int nvmem_add_cells_from_of(struct nvmem_device = *nvmem) =20 info.np =3D of_node_get(child); =20 + if (layout && layout->fixup_cell_info) + layout->fixup_cell_info(nvmem, layout, &info); + ret =3D nvmem_add_one_cell(nvmem, &info); kfree(info.name); if (ret) { diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h index 1930496d8854..bfaba5227ac9 100644 --- a/include/linux/nvmem-provider.h +++ b/include/linux/nvmem-provider.h @@ -157,6 +157,8 @@ struct nvmem_cell_table { * @add_cells: Will be called if a nvmem device is found which * has this layout. The function will add layout * specific cells with nvmem_add_one_cell(). + * @fixup_cell_info: Will be called before a cell is added. Can be + * used to modify the nvmem_cell_info. * @owner: Pointer to struct module. * @node: List node. * @@ -170,6 +172,9 @@ struct nvmem_layout { const struct of_device_id *of_match_table; int (*add_cells)(struct device *dev, struct nvmem_device *nvmem, struct nvmem_layout *layout); + void (*fixup_cell_info)(struct nvmem_device *nvmem, + struct nvmem_layout *layout, + struct nvmem_cell_info *cell); =20 /* private */ struct module *owner; --=20 2.30.2 From nobody Thu Apr 16 03:45:22 2026 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 1EDBAC4332F for ; Wed, 23 Nov 2022 18:04:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239533AbiKWSEZ (ORCPT ); Wed, 23 Nov 2022 13:04:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239416AbiKWSCa (ORCPT ); Wed, 23 Nov 2022 13:02:30 -0500 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 146D5B85; Wed, 23 Nov 2022 10:02:26 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id AE81A27BF; Wed, 23 Nov 2022 19:02:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1669226544; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BPNHYJ7cdASLHAEjEX3cpHT6PEI/wCz5wvyevFbTiJM=; b=w86O7N3OKtp8gWhowSQtXL8imOvtNFWH65d7LXHQkMQA8N+Lio0/i8k3YGeixS0gr59oUU tXX17iGKPUfrspytGuLqtk6KK4MWzq5iSjkL07jzHSHE0kSZmJg2xJCOe5rMZjjW1xY8Ds jdpSwNbRk+bSdioshV2RHL26JgkettVKKEQkTjBXCm6o/uoDuUWUc0S8ptQNArh/n4LvBr NtMaJOT2AuRQtQ2XSot9eaSIidHffSTlWSxWmnc+iRTEl3aSceRoUQZgUNO7CKoos7fzUX VaAfCK+yaSa0XxcxiQkm6wXimeKKUGGRtyZBzeJiXyVqlHMO5aAFWY8aaTMo5Q== From: Michael Walle To: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand , Sascha Hauer Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle Subject: [PATCH v4 14/20] nvmem: imx-ocotp: replace global post processing with layouts Date: Wed, 23 Nov 2022 19:01:45 +0100 Message-Id: <20221123180151.2160033-15-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123180151.2160033-1-michael@walle.cc> References: <20221123180151.2160033-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In preparation of retiring the global post processing hook change this driver to use layouts. The layout will be supplied during registration and will be used to add the post processing hook to all added cells. Signed-off-by: Michael Walle Tested-by: Michael Walle # on kontron-pitx-imx8m --- changes since v3: - none changes since v2: - none changes since v1: - new patch drivers/nvmem/imx-ocotp.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/drivers/nvmem/imx-ocotp.c b/drivers/nvmem/imx-ocotp.c index e9b52ecb3f72..ac0edb6398f1 100644 --- a/drivers/nvmem/imx-ocotp.c +++ b/drivers/nvmem/imx-ocotp.c @@ -225,18 +225,13 @@ static int imx_ocotp_read(void *context, unsigned int= offset, static int imx_ocotp_cell_pp(void *context, const char *id, int index, unsigned int offset, void *data, size_t bytes) { - struct ocotp_priv *priv =3D context; + u8 *buf =3D data; + int i; =20 /* Deal with some post processing of nvmem cell data */ - if (id && !strcmp(id, "mac-address")) { - if (priv->params->reverse_mac_address) { - u8 *buf =3D data; - int i; - - for (i =3D 0; i < bytes/2; i++) - swap(buf[i], buf[bytes - i - 1]); - } - } + if (id && !strcmp(id, "mac-address")) + for (i =3D 0; i < bytes / 2; i++) + swap(buf[i], buf[bytes - i - 1]); =20 return 0; } @@ -488,7 +483,6 @@ static struct nvmem_config imx_ocotp_nvmem_config =3D { .stride =3D 1, .reg_read =3D imx_ocotp_read, .reg_write =3D imx_ocotp_write, - .cell_post_process =3D imx_ocotp_cell_pp, }; =20 static const struct ocotp_params imx6q_params =3D { @@ -595,6 +589,17 @@ static const struct of_device_id imx_ocotp_dt_ids[] = =3D { }; MODULE_DEVICE_TABLE(of, imx_ocotp_dt_ids); =20 +static void imx_ocotp_fixup_cell_info(struct nvmem_device *nvmem, + struct nvmem_layout *layout, + struct nvmem_cell_info *cell) +{ + cell->read_post_process =3D imx_ocotp_cell_pp; +} + +struct nvmem_layout imx_ocotp_layout =3D { + .fixup_cell_info =3D imx_ocotp_fixup_cell_info, +}; + static int imx_ocotp_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; @@ -619,6 +624,9 @@ static int imx_ocotp_probe(struct platform_device *pdev) imx_ocotp_nvmem_config.size =3D 4 * priv->params->nregs; imx_ocotp_nvmem_config.dev =3D dev; imx_ocotp_nvmem_config.priv =3D priv; + if (priv->params->reverse_mac_address) + imx_ocotp_nvmem_config.layout =3D &imx_ocotp_layout; + priv->config =3D &imx_ocotp_nvmem_config; =20 clk_prepare_enable(priv->clk); --=20 2.30.2 From nobody Thu Apr 16 03:45:22 2026 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 DC61DC4332F for ; Wed, 23 Nov 2022 18:04:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239565AbiKWSEe (ORCPT ); Wed, 23 Nov 2022 13:04:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239419AbiKWSCa (ORCPT ); Wed, 23 Nov 2022 13:02:30 -0500 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14BD6BD0; Wed, 23 Nov 2022 10:02:26 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id EAEA93B39; Wed, 23 Nov 2022 19:02:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1669226545; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dt7gv7UWTFT+KjfBR1FnRd4lXKFqrxsoSYpqJkYrGFc=; b=lQWigEEpSa2UMOYWkFrGdKZiGDphnbpc9nljSjell7xokktJfJxc+Fe3sqfVN9rCoLfJfN LrFreogJYSUfxYeilesi6Ad5qROqoLnKOGRJeRSL6CCX5wcMdT5OmZKUyn2AWAniXx3Nc5 Z0cois5Vk3+gibMSEJorAG/dWS8ObCYepNJlpYJoJccc7APIJ7ZSCmiHYVECXtFyy02v3S QiFCmu5bJmh/6Cn7Q2N2W9HOcPoJWrHloH+bW8ZO+C7NyrC8xBTAq8Wlh4WoKa0DVUl7m5 hg46bvRVCfk3bIXO7sIxiZsExrgjuNd/oN/E1jtvSQx1xWU4l3UpmB5nI+5Zww== From: Michael Walle To: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand , Sascha Hauer Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle Subject: [PATCH v4 15/20] nvmem: cell: drop global cell_post_process Date: Wed, 23 Nov 2022 19:01:46 +0100 Message-Id: <20221123180151.2160033-16-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123180151.2160033-1-michael@walle.cc> References: <20221123180151.2160033-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" There are no users anymore for the global cell_post_process callback anymore. New users should use proper nvmem layouts. Signed-off-by: Michael Walle --- changes since v3: - none changes since v2: - none changes since v1: - new patch drivers/nvmem/core.c | 9 --------- include/linux/nvmem-provider.h | 2 -- 2 files changed, 11 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index ccbde9629f7f..5733bf79dda1 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -38,7 +38,6 @@ struct nvmem_device { unsigned int nkeepout; nvmem_reg_read_t reg_read; nvmem_reg_write_t reg_write; - nvmem_cell_post_process_t cell_post_process; struct gpio_desc *wp_gpio; struct nvmem_layout *layout; void *priv; @@ -899,7 +898,6 @@ struct nvmem_device *nvmem_register(const struct nvmem_= config *config) nvmem->type =3D config->type; nvmem->reg_read =3D config->reg_read; nvmem->reg_write =3D config->reg_write; - nvmem->cell_post_process =3D config->cell_post_process; nvmem->keepout =3D config->keepout; nvmem->nkeepout =3D config->nkeepout; if (config->of_node) @@ -1570,13 +1568,6 @@ static int __nvmem_cell_read(struct nvmem_device *nv= mem, return rc; } =20 - if (nvmem->cell_post_process) { - rc =3D nvmem->cell_post_process(nvmem->priv, id, index, - cell->offset, buf, cell->bytes); - if (rc) - return rc; - } - if (len) *len =3D cell->bytes; =20 diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h index bfaba5227ac9..12833fe4eb4d 100644 --- a/include/linux/nvmem-provider.h +++ b/include/linux/nvmem-provider.h @@ -85,7 +85,6 @@ struct nvmem_cell_info { * @no_of_node: Device should not use the parent's of_node even if it's !N= ULL. * @reg_read: Callback to read data. * @reg_write: Callback to write data. - * @cell_post_process: Callback for vendor specific post processing of cel= l data * @size: Device size. * @word_size: Minimum read/write access granularity. * @stride: Minimum read/write access stride. @@ -120,7 +119,6 @@ struct nvmem_config { bool no_of_node; nvmem_reg_read_t reg_read; nvmem_reg_write_t reg_write; - nvmem_cell_post_process_t cell_post_process; int size; int word_size; int stride; --=20 2.30.2 From nobody Thu Apr 16 03:45:22 2026 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 6E376C433FE for ; Wed, 23 Nov 2022 18:04:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239243AbiKWSEv (ORCPT ); Wed, 23 Nov 2022 13:04:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239437AbiKWSCi (ORCPT ); Wed, 23 Nov 2022 13:02:38 -0500 Received: from mail.3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C35538B0; Wed, 23 Nov 2022 10:02:27 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id 7D1AC322F; Wed, 23 Nov 2022 19:02:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1669226545; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LWIy14I/UvLVcaIWHNN4F1QfxaBMysU7plut6EIoZF4=; b=IE1H+doMlIY1EfJeSW2TWe9C7687yXBsjzdNWihFHWDcTM9TQifBJovYRcBzUtzhHfq9J9 iwCba5GXwfX6HxxViisFb98uUN68gZom9Xf1LMh1H0rhmdYrj+wUpKMGIKNXSOc4bT3EB1 TbCMQ+u6c9XSvWj3HulbEgK6ifW5oVHQmNzr3B56Wfz5BTM3BkANvMYzh4QtjPN7eLkpyz PQXuKyRi/oyxTNHfX83wSof+YCMTz34JItJs+EkPBtgpEVrfVB36NUjnpIqEKjWjvHneld oaPG1/KM06E02l4K8Eq0xH1Ts2NHLYO8Kga79PLmBFdHTcjpk0z8cHnZQ67A8g== From: Michael Walle To: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand , Sascha Hauer Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle Subject: [PATCH v4 16/20] nvmem: core: provide own priv pointer in post process callback Date: Wed, 23 Nov 2022 19:01:47 +0100 Message-Id: <20221123180151.2160033-17-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123180151.2160033-1-michael@walle.cc> References: <20221123180151.2160033-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" It doesn't make any more sense to have a opaque pointer set up by the nvmem device. Usually, the layout isn't associated with a particular nvmem device. Instead, let the caller who set the post process callback provide the priv pointer. Signed-off-by: Michael Walle --- changes since v3: - none changes since v2: - don't drop the pointer but let the user specify an opaque pointer changes since v1: - new patch drivers/nvmem/core.c | 4 +++- include/linux/nvmem-provider.h | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 5733bf79dda1..a52c810e9b02 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -53,6 +53,7 @@ struct nvmem_cell_entry { int bit_offset; int nbits; nvmem_cell_post_process_t read_post_process; + void *priv; struct device_node *np; struct nvmem_device *nvmem; struct list_head node; @@ -470,6 +471,7 @@ static int nvmem_cell_info_to_nvmem_cell_entry_nodup(st= ruct nvmem_device *nvmem, cell->bytes =3D info->bytes; cell->name =3D info->name; cell->read_post_process =3D info->read_post_process; + cell->priv =3D info->priv; =20 cell->bit_offset =3D info->bit_offset; cell->nbits =3D info->nbits; @@ -1562,7 +1564,7 @@ static int __nvmem_cell_read(struct nvmem_device *nvm= em, nvmem_shift_read_buffer_in_place(cell, buf); =20 if (cell->read_post_process) { - rc =3D cell->read_post_process(nvmem->priv, id, index, + rc =3D cell->read_post_process(cell->priv, id, index, cell->offset, buf, cell->bytes); if (rc) return rc; diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h index 12833fe4eb4d..cb0814f2ddae 100644 --- a/include/linux/nvmem-provider.h +++ b/include/linux/nvmem-provider.h @@ -20,7 +20,8 @@ typedef int (*nvmem_reg_write_t)(void *priv, unsigned int= offset, void *val, size_t bytes); /* used for vendor specific post processing of cell data */ typedef int (*nvmem_cell_post_process_t)(void *priv, const char *id, int i= ndex, - unsigned int offset, void *buf, size_t bytes); + unsigned int offset, void *buf, + size_t bytes); =20 enum nvmem_type { NVMEM_TYPE_UNKNOWN =3D 0, @@ -56,6 +57,7 @@ struct nvmem_keepout { * @np: Optional device_node pointer. * @read_post_process: Callback for optional post processing of cell data * on reads. + * @priv: Opaque data passed to the read_post_process hook. */ struct nvmem_cell_info { const char *name; @@ -65,6 +67,7 @@ struct nvmem_cell_info { unsigned int nbits; struct device_node *np; nvmem_cell_post_process_t read_post_process; + void *priv; }; =20 /** --=20 2.30.2 From nobody Thu Apr 16 03:45:22 2026 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 CCBA5C433FE for ; Wed, 23 Nov 2022 18:05:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239634AbiKWSFS (ORCPT ); Wed, 23 Nov 2022 13:05:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239489AbiKWSDK (ORCPT ); Wed, 23 Nov 2022 13:03:10 -0500 Received: from mail.3ffe.de (0001.3ffe.de [IPv6:2a01:4f8:c0c:9d57::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8280A5F6B; Wed, 23 Nov 2022 10:02:27 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id C5B3D27B2; Wed, 23 Nov 2022 19:02:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1669226545; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gx58Y1T19qV8Bq9PgxKKY6gnXxp8UlcL8mKnK8kjD4w=; b=dRQajWbUb2FkbeedIH/kXXPtAGgDJr31JVvVvqLGyx+wZGtexa2v84wx7N3cJdZ6XlRrH9 o+BAzEdw9ANJnwWolU+SUnNgJsttxNRBMNzY9ob6kLQKT/O4pCZ4BhGt6dNJMRDcs/6rg9 3CrSo6QVVAPbrkKT3FS3BHgKgasLwk9RmC++wd92i4NmsIZJaffCaCbz7ZYvPjeLzM45OI Ret59ELFrKyaZ03D36sC+aklPCBI+OUOMCgE8ljiSmd85VM/v+Zwwb2i3LKSxFAywObM0Z Oh7dyZ6Vl8IQP7YeHnDpCLMOMVYR+QRAq6ZRlI0Jo+FZHvQlqBvE37BuDiZFJA== From: Michael Walle To: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand , Sascha Hauer Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle Subject: [PATCH v4 17/20] nvmem: layouts: add sl28vpd layout Date: Wed, 23 Nov 2022 19:01:48 +0100 Message-Id: <20221123180151.2160033-18-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123180151.2160033-1-michael@walle.cc> References: <20221123180151.2160033-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This layout applies to the VPD of the Kontron sl28 boards. The VPD only contains a base MAC address. Therefore, we have to add an individual offset to it. This is done by taking the second argument of the nvmem phandle into account. Also this let us checking the VPD version and the checksum. Signed-off-by: Michael Walle --- changes since v3: - none changes since v2: - use of_nvmem_layout_get_container() changes since v1: - none drivers/nvmem/layouts/Kconfig | 9 ++ drivers/nvmem/layouts/Makefile | 2 + drivers/nvmem/layouts/sl28vpd.c | 153 ++++++++++++++++++++++++++++++++ 3 files changed, 164 insertions(+) create mode 100644 drivers/nvmem/layouts/sl28vpd.c diff --git a/drivers/nvmem/layouts/Kconfig b/drivers/nvmem/layouts/Kconfig index 9ad3911d1605..75082f6b471d 100644 --- a/drivers/nvmem/layouts/Kconfig +++ b/drivers/nvmem/layouts/Kconfig @@ -2,4 +2,13 @@ =20 menu "Layout Types" =20 +config NVMEM_LAYOUT_SL28_VPD + bool "Kontron sl28 VPD layout support" + select CRC8 + help + Say Y here if you want to support the VPD layout of the Kontron + SMARC-sAL28 boards. + + If unsure, say N. + endmenu diff --git a/drivers/nvmem/layouts/Makefile b/drivers/nvmem/layouts/Makefile index 6fdb3c60a4fa..fc617b9e87d0 100644 --- a/drivers/nvmem/layouts/Makefile +++ b/drivers/nvmem/layouts/Makefile @@ -2,3 +2,5 @@ # # Makefile for nvmem layouts. # + +obj-$(CONFIG_NVMEM_LAYOUT_SL28_VPD) +=3D sl28vpd.o diff --git a/drivers/nvmem/layouts/sl28vpd.c b/drivers/nvmem/layouts/sl28vp= d.c new file mode 100644 index 000000000000..a36800f201a3 --- /dev/null +++ b/drivers/nvmem/layouts/sl28vpd.c @@ -0,0 +1,153 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include +#include +#include +#include +#include + +#define SL28VPD_MAGIC 'V' + +struct sl28vpd_header { + u8 magic; + u8 version; +} __packed; + +struct sl28vpd_v1 { + struct sl28vpd_header header; + char serial_number[15]; + u8 base_mac_address[ETH_ALEN]; + u8 crc8; +} __packed; + +static int sl28vpd_mac_address_pp(void *priv, const char *id, int index, + unsigned int offset, void *buf, + size_t bytes) +{ + if (bytes !=3D ETH_ALEN) + return -EINVAL; + + if (index < 0) + return -EINVAL; + + if (!is_valid_ether_addr(buf)) + return -EINVAL; + + eth_addr_add(buf, index); + + return 0; +} + +static const struct nvmem_cell_info sl28vpd_v1_entries[] =3D { + { + .name =3D "serial-number", + .offset =3D offsetof(struct sl28vpd_v1, serial_number), + .bytes =3D sizeof_field(struct sl28vpd_v1, serial_number), + }, + { + .name =3D "base-mac-address", + .offset =3D offsetof(struct sl28vpd_v1, base_mac_address), + .bytes =3D sizeof_field(struct sl28vpd_v1, base_mac_address), + .read_post_process =3D sl28vpd_mac_address_pp, + }, +}; + +static int sl28vpd_v1_check_crc(struct device *dev, struct nvmem_device *n= vmem) +{ + struct sl28vpd_v1 data_v1; + u8 table[CRC8_TABLE_SIZE]; + int ret; + u8 crc; + + crc8_populate_msb(table, 0x07); + + ret =3D nvmem_device_read(nvmem, 0, sizeof(data_v1), &data_v1); + if (ret < 0) + return ret; + else if (ret !=3D sizeof(data_v1)) + return -EIO; + + crc =3D crc8(table, (void *)&data_v1, sizeof(data_v1) - 1, 0); + + if (crc !=3D data_v1.crc8) { + dev_err(dev, + "Checksum is invalid (got %02x, expected %02x).\n", + crc, data_v1.crc8); + return -EINVAL; + } + + return 0; +} + +static int sl28vpd_add_cells(struct device *dev, struct nvmem_device *nvme= m, + struct nvmem_layout *layout) +{ + const struct nvmem_cell_info *pinfo; + struct nvmem_cell_info info =3D {0}; + struct device_node *layout_np; + struct sl28vpd_header hdr; + int ret, i; + + /* check header */ + ret =3D nvmem_device_read(nvmem, 0, sizeof(hdr), &hdr); + if (ret < 0) + return ret; + else if (ret !=3D sizeof(hdr)) + return -EIO; + + if (hdr.magic !=3D SL28VPD_MAGIC) { + dev_err(dev, "Invalid magic value (%02x)\n", hdr.magic); + return -EINVAL; + } + + if (hdr.version !=3D 1) { + dev_err(dev, "Version %d is unsupported.\n", hdr.version); + return -EINVAL; + } + + ret =3D sl28vpd_v1_check_crc(dev, nvmem); + if (ret) + return ret; + + layout_np =3D of_nvmem_layout_get_container(nvmem); + if (!layout_np) + return -ENOENT; + + for (i =3D 0; i < ARRAY_SIZE(sl28vpd_v1_entries); i++) { + pinfo =3D &sl28vpd_v1_entries[i]; + + info.name =3D pinfo->name; + info.offset =3D pinfo->offset; + info.bytes =3D pinfo->bytes; + info.read_post_process =3D pinfo->read_post_process; + info.np =3D of_get_child_by_name(layout_np, pinfo->name); + + ret =3D nvmem_add_one_cell(nvmem, &info); + if (ret) { + of_node_put(layout_np); + return ret; + } + } + + of_node_put(layout_np); + + return 0; +} + +static const struct of_device_id sl28vpd_of_match_table[] =3D { + { .compatible =3D "kontron,sl28-vpd" }, + {}, +}; + +struct nvmem_layout sl28vpd_layout =3D { + .name =3D "sl28-vpd", + .of_match_table =3D sl28vpd_of_match_table, + .add_cells =3D sl28vpd_add_cells, +}; + +static int __init sl28vpd_init(void) +{ + return nvmem_layout_register(&sl28vpd_layout); +} +subsys_initcall(sl28vpd_init); --=20 2.30.2 From nobody Thu Apr 16 03:45:22 2026 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 242F0C4332F for ; Wed, 23 Nov 2022 18:04:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239202AbiKWSEk (ORCPT ); Wed, 23 Nov 2022 13:04:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239420AbiKWSCb (ORCPT ); Wed, 23 Nov 2022 13:02:31 -0500 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CABAB2AE1; Wed, 23 Nov 2022 10:02:28 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id 27866230D; Wed, 23 Nov 2022 19:02:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1669226546; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c39q6ZhQeyQe8ed7/1kQNBk2713M4zr204sHAsVaKPY=; b=MCb1/YPDtVdNDRJ9ubBOXl6Xjz6JnsawjNPCX/wuzADeJgdqa6uIoWXV/dllGy7nEWenET 5McKNTiYpPzwGdXZHfgdC9r/E/s3KVQGBlsmyb3HaxBGdWSFOu1svPVQ0yI0LWZhXfqyrG wAk5ME9+VK0tk5jE5vVa41bhqaCNal1Mdg7ub6hEKU2Gs2QjiR0EJDHyc2LgP785MOdwgw +SmiyIBmcoZC8keeZo5gNeu7C+EaqCCzWfJnvKo8JS+8Fr9nI0QIwRfwKKjFUrb2rSomZ7 LQ3dll1ZJ9KQ6OcH6pX2YSK9t5WUslg+s0GKcsAkU22s1bNw6MTEP9AwTrydyA== From: Michael Walle To: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand , Sascha Hauer Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle Subject: [PATCH v4 18/20] MAINTAINERS: add myself as sl28vpd nvmem layout driver Date: Wed, 23 Nov 2022 19:01:49 +0100 Message-Id: <20221123180151.2160033-19-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123180151.2160033-1-michael@walle.cc> References: <20221123180151.2160033-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add myself as a maintainer for the new sl28vpd nvmem layout driver. Signed-off-by: Michael Walle --- changes since v3: - none changes since v2: - new patch MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 36ff8badc6bb..0e0cc35d90b7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19103,6 +19103,12 @@ F: drivers/irqchip/irq-sl28cpld.c F: drivers/pwm/pwm-sl28cpld.c F: drivers/watchdog/sl28cpld_wdt.c =20 +SL28 VPD NVMEM LAYOUT DRIVER +M: Michael Walle +S: Maintained +F: Documentation/devicetree/bindings/nvmem/layouts/kontron,sl28-vpd.yaml +F: drivers/nvmem/layouts/sl28vpd.c + SLAB ALLOCATOR M: Christoph Lameter M: Pekka Enberg --=20 2.30.2 From nobody Thu Apr 16 03:45:22 2026 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 6A8D6C4332F for ; Wed, 23 Nov 2022 18:05:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239541AbiKWSFW (ORCPT ); Wed, 23 Nov 2022 13:05:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239490AbiKWSDK (ORCPT ); Wed, 23 Nov 2022 13:03:10 -0500 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA6EB5FD0; Wed, 23 Nov 2022 10:02:29 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id D864431FF; Wed, 23 Nov 2022 19:02:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1669226547; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4RVfSD2zFNimuLR7aI0Q7JbPv2Gm3wAXrNqA/yxPpQs=; b=ZOCPrLQhgk91EFHHlGUCeMJv2fDAU/c859PquUwi0f6spLBw8iuakRQbr97VLnkxWuEJ31 2i/7y6jASZnYPDxiHhTHCRm+M/dkpEGZ8iqNpRa914di6RNKHoRcSBOPFZSFqi29SYgpoL m96ZZsDv+FNCT/AbXSDIU87tAMpi44EbVdJH3fs+GrD5AARAEfH1+r1B+IxrLOA34RHrzO TVhrWB1LeMRlE4ft9YlZ9BjyqPfC2E+D2w4AMJ6lz+NaPmbBAX6yB1tDOxKbX9Ka6knp9v wuWmaaiowkTEfYqIPLzosQc5LBtzkNcypTvgdkHvPFEBHgMFWGTT3IERg+Bdcg== From: Michael Walle To: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand , Sascha Hauer Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle Subject: [PATCH v4 19/20] nvmem: layouts: Add ONIE tlv layout driver Date: Wed, 23 Nov 2022 19:01:50 +0100 Message-Id: <20221123180151.2160033-20-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123180151.2160033-1-michael@walle.cc> References: <20221123180151.2160033-1-michael@walle.cc> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miquel Raynal This layout applies on top of any non volatile storage device containing an ONIE table factory flashed. This table follows the tlv (type-length-value) organization described in the link below. We cannot afford using regular parsers because the content of these tables is manufacturer specific and must be dynamically discovered. Link: https://opencomputeproject.github.io/onie/design-spec/hw_requirements= .html Signed-off-by: Miquel Raynal --- changes since v3: - don't use kfree() - fix typo, s/no/on/ changes since v2: - new patch drivers/nvmem/layouts/Kconfig | 9 ++ drivers/nvmem/layouts/Makefile | 1 + drivers/nvmem/layouts/onie-tlv.c | 244 +++++++++++++++++++++++++++++++ 3 files changed, 254 insertions(+) create mode 100644 drivers/nvmem/layouts/onie-tlv.c diff --git a/drivers/nvmem/layouts/Kconfig b/drivers/nvmem/layouts/Kconfig index 75082f6b471d..9ad50474cb77 100644 --- a/drivers/nvmem/layouts/Kconfig +++ b/drivers/nvmem/layouts/Kconfig @@ -11,4 +11,13 @@ config NVMEM_LAYOUT_SL28_VPD =20 If unsure, say N. =20 +config NVMEM_LAYOUT_ONIE_TLV + bool "ONIE tlv support" + select CRC32 + help + Say Y here if you want to support the Open Compute Project ONIE + Type-Length-Value standard table. + + If unsure, say N. + endmenu diff --git a/drivers/nvmem/layouts/Makefile b/drivers/nvmem/layouts/Makefile index fc617b9e87d0..2974bd7d33ed 100644 --- a/drivers/nvmem/layouts/Makefile +++ b/drivers/nvmem/layouts/Makefile @@ -4,3 +4,4 @@ # =20 obj-$(CONFIG_NVMEM_LAYOUT_SL28_VPD) +=3D sl28vpd.o +obj-$(CONFIG_NVMEM_LAYOUT_ONIE_TLV) +=3D onie-tlv.o diff --git a/drivers/nvmem/layouts/onie-tlv.c b/drivers/nvmem/layouts/onie-= tlv.c new file mode 100644 index 000000000000..074c7c700845 --- /dev/null +++ b/drivers/nvmem/layouts/onie-tlv.c @@ -0,0 +1,244 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * ONIE tlv NVMEM cells provider + * + * Copyright (C) 2022 Open Compute Group ONIE + * Author: Miquel Raynal + * Based on the nvmem driver written by: Vadym Kochan + * Inspired by the first layout written by: Rafa=C5=82 Mi=C5=82ecki + */ + +#include +#include +#include +#include +#include + +#define ONIE_TLV_MAX_LEN 2048 +#define ONIE_TLV_CRC_FIELD_SZ 6 +#define ONIE_TLV_CRC_SZ 4 +#define ONIE_TLV_HDR_ID "TlvInfo" + +struct onie_tlv_hdr { + u8 id[8]; + u8 version; + __be16 data_len; +} __packed; + +struct onie_tlv { + u8 type; + u8 len; +} __packed; + +static const char *onie_tlv_cell_name(u8 type) +{ + switch (type) { + case 0x21: + return "product-name"; + case 0x22: + return "part-number"; + case 0x23: + return "serial-number"; + case 0x24: + return "mac-address"; + case 0x25: + return "manufacture-date"; + case 0x26: + return "device-version"; + case 0x27: + return "label-revision"; + case 0x28: + return "platforn-name"; + case 0x29: + return "onie-version"; + case 0x2A: + return "num-macs"; + case 0x2B: + return "manufacturer"; + case 0x2C: + return "country-code"; + case 0x2D: + return "vendor"; + case 0x2E: + return "diag-version"; + case 0x2F: + return "service-tag"; + case 0xFD: + return "vendor-extension"; + case 0xFE: + return "crc32"; + default: + break; + } + + return NULL; +} + +static int onie_tlv_mac_read_cb(void *priv, const char *id, int index, + unsigned int offset, void *buf, + size_t bytes) +{ + eth_addr_add(buf, index); + + return 0; +} + +static nvmem_cell_post_process_t onie_tlv_read_cb(u8 type, u8 *buf) +{ + switch (type) { + case 0x24: + return &onie_tlv_mac_read_cb; + default: + break; + } + + return NULL; +} + +static int onie_tlv_add_cells(struct device *dev, struct nvmem_device *nvm= em, + size_t data_len, u8 *data) +{ + struct nvmem_cell_info cell =3D {}; + struct device_node *layout; + struct onie_tlv tlv; + unsigned int hdr_len =3D sizeof(struct onie_tlv_hdr); + unsigned int offset =3D 0; + int ret; + + layout =3D of_nvmem_layout_get_container(nvmem); + if (!layout) + return -ENOENT; + + while (offset < data_len) { + memcpy(&tlv, data + offset, sizeof(tlv)); + if (offset + tlv.len >=3D data_len) { + dev_err(dev, "Out of bounds field (0x%x bytes at 0x%x)\n", + tlv.len, hdr_len + offset); + break; + } + + cell.name =3D onie_tlv_cell_name(tlv.type); + if (!cell.name) + continue; + + cell.offset =3D hdr_len + offset + sizeof(tlv.type) + sizeof(tlv.len); + cell.bytes =3D tlv.len; + cell.np =3D of_get_child_by_name(layout, cell.name); + cell.read_post_process =3D onie_tlv_read_cb(tlv.type, data + offset + si= zeof(tlv)); + + ret =3D nvmem_add_one_cell(nvmem, &cell); + if (ret) { + of_node_put(layout); + return ret; + } + + offset +=3D sizeof(tlv) + tlv.len; + } + + of_node_put(layout); + + return 0; +} + +static bool onie_tlv_hdr_is_valid(struct device *dev, struct onie_tlv_hdr = *hdr) +{ + if (memcmp(hdr->id, ONIE_TLV_HDR_ID, sizeof(hdr->id))) { + dev_err(dev, "Invalid header\n"); + return false; + } + + if (hdr->version !=3D 0x1) { + dev_err(dev, "Invalid version number\n"); + return false; + } + + return true; +} + +static bool onie_tlv_crc_is_valid(struct device *dev, size_t table_len, u8= *table) +{ + struct onie_tlv crc_hdr; + u32 read_crc, calc_crc; + __be32 crc_be; + + memcpy(&crc_hdr, table + table_len - ONIE_TLV_CRC_FIELD_SZ, sizeof(crc_hd= r)); + if (crc_hdr.type !=3D 0xfe || crc_hdr.len !=3D ONIE_TLV_CRC_SZ) { + dev_err(dev, "Invalid CRC field\n"); + return false; + } + + /* The table contains a JAMCRC, which is XOR'ed compared to the original + * CRC32 implementation as known in the Ethernet world. + */ + memcpy(&crc_be, table + table_len - ONIE_TLV_CRC_SZ, ONIE_TLV_CRC_SZ); + read_crc =3D be32_to_cpu(crc_be); + calc_crc =3D crc32(~0, table, table_len - ONIE_TLV_CRC_SZ) ^ 0xFFFFFFFF; + if (read_crc !=3D calc_crc) { + dev_err(dev, "Invalid CRC read: 0x%08x, expected: 0x%08x\n", + read_crc, calc_crc); + return false; + } + + return true; +} + +static int onie_tlv_parse_table(struct device *dev, struct nvmem_device *n= vmem, + struct nvmem_layout *layout) +{ + struct onie_tlv_hdr hdr; + size_t table_len, data_len, hdr_len; + u8 *table, *data; + int ret; + + ret =3D nvmem_device_read(nvmem, 0, sizeof(hdr), &hdr); + if (ret < 0) + return ret; + + if (!onie_tlv_hdr_is_valid(dev, &hdr)) { + dev_err(dev, "Invalid ONIE TLV header\n"); + return -EINVAL; + } + + hdr_len =3D sizeof(hdr.id) + sizeof(hdr.version) + sizeof(hdr.data_len); + data_len =3D be16_to_cpu(hdr.data_len); + table_len =3D hdr_len + data_len; + if (table_len > ONIE_TLV_MAX_LEN) { + dev_err(dev, "Invalid ONIE TLV data length\n"); + return -EINVAL; + } + + table =3D devm_kmalloc(dev, table_len, GFP_KERNEL); + if (!table) + return -ENOMEM; + + ret =3D nvmem_device_read(nvmem, 0, table_len, table); + if (ret !=3D table_len) + return ret; + + if (!onie_tlv_crc_is_valid(dev, table_len, table)) + return -EINVAL; + + data =3D table + hdr_len; + ret =3D onie_tlv_add_cells(dev, nvmem, data_len, data); + if (ret) + return ret; + + return 0; +} + +static const struct of_device_id onie_tlv_of_match_table[] =3D { + { .compatible =3D "onie,tlv-layout", }, + {}, +}; + +static struct nvmem_layout onie_tlv_layout =3D { + .name =3D "ONIE tlv layout", + .of_match_table =3D onie_tlv_of_match_table, + .add_cells =3D onie_tlv_parse_table, +}; + +static int __init onie_tlv_init(void) +{ + return nvmem_layout_register(&onie_tlv_layout); +} +subsys_initcall(onie_tlv_init); --=20 2.30.2 From nobody Thu Apr 16 03:45:22 2026 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 0B1E0C433FE for ; Wed, 23 Nov 2022 18:05:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239623AbiKWSFK (ORCPT ); Wed, 23 Nov 2022 13:05:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239412AbiKWSDE (ORCPT ); Wed, 23 Nov 2022 13:03:04 -0500 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3D3A635D; Wed, 23 Nov 2022 10:02:29 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id 989813B3B; Wed, 23 Nov 2022 19:02:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1669226547; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rylqEwz1+bn7DE+ns+IvNz+B/VeOKU/ixN6d8R2r6nY=; b=Jlbm3mquRT12NKmKh5Kck//WtT5Mo3RuBQWhGkHvzlfBZo0Bqf3gpE2BSdPZtuJaJzxxYA n1HOAu3R4TK+Owx5qWbZUtoQc+YmkfzvbXW7LjNscyScjGBnv/CgcmzCjNBkLTiioi+PZc Uyug3VRFX/CxyZCJKu7xdeEiOqZfsW3E21I4U5TvjRsS3mOaPD2915uqI8cVSYAiMFCbjc kI8onZjhKhFoFAnl/Nwi8Wk7k63feDsnJ5tkuGy3PwrwdhhY728kUbd35oMdKhd612/p4g smwXO3O09BUX+/Fu8Be7XNjsmKqkrWrenMxEdhZ5XcyqbG6WCD8sX5kfwYpLkw== From: Michael Walle To: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand , Sascha Hauer Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle Subject: [PATCH v4 20/20] MAINTAINERS: Add myself as ONIE tlv NVMEM layout maintainer Date: Wed, 23 Nov 2022 19:01:51 +0100 Message-Id: <20221123180151.2160033-21-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123180151.2160033-1-michael@walle.cc> References: <20221123180151.2160033-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Miquel Raynal Following the introduction of the bindings for this NVMEM parser and the layout driver, add myself as maintainer. Signed-off-by: Miquel Raynal --- changes since v3: - none changes since v2: - new patch MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 0e0cc35d90b7..22abbbcf42c2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -15507,6 +15507,12 @@ L: linux-hwmon@vger.kernel.org S: Maintained F: drivers/hwmon/oxp-sensors.c =20 +ONIE TLV NVMEM LAYOUT DRIVER +M: Miquel Raynal +S: Maintained +F: Documentation/devicetree/bindings/nvmem/layouts/onie,tlv-layout.yaml +F: drivers/nvmem/layouts/onie-tlv.c + ONION OMEGA2+ BOARD M: Harvey Hunt L: linux-mips@vger.kernel.org --=20 2.30.2