From patchwork Mon Aug 7 08:24:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 131741 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp1307256vqr; Mon, 7 Aug 2023 01:40:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEILrP1nwzpHulA5BvPTciYwHTBIwyo2wERs6CdUh4PMiicDE4Q6Z94diR1Xw+A8JG5qp3q X-Received: by 2002:a17:906:3150:b0:99b:c952:309a with SMTP id e16-20020a170906315000b0099bc952309amr6701115eje.39.1691397640370; Mon, 07 Aug 2023 01:40:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691397640; cv=none; d=google.com; s=arc-20160816; b=z0IanGB3/iMEjOxhTDEbexse3fvOavaMgyQnUATzPuz94J78hPlFVcxIeWo1m4mUQY jWvpj1Jtf3iGdtkL5c76h4KTBnS1J/fETNMh3hTOVN3PQIrPZV6Cs73V1vJ0aXpXCBtc eLmO/sLu7YeAD6RZU21xged5SEBJFhCqMNuaBDKC0IjDPLQCXfuBb6h7j/o8DgcSqhxt Z9t6+8nTfGFVrR0H8tQTU+U+qAQF1hbswJgtuz8XalVQ1cMsGKEyhu35UIoeg2XZUkFh K0aNfWQfe/e7z5zPaBUZdOpZhvv4FzsZmYhm5ugc17ICEjGus1gQH8xYvgiJvudJm7I/ GJ/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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dfOp8t/SWXoAMbVxsmdWr6p/Yay0CylcPPBrARczmbM=; fh=OHS2tDwbcHt81zFnYeyYq8ynDfpjq+e2h9R20vebRfM=; b=b033axWpkf5mwn/Mo7lVr+a0d+WjG56F/66RCrg3PpGwhPxly5c3jT7X8H8dl9Ur+F 89vZSTfRVHMYaj+4lDV4ZO02uU1UzyhL3X3EYg0jo4NhJayhEMsPYkEM0PDBCmCOfaT0 KFBaYFtRGeph4B5GLvghzcWEDIFSdPlU8r4PVbXvkeXW8uVpGbJNcYlPgL3bcGg7ELk0 NK+ARBzeufnUL+pL5XPR8/Eq1P8n4scdcz50zkT3ZmWupJhWG+I2AEpmNhXbt2Ej4hOB LiYugpIQzV85Lyvqq5nTD2EXX9HNBlmY19U09jr55Z5vc9SfKpbnA2xdOlWyhgtMYYaq zZjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=kjUDxNyS; 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 o5-20020a1709064f8500b0099bc79a3897si5810811eju.886.2023.08.07.01.40.16; Mon, 07 Aug 2023 01:40:40 -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=kjUDxNyS; 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 S230382AbjHGIYp (ORCPT + 99 others); Mon, 7 Aug 2023 04:24:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231191AbjHGIYc (ORCPT ); Mon, 7 Aug 2023 04:24:32 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A9FD1721 for ; Mon, 7 Aug 2023 01:24:31 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id C3D50E000C; Mon, 7 Aug 2023 08:24:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1691396669; 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=kjUDxNyS0uxFR0kzo+cDIBNqOC7LUzEn02ykcHbnNSze025tvzy0QDcE4EGC619pvA9rLd Qw4G81M2oHmkRSfdPHeOGK0hnZT5oDWD/NMjHhpxR8VgKbfcHmMXfcdk3nVS6W/9ht0Ol3 7jwQaFF0HQrvZMZQqcmmDav2NYYW4jzbRLsmhWzh80IO7p8r2NkS5Ik6GPdyB6A771sO5e pxo8VfM8Gcq+mx6FCvGxTcIivij6NHOFwdfdUQJs7WxuvrjATWkio34auJm/CGnS4SBr6H n+J1V4Fjxh3+ZOkcOyWWK3a17Ea1x7a08QFR2sE+9oXaEXLQcpzyuGAug5q5JQ== 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 v8 7/8] ABI: sysfs-nvmem-cells: Expose cells through sysfs Date: Mon, 7 Aug 2023 10:24:18 +0200 Message-Id: <20230807082419.38780-8-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807082419.38780-1-miquel.raynal@bootlin.com> References: <20230807082419.38780-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 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: 1773558972001948490 X-GMAIL-MSGID: 1773558972001948490 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