From patchwork Thu Oct 5 15:59:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 148887 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp414262vqb; Thu, 5 Oct 2023 09:22:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE5N+V9rx2KX89PtUGKuw+xv+7DmGelnSL+9q3HROuhk/0yqO1Qvqi2wE0Gi5N8mjaVNWip X-Received: by 2002:a17:90b:4ad0:b0:274:a021:9383 with SMTP id mh16-20020a17090b4ad000b00274a0219383mr5696439pjb.17.1696522966349; Thu, 05 Oct 2023 09:22:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696522966; cv=none; d=google.com; s=arc-20160816; b=p9e2DGgHitD4NI8qs7UgVYwxCrCXYx0sqFpIg2hhMPzfQmcuBt/eWXsCt07fDWjOyY L8dK6otIXUerpjMfBcR7kPxYSDzPh9OPcysdnxF8WQS6lLgNitKSXRr6wEkwe9h1TEDU VkLoiV4bXle9MAXt483A61Q/Tgqi7FlHQnCsR/XX6qioDMpdBsv2yefyNvSJcdNmky1b XGmosxcqjyIxkhNbE6vyz7EwI1EFbsQC+7J/kIdPr0MqmlFqIgJMCpPr4DoF95hmvwL2 48NbKsQVQuwPf+3dqjrJ6HoMKdfML3udFaewrjwxWI2JfcjHo33Rpt73/uk7KdBLwt4R x2tg== 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=XQzgxiPMj/Cqsom9sWl23DkvcXkGD6r/vx0NuuBn5R0=; b=no0In6QdzUQBzeapPVrLyKWz1Sh/3etsueSfl/EVMMJ8ixXRh/NXtUBaijFiM0UV83 S33BdhwFIIVAWrcUhVMvHb2CRNcHmF63gpEJ31X2U/umfYeOU3B88uEWU7JL6faPvmCQ fFRddLwfQi/1m1V2juK01LLamgZVt/JmB+XXdddvmpmqWMzlMOYHmPtuUnYgHAKrvon7 ocVw44GcSdp56g/N07ubRBLbtVdJCvZvZLDiaKN710+LNpf2+EBj+iXh5EkDqEpjg/NS G/UDA9IXOXXXZ9GbCcY0MsUBcl6JYc9wfIlHFGoi35SQtSyHpGGDfNKZoGI73PjeFbjs 73nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=oSba1V3M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id f18-20020a17090ace1200b00278ea235413si4026937pju.31.2023.10.05.09.22.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 09:22:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=oSba1V3M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 87D0C82F09B6; Thu, 5 Oct 2023 09:22:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242509AbjJEQUy (ORCPT + 19 others); Thu, 5 Oct 2023 12:20:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240385AbjJEQQC (ORCPT ); Thu, 5 Oct 2023 12:16:02 -0400 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::228]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D98E47B8; Thu, 5 Oct 2023 08:59:22 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id BBCE81BF20B; Thu, 5 Oct 2023 15:59:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1696521561; 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=oSba1V3MvsJggcGvucw1bE9xLdxB38sDD+5KUIvRUW3fdC0PY9DF7Kvz+B9RBagJFc5jVD EnOZYK6T6jcctQnr/xAEVDTh9UzCnn62SkQ+xwjVxTLBZv/kNmpNPwqCuf1NcwWC8LLFdK Vka7RG7le3hr5HHMo/NVPbvkCgKIXnJB5UpeysNgBbRMjj+Dgy9mBBKWZ+HvIkoetD8RKU LYiSQoaNYdi00Qs0qWeIWR8dveGfxYt37+OHlZobWaG5Vxd6KFkU12Vgl5sSZOqamBN3BK 1OjZEyeulYFJMi/5xRc3cP4FrhCbys+uA40qQHTt9q8S/5ULUcZerM+sS2UMcw== From: Miquel Raynal To: Srinivas Kandagatla , Greg Kroah-Hartman Cc: Michael Walle , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Rob Herring , Frank Rowand , devicetree@vger.kernel.org, , Robert Marko , Thomas Petazzoni , Luka Perkov , Randy Dunlap , Chen-Yu Tsai , Daniel Golle , Miquel Raynal Subject: [PATCH v12 6/7] ABI: sysfs-nvmem-cells: Expose cells through sysfs Date: Thu, 5 Oct 2023 17:59:06 +0200 Message-Id: <20231005155907.2701706-7-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231005155907.2701706-1-miquel.raynal@bootlin.com> References: <20231005155907.2701706-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: miquel.raynal@bootlin.com X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Thu, 05 Oct 2023 09:22:25 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778933265660006297 X-GMAIL-MSGID: 1778933265660006297 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