From patchwork Tue Aug 8 06:29:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 132648 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2295534vqr; Tue, 8 Aug 2023 10:57:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEO3eE41gibRW9EJIP42vRJ8gBrUNZLOaycQ05N5LuOK0z6G0moWDANeT1h4yjbgyvJTXJx X-Received: by 2002:a05:6a20:970a:b0:135:1af6:9a01 with SMTP id hr10-20020a056a20970a00b001351af69a01mr250149pzc.8.1691517457953; Tue, 08 Aug 2023 10:57:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691517457; cv=none; d=google.com; s=arc-20160816; b=eHWrxkHOV2AlV48G69MM8v+KV6b84TQ4r1c8BLVrlTwfGxcMLVSHPpWtmHptrJuiY0 KTS/75M0ho5iUCLHb91fB6DH6AAe2HOCPNvj1PZgZ2+5BX0oqeKJeEWv1UALmHGU6FnE xLKMLzUGg9H69rILiFhlXV9qqud1KtoogvTakuFogr5s2khr8zUqXwr8Sr9p5S4D7S8N 1B1Gr+xhK3ghoqWQ2084edmeSv4ibilBS3kYdiMeZUDPw9rFP86XpLJq/uIBT76khtWm NbZ9BoFjmg7dJsTYWRBeJlZTHsUhb+zp87XJW5H7rFfjwrppo6QNyAWZh58pRxdGd3in ZgLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dfOp8t/SWXoAMbVxsmdWr6p/Yay0CylcPPBrARczmbM=; fh=OHS2tDwbcHt81zFnYeyYq8ynDfpjq+e2h9R20vebRfM=; b=dsX4RDz+08heNrPSyYmn6vcqJ/2pUWRGcSyu3a9vhnYW7kjZVVJbSkSDpptJndAuaG A0VD4lPltShri0t/+mlATJH5i89lsqF6Q8dzsozE2hpj5YZNB4RIU+Y+92OevleRoQgY OL3apUXi3oYToA9qxgsVFN3UdNRdHMbGaJIjxGAS7Kdqwvljl8DXASmm/o5BB2SRIYb8 wkQeE8PQv14Wzsww1vHCxBQyyhdhBDUKalj39v48XD+jKgG387Fpg3iX6Sk12Q9BRuX4 iaaqfwBfFbiLzbNoPUuul0Y+y9bDpIyaCZgGWLaGLVutLC4nuvIperCgNRFdgYxW71+f gCqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=aPlicZy0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h8-20020a63c008000000b005642341d635si7227244pgg.373.2023.08.08.10.57.24; Tue, 08 Aug 2023 10:57:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=aPlicZy0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232569AbjHHRPt (ORCPT + 99 others); Tue, 8 Aug 2023 13:15:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234113AbjHHRPL (ORCPT ); Tue, 8 Aug 2023 13:15:11 -0400 Received: from mslow1.mail.gandi.net (mslow1.mail.gandi.net [217.70.178.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 160AD6F480 for ; Tue, 8 Aug 2023 09:06:15 -0700 (PDT) Received: from relay1-d.mail.gandi.net (unknown [217.70.183.193]) by mslow1.mail.gandi.net (Postfix) with ESMTP id CDEFAD2E96 for ; Tue, 8 Aug 2023 06:29:42 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id C88CE24000E; Tue, 8 Aug 2023 06:29:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1691476182; 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=dfOp8t/SWXoAMbVxsmdWr6p/Yay0CylcPPBrARczmbM=; b=aPlicZy0aPqt9XsWb2nXiOrAppv/JeO7nsjgYBSfEYe5L3RdHR7InI1x+hVetQWIy4RoaZ a2TbAmK8kWZszZdGQgPlblHYwmyI9y67Nrr64mnNC0ckatbaI9YIwwsY+HgKkH/6YKQdPx m9/rz+5DJM9wBkQ7C5/6uNhwBhYV6amMqKZtpH2SyfSc0Zck61wLBvlMGRCe8ULcnpvc/r 9hJGwuMmc7j+wopMKyU9thd5TouF1Xaai1RBnYF4bv5rcomTEEby8q85+TIai6Ll/zLMgk 87pKnEmmmBH2VvF+qRPTUPuFhZcTpqeWy7W7mczztu0FanxudL0fiDkh/abSyw== From: Miquel Raynal To: Srinivas Kandagatla Cc: Greg Kroah-Hartman , Thomas Petazzoni , Robert Marko , Luka Perkov , Michael Walle , , Randy Dunlap , Chen-Yu Tsai , Daniel Golle , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Miquel Raynal Subject: [PATCH v9 6/7] ABI: sysfs-nvmem-cells: Expose cells through sysfs Date: Tue, 8 Aug 2023 08:29:31 +0200 Message-Id: <20230808062932.150588-7-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230808062932.150588-1-miquel.raynal@bootlin.com> References: <20230808062932.150588-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 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, SPF_HELO_PASS,SPF_PASS,URIBL_BLOCKED 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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773684610418072902 X-GMAIL-MSGID: 1773684610418072902 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 their position/size in the underlying device, but these information were not accessible to the user. By exposing the nvmem cells to the user through a dedicated cell/ folder containing one file per cell, we provide a straightforward access to useful user information without the need for re-writing a userland parser. Content of nvmem cells is usually: product names, manufacturing date, MAC addresses, etc, Signed-off-by: Miquel Raynal Reviewed-by: Greg Kroah-Hartman --- Documentation/ABI/testing/sysfs-nvmem-cells | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-nvmem-cells diff --git a/Documentation/ABI/testing/sysfs-nvmem-cells b/Documentation/ABI/testing/sysfs-nvmem-cells new file mode 100644 index 000000000000..7af70adf3690 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-nvmem-cells @@ -0,0 +1,21 @@ +What: /sys/bus/nvmem/devices/.../cells/ +Date: May 2023 +KernelVersion: 6.5 +Contact: Miquel Raynal +Description: + The "cells" folder contains one file per cell exposed by the + NVMEM device. The name of the file is: @, with + being the cell name and its location in the NVMEM + device, in hexadecimal (without the '0x' prefix, to mimic device + tree node names). The length of the file is the size of the cell + (when known). The content of the file is the binary content of + the cell (may sometimes be ASCII, likely without trailing + character). + Note: This file is only present if CONFIG_NVMEM_SYSFS + is enabled. + + Example:: + + hexdump -C /sys/bus/nvmem/devices/1-00563/cells/product-name@d + 00000000 54 4e 34 38 4d 2d 50 2d 44 4e |TN48M-P-DN| + 0000000a