From patchwork Tue Aug 1 18:21: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: 129459 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2908913vqg; Tue, 1 Aug 2023 13:13:22 -0700 (PDT) X-Google-Smtp-Source: APBJJlH5PcnnNh1gyz7hSPa2LetHLPm+p71zhkMVD+JzM4L1aohMGWpog9pExLiROy26xnpuRFqr X-Received: by 2002:a17:906:3046:b0:98e:419b:4cc6 with SMTP id d6-20020a170906304600b0098e419b4cc6mr3112521ejd.70.1690920801846; Tue, 01 Aug 2023 13:13:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690920801; cv=none; d=google.com; s=arc-20160816; b=WbmxG1mY/aXnJAYUyb2+mqzn2JOFqGpm7y67OtDntNLzU645ckZEUKiNYCDC+5mWop PmbqKUs50PlU+1itCRZvnbMNhyjHpWwur2ewmBqM1pF4Bk5lUOyMdsiW4W6vLTv2AOt5 YsuymkdGultLCKIPc1i9IVurMFRLpvre/9QHtwJGgMadFyJvUUVd+gRPgey4XwD2sA12 VU4C2K2/1ogo55SLQa1ppfElKPSvStQJ7NmlsgYTHMlQWvUvceNGhvXh0okldKi9r7Z+ 1JYx5ZzLK4zc8dEnvDJ9kNMnycMmZJ815OyJh6tRa+ku+PsguiUxe4NvaN7yCNl5q3jP 3/hg== 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=fgVWjsMD95oohAim9ffD6zzKWxq5jwXobYlPEBDHn2g=; fh=OHS2tDwbcHt81zFnYeyYq8ynDfpjq+e2h9R20vebRfM=; b=sqwshZ+Olyxe/Oisvvzxbolp4Sez53hzii2OMm0NlZArWbCkQsmoA+tJ0HqKiZLV+t iAEW4kPwGvSFv2IY9zAHqMgMxBhMNWS06feu2fjoyOpVKtGSXr6+lnBVA2qQQh3DaPRd sOxC0xFwuOu8du/YA5ozzD8nON9M6F14A4zPuKt1IKxtkxka1aWM0FDAIJw3KfNpT+w0 6hecvJTqTqp9CS6u6QrzJoUzwQNrHYNzPyRsYfXu/MBCX1vnC41oa3/0dfrNgNzgQ3rG jgj8Qa2oHtANKwHkg3up/dnu3PO7QeSixkomKnwmnAeyqU4qf6gBgZKUfRdfu9ZLX7uh NATg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Y5Dh9IwC; 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 ga6-20020a170906b84600b00993199125d8si9361268ejb.378.2023.08.01.13.12.56; Tue, 01 Aug 2023 13:13:21 -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=Y5Dh9IwC; 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 S232310AbjHASWE (ORCPT + 99 others); Tue, 1 Aug 2023 14:22:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231339AbjHASVt (ORCPT ); Tue, 1 Aug 2023 14:21:49 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0206A2690 for ; Tue, 1 Aug 2023 11:21:47 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 3C5EBE0003; Tue, 1 Aug 2023 18:21:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1690914106; 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=fgVWjsMD95oohAim9ffD6zzKWxq5jwXobYlPEBDHn2g=; b=Y5Dh9IwCXc6tDCKv/3n+PfJ37a5cV9pwH3K0jGu7CBnVp96Kchq50jp/tdKPxHvkzDeLlI itDJgHJUPKrWCgjHjJ5ORYV15lGWcGzs8eyXR65IKzDOXPVtAbECNL/0EW5hQRo8/d8j0w Fh/RXuomXPhCuLuz3wnd9xp6u47IOGabCRSTxuJkpwL78TAKkOfAqu58OAhyP3+5P+ei7y ZJRDM10sOr80MwV9kq4FRzEdIWR7HiHiUdAMGgOfb5JIN/veCVfdlWivbadg4ztZs3lhym f3LK2u67j8pkudU+wCTDQ9JTqqyqEmR63UQGfdgkVolTUinDblzI9FblIBKksA== 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 v7 6/7] ABI: sysfs-nvmem-cells: Expose cells through sysfs Date: Tue, 1 Aug 2023 20:21:31 +0200 Message-Id: <20230801182132.1058707-7-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230801182132.1058707-1-miquel.raynal@bootlin.com> References: <20230801182132.1058707-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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,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: 1773058970683933948 X-GMAIL-MSGID: 1773058970683933948 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..a1d140dcbd5d --- /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 + 00000000 54 4e 34 38 4d 2d 50 2d 44 4e |TN48M-P-DN| + 0000000a