[PATCH -next] mtd: rawnand: brcmnand: Remove unnecessary ternary operators

Miquel Raynal miquel.raynal at bootlin.com
Fri Aug 4 06:44:25 PDT 2023


Hi Ruan,

ruanjinjie at huawei.com wrote on Fri, 4 Aug 2023 15:57:17 +0800:

> Ther are a little ternary operators, the true or false judgement
> of which is unnecessary in C language semantics.
> 
> Signed-off-by: Ruan Jinjie <ruanjinjie at huawei.com>
> ---
>  drivers/mtd/nand/raw/brcmnand/brcmnand.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> index 03764b589ec5..dc66590eb4cf 100644
> --- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> +++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
> @@ -1666,13 +1666,13 @@ 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 < 0;

This function returns a negative errno, please propagate the error
instead upon error.

>  	} 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;
> +		err = sts <= 0;

The < 0 case does not exist so instead you can return -ETIMEDOUT if
(!sts) and zero otherwise.

>  	}
>  
>  	return err;


Thanks,
Miquèl



More information about the linux-mtd mailing list