Message ID | 20230530100929.285235-1-miquel.raynal@bootlin.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2070413vqr; Tue, 30 May 2023 03:16:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4dUz/ndXBvdYx74ST2RGJG34Eqes0mZVNTANa6T3LWg1REg7qwzbPtSC/kBh5C5zVc2z3B X-Received: by 2002:a17:903:1106:b0:1ac:8475:87c5 with SMTP id n6-20020a170903110600b001ac847587c5mr2392001plh.56.1685441765012; Tue, 30 May 2023 03:16:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685441764; cv=none; d=google.com; s=arc-20160816; b=0hjJmlP3cFKpLzRI4BV3XsRMJyO4s+czYSnAGIthJI2kAQ9MeoYEzB1cogoM/BjHK8 8CJzPXAkKcxzhvaonx52CoQqQS03fY4zCoK4q87RaYAvY2QIls1rM7q9ViAA6pnPYg8a fkR4dNfCDEjAvq6d07arJoFsFO4mgmiJB4vNswnu/1caD3us2YFeNEgUbm3hdPJuQFhP IAfdyrVKeGeek7jHjLHphFpN2ruGbP7W32haLkhiVDalXUDA4es2zWUTHVJj83lJUSei 3UQQv9RDMf49AXAqmj4sH8ScKtNHBHDbfjtnno+VicADbxrJExOfPXokIcFFGf8U4y+t 8qWg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=7IMC2N+5zMwD2FcWd+tBkCCpbpprLJnpD6w1wRdFkaw=; b=T2D+0bZWkhNwAcxOJtEmPPUGzmJzixuini08Eb8kQEJzG1VyZ4y6LtAUAbLeNVEMbe PjboFyiqASasF+8Kabrj7OaG1uFLb4+2UPcAfhGy64c0LrW+sdtQWkjGYHlO0cLh1BRp Xsfe92pu306V5PEuq4RPuI8U18evFOiZxGzzK7ClntMrmt4olNgZbVByJaACbxnJ+aqv gIctIHWtJb6s82AqMdwUmqeZU5sAW4FzUP30b1lUXq4iJNkWu8TZdTSzf6QoMcgHsgTk FnwjY7G7q7UfIOY5qq6qBt37c3zaDUk0oXdKxZs4LqRY2zRaGkFjbewmr746N2FzAwWq qVVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Y0+XUcSb; 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 n15-20020a170902d2cf00b001a9f42553dasi11823955plc.614.2023.05.30.03.15.50; Tue, 30 May 2023 03:16:04 -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=Y0+XUcSb; 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 S230141AbjE3KJi (ORCPT <rfc822;andrewvogler123@gmail.com> + 99 others); Tue, 30 May 2023 06:09:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229626AbjE3KJh (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 30 May 2023 06:09:37 -0400 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EFE693 for <linux-kernel@vger.kernel.org>; Tue, 30 May 2023 03:09:32 -0700 (PDT) X-GND-Sasl: miquel.raynal@bootlin.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1685441370; 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; bh=7IMC2N+5zMwD2FcWd+tBkCCpbpprLJnpD6w1wRdFkaw=; b=Y0+XUcSb3Wb2Gdh9tqkbaQyn1zicWZ/OXq1Yp69pLbd5egwE+11UsvfVY7fbBFTtSCqYmA Xu41FnnenyVpH0/c842AoJmVI8Yq4XOo89c52I3vQS7wBhCoqp8kDqCwN9yHL15Tr3y66b 5bZjaZ7TzrKcQRrtM7l3MdmhdwTjJB5uuOgGf9H+OEO8vG7OXA3m/PhT4+Yj8f2LeRWtbI ZpKT2wsdrK3MhXkBVByiKmh/GCZrjtOyhM+avrK0uDI5ihhXA2AYer0qQqLhqcd/Vaxvc9 6PdkijubyAUuZ9tajEdSqcu2nFHxAsvLh13almkxHXIWd9rpC0a4389932+a5w== X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com X-GND-Sasl: miquel.raynal@bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 2FFD42000D; Tue, 30 May 2023 10:09:30 +0000 (UTC) From: Miquel Raynal <miquel.raynal@bootlin.com> To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Luka Perkov <luka.perkov@sartura.hr>, Robert Marko <robert.marko@sartura.hr>, Thomas Petazzoni <thomas.petazzoni@bootlin.com>, <linux-kernel@vger.kernel.org>, Miquel Raynal <miquel.raynal@bootlin.com> Subject: [PATCH v2 0/2] NVMEM cells in sysfs Date: Tue, 30 May 2023 12:09:27 +0200 Message-Id: <20230530100929.285235-1-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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_NONE, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767313784137840449?= X-GMAIL-MSGID: =?utf-8?q?1767313784137840449?= |
Series |
NVMEM cells in sysfs
|
|
Message
Miquel Raynal
May 30, 2023, 10:09 a.m. UTC
Hello, As part of a previous effort, support for dynamic NVMEM layouts was brought into mainline, helping a lot in getting information from NVMEM devices at non-static locations. One common example of NVMEM cell is the MAC address that must be used. Sometimes the cell content is mainly (or only) useful to the kernel, and sometimes it is not. Users might also want to know the content of cells such as: the manufacturing place and date, the hardware version, the unique ID, etc. Two possibilities in this case: either the users re-implement their own parser to go through the whole device and search for the information they want, or the kernel can expose the content of the cells if deemed relevant. This second approach sounds way more relevant than the first one to avoid useless code duplication, so here is a series bringing NVMEM cells content to the user through sysfs. Here is a real life example with a Marvell Armada 7040 TN48m switch: $ nvmem=/sys/bus/nvmem/devices/1-00563/ $ for i in `ls -1 $nvmem/cells/*`; do basename $i; hexdump -C $i | head -n1; done country-code 00000000 54 57 |TW| crc32 00000000 bb cd 51 98 |..Q.| device-version 00000000 02 |.| diag-version 00000000 56 31 2e 30 2e 30 |V1.0.0| label-revision 00000000 44 31 |D1| mac-address 00000000 18 be 92 13 9a 00 |......| manufacture-date 00000000 30 32 2f 32 34 2f 32 30 32 31 20 31 38 3a 35 39 |02/24/2021 18:59| manufacturer 00000000 44 4e 49 |DNI| num-macs 00000000 00 40 |.@| onie-version 00000000 32 30 32 30 2e 31 31 2d 56 30 31 |2020.11-V01| platform-name 00000000 38 38 46 37 30 34 30 2f 38 38 46 36 38 32 30 |88F7040/88F6820| product-name 00000000 54 4e 34 38 4d 2d 50 2d 44 4e |TN48M-P-DN| serial-number 00000000 54 4e 34 38 31 50 32 54 57 32 30 34 32 30 33 32 |TN481P2TW2042032| vendor 00000000 44 4e 49 |DNI| Here is a list of known limitations though: * It is currently not possible to know whether the cell contains ASCII or binary data, so by default all cells are exposed in binary form. * For now the implementation focuses on the read aspect. Technically speaking, in some cases, it could be acceptable to write the cells, I guess, but for now read-only files sound more than enough. A writable path can be added later anyway. * The sysfs entries are created when the device probes, not when the NVMEM driver does. This means, if an NVMEM layout is used *and* compiled as a module *and* not installed properly in the system (a usermode helper tries to load the module otherwise), then the sysfs cells won't appear when the layout is actually insmod'ed because the sysfs folders/files have already been populated. Changes in v2: * Do not mention the cells might become writable in the future in the ABI documentation. * Fix a wrong return value reported by Dan and kernel test robot. * Implement .is_bin_visible(). * Avoid overwriting the list of attribute groups, but keep the cells attribute group writable as we need to populate it at run time. * Improve the commit messages. * Give a real life example in the cover letter. Miquel Raynal (2): ABI: sysfs-nvmem-cells: Expose cells through sysfs nvmem: core: Expose cells through sysfs Documentation/ABI/testing/sysfs-nvmem-cells | 19 +++ drivers/nvmem/core.c | 145 +++++++++++++++++++- 2 files changed, 160 insertions(+), 4 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-nvmem-cells