All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rtc: sunplus: fix format string for printing resource
@ 2023-01-17 17:24 Arnd Bergmann
  2023-01-17 17:55 ` Alexandre Belloni
  2023-01-23 22:34 ` Alexandre Belloni
  0 siblings, 2 replies; 6+ messages in thread
From: Arnd Bergmann @ 2023-01-17 17:24 UTC (permalink / raw)
  To: Vincent Shih, Alessandro Zummo, Alexandre Belloni
  Cc: Arnd Bergmann, linux-rtc, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

On 32-bit architectures with 64-bit resource_size_t, sp_rtc_probe()
causes a compiler warning:

drivers/rtc/rtc-sunplus.c: In function 'sp_rtc_probe':
drivers/rtc/rtc-sunplus.c:243:33: error: format '%x' expects argument of type 'unsigned int', but argument 4 has type 'resource_size_t' {aka 'long long unsigned int'} [-Werror=format=]
  243 |         dev_dbg(&plat_dev->dev, "res = 0x%x, reg_base = 0x%lx\n",
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The best way to print a resource is the special %pR format string,
and similarly to print a pointer we can use %p and avoid the cast.

Fixes: fad6cbe9b2b4 ("rtc: Add driver for RTC in Sunplus SP7021")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/rtc/rtc-sunplus.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-sunplus.c b/drivers/rtc/rtc-sunplus.c
index e8e2ab1103fc..4b578e4d44f6 100644
--- a/drivers/rtc/rtc-sunplus.c
+++ b/drivers/rtc/rtc-sunplus.c
@@ -240,8 +240,8 @@ static int sp_rtc_probe(struct platform_device *plat_dev)
 	if (IS_ERR(sp_rtc->reg_base))
 		return dev_err_probe(&plat_dev->dev, PTR_ERR(sp_rtc->reg_base),
 					    "%s devm_ioremap_resource fail\n", RTC_REG_NAME);
-	dev_dbg(&plat_dev->dev, "res = 0x%x, reg_base = 0x%lx\n",
-		sp_rtc->res->start, (unsigned long)sp_rtc->reg_base);
+	dev_dbg(&plat_dev->dev, "res = %pR, reg_base = %p\n",
+		sp_rtc->res, sp_rtc->reg_base);
 
 	sp_rtc->irq = platform_get_irq(plat_dev, 0);
 	if (sp_rtc->irq < 0)
-- 
2.39.0


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

* Re: [PATCH] rtc: sunplus: fix format string for printing resource
  2023-01-17 17:24 [PATCH] rtc: sunplus: fix format string for printing resource Arnd Bergmann
@ 2023-01-17 17:55 ` Alexandre Belloni
  2023-01-17 18:24   ` Randy Dunlap
  2023-01-23 22:34 ` Alexandre Belloni
  1 sibling, 1 reply; 6+ messages in thread
From: Alexandre Belloni @ 2023-01-17 17:55 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Vincent Shih, Alessandro Zummo, Arnd Bergmann, linux-rtc, linux-kernel

On 17/01/2023 18:24:44+0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> On 32-bit architectures with 64-bit resource_size_t, sp_rtc_probe()
> causes a compiler warning:
> 
> drivers/rtc/rtc-sunplus.c: In function 'sp_rtc_probe':
> drivers/rtc/rtc-sunplus.c:243:33: error: format '%x' expects argument of type 'unsigned int', but argument 4 has type 'resource_size_t' {aka 'long long unsigned int'} [-Werror=format=]
>   243 |         dev_dbg(&plat_dev->dev, "res = 0x%x, reg_base = 0x%lx\n",
>       |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> The best way to print a resource is the special %pR format string,
> and similarly to print a pointer we can use %p and avoid the cast.
> 

I got this one this morning, which one is more correct? :)
https://lore.kernel.org/all/20230117054232.24023-1-rdunlap@infradead.org/

> Fixes: fad6cbe9b2b4 ("rtc: Add driver for RTC in Sunplus SP7021")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/rtc/rtc-sunplus.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-sunplus.c b/drivers/rtc/rtc-sunplus.c
> index e8e2ab1103fc..4b578e4d44f6 100644
> --- a/drivers/rtc/rtc-sunplus.c
> +++ b/drivers/rtc/rtc-sunplus.c
> @@ -240,8 +240,8 @@ static int sp_rtc_probe(struct platform_device *plat_dev)
>  	if (IS_ERR(sp_rtc->reg_base))
>  		return dev_err_probe(&plat_dev->dev, PTR_ERR(sp_rtc->reg_base),
>  					    "%s devm_ioremap_resource fail\n", RTC_REG_NAME);
> -	dev_dbg(&plat_dev->dev, "res = 0x%x, reg_base = 0x%lx\n",
> -		sp_rtc->res->start, (unsigned long)sp_rtc->reg_base);
> +	dev_dbg(&plat_dev->dev, "res = %pR, reg_base = %p\n",
> +		sp_rtc->res, sp_rtc->reg_base);
>  
>  	sp_rtc->irq = platform_get_irq(plat_dev, 0);
>  	if (sp_rtc->irq < 0)
> -- 
> 2.39.0
> 

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

* Re: [PATCH] rtc: sunplus: fix format string for printing resource
  2023-01-17 17:55 ` Alexandre Belloni
@ 2023-01-17 18:24   ` Randy Dunlap
  2023-01-17 19:36     ` Arnd Bergmann
  0 siblings, 1 reply; 6+ messages in thread
From: Randy Dunlap @ 2023-01-17 18:24 UTC (permalink / raw)
  To: Alexandre Belloni, Arnd Bergmann
  Cc: Vincent Shih, Alessandro Zummo, Arnd Bergmann, linux-rtc, linux-kernel



On 1/17/23 09:55, Alexandre Belloni wrote:
> On 17/01/2023 18:24:44+0100, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@arndb.de>
>>
>> On 32-bit architectures with 64-bit resource_size_t, sp_rtc_probe()
>> causes a compiler warning:
>>
>> drivers/rtc/rtc-sunplus.c: In function 'sp_rtc_probe':
>> drivers/rtc/rtc-sunplus.c:243:33: error: format '%x' expects argument of type 'unsigned int', but argument 4 has type 'resource_size_t' {aka 'long long unsigned int'} [-Werror=format=]
>>   243 |         dev_dbg(&plat_dev->dev, "res = 0x%x, reg_base = 0x%lx\n",
>>       |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> The best way to print a resource is the special %pR format string,
>> and similarly to print a pointer we can use %p and avoid the cast.
>>
> 
> I got this one this morning, which one is more correct? :)
> https://lore.kernel.org/all/20230117054232.24023-1-rdunlap@infradead.org/

I prefer my handling of res->start and Arnd's no-cast handling of reg_base.
IMO using "%pR" prints too much info, but that's more up to the file's author
or maintainer...


How's that?  :)

>> Fixes: fad6cbe9b2b4 ("rtc: Add driver for RTC in Sunplus SP7021")
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>> ---
>>  drivers/rtc/rtc-sunplus.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/rtc/rtc-sunplus.c b/drivers/rtc/rtc-sunplus.c
>> index e8e2ab1103fc..4b578e4d44f6 100644
>> --- a/drivers/rtc/rtc-sunplus.c
>> +++ b/drivers/rtc/rtc-sunplus.c
>> @@ -240,8 +240,8 @@ static int sp_rtc_probe(struct platform_device *plat_dev)
>>  	if (IS_ERR(sp_rtc->reg_base))
>>  		return dev_err_probe(&plat_dev->dev, PTR_ERR(sp_rtc->reg_base),
>>  					    "%s devm_ioremap_resource fail\n", RTC_REG_NAME);
>> -	dev_dbg(&plat_dev->dev, "res = 0x%x, reg_base = 0x%lx\n",
>> -		sp_rtc->res->start, (unsigned long)sp_rtc->reg_base);
>> +	dev_dbg(&plat_dev->dev, "res = %pR, reg_base = %p\n",
>> +		sp_rtc->res, sp_rtc->reg_base);
>>  
>>  	sp_rtc->irq = platform_get_irq(plat_dev, 0);
>>  	if (sp_rtc->irq < 0)
>> -- 
>> 2.39.0
>>
> 

-- 
~Randy

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

* Re: [PATCH] rtc: sunplus: fix format string for printing resource
  2023-01-17 18:24   ` Randy Dunlap
@ 2023-01-17 19:36     ` Arnd Bergmann
  2023-01-18  0:56       ` Randy Dunlap
  0 siblings, 1 reply; 6+ messages in thread
From: Arnd Bergmann @ 2023-01-17 19:36 UTC (permalink / raw)
  To: Randy Dunlap, Alexandre Belloni, Arnd Bergmann
  Cc: Vincent Shih, Alessandro Zummo, linux-rtc, linux-kernel

On Tue, Jan 17, 2023, at 19:24, Randy Dunlap wrote:
> On 1/17/23 09:55, Alexandre Belloni wrote:
>> On 17/01/2023 18:24:44+0100, Arnd Bergmann wrote:
>>> From: Arnd Bergmann <arnd@arndb.de>
>>>
>>> On 32-bit architectures with 64-bit resource_size_t, sp_rtc_probe()
>>> causes a compiler warning:
>>>
>>> drivers/rtc/rtc-sunplus.c: In function 'sp_rtc_probe':
>>> drivers/rtc/rtc-sunplus.c:243:33: error: format '%x' expects argument of type 'unsigned int', but argument 4 has type 'resource_size_t' {aka 'long long unsigned int'} [-Werror=format=]
>>>   243 |         dev_dbg(&plat_dev->dev, "res = 0x%x, reg_base = 0x%lx\n",
>>>       |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>
>>> The best way to print a resource is the special %pR format string,
>>> and similarly to print a pointer we can use %p and avoid the cast.
>>>
>> 
>> I got this one this morning, which one is more correct? :)
>> https://lore.kernel.org/all/20230117054232.24023-1-rdunlap@infradead.org/

Both are equally correct, it's just a preference.

> I prefer my handling of res->start and Arnd's no-cast handling of reg_base.
> IMO using "%pR" prints too much info, but that's more up to the file's author
> or maintainer...

Right, I could have equally well picked the %pap version, and just
went for brevity in the source. It's only pr_debug(), so very few
users are going to actually see the output.

     Arnd

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

* Re: [PATCH] rtc: sunplus: fix format string for printing resource
  2023-01-17 19:36     ` Arnd Bergmann
@ 2023-01-18  0:56       ` Randy Dunlap
  0 siblings, 0 replies; 6+ messages in thread
From: Randy Dunlap @ 2023-01-18  0:56 UTC (permalink / raw)
  To: Arnd Bergmann, Alexandre Belloni, Arnd Bergmann
  Cc: Vincent Shih, Alessandro Zummo, linux-rtc, linux-kernel



On 1/17/23 11:36, Arnd Bergmann wrote:
> On Tue, Jan 17, 2023, at 19:24, Randy Dunlap wrote:
>> On 1/17/23 09:55, Alexandre Belloni wrote:
>>> On 17/01/2023 18:24:44+0100, Arnd Bergmann wrote:
>>>> From: Arnd Bergmann <arnd@arndb.de>
>>>>
>>>> On 32-bit architectures with 64-bit resource_size_t, sp_rtc_probe()
>>>> causes a compiler warning:
>>>>
>>>> drivers/rtc/rtc-sunplus.c: In function 'sp_rtc_probe':
>>>> drivers/rtc/rtc-sunplus.c:243:33: error: format '%x' expects argument of type 'unsigned int', but argument 4 has type 'resource_size_t' {aka 'long long unsigned int'} [-Werror=format=]
>>>>   243 |         dev_dbg(&plat_dev->dev, "res = 0x%x, reg_base = 0x%lx\n",
>>>>       |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>>
>>>> The best way to print a resource is the special %pR format string,
>>>> and similarly to print a pointer we can use %p and avoid the cast.
>>>>
>>>
>>> I got this one this morning, which one is more correct? :)
>>> https://lore.kernel.org/all/20230117054232.24023-1-rdunlap@infradead.org/
> 
> Both are equally correct, it's just a preference.
> 
>> I prefer my handling of res->start and Arnd's no-cast handling of reg_base.
>> IMO using "%pR" prints too much info, but that's more up to the file's author
>> or maintainer...
> 
> Right, I could have equally well picked the %pap version, and just
> went for brevity in the source. It's only pr_debug(), so very few
> users are going to actually see the output.

Alexandre, sounds like you should just go with Arnd's patch.

-- 
~Randy

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

* Re: [PATCH] rtc: sunplus: fix format string for printing resource
  2023-01-17 17:24 [PATCH] rtc: sunplus: fix format string for printing resource Arnd Bergmann
  2023-01-17 17:55 ` Alexandre Belloni
@ 2023-01-23 22:34 ` Alexandre Belloni
  1 sibling, 0 replies; 6+ messages in thread
From: Alexandre Belloni @ 2023-01-23 22:34 UTC (permalink / raw)
  To: Vincent Shih, Alessandro Zummo, Arnd Bergmann
  Cc: Arnd Bergmann, linux-rtc, linux-kernel


On Tue, 17 Jan 2023 18:24:44 +0100, Arnd Bergmann wrote:
> On 32-bit architectures with 64-bit resource_size_t, sp_rtc_probe()
> causes a compiler warning:
> 
> drivers/rtc/rtc-sunplus.c: In function 'sp_rtc_probe':
> drivers/rtc/rtc-sunplus.c:243:33: error: format '%x' expects argument of type 'unsigned int', but argument 4 has type 'resource_size_t' {aka 'long long unsigned int'} [-Werror=format=]
>   243 |         dev_dbg(&plat_dev->dev, "res = 0x%x, reg_base = 0x%lx\n",
>       |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> [...]

Applied, thanks!

[1/1] rtc: sunplus: fix format string for printing resource
      commit: 08279468a294d8c996a657ecc9e51bd5c084c75d


-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

end of thread, other threads:[~2023-01-23 22:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-17 17:24 [PATCH] rtc: sunplus: fix format string for printing resource Arnd Bergmann
2023-01-17 17:55 ` Alexandre Belloni
2023-01-17 18:24   ` Randy Dunlap
2023-01-17 19:36     ` Arnd Bergmann
2023-01-18  0:56       ` Randy Dunlap
2023-01-23 22:34 ` Alexandre Belloni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.