Linux-OMAP Archive on lore.kernel.org
 help / color / Atom feed
* [RESEND PATCH v2] mfd: syscon: Use a unique name with regmap_config
@ 2020-07-27 21:10 Suman Anna
  2020-07-28  7:44 ` Arnd Bergmann
  2020-07-28  8:01 ` Lee Jones
  0 siblings, 2 replies; 4+ messages in thread
From: Suman Anna @ 2020-07-27 21:10 UTC (permalink / raw)
  To: Lee Jones, Arnd Bergmann
  Cc: Grzegorz Jaszczyk, David Lechner, Tony Lindgren, Roger Quadros,
	linux-kernel, linux-arm-kernel, linux-omap, Suman Anna

The DT node full name is currently being used in regmap_config
which in turn is used to create the regmap debugfs directories.
This name however is not guaranteed to be unique and the regmap
debugfs registration can fail in the cases where the syscon nodes
have the same unit-address but are present in different DT node
hierarchies. Replace this logic using the syscon reg resource
address instead (inspired from logic used while creating platform
devices) to ensure a unique name is given for each syscon.

Signed-off-by: Suman Anna <s-anna@ti.com>
---
Hi Arnd,
Lee is looking for your review on this patch. Can you please
review and provide your comments.

This is a resend of the patch that was posted previously, rebased
now onto latest kernel.

v2: https://patchwork.kernel.org/patch/11353355/
 - Fix build warning reported by kbuild test bot
v1: https://patchwork.kernel.org/patch/11346363/

 drivers/mfd/syscon.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 3a97816d0cba..75859e492984 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -101,12 +101,14 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_clk)
 		}
 	}
 
-	syscon_config.name = of_node_full_name(np);
+	syscon_config.name = kasprintf(GFP_KERNEL, "%pOFn@%llx", np,
+				       (u64)res.start);
 	syscon_config.reg_stride = reg_io_width;
 	syscon_config.val_bits = reg_io_width * 8;
 	syscon_config.max_register = resource_size(&res) - reg_io_width;
 
 	regmap = regmap_init_mmio(NULL, base, &syscon_config);
+	kfree(syscon_config.name);
 	if (IS_ERR(regmap)) {
 		pr_err("regmap init failed\n");
 		ret = PTR_ERR(regmap);
-- 
2.26.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RESEND PATCH v2] mfd: syscon: Use a unique name with regmap_config
  2020-07-27 21:10 [RESEND PATCH v2] mfd: syscon: Use a unique name with regmap_config Suman Anna
@ 2020-07-28  7:44 ` Arnd Bergmann
  2020-07-28 15:34   ` Suman Anna
  2020-07-28  8:01 ` Lee Jones
  1 sibling, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2020-07-28  7:44 UTC (permalink / raw)
  To: Suman Anna
  Cc: Lee Jones, Grzegorz Jaszczyk, David Lechner, Tony Lindgren,
	Roger Quadros, linux-kernel, Linux ARM, linux-omap

On Mon, Jul 27, 2020 at 11:10 PM Suman Anna <s-anna@ti.com> wrote:
>
> The DT node full name is currently being used in regmap_config
> which in turn is used to create the regmap debugfs directories.
> This name however is not guaranteed to be unique and the regmap
> debugfs registration can fail in the cases where the syscon nodes
> have the same unit-address but are present in different DT node
> hierarchies. Replace this logic using the syscon reg resource
> address instead (inspired from logic used while creating platform
> devices) to ensure a unique name is given for each syscon.
>
> Signed-off-by: Suman Anna <s-anna@ti.com>
> ---
> Hi Arnd,
> Lee is looking for your review on this patch. Can you please
> review and provide your comments.

Sorry for missing this earlier. I think this makes sense, and I don't
expect the name change to cause problems, so

Reviewed-by: Arnd Bergmann <arnd@arndb.de>

> --- a/drivers/mfd/syscon.c
> +++ b/drivers/mfd/syscon.c
> @@ -101,12 +101,14 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_clk)
>                 }
>         }
>
> -       syscon_config.name = of_node_full_name(np);
> +       syscon_config.name = kasprintf(GFP_KERNEL, "%pOFn@%llx", np,
> +                                      (u64)res.start);

Note that you could avoid the cast by using "%pOFn@%pa", and
passing res.start by reference. Not important though, the result should
be similar, and you might not like the '0x' that this adds.

      Arnd

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RESEND PATCH v2] mfd: syscon: Use a unique name with regmap_config
  2020-07-27 21:10 [RESEND PATCH v2] mfd: syscon: Use a unique name with regmap_config Suman Anna
  2020-07-28  7:44 ` Arnd Bergmann
