From patchwork Tue Jul 18 13:55:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 122073 Return-Path: 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 + 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 ); 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 ; 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 ) id 1qLlBQ-0008CI-03; Tue, 18 Jul 2023 13:56:08 +0000 Date: Tue, 18 Jul 2023 14:55:57 +0100 From: Daniel Golle To: Miquel Raynal , Greg Kroah-Hartman , Srinivas Kandagatla , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] nvmem: core: append offset to cell name in sysfs Message-ID: MIME-Version: 1.0 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771769245688508973 X-GMAIL-MSGID: 1771769245688508973 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 --- 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); attrs[i].attr.mode = 0444; attrs[i].size = entry->bytes; attrs[i].read = &nvmem_cell_attr_read;