From a5bb384caa050660220270beb19452bbe927a72b Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Wed, 10 Mar 2021 10:27:22 +0100 Subject: dfu: dfu_mtd: remove the mtd_block_op error when mtd_lock is not supported Fix the result of DFU_OP_WRITE operation in mtd_block_op function when mtd_lock is not supported (-EOPNOTSUPP) to avoid DFU stack error on the DFU manifestation of the MTD device, when dfu_flush_medium_mtd is called. Without this patch, dfu-util failed on dfuERROR state at the end of the write operation on the alternate even if MTD write opeartion is correctly performed. $> dfu-util -a 3 -D test.bin .... DFU mode device DFU version 0110 Device returned transfer size 4096 Copying data from PC to DFU device .... Download [=========================] 100% 225469 bytes Download done. state(10) = dfuERROR, status(14) = Something went wrong, but the device does not know what it was Done! Fixes: 65f3fc18fc1e ("dfu_mtd: Add provision to unlock mtd device") Signed-off-by: Patrick Delaunay Acked-by: Sughosh Ganu --- drivers/dfu/dfu_mtd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/dfu/dfu_mtd.c b/drivers/dfu/dfu_mtd.c index ca67585a7e..ec40b8f6bb 100644 --- a/drivers/dfu/dfu_mtd.c +++ b/drivers/dfu/dfu_mtd.c @@ -150,7 +150,9 @@ static int mtd_block_op(enum dfu_op op, struct dfu_entity *dfu, /* Write done, lock again */ debug("Locking the mtd device\n"); ret = mtd_lock(mtd, lock_ofs, lock_len); - if (ret && ret != -EOPNOTSUPP) + if (ret == -EOPNOTSUPP) + ret = 0; + else if (ret) printf("MTD device lock failed\n"); } return ret; -- cgit From 6d734be905ef16043471dca6ce5495a905a8590f Mon Sep 17 00:00:00 2001 From: Patrice Chotard Date: Wed, 28 Apr 2021 13:42:45 +0200 Subject: 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 Signed-off-by: Pankaj Dev Reviewed-by: Patrick Delaunay --- drivers/reset/stm32-reset.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers') 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); -- cgit