linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: w.sang@pengutronix.de (Wolfram Sang)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] Introduce VPR200 board.
Date: Fri, 14 Jan 2011 11:06:40 +0100	[thread overview]
Message-ID: <20110114100640.GA4589@pengutronix.de> (raw)
In-Reply-To: <20110114083408.GD24920@pengutronix.de>

Hi,

> > +static void vpr200_init_keys(void)
> > +{
> > +	gpio_request(GPIO_BUTTON1, "BUTTON1");
> > +	gpio_direction_input(GPIO_BUTTON1);
> > +	gpio_free(GPIO_BUTTON1);
> > +
> > +	gpio_request(GPIO_BUTTON2, "BUTTON2");
> > +	gpio_direction_input(GPIO_BUTTON2);
> > +	gpio_free(GPIO_BUTTON2);
> > +
> > +	gpio_request(GPIO_BUTTON3, "BUTTON3");
> > +	gpio_direction_input(GPIO_BUTTON3);
> > +	gpio_free(GPIO_BUTTON3);
> > +
> > +	gpio_request(GPIO_BUTTON4, "BUTTON4");
> > +	gpio_direction_input(GPIO_BUTTON4);
> > +	gpio_free(GPIO_BUTTON4);
> > +
> > +	gpio_request(GPIO_BUTTON5, "BUTTON5");
> > +	gpio_direction_input(GPIO_BUTTON5);
> > +	gpio_free(GPIO_BUTTON5);
> > +
> > +	gpio_request(GPIO_BUTTON6, "BUTTON6");
> > +	gpio_direction_input(GPIO_BUTTON6);
> > +	gpio_free(GPIO_BUTTON6);
> > +
> > +	gpio_request(GPIO_BUTTON7, "BUTTON7");
> > +	gpio_direction_input(GPIO_BUTTON7);
> > +	gpio_free(GPIO_BUTTON7);
> > +
> > +	gpio_request(GPIO_BUTTON8, "BUTTON8");
> > +	gpio_direction_input(GPIO_BUTTON8);
> > +	gpio_free(GPIO_BUTTON8);
> Hmm, doesn't the gpio-keys driver does that already?

I'd think so, too.

> And to do it really correct, you need to check for errors returned by
> gpio_request and gpio_direction_input.
> 
> Provided you really need it, I'd do it as follows:
> 
> 	int ret;
> 
> 	#define setup_for_gpiokey(nr)					\
> 		ret = gpio_request(GPIO_BUTTON ## nr, "BUTTON" #nr);	\
> 		if (ret)						\
> 			return ret;					\
> 		ret = gpio_direction_input(GPIO_BUTTON ## nr);		\
> 		if (ret)						\
> 			return ret;					\
> 		gpio_free(GPIO_BUTTON ## nr);
> 
> 	setup_for_gpiokey(1);
> 	setup_for_gpiokey(2);
> 	setup_for_gpiokey(3);
> 	setup_for_gpiokey(4);
> 	...

I'd think using gpio_request_array() is the better option ;)

Regards,

   Wolfram

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110114/a5c66e98/attachment.sig>

  reply	other threads:[~2011-01-14 10:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-13 23:48 New i.MX35 based board - VPR200 Marc Reilly
2011-01-13 23:48 ` [PATCH] Introduce VPR200 board Marc Reilly
2011-01-14  0:22   ` Jamie Iles
2011-01-14  8:34   ` Uwe Kleine-König
2011-01-14 10:06     ` Wolfram Sang [this message]
2011-01-14 10:18       ` Uwe Kleine-König
2011-01-14 23:50         ` Marc Reilly
2011-01-14 10:06   ` Sascha Hauer
2011-01-14 14:59   ` Fabio Estevam
2011-01-14 19:32     ` Sascha Hauer
2011-01-15  0:36   ` New i.MX35 based board - VPR200, round 2 Marc Reilly
2011-01-15  0:36   ` [PATCH v2] Introduce VPR200 board Marc Reilly

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=20110114100640.GA4589@pengutronix.de \
    --to=w.sang@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).