mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Alexander Aring <alex.aring@gmail.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 19/21] mtd: Nand: Use dev_add_param_bool for erasebad parameter
Date: Mon, 8 Apr 2013 12:15:39 +0200	[thread overview]
Message-ID: <20130408101538.GA724@x61s> (raw)
In-Reply-To: <20130408081143.GS1906@pengutronix.de>

On Mon, Apr 08, 2013 at 10:11:43AM +0200, Sascha Hauer wrote:
> On Mon, Apr 08, 2013 at 12:35:38AM +0200, Alexander Aring wrote:
> > Hi Sascha,
> > 
> > On Sun, Apr 07, 2013 at 04:00:53PM +0200, Sascha Hauer wrote:
> > > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > > ---
> > >  drivers/mtd/nand/nand_base.c | 22 ++++++++++++----------
> > >  include/linux/mtd/mtd.h      |  1 +
> > >  2 files changed, 13 insertions(+), 10 deletions(-)
> > > 
> > > diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> > > index fa10d95..67e913a 100644
> > > --- a/drivers/mtd/nand/nand_base.c
> > > +++ b/drivers/mtd/nand/nand_base.c
> > > @@ -1672,18 +1672,20 @@ EXPORT_SYMBOL(nand_scan_ident);
> > >  EXPORT_SYMBOL(nand_scan_tail);
> > >  EXPORT_SYMBOL(nand_release);
> > >  
> > > -static int mtd_set_erasebad(struct device_d *dev, struct param_d *param,
> > > -		const char *val)
> > > +static int mtd_set_erasebad(struct param_d *param, void *priv)
> > >  {
> > > -	struct mtd_info *mtd = container_of(dev, struct mtd_info, class_dev);
> > > -	int erasebad;
> > > +	struct mtd_info *mtd = priv;
> > >  
> > > -	erasebad = simple_strtoul(val, NULL, 0);
> > > +	if (!mtd->p_allow_erasebad) {
> > > +		mtd->allow_erasebad = false;
> > > +		return 0;
> > > +	}
> > >
> > > -	if (erasebad && !mtd->allow_erasebad)
> > > -		dev_warn(dev, "Allowing to erase bad blocks. This may be dangerous!\n");
> > > +	if (!mtd->allow_erasebad)
> > > +		dev_warn(&mtd->class_dev,
> > > +			"Allowing to erase bad blocks. This may be dangerous!\n");
> > >  
> > > -	mtd->allow_erasebad = erasebad ? true : false;
> > > +	mtd->allow_erasebad = true;
> > >  
> > >  	return 0;
> > 
> > I think we need to change it to:
> > 
> > ...
> > dev_warn(....);
> > mtd->allow_erasebad = true;
> > 
> > return 0;
> > 
> > without condition.
> > 
> > The reason is that we are already in the truth "allow_erasebad" part after
> > the check of (!mtd->p_allow_erasebad).
> > The branch on (!mtd->allow_erasebad) is will never reach and we need to
> > print out the dev_warn when (mtd->allow_erasebad) is turning on?
> > 
> > I think we can drop this condition here.
> 
> When we drop the condition we get this message everytime we do
> nand0.erasebad=1. I only want to have it once when it is enabled
> (and was disabled before).
> 
ah, thank you for explaining. Good idea. :-)

Alex

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2013-04-08 10:13 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-07 14:00 [PATCH] Add device parameter convenience helpers Sascha Hauer
2013-04-07 14:00 ` [PATCH 01/21] param: Add dev member to struct param_d Sascha Hauer
2013-04-07 14:00 ` [PATCH 02/21] param: refactor __dev_add_param Sascha Hauer
2013-04-07 14:00 ` [PATCH 03/21] param: Add integer and boolean parameter helpers Sascha Hauer
2013-04-07 14:00 ` [PATCH 04/21] param: Add ip address convenience function Sascha Hauer
2013-04-07 14:00 ` [PATCH 05/21] net: ksz8864: Use dev_add_param_bool for enable parameter Sascha Hauer
2013-04-07 14:00 ` [PATCH 06/21] net: store ethernet device parameters in device Sascha Hauer
2013-04-07 14:00 ` [PATCH 07/21] netconsole: use dev_add_param_* helpers Sascha Hauer
2013-04-07 14:00 ` [PATCH 08/21] param: remove now unused dev_[gs]et_param_ip Sascha Hauer
2013-04-07 14:00 ` [PATCH 09/21] treewide: Use dev_add_param_int_ro where possible Sascha Hauer
2013-04-07 14:00 ` [PATCH 10/21] mci: Use dev_add_param_int for probe parameter Sascha Hauer
2013-04-07 14:00 ` [PATCH 11/21] ata: Use dev_add_param_bool " Sascha Hauer
2013-04-07 14:00 ` [PATCH 12/21] fb: Use dev_add_param_bool for enable parameter Sascha Hauer
2013-04-07 14:00 ` [PATCH 13/21] fb: imxfb: Use dev_add_param_int for alpha parameter Sascha Hauer
2013-04-07 14:00 ` [PATCH 14/21] fb: imx-ipu-fb: " Sascha Hauer
2013-04-07 14:00 ` [PATCH 15/21] param: pass param to dev_remove_param Sascha Hauer
2013-04-07 14:00 ` [PATCH 16/21] pwm: Use dev_add_param_int for pwm parameters Sascha Hauer
2013-04-07 14:00 ` [PATCH 17/21] ARM: i.MX: iim: Use dev_add_param_bool for parameters Sascha Hauer
2013-04-07 14:00 ` [PATCH 18/21] console: Use dev_add_param_int for baudrate parameter Sascha Hauer
2013-04-07 14:00 ` [PATCH 19/21] mtd: Nand: Use dev_add_param_bool for erasebad parameter Sascha Hauer
2013-04-07 22:35   ` Alexander Aring
2013-04-08  8:11     ` Sascha Hauer
2013-04-08 10:15       ` Alexander Aring [this message]
2013-04-07 14:00 ` [PATCH 20/21] USB gadget at91: Use dev_add_param_bool for vbus parameter Sascha Hauer
2013-04-07 14:00 ` [PATCH 21/21] ARM: MXS: ocotp: Use dev_add_param_bool for parameter Sascha Hauer

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=20130408101538.GA724@x61s \
    --to=alex.aring@gmail.com \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox