Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1084328rdb; Sun, 1 Oct 2023 20:16:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEKpvpAwDo1Wr/xC7UliLSKKkA8xG8MIaF32Tu4U8WMJTdZHGd+9URu9BiFmOPatcLAkXmG X-Received: by 2002:a05:6a20:1613:b0:160:6577:c527 with SMTP id l19-20020a056a20161300b001606577c527mr12540785pzj.52.1696216606615; Sun, 01 Oct 2023 20:16:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696216606; cv=none; d=google.com; s=arc-20160816; b=tHIrWqG/6e6n/zKBzum/JHilzQ6ikPu7xwiPMcLvO/t8sLzuO++SgZwnphu1176yzm 7vxgVyuwGjMsU/Og/ycf/MjamC+tf6LHn69GeQAQLmxk1Srmv4g71bDHkUM4IloO0zna Di7sbBEvZkUPv1oppjHkOJzamCCDzEIRecN2N5R62ZLRurPb8xHC/fG8+aX5FyKzTrNs gGy2azxxY+OKYUt4cIz3e/f4vAI4NtL70Hkm5JyH00+mtIC/ifUF8A5YP+/DcwVEnECs JK9HLLoKlGu0GfsGcgCKh67L2hqIQl+NuMgT7Eo4dcgT1Aq1qBzzdQuqz+X3MF8rQWFA y6/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=VRzqWCTxRUztaMZlK8v6aOumJ51TcHdPHCtL5+sT2OE=; fh=sELcwdkMuN2kp9FILt2UISeDmL3gu+u/vYUu+BOlmf4=; b=l8nHU5beEWu/oIQT/tJgYfH4TrB+WJEOW9LeD/noK+ke7ozMy+ZCL343eRtjLPlXFM NHY5HcmEJ1DYo8PsBCjQnomDdZ2a2S5/ZW06EWh/dO6Z+MZov6kcTou+nhfNhDuprNsf JJqu7rE7OnTInywoddZiUyNp8ALSA6AyK8PEKayTG5cczgnk39RsRnAtTzVoonDGnzFM cHF6zOzezOwDXg5QEh/aX2qfyOlucdjuEN4KELa6y9ZM9SxkRSwyzk9abipNmr86VlkD qsE+hzZV0B9nt2VK9fLlxSSmpDiiJN5kqAkuuglUG4z1HwMdYsU6nKfIXrbbZ3FueeNL ejGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=bRjfPi7a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id i184-20020a6387c1000000b005819be28987si6979973pge.346.2023.10.01.20.16.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 20:16:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=bRjfPi7a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 86DB88226ADE; Sun, 1 Oct 2023 09:00:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235178AbjJAP7y (ORCPT + 99 others); Sun, 1 Oct 2023 11:59:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235093AbjJAP7x (ORCPT ); Sun, 1 Oct 2023 11:59:53 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76973D3 for ; Sun, 1 Oct 2023 08:59:49 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 7A70160003; Sun, 1 Oct 2023 15:59:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1696175987; 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=VRzqWCTxRUztaMZlK8v6aOumJ51TcHdPHCtL5+sT2OE=; b=bRjfPi7aEyDDSoacSwXVKW1HXj2fQ9UHKQqyb7QZZacM1McD+hOp7J6Cs/4Dc/twEsyw/L SinCXoFu+pbpbJAmwEOh8wiWKbJG0HsSRrnZUQN66SkmIPYvt2GoLzchT1PoMQJ+DV+kgJ wPs+S5DeM7O0axqr+mn+KqLxmOQpexhomGptAT5DJzVdF++mGo892xN/YZxQBrT/RaxwGY HwWrwDOyoeCanBYi/1/UgXIGgG5WR228ic5wTD6qSp7zMknJKHlGemjAbnznrZz3g2gzGd BJAg0qiyz2tjT0bbT3q2zldOuYUVi4/aVYPwzbyXCYbFya/aDY6sD0mSjiNqsg== Date: Sun, 1 Oct 2023 17:59:42 +0200 From: Miquel Raynal To: =?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?= Cc: Srinivas Kandagatla , Greg Kroah-Hartman , Michael Walle , Thomas Petazzoni , Robert Marko , Luka Perkov , linux-kernel@vger.kernel.org, Randy Dunlap , Chen-Yu Tsai , Daniel Golle Subject: Re: [PATCH v10 3/3] nvmem: core: Expose cells through sysfs Message-ID: <20231001175942.749d9bb3@xps-13> In-Reply-To: <5f1221613fb71b87c01c82add9fe5097@milecki.pl> References: <20230922174854.611975-1-miquel.raynal@bootlin.com> <20230922174854.611975-4-miquel.raynal@bootlin.com> <1a27a3341379b9679174f7c5143bbeb3@milecki.pl> <5f1221613fb71b87c01c82add9fe5097@milecki.pl> Organization: Bootlin X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: miquel.raynal@bootlin.com X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Sun, 01 Oct 2023 09:00:08 -0700 (PDT) Hi Rafa=C5=82, rafal@milecki.pl wrote on Fri, 29 Sep 2023 07:18:32 +0200: > On 2023-09-28 17:31, Rafa=C5=82 Mi=C5=82ecki wrote: > > On 2023-09-22 19:48, Miquel Raynal wrote: =20 > >> The binary content of nvmem devices is available to the user so in the > >> easiest cases, finding the content of a cell is rather easy as it is > >> just a matter of looking at a known and fixed offset. However, nvmem > >> layouts have been recently introduced to cope with more advanced > >> situations, where the offset and size of the cells is not known in > >> advance or is dynamic. When using layouts, more advanced parsers are > >> used by the kernel in order to give direct access to the content of >>= each > >> cell, regardless of its position/size in the underlying > >> device. Unfortunately, these information are not accessible by users, > >> unless by fully re-implementing the parser logic in userland. =20 > >> >> Let's expose the cells and their content through sysfs to avoid the= se =20 > >> situations. Of course the relevant NVMEM sysfs Kconfig option must be > >> enabled for this support to be available. =20 > >> >> Not all nvmem devices expose cells. Indeed, the .bin_attrs attribut= e =20 > >> group member will be filled at runtime only when relevant and will > >> remain empty otherwise. In this case, as the cells attribute group >> = will > >> be empty, it will not lead to any additional folder/file creation. =20 > >> >> Exposed cells are read-only. There is, in practice, everything in t= he =20 > >> core to support a write path, but as I don't see any need for that, I > >> prefer to keep the interface simple (and probably safer). The >> inter= face > >> is documented as being in the "testing" state which means we can later > >> add a write attribute if though relevant. =20 > >> >> Signed-off-by: Miquel Raynal =20 > >=20 > > Tested-by: Rafa=C5=82 Mi=C5=82ecki > >=20 > > # hexdump -C /sys/bus/nvmem/devices/u-boot-env0/cells/ipaddr@15c > > 00000000 31 39 32 2e 31 36 38 2e 31 2e 31 > |192.168.= 1.1| > > 0000000b =20 >=20 > The same test after converting U-Boot env into layout driver: >=20 > # hexdump -C /sys/bus/nvmem/devices/mtd1/cells/ipaddr@15c > 00000000 31 39 32 2e 31 36 38 2e 31 2e 31 |192.168.1.1| > 0000000b >=20 > Looks good! >=20 Great! Thanks a lot for testing! Miqu=C3=A8l