@ 2020-07-28  8:01 ` Lee Jones
  1 sibling, 0 replies; 4+ messages in thread
From: Lee Jones @ 2020-07-28  8:01 UTC (permalink / raw)
  To: Suman Anna
  Cc: Arnd Bergmann, Grzegorz Jaszczyk, David Lechner, Tony Lindgren,
	Roger Quadros, linux-kernel, linux-arm-kernel, linux-omap

On Mon, 27 Jul 2020, Suman Anna wrote:

> The DT node full name is currently being used in regmap_config
> which in turn is used to create the regmap debugfs directories.
> This name however is not guaranteed to be unique and the regmap
> debugfs registration can fail in the cases where the syscon nodes
> have the same unit-address but are present in different DT node
> hierarchies. Replace this logic using the syscon reg resource
> address instead (inspired from logic used while creating platform
> devices) to ensure a unique name is given for each syscon.
> 
> Signed-off-by: Suman Anna <s-anna@ti.com>
> ---
> Hi Arnd,
> Lee is looking for your review on this patch. Can you please
> review and provide your comments.
> 
> This is a resend of the patch that was posted previously, rebased
> now onto latest kernel.
> 
> v2: https://patchwork.kernel.org/patch/11353355/
>  - Fix build warning reported by kbuild test bot
> v1: https://patchwork.kernel.org/patch/11346363/
> 
>  drivers/mfd/syscon.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Applied, thanks.

-- 
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RESEND PATCH v2] mfd: syscon: Use a unique name with regmap_config
  2020-07-28  7:44 ` Arnd Bergmann
@ 2020-07-28 15:34   ` Suman Anna
  0 siblings, 0 replies; 4+ messages in thread
From: Suman Anna @ 2020-07-28 15:34 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Lee Jones, Grzegorz Jaszczyk, David Lechner, Tony Lindgren,
	Roger Quadros, linux-kernel, Linux ARM, linux-omap

On 7/28/20 2:44 AM, Arnd Bergmann wrote:
> On Mon, Jul 27, 2020 at 11:10 PM Suman Anna <s-anna@ti.com> wrote:
>>
>> The DT node full name is currently being used in regmap_config
>> which in turn is used to create the regmap debugfs directories.
>> This name however is not guaranteed to be unique and the regmap
>> debugfs registration can fail in the cases where the syscon nodes
>> have the same unit-address but are present in different DT node
>> hierarchies. Replace this logic using the syscon reg resource
>> address instead (inspired from logic used while creating platform
>> devices) to ensure a unique name is given for each syscon.
>>
>> Signed-off-by: Suman Anna <s-anna@ti.com>
>> ---
>> Hi Arnd,
>> Lee is looking for your review on this patch. Can you please
>> review and provide your comments.
> 
> Sorry for missing this earlier. I think this makes sense, and I don't
> expect the name change to cause problems, so
> 
> Reviewed-by: Arnd Bergmann <arnd@arndb.de>

Thanks Arnd.

> 
>> --- a/drivers/mfd/syscon.c
>> +++ b/drivers/mfd/syscon.c
>> @@ -101,12 +101,14 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_clk)
>>                  }
>>          }
>>
>> -       syscon_config.name = of_node_full_name(np);
>> +       syscon_config.name = kasprintf(GFP_KERNEL, "%pOFn@%llx", np,
>> +                                      (u64)res.start);
> 
> Note that you could avoid the cast by using "%pOFn@%pa", and
> passing res.start by reference. Not important though, the result should
> be similar, and you might not like the '0x' that this adds.

Yeah, preference was not to add the leading 0x or any leading 0s. We did 
discuss about this on the original v2 submission [1].

regards
Suman

[1] https://patchwork.kernel.org/comment/23129393/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-27 21:10 [RESEND PATCH v2] mfd: syscon: Use a unique name with regmap_config Suman Anna
2020-07-28  7:44 ` Arnd Bergmann
2020-07-28 15:34   ` Suman Anna
2020-07-28  8:01 ` Lee Jones

Linux-OMAP Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-omap/0 linux-omap/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-omap linux-omap/ https://lore.kernel.org/linux-omap \
		linux-omap@vger.kernel.org
	public-inbox-index linux-omap

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-omap


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git