From: Egbert Eich <egbert.eich@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [Patch v3] cmd/gpt: Support gpt command for all devices
Date: Sun, 13 Oct 2013 01:13:52 +0200 [thread overview]
Message-ID: <20131012121541.GB29300@debian> (raw)
In-Reply-To: <001e01cec651$5f786760$1e693620$%wilczek@samsung.com>
On Fri, Oct 11, 2013 at 09:13:22AM +0200, Piotr Wilczek wrote:
> Dear Egbert Eich,
>
> > -----Original Message-----
> > From: Egbert Eich [mailto:egbert.eich at gmail.com]
> > Sent: Friday, October 04, 2013 6:53 PM
> > To: u-boot at lists.denx.de
> > Cc: Piotr Wilczek; Tom Rini; Egbert Eich; Egbert Eich
> > Subject: [Patch v3] cmd/gpt: Support gpt command for all devices
> >
> > From: Egbert Eich <eich@suse.com>
> >
> > The gpt command was only implemented for mmc devices. There is no
> > reason why this command should not be generalized and be applied all
> > other storage device classes.
> > This change both simplifies the implementation and eliminates a build
> > failure for systems that don't support mmcs.
> >
> > Signed-off-by: Egbert Eich <eich@suse.com>
> > ---
> > Changes for v2:
> > - Coding style cleanup.
> > Changes for v3:
> > - Removed wrong '&'
> > - Removed unused variable
> > - Fixed argument checking
> > Spotted by Piotr Wilczek <p.wilczek@samsung.com>
> >
> > common/cmd_gpt.c | 45 +++++++++++++++++++--------------------------
> > 1 file changed, 19 insertions(+), 26 deletions(-)
> >
> > diff --git a/common/cmd_gpt.c b/common/cmd_gpt.c index a46f5cc..17b1180
> > 100644
> > --- a/common/cmd_gpt.c
> > +++ b/common/cmd_gpt.c
[..]
> >
> > @@ -287,27 +279,28 @@ static int do_gpt(cmd_tbl_t *cmdtp, int flag, int
[..]
> > - /* device: 'mmc' */
> > - if (strcmp(argv[2], "mmc") == 0) {
> > - /* check if 'dev' is a number */
> > - for (pstr = argv[3]; *pstr != '\0'; pstr++)
> > - if (!isdigit(*pstr)) {
> > - printf("'%s' is not a number\n",
> > - argv[3]);
> > - return CMD_RET_USAGE;
> > - }
> > - dev = (int)simple_strtoul(argv[3], NULL, 10);
> > - /* write to mmc */
> > - if (gpt_mmc_default(dev, argv[4]))
> > - return CMD_RET_FAILURE;
> > + char *ep;
> > + block_dev_desc_t *blk_dev_desc;
> This probably should be at the beginning of the function
I personally prefer to keep symbols as local as possible (ie. declare them
in the block they are used in if they are just used within a single block)
for the following rasons:
1. It makes the code more readable ie. the definition is closeby to
the location where it is used and doesn't require scrolling to
the beginning of a function and the scope of the variable is is
much more obvious.
2. The compiler can optimize much better as it knows that a variable
can be discarded at the end of the block also by reusing stack
slots stack sapce can be used much more efficiently by the compiler.
I agree that in the case at hand the second argument is not too
relevant, it is more a coding style issue. If there is a coding
style requirement to have those definitions at the beginning of
the function I will create a new patch.
[..]
> > + blk_dev_desc = get_dev(argv[2], dev);
> > + if (!blk_dev_desc) {
> > + printf("%s: %s dev %d NOT available\n",
> > + __func__, argv[2], dev);
> I think it is not necessary since the mmc subsystem prints 'MMC Device not
> found'.
I've done a quick look over the code - of all subsystems MMC seems to be
the only one which prints a message when its get_dev() method is called
but no device is found. Therefore I'd prefer to leave this there.
>
> Except minor comments this patch looks good to me.
> I tested it on mmc device (Trats2) and works well.
Ok, thanks!
>
> Tested-by: Piotr Wilczek <p.wilczek@samsung.com>
>
Thanks a lot for testing!
Cheers,
Egbert.
next prev parent reply other threads:[~2013-10-12 23:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <000101ce35f115206703f61350$%wilczek@samsung.com>
2013-10-04 16:53 ` [U-Boot] [Patch v3] cmd/gpt: Support gpt command for all devices Egbert Eich
2013-10-11 7:13 ` Piotr Wilczek
2013-10-12 23:13 ` Egbert Eich [this message]
2013-10-14 9:50 ` Piotr Wilczek
2013-11-08 22:25 ` [U-Boot] [U-Boot, " Tom Rini
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=20131012121541.GB29300@debian \
--to=egbert.eich@gmail.com \
--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