Message ID | ZLaZ7fzUSsa0Igx1@makrotopia.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1791223vqt; Tue, 18 Jul 2023 07:33:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlG2272e/EdXz+RYp7LZw+dVXneYABjmc/YlaC/g7KWEAS11cN0c1KcjF4jprKsu7D9DKkIW X-Received: by 2002:a17:907:b09:b0:994:1844:c7d1 with SMTP id h9-20020a1709070b0900b009941844c7d1mr87547ejl.13.1689690824549; Tue, 18 Jul 2023 07:33:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689690824; cv=none; d=google.com; s=arc-20160816; b=sC3TtNj5lm9lM05AhdctOrRMybWwJ8C8s2SLMJefl4QPjqRY0eyf/oih+xiPjAiijE Eove48KO054J5tkcWa7p0g2+qn858VIcf+HesKS/gxr1slmBc9ockzDOadtg8S1pIlEr C9GRrvyKRgojRVMkw9yIQx3ktmBCr+VAt1x0dtJIH7qI/qoOkIQLuSFRH2Dlf78rZZjq zUMW7mePUPu+pVI6Bs3czLKyX6+TP+AJOX3ImvaS+C9cKbhwZ8QekJq2fHB/gnpvZlqv cod9s7bzsXkng2F+k1umZosmulo3mfJ7sdKPG7GtfE+ov4MefI0QZoE5QelbYI1vNVVU GoPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date; bh=9rZu1ndO7BwoisEWFnA9Ij+utPV77y+0+ThAO9S+0R0=; fh=he+Yx86cu3mN0DOFH5VYr11DEff1suEG6d8HBMg/nEI=; b=nG9dqF3+AnUwyq8+PJGJRrWzeFMmEhKKgDbj8U86fTryLsddC/tk1fvtq+KIpcBQZr r6FVsO+N40QeJrSxrc3Ql7ypkuM1EtEuKpdCDj7Ljp5cUmPhmGo4bq0TRXg0jUkxfeHn SfQohaem/6LYRvb0fFlxtKt+/d/f8HOG9dKl5NoG/SMOfNS2mleqcKiJO9Wh1R5/sZwi TUscS83jYV1WQSKu2nzwod9wkgpUTVCwMzXzijaS4BC4A12vMbVENPva8NutGzSBNTU8 K+EwP2z0LDpUVSVmkCkThAwSQXRxhO72qb6ObFKNFQkegF19oWp3nQGn7H23iPavQXFz zp8w== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bq8-20020a170906d0c800b00992aa293bc4si1141348ejb.1006.2023.07.18.07.33.20; Tue, 18 Jul 2023 07:33:44 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232996AbjGRN4e (ORCPT <rfc822;chrisben.tianve@gmail.com> + 99 others); Tue, 18 Jul 2023 09:56:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229986AbjGRN4c (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 18 Jul 2023 09:56:32 -0400 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C4391712 for <linux-kernel@vger.kernel.org>; Tue, 18 Jul 2023 06:56:11 -0700 (PDT) Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from <daniel@makrotopia.org>) id 1qLlBQ-0008CI-03; Tue, 18 Jul 2023 13:56:08 +0000 Date: Tue, 18 Jul 2023 14:55:57 +0100 From: Daniel Golle <daniel@makrotopia.org> To: Miquel Raynal <miquel.raynal@bootlin.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Srinivas Kandagatla <srinivas.kandagatla@linaro.org>, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] nvmem: core: append offset to cell name in sysfs Message-ID: <ZLaZ7fzUSsa0Igx1@makrotopia.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771769245688508973 X-GMAIL-MSGID: 1771769245688508973 |
Series |
[1/2] nvmem: core: clear sysfs attributes for each NVMEM device
|
|
Commit Message
Daniel Golle
July 18, 2023, 1:55 p.m. UTC
The device tree node names are not required to be unique. Append the
offset to the name to make cell nodes with identical names become
accessible via sysfs and avoid kernel stackdump caused by
sysfs: cannot create duplicate filename '...'
Fixes: 757f8b3835c9 ("nvmem: core: Expose cells through sysfs")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
drivers/nvmem/core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Comments
On Tue, Jul 18, 2023 at 02:55:57PM +0100, Daniel Golle wrote: > The device tree node names are not required to be unique. Append the > offset to the name to make cell nodes with identical names become > accessible via sysfs and avoid kernel stackdump caused by > sysfs: cannot create duplicate filename '...' > > Fixes: 757f8b3835c9 ("nvmem: core: Expose cells through sysfs") > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > --- > drivers/nvmem/core.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c > index 70e951088826d..90fe9dc30f8ba 100644 > --- a/drivers/nvmem/core.c > +++ b/drivers/nvmem/core.c > @@ -480,7 +480,9 @@ static int nvmem_populate_sysfs_cells(struct nvmem_device *nvmem) > /* Initialize each attribute to take the name and size of the cell */ > list_for_each_entry(entry, &nvmem->cells, node) { > sysfs_bin_attr_init(&attrs[i]); > - attrs[i].attr.name = devm_kstrdup(&nvmem->dev, entry->name, GFP_KERNEL); > + attrs[i].attr.name = devm_kasprintf(&nvmem->dev, GFP_KERNEL, > + "%s@%d", entry->name, > + entry->offset); No documenatation update to show the new naming scheme? And again, I don't see that git id in Linus's tree, am I just not up to date properly? thanks, greg k-h
Hi Daniel, daniel@makrotopia.org wrote on Tue, 18 Jul 2023 14:55:57 +0100: > The device tree node names are not required to be unique. Append the > offset to the name to make cell nodes with identical names become > accessible via sysfs and avoid kernel stackdump caused by > sysfs: cannot create duplicate filename '...' > > Fixes: 757f8b3835c9 ("nvmem: core: Expose cells through sysfs") > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > --- > drivers/nvmem/core.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c > index 70e951088826d..90fe9dc30f8ba 100644 > --- a/drivers/nvmem/core.c > +++ b/drivers/nvmem/core.c > @@ -480,7 +480,9 @@ static int nvmem_populate_sysfs_cells(struct nvmem_device *nvmem) > /* Initialize each attribute to take the name and size of the cell */ > list_for_each_entry(entry, &nvmem->cells, node) { > sysfs_bin_attr_init(&attrs[i]); > - attrs[i].attr.name = devm_kstrdup(&nvmem->dev, entry->name, GFP_KERNEL); > + attrs[i].attr.name = devm_kasprintf(&nvmem->dev, GFP_KERNEL, > + "%s@%d", entry->name, > + entry->offset); Shouldn't we use %s@%x instead to match the DT descriptions? > attrs[i].attr.mode = 0444; > attrs[i].size = entry->bytes; > attrs[i].read = &nvmem_cell_attr_read; I plan another version of the series which triggered these patches, if you don't mind I will squash patch 1 into my patches and pick this one as a preparation change (likely with the above fix if you agree and without the Fixes tag). Thanks, Miquèl
Hi Miquel, On Mon, Jul 31, 2023 at 05:45:06PM +0200, Miquel Raynal wrote: > Hi Daniel, > > daniel@makrotopia.org wrote on Tue, 18 Jul 2023 14:55:57 +0100: > > > The device tree node names are not required to be unique. Append the > > offset to the name to make cell nodes with identical names become > > accessible via sysfs and avoid kernel stackdump caused by > > sysfs: cannot create duplicate filename '...' > > > > Fixes: 757f8b3835c9 ("nvmem: core: Expose cells through sysfs") > > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > > --- > > drivers/nvmem/core.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c > > index 70e951088826d..90fe9dc30f8ba 100644 > > --- a/drivers/nvmem/core.c > > +++ b/drivers/nvmem/core.c > > @@ -480,7 +480,9 @@ static int nvmem_populate_sysfs_cells(struct nvmem_device *nvmem) > > /* Initialize each attribute to take the name and size of the cell */ > > list_for_each_entry(entry, &nvmem->cells, node) { > > sysfs_bin_attr_init(&attrs[i]); > > - attrs[i].attr.name = devm_kstrdup(&nvmem->dev, entry->name, GFP_KERNEL); > > + attrs[i].attr.name = devm_kasprintf(&nvmem->dev, GFP_KERNEL, > > + "%s@%d", entry->name, > > + entry->offset); > > Shouldn't we use %s@%x instead to match the DT descriptions? True, I agree. > > > attrs[i].attr.mode = 0444; > > attrs[i].size = entry->bytes; > > attrs[i].read = &nvmem_cell_attr_read; > > I plan another version of the series which triggered these patches, if > you don't mind I will squash patch 1 into my patches and pick this one > as a preparation change (likely with the above fix if you agree and > without the Fixes tag). Yes, sure, please go ahead. Cheers Daniel > > Thanks, > Miquèl
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 70e951088826d..90fe9dc30f8ba 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -480,7 +480,9 @@ static int nvmem_populate_sysfs_cells(struct nvmem_device *nvmem) /* Initialize each attribute to take the name and size of the cell */ list_for_each_entry(entry, &nvmem->cells, node) { sysfs_bin_attr_init(&attrs[i]); - attrs[i].attr.name = devm_kstrdup(&nvmem->dev, entry->name, GFP_KERNEL); + attrs[i].attr.name = devm_kasprintf(&nvmem->dev, GFP_KERNEL, + "%s@%d", entry->name, + entry->offset); attrs[i].attr.mode = 0444; attrs[i].size = entry->bytes; attrs[i].read = &nvmem_cell_attr_read;