Message ID | 20230417-ux500-sram-v1-2-5924988bb835@linaro.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1947964vqo; Mon, 17 Apr 2023 00:49:20 -0700 (PDT) X-Google-Smtp-Source: AKy350Y3uSGTcM0LUbEWgKSw/wVd3BNJXFdAq7uzuzTAbvPljdYuRg2A8+AKFtFgaxd1cykUgbn2 X-Received: by 2002:a17:90b:1090:b0:247:944d:b75e with SMTP id gj16-20020a17090b109000b00247944db75emr2620826pjb.12.1681717759754; Mon, 17 Apr 2023 00:49:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681717759; cv=none; d=google.com; s=arc-20160816; b=mOT63g7TAILga8qzU0/VrNthSuC4rbNr4awszqFWxClKc2K4oWrtMVlGweFOH4Cn2G zU4kThe7d63tQNKyLAL9qnkTM1mJAMZD6zuA+21LD41qP/K3A8kWjWAV8aqQkvPoN8VN hgtf0x/n2yQhc2nQICebStdHZAUV00bzJqkHX2uPfEnZUis6nRJaH/uhVEbMjmc8w2G8 wR9l6TnrUGWFeqvJl2Euu2+9uO9KPBbAYL1ZsZ7e0kjvx+n83FgAnBCqxGjOdFlJRQIk /+eKz/FtVLeICOoRKcJKMtdp4pSnTrJV36ye6FKPZ5S1Dkpoa+HycWPn8FKkmp4kY26/ 5iag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=n47v9+PzhQgXr23TTNhsK7isjIIKM72ZIjxtKH7ks7Q=; b=nC1pDs17KOzigBra3BXW40ZEZbkVW1c1jiBUWFHoEaEFm/Tdza9Aj+inWbSuzv5dNL V6UG6KdEFrM6IowDBfgOvFCnRLdMAe3IG5OI5jBxbp+l5uHaaHYuV1Mx/S6EYGFqshGR 1i1syllfCoE2bX9veioxM97/li9Lx27GqXoSTX0OaCsZLTjCW4l5rvlvVkjXEzCncC5D BiiOfnb+fz5pKhHR6M7FYkFuZH+65t6JMTk7Nov3qZdEE6PgghtIEMrjPVfqGk1/GarY mv017bPZVpdYeeH1Bi3bE7dDR0QKB9OzGGUrXM8WY2YMAR8K5Gjoe9tHSYUON0eWeU5H ziUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q5yMGpOV; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h189-20020a6383c6000000b0051e011fcd73si1891683pge.237.2023.04.17.00.49.04; Mon, 17 Apr 2023 00:49:19 -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=@linaro.org header.s=google header.b=q5yMGpOV; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229573AbjDQHg5 (ORCPT <rfc822;leviz.kernel.dev@gmail.com> + 99 others); Mon, 17 Apr 2023 03:36:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230450AbjDQHgS (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 17 Apr 2023 03:36:18 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21542468D for <linux-kernel@vger.kernel.org>; Mon, 17 Apr 2023 00:35:04 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-4ec8da7aaf8so1241996e87.2 for <linux-kernel@vger.kernel.org>; Mon, 17 Apr 2023 00:35:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681716899; x=1684308899; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=n47v9+PzhQgXr23TTNhsK7isjIIKM72ZIjxtKH7ks7Q=; b=q5yMGpOVyeyFCk+S0Ffj+uDLwQX1UOOr4uKsV6Wz3P69P9eIzxL57eahmDFLtoDCr1 9spzByynB6vOIJTvgD7o6auKxzc2fYDstW89N7lKOyWaiY0NSOUN07Ex2YGqUndJFVZH CtdBourk1Fb4eUKGsqmtvcb+tEvXtOgqVeWpYpBuOye580U/kPK7DAwVs/vfgpGNEhRa KkmmtCCvYs7xHeMWe/2gEvzOSfMU/4aHSDTXUYdVCBuzie7kNpu2y3DPT8x4GkMP3Kd8 dJRSXuYdOkz7x7DCcOyg6oMFtGMldgtB900Fv1ysiJkIYjsrJxiZA4FO1hfhotwxS93A o1Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681716899; x=1684308899; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n47v9+PzhQgXr23TTNhsK7isjIIKM72ZIjxtKH7ks7Q=; b=hBgVNhzRXSMsr7GFFZKADvTBBu9TUY+pb9ZBihYSmab5GOpgUQyIY6IFsnkjUII6ml 2jl0GNGZsYokCF9MxS/E26i5KQAzN5gSaoTpT0w57Spqr8hYhKoT4NWcSXP+Sf0df5LG G7guPe1ws3xKUa5J369Dxg4Y/puH4LUYNASWdZQ54KoEBOA0LYbmyqGBNGmMe3Y37orv rAO95IeJG2BxoPlq0SigarlyWvT/ltPfpJ2JqQYqW3eGJSoVD9gxTWSAmpbmQdIqYLU8 3TPq0O6JqABur+hW73vxM58+6Zyz2aL4sWEbg//nCF7iDJT55yZw8B1gQbw+TsjarEej SA/g== X-Gm-Message-State: AAQBX9cf6cYelxRHgtC1rbALtHJAWF3ZTcElDWQjREcf7cO3abGciuxv ue2ST0sm7jYGV+ZkJv9Wu2sF+w== X-Received: by 2002:ac2:4848:0:b0:4db:28ce:e5ef with SMTP id 8-20020ac24848000000b004db28cee5efmr1635960lfy.0.1681716899646; Mon, 17 Apr 2023 00:34:59 -0700 (PDT) Received: from [192.168.1.2] (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id w15-20020a056512098f00b004eb2f35045bsm1956275lft.269.2023.04.17.00.34.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 00:34:59 -0700 (PDT) From: Linus Walleij <linus.walleij@linaro.org> Date: Mon, 17 Apr 2023 09:34:57 +0200 Subject: [PATCH 2/2] misc: sram: Generate unique names for subpools MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230417-ux500-sram-v1-2-5924988bb835@linaro.org> References: <20230417-ux500-sram-v1-0-5924988bb835@linaro.org> In-Reply-To: <20230417-ux500-sram-v1-0-5924988bb835@linaro.org> To: Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Arnd Bergmann <arnd@arndb.de>, Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Rob Herring <robh@kernel.org>, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Walleij <linus.walleij@linaro.org> X-Mailer: b4 0.12.2 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_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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?1763408881584182673?= X-GMAIL-MSGID: =?utf-8?q?1763408881584182673?= |
Series |
SRAM dt binding and fix
|
|
Commit Message
Linus Walleij
April 17, 2023, 7:34 a.m. UTC
The current code will, if we do not specify unique labels
for the SRAM subnodes, fail to register several nodes named
the same.
Example:
sram@40020000 {
(...)
sram@0 {
(...)
};
sram@1000 {
(...)
};
};
Since the child->name in both cases will be "sram" the
gen_pool_create() will fail because the name is not unique.
So let's use of_full_node_name() instead of child->name
so the name is "sram@0" and "sram@1000" respectively.
However if there are two or more SRAMs on the system
with subnodes named the same (that exists on the U8500)
then this again will not work. So catenate the top node
name and the subnode full name to form a string that will
always be unique.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/misc/sram.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
Comments
On Mon, Apr 17, 2023 at 09:34:57AM +0200, Linus Walleij wrote: > The current code will, if we do not specify unique labels > for the SRAM subnodes, fail to register several nodes named > the same. > > Example: > > sram@40020000 { > (...) > sram@0 { > (...) > }; > sram@1000 { > (...) > }; > }; > > Since the child->name in both cases will be "sram" the > gen_pool_create() will fail because the name is not unique. > So let's use of_full_node_name() instead of child->name > so the name is "sram@0" and "sram@1000" respectively. > > However if there are two or more SRAMs on the system > with subnodes named the same (that exists on the U8500) > then this again will not work. So catenate the top node > name and the subnode full name to form a string that will > always be unique. Use the naming platform devices use which has the translated address. How the addresses are defined should not affect the device name. Rob
On Wed, Apr 19, 2023 at 12:38 AM Rob Herring <robh@kernel.org> wrote: > On Mon, Apr 17, 2023 at 09:34:57AM +0200, Linus Walleij wrote: > > The current code will, if we do not specify unique labels > > for the SRAM subnodes, fail to register several nodes named > > the same. > > > > Example: > > > > sram@40020000 { > > (...) > > sram@0 { > > (...) > > }; > > sram@1000 { > > (...) > > }; > > }; > > > > Since the child->name in both cases will be "sram" the > > gen_pool_create() will fail because the name is not unique. > > So let's use of_full_node_name() instead of child->name > > so the name is "sram@0" and "sram@1000" respectively. > > > > However if there are two or more SRAMs on the system > > with subnodes named the same (that exists on the U8500) > > then this again will not work. So catenate the top node > > name and the subnode full name to form a string that will > > always be unique. > > Use the naming platform devices use which has the translated address. > How the addresses are defined should not affect the device name. Aha just dev_name(&pdev->dev) I'll try this, thanks! Yours, Linus Walleij
diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c index f0e7f02605eb..84d4e090678b 100644 --- a/drivers/misc/sram.c +++ b/drivers/misc/sram.c @@ -240,10 +240,12 @@ static int sram_reserve_regions(struct sram_dev *sram, struct resource *res) goto err_chunks; } if (!label) - label = child->name; - - block->label = devm_kstrdup(sram->dev, - label, GFP_KERNEL); + block->label = devm_kasprintf(sram->dev, GFP_KERNEL, + "%s-%s", dev_name(sram->dev), + of_node_full_name(child)); + else + block->label = devm_kstrdup(sram->dev, + label, GFP_KERNEL); if (!block->label) { ret = -ENOMEM; goto err_chunks;