All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] reset: stm32: Fix bank and offset computation
@ 2021-04-28 11:42 Patrice Chotard
  2021-05-04 14:01 ` Patrick DELAUNAY
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Patrice Chotard @ 2021-04-28 11:42 UTC (permalink / raw)
  To: u-boot

BITS_PER_LONG is used to represent register's size which is 32.
But when compiled on arch64, BITS_PER_LONG is then equal to 64.

Fix bank and offset computation to make it work on arch32 and
arch64 and ensure that register's size is always equal to 32.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Signed-off-by: Pankaj Dev <pankaj.dev@st.com>
---

 drivers/reset/stm32-reset.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/reset/stm32-reset.c b/drivers/reset/stm32-reset.c
index daa2e47ebb..bbc6b135a9 100644
--- a/drivers/reset/stm32-reset.c
+++ b/drivers/reset/stm32-reset.c
@@ -40,8 +40,8 @@ static int stm32_reset_free(struct reset_ctl *reset_ctl)
 static int stm32_reset_assert(struct reset_ctl *reset_ctl)
 {
 	struct stm32_reset_priv *priv = dev_get_priv(reset_ctl->dev);
-	int bank = (reset_ctl->id / BITS_PER_LONG) * 4;
-	int offset = reset_ctl->id % BITS_PER_LONG;
+	int bank = (reset_ctl->id / (sizeof(u32) * BITS_PER_BYTE)) * 4;
+	int offset = reset_ctl->id % (sizeof(u32) * BITS_PER_BYTE);
 
 	dev_dbg(reset_ctl->dev, "reset id = %ld bank = %d offset = %d)\n",
 		reset_ctl->id, bank, offset);
@@ -61,8 +61,8 @@ static int stm32_reset_assert(struct reset_ctl *reset_ctl)
 static int stm32_reset_deassert(struct reset_ctl *reset_ctl)
 {
 	struct stm32_reset_priv *priv = dev_get_priv(reset_ctl->dev);
-	int bank = (reset_ctl->id / BITS_PER_LONG) * 4;
-	int offset = reset_ctl->id % BITS_PER_LONG;
+	int bank = (reset_ctl->id / (sizeof(u32) * BITS_PER_BYTE)) * 4;
+	int offset = reset_ctl->id % (sizeof(u32) * BITS_PER_BYTE);
 
 	dev_dbg(reset_ctl->dev, "reset id = %ld bank = %d offset = %d)\n",
 		reset_ctl->id, bank, offset);
-- 
2.17.1

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

* [PATCH] reset: stm32: Fix bank and offset computation
  2021-04-28 11:42 [PATCH] reset: stm32: Fix bank and offset computation Patrice Chotard
@ 2021-05-04 14:01 ` Patrick DELAUNAY
  2021-05-28  9:36 ` Patrick DELAUNAY
  2021-05-28 12:36 ` Patrick DELAUNAY
  2 siblings, 0 replies; 4+ messages in thread
From: Patrick DELAUNAY @ 2021-05-04 14:01 UTC (permalink / raw)
  To: u-boot

Hi Patrice,

