[PATCH] mtd: mtdchar: handle a block that should be marked bad that already is
Boris Brezillon
boris.brezillon at free-electrons.com
Thu Aug 31 13:08:46 PDT 2017
On Thu, 31 Aug 2017 21:35:43 +0200
Uwe Kleine-König <u.kleine-koenig at pengutronix.de> wrote:
> Otherwise at least /sys/class/mtd/mtdX/bad_blocks is increased each time
> the same block is remarked as bad.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig at pengutronix.de>
> ---
> drivers/mtd/mtdchar.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
> index 3568294d4854..049496a1d7a5 100644
> --- a/drivers/mtd/mtdchar.c
> +++ b/drivers/mtd/mtdchar.c
> @@ -916,6 +916,11 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg)
>
> if (copy_from_user(&offs, argp, sizeof(loff_t)))
> return -EFAULT;
> +
> + if (mtd_block_isbad(mtd, offs))
> + /* already done */
> + return 0;
> +
Just a matter of taste but I prefer to have comments before the
conditional branch and not inside it, especially when the code chunk is
not enclosed into brackets.
> return mtd_block_markbad(mtd, offs);
> break;
This break statement is redundant. Care to send another patch to fix
that?
> }
More information about the linux-mtd
mailing list