From: Antony Pavlov <antonynpavlov@gmail.com>
To: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2 3/5] gpiolib: gpio_request(): add error message
Date: Fri, 1 Feb 2013 22:09:39 +0400 [thread overview]
Message-ID: <CAA4bVAEDnY4JCr6OGYo4hY8o3n6DrZ6sRSHTVfX+VBq_L2v=ng@mail.gmail.com> (raw)
In-Reply-To: <20130201081351.GK26329@game.jcrosoft.org>
On 1 February 2013 12:13, Jean-Christophe PLAGNIOL-VILLARD
<plagnioj@jcrosoft.com> wrote:
> Nack the is need to handle by the caller not here
You want to get duplicated code? Ok, you will get in the "patch v3" series! :)))
>
> Best Regards,
> J.
>>
>> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
>> ---
>> drivers/gpio/gpio.c | 29 ++++++++++++++++++++++-------
>> 1 file changed, 22 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/gpio/gpio.c b/drivers/gpio/gpio.c
>> index 5876454..179fc7b 100644
>> --- a/drivers/gpio/gpio.c
>> +++ b/drivers/gpio/gpio.c
>> @@ -29,22 +29,37 @@ int gpio_request(unsigned gpio, const char *label)
>> struct gpio_chip *chip = gi->chip;
>> int ret;
>>
>> - if (!gpio_is_valid(gpio))
>> - return -EINVAL;
>> - if (!chip)
>> - return -EINVAL;
>> - if (gi->requested)
>> - return -EBUSY;
>> + if (!gpio_is_valid(gpio)) {
>> + ret = -EINVAL;
>> + goto err;
>> + }
>> +
>> + if (!chip) {
>> + ret = -EINVAL;
>> + goto err;
>> + }
>> +
>> + if (gi->requested) {
>> + ret = -EBUSY;
>> + goto err;
>> + }
>> +
>> if (chip->ops->request) {
>> ret = chip->ops->request(chip, gpio - chip->base);
>> if (ret)
>> - return ret;
>> + goto err;
>> }
>>
>> gi->requested = true;
>> gi->label = xstrdup(label);
>>
>> return 0;
>> +
>> +err:
>> + pr_err("can't request gpio %d as %s (%d)\n",
>> + gpio, label, ret);
>> +
>> + return ret;
>> }
>>
>> int gpio_request_input(unsigned gpio, const char *label)
>> --
>> 1.7.10.4
>>
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2013-02-01 18:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-31 21:46 [PATCH v2 0/5] gpiolib: add gpio_request_{in,out}put support Antony Pavlov
2013-01-31 21:46 ` [PATCH v2 1/5] gpiolib: fix whitespaces Antony Pavlov
2013-01-31 21:46 ` [PATCH v2 2/5] gpiolib: add gpio_request_{in,out}put support Antony Pavlov
2013-01-31 21:46 ` [PATCH v2 3/5] gpiolib: gpio_request(): add error message Antony Pavlov
2013-02-01 8:13 ` Jean-Christophe PLAGNIOL-VILLARD
2013-02-01 18:09 ` Antony Pavlov [this message]
2013-02-01 18:24 ` Jean-Christophe PLAGNIOL-VILLARD
2013-01-31 21:46 ` [PATCH v2 4/5] at91sam9*: use gpio_request_output() Antony Pavlov
2013-01-31 21:46 ` [PATCH v2 5/5] animeo_ip: use gpio_request_input() Antony Pavlov
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='CAA4bVAEDnY4JCr6OGYo4hY8o3n6DrZ6sRSHTVfX+VBq_L2v=ng@mail.gmail.com' \
--to=antonynpavlov@gmail.com \
--cc=barebox@lists.infradead.org \
--cc=plagnioj@jcrosoft.com \
/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