public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 8/8] sandbox: Add basic command line parsing
Date: Mon, 27 Feb 2012 13:32:17 -0500	[thread overview]
Message-ID: <201202271332.18436.vapier@gentoo.org> (raw)
In-Reply-To: <CAPnjgZ2JaNzkH7KQfjxoZz-qMt-SRBd0k21T-gNF64YehXfF3A@mail.gmail.com>

On Monday 27 February 2012 00:43:30 Simon Glass wrote:
> On Sun, Feb 26, 2012 at 8:42 PM, Mike Frysinger wrote:
> > drivers/mtd/spi/sandbox.c:
> > static int sb_cmdline_cb_spi_sf(struct sandbox_state *state, const char
> > *arg) {
> >    unsigned long bus, cs;
> >    const char *spec = sb_spi_parse_spec(arg, &bus, &cs);
> > 
> >    if (!spec)
> >        return 1;
> > 
> >    state->spi[bus][cs][0] = &sb_sf_ops;
> >    state->spi[bus][cs][1] = spec;
> >    return 0;
> > }
> > SB_CMDLINE_OPT(spi_sf, 1, "connect a SPI flash: <bus>:<cs>:<id>:<file>");
> 
> sandbox...give me your address and I'll send you a cheque to cover the
> bytes so used :-)

it'll have to be a big one to stop the cascading line wrapping :P

> > and people could do:
> >        ./u-boot --spi_sf 0:3:m25p16:./some-file.bin
> > this would connect the spi flash simulation up to the simulated spi bus 0
> > on cs 3 and have it simulate a m25p16 flash with "some-file.bin" backing
> > it.
> > 
> > if someone were to enter the wrong value for
> > "0:3:m25p16:./some-file.bin", how do you propose we communicate that ?
> >  the existing code can easily signal the higher parsing logic via return
> > values, but then we'd just get:
> >        failed to parse option: 0:3:m25p16:./some-file.bin
> > 
> > but what exactly did the code not like ?  was it the bus # ?  the cs # ?
> >  the spi flash id ?  the backing file ?  if the getopt code has access
> > to printf(), we can clearly communicate to the user what is going wrong.
> 
> Yes I think printf() is useful in getopt, I just would prefer to avoid
> using U-Boot's printf. It goes through all the console code, and we
> might be running a test that deliberately breaks that, perhaps.
> Actually this could be a pretty important thing to sort out - we need
> to keep a clear boundary between test code and U-Boot code (as we
> discussed over GPIO). Having the test code use U-Boot's printf() is
> blurring that.

we probably need to add architecture details like this to doc/README.sandbox 
so we can stay on the same page ...

> To your example, if the syntax is correct perhaps, then it got through
> initial parsing. If the filename is wrong, or the bus number, then
> perhaps there will be a message and failure much later. Perhaps the
> initial parsing just does what it can to avoid running past an obvious
> syntax error. But we can't really know success until we open the file,
> or try the bus.

if the bus/cs are valid, the rest of the parsing is delayed until you do "sf 
probe" at which point you'd get an explanation of what is wrong.  i guess we 
can live with this for now.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120227/d9ad9395/attachment.pgp>

  reply	other threads:[~2012-02-27 18:32 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-15 23:51 [U-Boot] [PATCH v4 1/8] sandbox: fdt: Add support for CONFIG_OF_CONTROL Simon Glass
2012-02-15 23:51 ` [U-Boot] [PATCH v4 2/8] sandbox: config: Enable fdt and snprintf() options Simon Glass
2012-02-16  6:03   ` Mike Frysinger
2012-02-15 23:51 ` [U-Boot] [PATCH v4 3/8] sandbox: gpio: Add basic driver for simulating GPIOs Simon Glass
2012-02-21  6:11   ` Mike Frysinger
2012-02-21  6:27     ` Simon Glass
2012-02-21 16:04       ` Mike Frysinger
2012-02-21 21:55         ` Simon Glass
2012-02-21 22:13           ` Mike Frysinger
2012-02-21 22:21             ` Simon Glass
2012-02-22  5:08               ` [U-Boot] [PATCH v5] " Mike Frysinger
2012-02-22  5:45                 ` Simon Glass
2012-02-22 18:31                   ` Mike Frysinger
2012-02-15 23:51 ` [U-Boot] [PATCH v4 4/8] sandbox: Enable GPIO driver Simon Glass
2012-02-15 23:51 ` [U-Boot] [PATCH v4 5/8] sandbox: Add concept of sandbox state Simon Glass
2012-02-15 23:51 ` [U-Boot] [PATCH v4 6/8] sandbox: Allow processing instead of or before main loop Simon Glass
2012-02-15 23:51 ` [U-Boot] [PATCH v4 7/8] sandbox: Add flags for open() call Simon Glass
2012-02-16  6:09   ` Mike Frysinger
2012-02-21  4:32     ` Simon Glass
2012-02-15 23:51 ` [U-Boot] [PATCH v4 8/8] sandbox: Add basic command line parsing Simon Glass
2012-02-26 21:04   ` Mike Frysinger
2012-02-27  2:50     ` Simon Glass
2012-02-27  4:08       ` Mike Frysinger
2012-02-27  4:33         ` Simon Glass
2012-02-27  4:42           ` Mike Frysinger
2012-02-27  5:43             ` Simon Glass
2012-02-27 18:32               ` Mike Frysinger [this message]
2012-02-27 20:55                 ` Simon Glass
2012-02-16  6:03 ` [U-Boot] [PATCH v4 1/8] sandbox: fdt: Add support for CONFIG_OF_CONTROL Mike Frysinger
2012-02-16 10:50 ` Marek Vasut
2012-02-16 19:16   ` Simon Glass

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=201202271332.18436.vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=u-boot@lists.denx.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