On 4/28/21 1:42 PM, Patrice Chotard wrote:
> BITS_PER_LONG is used to represent register's size which is 32.
> But when compiled on arch64, BITS_PER_LONG is then equal to 64.
>
> Fix bank and offset computation to make it work on arch32 and
> arch64 and ensure that register's size is always equal to 32.
>
> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
> Signed-off-by: Pankaj Dev <pankaj.dev@st.com>
> ---
>
>   drivers/reset/stm32-reset.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/reset/stm32-reset.c b/drivers/reset/stm32-reset.c
> index daa2e47ebb..bbc6b135a9 100644
> --- a/drivers/reset/stm32-reset.c
> +++ b/drivers/reset/stm32-reset.c
> @@ -40,8 +40,8 @@ static int stm32_reset_free(struct reset_ctl *reset_ctl)
>   static int stm32_reset_assert(struct reset_ctl *reset_ctl)
>   {
>   	struct stm32_reset_priv *priv = dev_get_priv(reset_ctl->dev);
> -	int bank = (reset_ctl->id / BITS_PER_LONG) * 4;
> -	int offset = reset_ctl->id % BITS_PER_LONG;
> +	int bank = (reset_ctl->id / (sizeof(u32) * BITS_PER_BYTE)) * 4;
> +	int offset = reset_ctl->id % (sizeof(u32) * BITS_PER_BYTE);
>   
>   	dev_dbg(reset_ctl->dev, "reset id = %ld bank = %d offset = %d)\n",
>   		reset_ctl->id, bank, offset);
> @@ -61,8 +61,8 @@ static int stm32_reset_assert(struct reset_ctl *reset_ctl)
>   static int stm32_reset_deassert(struct reset_ctl *reset_ctl)
>   {
>   	struct stm32_reset_priv *priv = dev_get_priv(reset_ctl->dev);
> -	int bank = (reset_ctl->id / BITS_PER_LONG) * 4;
> -	int offset = reset_ctl->id % BITS_PER_LONG;
> +	int bank = (reset_ctl->id / (sizeof(u32) * BITS_PER_BYTE)) * 4;
> +	int offset = reset_ctl->id % (sizeof(u32) * BITS_PER_BYTE);
>   
>   	dev_dbg(reset_ctl->dev, "reset id = %ld bank = %d offset = %d)\n",
>   		reset_ctl->id, bank, offset);


Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

Thanks
Patrick

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

* Re: [PATCH] reset: stm32: Fix bank and offset computation
  2021-04-28 11:42 [PATCH] reset: stm32: Fix bank and offset computation Patrice Chotard
  2021-05-04 14:01 ` Patrick DELAUNAY
@ 2021-05-28  9:36 ` Patrick DELAUNAY
  2021-05-28 12:36 ` Patrick DELAUNAY
  2 siblings, 0 replies; 4+ messages in thread
From: Patrick DELAUNAY @ 2021-05-28  9:36 UTC (permalink / raw)
  To: Patrice Chotard, u-boot; +Cc: U-Boot STM32, Pankaj Dev

Hi,

On 4/28/21 1:42 PM, Patrice Chotard wrote:
> BITS_PER_LONG is used to represent register's size which is 32.
> But when compiled on arch64, BITS_PER_LONG is then equal to 64.
>
> Fix bank and offset computation to make it work on arch32 and
> arch64 and ensure that register's size is always equal to 32.
>
> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
> Signed-off-by: Pankaj Dev <pankaj.dev@st.com>
> ---
>
>   drivers/reset/stm32-reset.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
>

Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

Thanks
Patrick


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

* Re: [PATCH] reset: stm32: Fix bank and offset computation
  2021-04-28 11:42 [PATCH] reset: stm32: Fix bank and offset computation Patrice Chotard
  2021-05-04 14:01 ` Patrick DELAUNAY
  2021-05-28  9:36 ` Patrick DELAUNAY
@ 2021-05-28 12:36 ` Patrick DELAUNAY
  2 siblings, 0 replies; 4+ messages in thread
From: Patrick DELAUNAY @ 2021-05-28 12:36 UTC (permalink / raw)
  To: Patrice Chotard, u-boot; +Cc: U-Boot STM32, Pankaj Dev


On 4/28/21 1:42 PM, Patrice Chotard wrote:
> BITS_PER_LONG is used to represent register's size which is 32.
> But when compiled on arch64, BITS_PER_LONG is then equal to 64.
>
> Fix bank and offset computation to make it work on arch32 and
> arch64 and ensure that register's size is always equal to 32.
>
> Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
> Signed-off-by: Pankaj Dev <pankaj.dev@st.com>
> ---
>
>   drivers/reset/stm32-reset.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
>

Applied to u-boot-stm/master, thanks!

Regards
Patrick


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

end of thread, other threads:[~2021-05-28 12:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-28 11:42 [PATCH] reset: stm32: Fix bank and offset computation Patrice Chotard
2021-05-04 14:01 ` Patrick DELAUNAY
2021-05-28  9:36 ` Patrick DELAUNAY
2021-05-28 12:36 ` Patrick DELAUNAY

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.