From: Ray Jui <rjui@broadcom.com>
To: Axel Lin <axel.lin@ingics.com>, Linus Walleij <linus.walleij@linaro.org>
Cc: Alexandre Courbot <gnurou@gmail.com>,
bcm-kernel-feedback-list@broadcom.com,
"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>
Subject: Re: [RFT][PATCH 1/2] gpio: bcm-kona: Return error if requesting an already taken gpio
Date: Fri, 10 Apr 2015 09:05:03 -0700 [thread overview]
Message-ID: <5527F4AF.20304@broadcom.com> (raw)
In-Reply-To: <1428629325.5384.1.camel@phoenix>
Hi Axel,
On 4/9/2015 6:28 PM, Axel Lin wrote:
> If a gpio is already taken, .gpio_request should return error.
Isn't the protection logic already there at the higher layer in gpiolib?
Ray
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
> drivers/gpio/gpio-bcm-kona.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c
> index b164ce8..632352d 100644
> --- a/drivers/gpio/gpio-bcm-kona.c
> +++ b/drivers/gpio/gpio-bcm-kona.c
> @@ -106,7 +106,7 @@ static void bcm_kona_gpio_lock_gpio(struct bcm_kona_gpio *kona_gpio,
> spin_unlock_irqrestore(&kona_gpio->lock, flags);
> }
>
> -static void bcm_kona_gpio_unlock_gpio(struct bcm_kona_gpio *kona_gpio,
> +static int bcm_kona_gpio_unlock_gpio(struct bcm_kona_gpio *kona_gpio,
> unsigned gpio)
> {
> u32 val;
> @@ -116,10 +116,17 @@ static void bcm_kona_gpio_unlock_gpio(struct bcm_kona_gpio *kona_gpio,
> spin_lock_irqsave(&kona_gpio->lock, flags);
>
> val = readl(kona_gpio->reg_base + GPIO_PWD_STATUS(bank_id));
> + if (!(val & BIT(gpio))) {
> + spin_unlock_irqrestore(&kona_gpio->lock, flags);
> + return -EBUSY;
> + }
> +
> val &= ~BIT(gpio);
> bcm_kona_gpio_write_lock_regs(kona_gpio->reg_base, bank_id, val);
>
> spin_unlock_irqrestore(&kona_gpio->lock, flags);
> +
> + return 0;
> }
>
> static void bcm_kona_gpio_set(struct gpio_chip *chip, unsigned gpio, int value)
> @@ -185,8 +192,7 @@ static int bcm_kona_gpio_request(struct gpio_chip *chip, unsigned gpio)
> {
> struct bcm_kona_gpio *kona_gpio = to_kona_gpio(chip);
>
> - bcm_kona_gpio_unlock_gpio(kona_gpio, gpio);
> - return 0;
> + return bcm_kona_gpio_unlock_gpio(kona_gpio, gpio);
> }
>
> static void bcm_kona_gpio_free(struct gpio_chip *chip, unsigned gpio)
>
next prev parent reply other threads:[~2015-04-10 16:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-10 1:28 [RFT][PATCH 1/2] gpio: bcm-kona: Return error if requesting an already taken gpio Axel Lin
2015-04-10 1:30 ` [RFT][PATCH 2/2] gpio: bcm-kona: Implement get_direction callback Axel Lin
2015-04-10 16:13 ` Ray Jui
2015-04-10 23:13 ` Axel Lin
2015-04-13 4:15 ` Ray Jui
2015-04-10 16:05 ` Ray Jui [this message]
2015-04-10 23:01 ` [RFT][PATCH 1/2] gpio: bcm-kona: Return error if requesting an already taken gpio Axel Lin
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=5527F4AF.20304@broadcom.com \
--to=rjui@broadcom.com \
--cc=axel.lin@ingics.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=gnurou@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.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