linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: s.hauer@pengutronix.de (Sascha Hauer)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: mx28evk: Simplify GPIO requests for mx28evk_fec_reset
Date: Thu, 10 Nov 2011 08:53:24 +0100	[thread overview]
Message-ID: <20111110075324.GQ16886@pengutronix.de> (raw)
In-Reply-To: <1320865742-16768-1-git-send-email-fabio.estevam@freescale.com>

Hi Fabio,

On Wed, Nov 09, 2011 at 05:09:02PM -0200, Fabio Estevam wrote:
> Simplify GPIO requests inside mx28evk_fec_reset by using gpio_request_array.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
>  arch/arm/mach-mxs/mach-mx28evk.c |   29 ++++++++---------------------
>  1 files changed, 8 insertions(+), 21 deletions(-)
> 
> diff --git a/arch/arm/mach-mxs/mach-mx28evk.c b/arch/arm/mach-mxs/mach-mx28evk.c
> index ac2316d..c565c33 100644
> --- a/arch/arm/mach-mxs/mach-mx28evk.c
> +++ b/arch/arm/mach-mxs/mach-mx28evk.c
> @@ -219,6 +219,11 @@ static const struct gpio_led_platform_data mx28evk_led_data __initconst = {
>  	.num_leds = ARRAY_SIZE(mx28evk_leds),
>  };
>  
> +static struct gpio mx28evk_fec_gpios[] = {
> +	{ MX28EVK_FEC_PHY_POWER, GPIOF_OUT_INIT_LOW, "fec-power" },
> +	{ MX28EVK_FEC_PHY_RESET, GPIOF_OUT_INIT_LOW, "fec-enable" },
> +};
> +
>  /* fec */
>  static void __init mx28evk_fec_reset(void)
>  {
> @@ -231,28 +236,10 @@ static void __init mx28evk_fec_reset(void)
>  		clk_enable(clk);
>  
>  	/* Power up fec phy */
> -	ret = gpio_request(MX28EVK_FEC_PHY_POWER, "fec-phy-power");
> -	if (ret) {
> -		pr_err("Failed to request gpio fec-phy-%s: %d\n", "power", ret);
> -		return;
> -	}
> -
> -	ret = gpio_direction_output(MX28EVK_FEC_PHY_POWER, 0);
> -	if (ret) {
> -		pr_err("Failed to drive gpio fec-phy-%s: %d\n", "power", ret);
> -		return;
> -	}
> -
> -	/* Reset fec phy */
> -	ret = gpio_request(MX28EVK_FEC_PHY_RESET, "fec-phy-reset");
> -	if (ret) {
> -		pr_err("Failed to request gpio fec-phy-%s: %d\n", "reset", ret);
> -		return;
> -	}
> -
> -	gpio_direction_output(MX28EVK_FEC_PHY_RESET, 0);
> +	ret = gpio_request_array(mx28evk_fec_gpios,
> +				ARRAY_SIZE(mx28evk_fec_gpios));

I think it makes more sense to create an array per board and not per
board function. In the mx28evk file we use gpios for the fec, we have
a gpio_request_one for the flexcan switch and a gpio_request_array for
the lcd pins. All these could be added to a single mx28evk_gpios array.
Then it would be easy to see which gpios a board uses and it would be
trivial to add additional gpios. The same applies for other boards
aswell of course.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

  parent reply	other threads:[~2011-11-10  7:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-09 19:09 [PATCH] ARM: mx28evk: Simplify GPIO requests for mx28evk_fec_reset Fabio Estevam
2011-11-09 19:13 ` Uwe Kleine-König
2011-11-10  7:53 ` Sascha Hauer [this message]
2011-11-10  8:11   ` Dong Aisheng-B29396
2011-11-10  8:47     ` Sascha Hauer

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=20111110075324.GQ16886@pengutronix.de \
    --to=s.hauer@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).