[PATCH -next v2] mtd: rawnand: Propagate error values for brcmstb_nand_wait_for_completion()
Ruan Jinjie
ruanjinjie at huawei.com
Fri Aug 4 22:01:46 PDT 2023
As bcmnand_ctrl_poll_status() return negative errno, and the < 0
case does not exist for wait_for_completion_timeout(), so return
-ETIMEDOUT if sts = 0 and zero otherwise. It is not sensible for
brcmstb_nand_wait_for_completion() to return bool value, change it
to int to propagate the error.
Signed-off-by: Ruan Jinjie <ruanjinjie at huawei.com>
---
v2:
- Update the commit title and message.
- Propagate the error instead of upon error.
---
drivers/mtd/nand/raw/brcmnand/brcmnand.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index 03764b589ec5..25e5b15fbd6a 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -1653,12 +1653,12 @@ static void brcmnand_cmd_ctrl(struct nand_chip *chip, int dat,
/* intentionally left blank */
}
-static bool brcmstb_nand_wait_for_completion(struct nand_chip *chip)
+static int brcmstb_nand_wait_for_completion(struct nand_chip *chip)
{
struct brcmnand_host *host = nand_get_controller_data(chip);
struct brcmnand_controller *ctrl = host->ctrl;
struct mtd_info *mtd = nand_to_mtd(chip);
- bool err = false;
+ int err = 0;
int sts;
if (mtd->oops_panic_write || ctrl->irq < 0) {
@@ -1666,13 +1666,14 @@ static bool brcmstb_nand_wait_for_completion(struct nand_chip *chip)
disable_ctrl_irqs(ctrl);
sts = bcmnand_ctrl_poll_status(ctrl, NAND_CTRL_RDY,
NAND_CTRL_RDY, 0);
- err = (sts < 0) ? true : false;
+ err = sts;
} else {
unsigned long timeo = msecs_to_jiffies(
NAND_POLL_STATUS_TIMEOUT_MS);
/* wait for completion interrupt */
sts = wait_for_completion_timeout(&ctrl->done, timeo);
- err = (sts <= 0) ? true : false;
+ if (!sts)
+ err = -ETIMEDOUT;
}
return err;
--
2.34.1
More information about the linux-mtd
mailing list