From mboxrd@z Thu Jan 1 00:00:00 1970 From: Florian Fainelli Date: Sat, 20 Mar 2010 19:02:58 +0100 Subject: [U-Boot] [PATCH] cmd_nand: show nand scrub confirmation character In-Reply-To: <20100319220211.GA8992@loki.buserror.net> References: <201003191606.16508.f.fainelli@gmail.com> <20100319220211.GA8992@loki.buserror.net> Message-ID: <201003201902.58625.f.fainelli@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Friday 19 March 2010 23:02:11 Scott Wood wrote: > On Fri, Mar 19, 2010 at 04:06:16PM +0100, Florian Fainelli wrote: > > When issuing a nand scrub command, the entered character is not displayed > > this may be confusing. This patch makes the input character being > > displayed if it is a 'y' so that an user knows he is about to scrub his > > nand. > > > > Signed-off-by: Florian Fainelli > > --- > > diff --git a/common/cmd_nand.c b/common/cmd_nand.c > > index 075a8af..69cc0a8 100644 > > --- a/common/cmd_nand.c > > +++ b/common/cmd_nand.c > > @@ -327,8 +327,10 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, > > char *argv[]) "are sure of what you are doing!\n" > > "\nReally scrub this NAND flash? \n"); > > > > - if (getc() == 'y' && getc() == '\r') { > > - opts.scrub = 1; > > + if (getc() == 'y') { > > + puts("y"); > > + if (getc() == '\r') > > + opts.scrub = 1; > > } else { > > puts("scrub aborted\n"); > > return -1; > > You're changing the behavior in case the user presses y and then does > something other than hit return. You won't set scrub = 1, but you'll > continue with the erase rather than printing "scrub aborted" and returning. That's correct, what about this: -- From: Florian Fainelli Subject: [PATCH] cmd_nand: show nand scrub confirmation character When issuing a nand scrub command, the entered character is not displayed this may be confusing. This patch makes the input character being displayed if it is a 'y' so that an user knows he is about to scrub his nand. Signed-off-by: Florian Fainelli --- diff --git a/common/cmd_nand.c b/common/cmd_nand.c index 075a8af..9b0c930 100644 --- a/common/cmd_nand.c +++ b/common/cmd_nand.c @@ -327,8 +327,14 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) "are sure of what you are doing!\n" "\nReally scrub this NAND flash? \n"); - if (getc() == 'y' && getc() == '\r') { - opts.scrub = 1; + if (getc() == 'y') { + puts("y"); + if (getc() == '\r') + opts.scrub = 1; + else { + puts("scrub aborted\n"); + return -1; + } } else { puts("scrub aborted\n"); return -1;