From: Linus Walleij <linus.walleij@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>
Subject: [PATCH 2/2] misc: sram: Generate unique names for subpools
Date: Mon, 17 Apr 2023 09:34:57 +0200 [thread overview]
Message-ID: <20230417-ux500-sram-v1-2-5924988bb835@linaro.org> (raw)
In-Reply-To: <20230417-ux500-sram-v1-0-5924988bb835@linaro.org>
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(-)
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;
--
2.39.2
next prev parent reply other threads:[~2023-04-17 7:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-17 7:34 [PATCH 0/2] SRAM dt binding and fix Linus Walleij
2023-04-17 7:34 ` [PATCH 1/2] dt-bindings: sram: Add compatible for ST-Ericsson U8500 eSRAM Linus Walleij
2023-04-18 22:38 ` Rob Herring
2023-04-17 7:34 ` Linus Walleij [this message]
2023-04-18 22:38 ` [PATCH 2/2] misc: sram: Generate unique names for subpools Rob Herring
2023-04-19 12:56 ` Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230417-ux500-sram-v1-2-5924988bb835@linaro.org \
--to=linus.walleij@linaro.org \
--cc=arnd@arndb.de \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).