All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: David Woodhouse <dwmw2@infradead.org>,
	Brian Norris <computersforpeace@gmail.com>,
	Marek Vasut <marek.vasut@gmail.com>,
	Richard Weinberger <richard@nod.at>,
	Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>,
	kernel@pengutronix.de, linux-mtd@lists.infradead.org
Subject: Re: [PATCH] mtd: mtdchar: handle a block that should be marked bad that already is
Date: Thu, 31 Aug 2017 22:08:46 +0200	[thread overview]
Message-ID: <20170831220846.35014f87@bbrezillon> (raw)
In-Reply-To: <20170831193543.27543-1-u.kleine-koenig@pengutronix.de>

On Thu, 31 Aug 2017 21:35:43 +0200
Uwe Kleine-König <u.kleine-koenig@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@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?

>  	}

      reply	other threads:[~2017-08-31 20:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-31 19:35 [PATCH] mtd: mtdchar: handle a block that should be marked bad that already is Uwe Kleine-König
2017-08-31 20:08 ` Boris Brezillon [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170831220846.35014f87@bbrezillon \
    --to=boris.brezillon@free-electrons.com \
    --cc=computersforpeace@gmail.com \
    --cc=cyrille.pitchen@wedev4u.fr \
    --cc=dwmw2@infradead.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=richard@nod.at \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.