* [PATCH] clk: socfpga: fix iomem pointer cast on 64-bit
@ 2021-03-11 14:48 Krzysztof Kozlowski
2021-03-11 16:03 ` Dinh Nguyen
2021-03-13 21:10 ` Stephen Boyd
0 siblings, 2 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2021-03-11 14:48 UTC (permalink / raw)
To: Dinh Nguyen, Michael Turquette, Stephen Boyd, linux-clk, linux-kernel
Cc: Arnd Bergmann, Krzysztof Kozlowski
Pointers should be cast to unsigned long instead of integer. This fixes
warning when compile testing on ARM64:
drivers/clk/socfpga/clk-gate.c: In function ‘socfpga_clk_recalc_rate’:
drivers/clk/socfpga/clk-gate.c:102:7: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
drivers/clk/socfpga/clk-gate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/clk/socfpga/clk-gate.c b/drivers/clk/socfpga/clk-gate.c
index 43ecd507bf83..c876523d5d51 100644
--- a/drivers/clk/socfpga/clk-gate.c
+++ b/drivers/clk/socfpga/clk-gate.c
@@ -99,7 +99,7 @@ static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk,
val = readl(socfpgaclk->div_reg) >> socfpgaclk->shift;
val &= GENMASK(socfpgaclk->width - 1, 0);
/* Check for GPIO_DB_CLK by its offset */
- if ((int) socfpgaclk->div_reg & SOCFPGA_GPIO_DB_CLK_OFFSET)
+ if ((unsigned long) socfpgaclk->div_reg & SOCFPGA_GPIO_DB_CLK_OFFSET)
div = val + 1;
else
div = (1 << val);
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] clk: socfpga: fix iomem pointer cast on 64-bit
2021-03-11 14:48 [PATCH] clk: socfpga: fix iomem pointer cast on 64-bit Krzysztof Kozlowski
@ 2021-03-11 16:03 ` Dinh Nguyen
2021-03-13 21:10 ` Stephen Boyd
1 sibling, 0 replies; 4+ messages in thread
From: Dinh Nguyen @ 2021-03-11 16:03 UTC (permalink / raw)
To: Krzysztof Kozlowski, Michael Turquette, Stephen Boyd, linux-clk,
linux-kernel
Cc: Arnd Bergmann
On 3/11/21 8:48 AM, Krzysztof Kozlowski wrote:
> Pointers should be cast to unsigned long instead of integer. This fixes
> warning when compile testing on ARM64:
>
> drivers/clk/socfpga/clk-gate.c: In function ‘socfpga_clk_recalc_rate’:
> drivers/clk/socfpga/clk-gate.c:102:7: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
> ---
> drivers/clk/socfpga/clk-gate.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/clk/socfpga/clk-gate.c b/drivers/clk/socfpga/clk-gate.c
> index 43ecd507bf83..c876523d5d51 100644
> --- a/drivers/clk/socfpga/clk-gate.c
> +++ b/drivers/clk/socfpga/clk-gate.c
> @@ -99,7 +99,7 @@ static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk,
> val = readl(socfpgaclk->div_reg) >> socfpgaclk->shift;
> val &= GENMASK(socfpgaclk->width - 1, 0);
> /* Check for GPIO_DB_CLK by its offset */
> - if ((int) socfpgaclk->div_reg & SOCFPGA_GPIO_DB_CLK_OFFSET)
> + if ((unsigned long) socfpgaclk->div_reg & SOCFPGA_GPIO_DB_CLK_OFFSET)
> div = val + 1;
> else
> div = (1 << val);
>
Acked-by: Dinh Nguyen <dinguyen@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] clk: socfpga: fix iomem pointer cast on 64-bit
2021-03-11 14:48 [PATCH] clk: socfpga: fix iomem pointer cast on 64-bit Krzysztof Kozlowski
2021-03-11 16:03 ` Dinh Nguyen
@ 2021-03-13 21:10 ` Stephen Boyd
2021-03-14 11:04 ` Krzysztof Kozlowski
1 sibling, 1 reply; 4+ messages in thread
From: Stephen Boyd @ 2021-03-13 21:10 UTC (permalink / raw)
To: Dinh Nguyen, Krzysztof Kozlowski, Michael Turquette, linux-clk,
linux-kernel
Cc: Arnd Bergmann, Krzysztof Kozlowski
Quoting Krzysztof Kozlowski (2021-03-11 06:48:33)
> Pointers should be cast to unsigned long instead of integer. This fixes
> warning when compile testing on ARM64:
>
> drivers/clk/socfpga/clk-gate.c: In function ‘socfpga_clk_recalc_rate’:
> drivers/clk/socfpga/clk-gate.c:102:7: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Any Fixes tag?
> ---
> drivers/clk/socfpga/clk-gate.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/clk/socfpga/clk-gate.c b/drivers/clk/socfpga/clk-gate.c
> index 43ecd507bf83..c876523d5d51 100644
> --- a/drivers/clk/socfpga/clk-gate.c
> +++ b/drivers/clk/socfpga/clk-gate.c
> @@ -99,7 +99,7 @@ static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk,
> val = readl(socfpgaclk->div_reg) >> socfpgaclk->shift;
> val &= GENMASK(socfpgaclk->width - 1, 0);
> /* Check for GPIO_DB_CLK by its offset */
> - if ((int) socfpgaclk->div_reg & SOCFPGA_GPIO_DB_CLK_OFFSET)
> + if ((unsigned long) socfpgaclk->div_reg & SOCFPGA_GPIO_DB_CLK_OFFSET)
Should it be uintptr_t casted instead? This isn't a very great code
pattern given the way we store information in the iomem pointer about
which clk type it is and then have to cast the pointer and assume
alignment. Would be nice to get rid of it but I understand.
> div = val + 1;
> else
> div = (1 << val);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] clk: socfpga: fix iomem pointer cast on 64-bit
2021-03-13 21:10 ` Stephen Boyd
@ 2021-03-14 11:04 ` Krzysztof Kozlowski
0 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2021-03-14 11:04 UTC (permalink / raw)
To: Stephen Boyd, Dinh Nguyen, Michael Turquette, linux-clk, linux-kernel
Cc: Arnd Bergmann
On 13/03/2021 22:10, Stephen Boyd wrote:
> Quoting Krzysztof Kozlowski (2021-03-11 06:48:33)
>> Pointers should be cast to unsigned long instead of integer. This fixes
>> warning when compile testing on ARM64:
>>
>> drivers/clk/socfpga/clk-gate.c: In function ‘socfpga_clk_recalc_rate’:
>> drivers/clk/socfpga/clk-gate.c:102:7: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
>>
>> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
>
> Any Fixes tag?
I'll add it.
>
>> ---
>> drivers/clk/socfpga/clk-gate.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/clk/socfpga/clk-gate.c b/drivers/clk/socfpga/clk-gate.c
>> index 43ecd507bf83..c876523d5d51 100644
>> --- a/drivers/clk/socfpga/clk-gate.c
>> +++ b/drivers/clk/socfpga/clk-gate.c
>> @@ -99,7 +99,7 @@ static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk,
>> val = readl(socfpgaclk->div_reg) >> socfpgaclk->shift;
>> val &= GENMASK(socfpgaclk->width - 1, 0);
>> /* Check for GPIO_DB_CLK by its offset */
>> - if ((int) socfpgaclk->div_reg & SOCFPGA_GPIO_DB_CLK_OFFSET)
>> + if ((unsigned long) socfpgaclk->div_reg & SOCFPGA_GPIO_DB_CLK_OFFSET)
>
> Should it be uintptr_t casted instead?
Good point, thanks!
> his isn't a very great code
> pattern given the way we store information in the iomem pointer about
> which clk type it is and then have to cast the pointer and assume
> alignment. Would be nice to get rid of it but I understand.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-03-14 11:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-11 14:48 [PATCH] clk: socfpga: fix iomem pointer cast on 64-bit Krzysztof Kozlowski
2021-03-11 16:03 ` Dinh Nguyen
2021-03-13 21:10 ` Stephen Boyd
2021-03-14 11:04 ` Krzysztof Kozlowski
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.