* [PATCH 2/2] nvmem: core: append offset to cell name in sysfs
@ 2023-07-18 13:55 Daniel Golle
2023-07-18 14:44 ` Greg Kroah-Hartman
2023-07-31 15:45 ` Miquel Raynal
0 siblings, 2 replies; 4+ messages in thread
From: Daniel Golle @ 2023-07-18 13:55 UTC (permalink / raw)
To: Miquel Raynal, Greg Kroah-Hartman, Srinivas Kandagatla,
linux-kernel
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);
attrs[i].attr.mode = 0444;
attrs[i].size = entry->bytes;
attrs[i].read = &nvmem_cell_attr_read;
--
2.41.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] nvmem: core: append offset to cell name in sysfs
2023-07-18 13:55 [PATCH 2/2] nvmem: core: append offset to cell name in sysfs Daniel Golle
@ 2023-07-18 14:44 ` Greg Kroah-Hartman
2023-07-31 15:45 ` Miquel Raynal
1 sibling, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2023-07-18 14:44 UTC (permalink / raw)
To: Daniel Golle; +Cc: Miquel Raynal, Srinivas Kandagatla, linux-kernel
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] nvmem: core: append offset to cell name in sysfs
2023-07-18 13:55 [PATCH 2/2] nvmem: core: append offset to cell name in sysfs Daniel Golle
2023-07-18 14:44 ` Greg Kroah-Hartman
@ 2023-07-31 15:45 ` Miquel Raynal
2023-07-31 15:54 ` Daniel Golle
1 sibling, 1 reply; 4+ messages in thread
From: Miquel Raynal @ 2023-07-31 15:45 UTC (permalink / raw)
To: Daniel Golle; +Cc: Greg Kroah-Hartman, Srinivas Kandagatla, linux-kernel
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] nvmem: core: append offset to cell name in sysfs
2023-07-31 15:45 ` Miquel Raynal
@ 2023-07-31 15:54 ` Daniel Golle
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Golle @ 2023-07-31 15:54 UTC (permalink / raw)
To: Miquel Raynal; +Cc: Greg Kroah-Hartman, Srinivas Kandagatla, linux-kernel
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-07-31 15:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-18 13:55 [PATCH 2/2] nvmem: core: append offset to cell name in sysfs Daniel Golle
2023-07-18 14:44 ` Greg Kroah-Hartman
2023-07-31 15:45 ` Miquel Raynal
2023-07-31 15:54 ` Daniel Golle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox