From patchwork Fri Sep 22 17:48:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 143786 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:910f:0:b0:403:3b70:6f57 with SMTP id r15csp40980vqg; Fri, 22 Sep 2023 19:24:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE39LIGOISWfePNYR4EAWx0YkMnlz+OblBJF3YT3c2URJ0U/t6ZX1aXxBmMTm5NBZCJwfLG X-Received: by 2002:a9d:7654:0:b0:6c4:ce0e:29ae with SMTP id o20-20020a9d7654000000b006c4ce0e29aemr1193648otl.21.1695435893631; Fri, 22 Sep 2023 19:24:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695435893; cv=none; d=google.com; s=arc-20160816; b=IbFMfDHcdUCVrxa+bfPtp3sgk0DmE81+/u88dgt5UM3WAgUDWUncVYU0Sq2SGBa2IW jZsSbHlJ3kfwOqI9hwUZtDHBsurHR2Ci+IzcbYfHH/HCLzBtN/WSvZOpCEocpad22TOz jRcV6LYjki3CBMW11IB1ggE1Yqylq11r+IjjTa6IEvymqLcto/VU3DpULt527Vpayt5l OAnwDrjKalhC0DBUNn771vIKm92CKGz1CVXu9ofsm/52FD6BtD/wtOOmiDOleil34IoO 1gHyBckfcy3NORSgfPIzAXewoDQsx53DYjLwNwVSaWe6UKyXCZcEi3lKL9ECryTfHldR IUwA== 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=uNRYBw15K+4lj0RowSR5ppkZ/jQAGNdwwLd8P1k8N6c=; b=LJMqBVFDKqYF8vlqCBjtdDXnMppDkP+DhjKCM4QRNzMaH5HGl0sd4GoIKFuYH6Xw7b YmNpjRQ/rHNf2JPcdr1FJvJ7jdj3nRWXg64bt3ss7C0YP7liJ5I3wLaSk3Ixar8hMsRB L8VptoPmz1420iQwzPyYRQJfofIrC5ZAok1UuSwxzGyyUqlfBiYUkPPvpgpwhQZG6CP8 kEbfBTNvDVL5kA4WAHoO/kfAWDA3zzd3sdmgA7SLaIIotKtQQAoXVgYnbDDliSy8EC6G kJL7NB9xbXCjO0TgEokNyJX0XIJoqj1vSXj0vTF/ngfc4wj+ZkvIGH+s5nTlXwzw6Oa9 A2zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=cUjfLTWd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id y63-20020a636442000000b00578e4816c9asi5131803pgb.19.2023.09.22.19.24.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 19:24:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=cUjfLTWd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id AC014821707E; Fri, 22 Sep 2023 10:49:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233102AbjIVRtU (ORCPT + 28 others); Fri, 22 Sep 2023 13:49:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232987AbjIVRtM (ORCPT ); Fri, 22 Sep 2023 13:49:12 -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 090C299 for ; Fri, 22 Sep 2023 10:49:05 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id DD990E0003; Fri, 22 Sep 2023 17:49:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1695404944; 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=cUjfLTWdIYMKuMb63IFz5LtWQxIs46prbk3G4JAlSMOp+uDL3HTdPZyUwhl9BXgEFYElEd x5g+N9LHLyH0C0gIQZ5szWDBqgnI9a+9VQCZl/SfDh88YFnU0d5WMKmLxS/xPQvD9v5wuR leInR8cKhka+/Pvlyj2RDLFb0ILjDw55WVyhdeMKZCHQQNTiyBbqwiePOiKuFvBpO3e0Od 2Pp1QprnAQpG8kZetLNN0BzhmB2EZTNVbilAkMSywOvwW0ossH38uPhWSAfMpnLKO7rlHT VNpZGpa50DBJHOb4WTwt6nZ1M/twGUBuYRsVZWX7HkdSbkfO9wkV5TEK+O+8Cg== From: Miquel Raynal To: Srinivas Kandagatla , Greg Kroah-Hartman Cc: Michael Walle , Thomas Petazzoni , Robert Marko , Luka Perkov , , Randy Dunlap , Chen-Yu Tsai , Daniel Golle , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Miquel Raynal Subject: [PATCH v10 2/3] ABI: sysfs-nvmem-cells: Expose cells through sysfs Date: Fri, 22 Sep 2023 19:48:53 +0200 Message-Id: <20230922174854.611975-3-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230922174854.611975-1-miquel.raynal@bootlin.com> References: <20230922174854.611975-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: miquel.raynal@bootlin.com X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 22 Sep 2023 10:49:21 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777793387401578551 X-GMAIL-MSGID: 1777793387401578551 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