Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

misc: sram: Generate unique names for subpools

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.

Use dev_name() for the device as this will have bus ID
set to the fully translated address for the node, and that
will always be unique.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20230417-ux500-sram-v2-2-6e62ad551faa@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Linus Walleij and committed by
Greg Kroah-Hartman
b866e7e7 ca3222ac

+5 -4
+5 -4
drivers/misc/sram.c
··· 235 235 goto err_chunks; 236 236 } 237 237 if (!label) 238 - label = child->name; 239 - 240 - block->label = devm_kstrdup(sram->dev, 241 - label, GFP_KERNEL); 238 + block->label = devm_kasprintf(sram->dev, GFP_KERNEL, 239 + "%s", dev_name(sram->dev)); 240 + else 241 + block->label = devm_kstrdup(sram->dev, 242 + label, GFP_KERNEL); 242 243 if (!block->label) { 243 244 ret = -ENOMEM; 244 245 goto err_chunks;