public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Marek Vasut <marek.vasut@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] M28: Added pin name support in GPIO driver
Date: Tue, 22 Nov 2011 20:32:32 +0100	[thread overview]
Message-ID: <201111222032.32956.marek.vasut@gmail.com> (raw)
In-Reply-To: <BD0A6336-13C3-4637-AA5F-A38C2DD5EA5F@delien.nl>

> > No, move this to mxs_gpio.c and simply make the function not static.
> 
> I too find the construction a little strange, but I copied it from the
> Blackfin implementation.
> 
> But after taking a second look at it, it made sense: It makes the file
> pulling including it, define it statically locally. The macro below
> exports it to the macro name space and cmd_gpio checks for the existence
> of that makro. If it doesn't exist there, cmd_gpio defines it as
> simple_strtoul. I suppose this is created that way to allow diversity
> between platforms with and without name support.
> 
> Currently, Blackfin is the only platform supporting named pins. I'd be
> happy to change it, but then Blackfin needs some work too and I don't have
> the hardware to test it.

I don't think I follow ... don't you only have to define the function and that's 
it?

> 
> > So if I pass name == NULL, we're done for here ;-)
> 
> We would, but it's a static function, so it's unavailable to the rest of
> the world.

What? Which one is?

The name_to_gpio_number() function, which I assume is used by the cmd_gpio must 
exactly be NON-static! Or prove me wrong please.

> And name won't be NULL unless the command line argument parsing
> is borked. I know what you mean, but if even all static functions start
> schizophrenically checking all their parameters we'd be doing that half
> the CPU cycles.
> 
> > Braces missing around this return statement.
> 
> Will do! I actually do that for all of my code, but this is how it was in
> Blackfin  (and in drivers/gpio/mxs_gpio.c, and in common/cmd_gpio.c, for
> that matter).
> 
> > Also, why not do something like:
> > 
> > if (tolower(name[0]) != 'b')
> > 
> > 	return -EINVAL;
> > 
> > name++;
> > pinnr = ...
> > 
> > if (tolower(name[0]) != 'p')
> > 
> > 	return -EINVAL;
> > 
> > name++;
> > ...
> > 
> > It seems more explicit to me that way.
> 
> Agreed; Will do!
> 
> > What's this define for ?
> 
> See above.
> 
> > Do you even need this if CONFIG_CMD_GPIO is undefined? Move the function
> > to mxs_gpio.c and make it not static should work for you.
> 
> Nope, I don't, but I didn't put it there. It was already there, so somebody
> must have approved (of overlooked) it ;-)

Don't rely on other code too much, improvise and bring progress :)

M

  reply	other threads:[~2011-11-22 19:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-22 15:40 [U-Boot] [PATCH] M28: Added pin name support in GPIO driver Robert Deliën
2011-11-22 18:28 ` Marek Vasut
2011-11-22 19:13   ` Robert Deliën
2011-11-22 19:32     ` Marek Vasut [this message]
2011-11-22 20:49       ` Robert Deliën
2011-11-22 22:18         ` Mike Frysinger
2011-11-22 22:37           ` Marek Vasut
2011-11-23 10:08             ` Robert Deliën
2011-11-23 22:18             ` Mike Frysinger
2011-11-22 21:10 ` Mike Frysinger
2011-11-22 21:11 ` Mike Frysinger
2011-11-23  9:07 ` Stefano Babic
2011-11-23  9:51   ` Robert Deliën
2011-11-23 22:11     ` Mike Frysinger

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=201111222032.32956.marek.vasut@gmail.com \
    --to=marek.vasut@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