summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrice Chotard <patrice.chotard@foss.st.com>2021-04-28 13:42:45 +0200
committerPatrick Delaunay <patrick.delaunay@foss.st.com>2021-05-28 11:24:02 +0200
commit6d734be905ef16043471dca6ce5495a905a8590f (patch)
tree27c8cad7caf1b1b5b7ba71b3756ac407f5f2f97a
parenta5bb384caa050660220270beb19452bbe927a72b (diff)
downloadu-boot-6d734be905ef16043471dca6ce5495a905a8590f.tar.gz
u-boot-6d734be905ef16043471dca6ce5495a905a8590f.tar.xz
u-boot-6d734be905ef16043471dca6ce5495a905a8590f.zip
reset: stm32: Fix bank and offset computation
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> Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
-rw-r--r--drivers/reset/stm32-reset.c8
1 files 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);