From patchwork Mon Jul 17 07:51:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 121111 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp971850vqt; Mon, 17 Jul 2023 01:10:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlF0OH1RZbXKC1uV2dDL0X56Pn0XhWdyNlnVMLAbZV/oE8HGL2J7znQ6vgUS5gnbjD6JwAaz X-Received: by 2002:a05:6a20:258c:b0:133:83b5:c3cd with SMTP id k12-20020a056a20258c00b0013383b5c3cdmr13609784pzd.53.1689581428794; Mon, 17 Jul 2023 01:10:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689581428; cv=none; d=google.com; s=arc-20160816; b=eOm17mzoIkywZvSkyXEzpvkmNhLgXOnYHe3al74+Sx2VdZdZiTsZ8ODf7UHUXT3MUj auhPLDFOPGIDihaBBL9vznmCRN0pkEEEBxxWvH9vEWq17b9sxbB+e838oASZfsxBA8rs 9kasYnhi+9FLRWIfJ0V3jLM4v4zX7Z/mfvJJpo24UM5HEXLBvlgSuD4Sqk7UEuO+UibL ebLsjgdN0BiLON9RZAoC1vpN00fsiZT2UrT7JaVuuHnXTJgvYBR2eq8BjWMsG/nWqgQR ikwhijiYlSrts2vckc/P1KUbBIAwt6V8EwpeHMmTYpnWwXIRjb1gdfx91hCB6xPLmHV4 NjjA== 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=nH6/LjRkYId88yq613RlWdOphmfE4iRu7Ck+Oxwm0yc=; fh=JpygR/0v0UTOXdyljMXVkuezv/HjT4xrIjOwJ6y50X0=; b=QQIjxQTdMtyg4y5NkA/XJ4NWqR1pWMOKkGcLAxpHLVplAY/ewsXL4fXV4o/mPbWieU 1WiMvG9moomJSCzvhtB8GyGlXsN1zhD08z5LCCXobA9HH9bxTtMrpxyG7hcZobeE4tm3 tBy5VD7fDMcET+gMrQmd/LmKA1N9W0JQaVxwl3Z0jXj7ngTOBdnCa4MarY+AIo0PBynU ky5NoWeJMOFPDSz24VDvfuBMRIzZ/sEPtBTPreDxwYPsTe+Lg53uHDI3QUImd8nzmRm5 8hMbu5dgdniC3Ay+a2vr5nrVC0zcWvwkYu3aXpYZCuC7XFLmMPcCPMQHPNHE0hb4siCE QlVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=WDkqvzg8; 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 bv10-20020a056a00414a00b006724753efe8si11157318pfb.192.2023.07.17.01.10.16; Mon, 17 Jul 2023 01:10:28 -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=WDkqvzg8; 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 S231202AbjGQHwW (ORCPT + 99 others); Mon, 17 Jul 2023 03:52:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231186AbjGQHwD (ORCPT ); Mon, 17 Jul 2023 03:52:03 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77576118 for ; Mon, 17 Jul 2023 00:51:53 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 7811C60007; Mon, 17 Jul 2023 07:51:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1689580311; 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=nH6/LjRkYId88yq613RlWdOphmfE4iRu7Ck+Oxwm0yc=; b=WDkqvzg8QAfJqTq4uPlJhLx4c7ON8Cote9uwAPhSzr8+CJy20QpkqHe28R/g8CfLl3pJuJ +QGUPfERJPkT6c9ZYfzQj8zwSFVhCzvCJxUGXrlLy5RzDHHSISRHCuxhSIgulWpbjB81KL 70XZc+DOzkMOjBw1uHYInwhVjcF/Y208/M96Yr1ZlfI2ltPEgV/x9VXYIGt46UuEYbNxhX XX45Bpn1e0TSLhRWK1pigr9VKlatROaI4ATRrdl7TgOp1ncXtdPWBXGcYR71sIBYoyS1+D 6Mv/8wk8U9BtgntdJqlGZRdlnhEAu0DUbpJnQd7+ZMreKIhEIsm+ediXMETSfQ== From: Miquel Raynal To: Srinivas Kandagatla , Greg Kroah-Hartman , Cc: Thomas Petazzoni , Robert Marko , Luka Perkov , Michael Walle , Randy Dunlap , Miquel Raynal Subject: [PATCH v6 1/3] ABI: sysfs-nvmem-cells: Expose cells through sysfs Date: Mon, 17 Jul 2023 09:51:45 +0200 Message-Id: <20230717075147.43326-2-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230717075147.43326-1-miquel.raynal@bootlin.com> References: <20230717075147.43326-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,T_SCC_BODY_TEXT_LINE 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: 1771654536529091473 X-GMAIL-MSGID: 1771654536529091473 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 | 19 +++++++++++++++++++ 1 file changed, 19 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..b2d15a8d36e5 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-nvmem-cells @@ -0,0 +1,19 @@ +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 the cell name. + 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