rockchip_rk3288_efuse_read: Fix segfault in rockchip_rk3288_efuse_read by using readl instead of readb when reading REG_EFUSE_DOUT.
diff mbox series

Message ID CAHmAUHKD90eibgj3JmHaJNduhrOQZUZBZixtZE+dWxR2L6Bq1Q@mail.gmail.com
State New
Headers show
Series
  • rockchip_rk3288_efuse_read: Fix segfault in rockchip_rk3288_efuse_read by using readl instead of readb when reading REG_EFUSE_DOUT.
Related show

Commit Message

Amr Bekhit Oct. 5, 2019, 7:50 a.m. UTC
When trying to read the efuse of the RK3188 a segfault is raised when
the following line is called in rockchip_rk3288_efuse_read:

*buf++ = readb(efuse->base + REG_EFUSE_DOUT);

It appears that the problem here might be the use of readb, which I
suspect is triggering an unaligned access. Changing this to readl
resolves the issue (as is done in rockchip_rk3399_efuse_read).

From 9923a6889aa325faf842a6757c9f9bd0f0195acb Mon Sep 17 00:00:00 2001
From: Amr Bekhit <amr@helmpcb.com>
Date: Sat, 5 Oct 2019 10:45:17 +0300
Subject: [PATCH] Fix segfault in rockchip_rk3288_efuse_read by using readl
 instead of readb when reading REG_EFUSE_DOUT.

Signed-off-by: Amr Bekhit <amr@helmpcb.com>
---
 drivers/nvmem/rockchip-efuse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

  udelay(1);

Patch
diff mbox series

diff --git a/drivers/nvmem/rockchip-efuse.c b/drivers/nvmem/rockchip-efuse.c
index e4579de5d014..f680a80d81cf 100644
--- a/drivers/nvmem/rockchip-efuse.c
+++ b/drivers/nvmem/rockchip-efuse.c
@@ -78,7 +78,7 @@  static int rockchip_rk3288_efuse_read(void *context,
unsigned int offset,
  writel(readl(efuse->base + REG_EFUSE_CTRL) |
       RK3288_STROBE, efuse->base + REG_EFUSE_CTRL);
  udelay(1);
- *buf++ = readb(efuse->base + REG_EFUSE_DOUT);
+ *buf++ = readl(efuse->base + REG_EFUSE_DOUT);
  writel(readl(efuse->base + REG_EFUSE_CTRL) &
         (~RK3288_STROBE), efuse->base + REG_EFUSE_CTRL);