All of lore.kernel.org
 help / color / mirror / Atom feed
From: LW@KARO-electronics.de (Lothar Waßmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] gpio/generic: initialize the shadow of direction register
Date: Tue, 15 May 2012 09:17:50 +0200	[thread overview]
Message-ID: <20402.798.622618.263780@ipc1.ka-ro> (raw)
In-Reply-To: <1337054198-24674-1-git-send-email-shawn.guo@linaro.org>

Hi,

Shawn Guo writes:
> Same as what the driver does for data register shadow bgc->data,
> the bgpio_init should also initialize direction register shadow
> bgc->dir to preserve the existing setting.
> 
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
>  drivers/gpio/gpio-generic.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c
> index e38dd0c..53222c7 100644
> --- a/drivers/gpio/gpio-generic.c
> +++ b/drivers/gpio/gpio-generic.c
> @@ -394,6 +394,7 @@ int bgpio_init(struct bgpio_chip *bgc, struct device *dev,
>  		return ret;
>  
>  	bgc->data = bgc->read_reg(bgc->reg_dat);
> +	bgc->dir = bgc->read_reg(bgc->reg_dir);
>  
This will blow up in your face when calling bgpio_init() without any
direction register (which is well supported by the generic driver).

You need to do this in the platform specific driver that uses the
generic driver. See gpio-mxc.c for reference:
|        err = bgpio_init(&port->bgc, &pdev->dev, 4,
|                         port->base + GPIO_PSR,
|                         port->base + GPIO_DR, NULL,
|                         port->base + GPIO_GDIR, NULL, false);
|        if (err)
|                goto out_iounmap;
|
|        port->bgc.gc.to_irq = mxc_gpio_to_irq;
|        port->bgc.gc.base = pdev->id * 32;
|        port->bgc.dir = port->bgc.read_reg(port->bgc.reg_dir);
|        port->bgc.data = port->bgc.read_reg(port->bgc.reg_set);


Lothar Wa?mann
-- 
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Gesch?ftsf?hrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info at karo-electronics.de
___________________________________________________________

  reply	other threads:[~2012-05-15  7:17 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-15  3:56 [PATCH] gpio/generic: initialize the shadow of direction register Shawn Guo
2012-05-15  7:17 ` Lothar Waßmann [this message]
2012-05-16  5:33   ` Shawn Guo
2012-05-16  6:53     ` Lothar Waßmann
2012-05-16  7:29       ` Shawn Guo
2012-05-16  7:34         ` Lothar Waßmann
2012-05-16 12:36           ` Shawn Guo
2012-05-16 12:48             ` Lothar Waßmann
2012-05-16 13:38               ` Shawn Guo
2012-05-16 13:33                 ` Lothar Waßmann
2012-05-16 14:07                   ` Shawn Guo
2012-05-16 14:03                     ` Lothar Waßmann
2012-05-16 16:21                       ` Shawn Guo
2012-05-16 13:54             ` Lothar Waßmann
2012-05-16 16:17               ` Shawn Guo
2012-05-17 20:39                 ` Grant Likely

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=20402.798.622618.263780@ipc1.ka-ro \
    --to=lw@karo-electronics.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.