From: Mike Rapoport <mike@compulab.co.il>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: alessandro.zummo@towertech.it, rtc-linux@googlegroups.com,
linux-kernel@vger.kernel.org, raph@8d.com,
David Brownell <david-b@pacbell.net>
Subject: Re: [PATCH] rtc-v3020: add ability to access v3020 chip with GPIOs
Date: Tue, 03 Mar 2009 08:16:14 +0200 [thread overview]
Message-ID: <49ACCB2E.8020400@compulab.co.il> (raw)
In-Reply-To: <20090302143604.57bd4f53.akpm@linux-foundation.org>
Andrew Morton wrote:
> On Mon, 2 Mar 2009 13:40:57 +0200
> Mike Rapoport <mike@compulab.co.il> wrote:
>
>> +static int v3020_gpio_map(struct v3020 *chip, struct platform_device *pdev,
>> + struct v3020_platform_data *pdata)
>> +{
>> + int i, err;
>> +
>> + v3020_gpio[V3020_CS].gpio = pdata->gpio_cs;
>> + v3020_gpio[V3020_WR].gpio = pdata->gpio_wr;
>> + v3020_gpio[V3020_RD].gpio = pdata->gpio_rd;
>> + v3020_gpio[V3020_IO].gpio = pdata->gpio_io;
>> +
>> + for (i = 0; i < ARRAY_SIZE(v3020_gpio); i++) {
>> + err = gpio_request(v3020_gpio[i].gpio, v3020_gpio[i].name);
>> + if (err)
>> + goto err_request;
>> +
>> + gpio_direction_output(v3020_gpio[i].gpio, 1);
>> + }
>> +
>> + chip->gpio = v3020_gpio;
>> +
>> + return 0;
>> +
>> +err_request:
>> + for (; i >= 0; i--)
>> + gpio_free(v3020_gpio[i].gpio);
>> +
>> + return err;
>> +}
>
> It needs this fix, I think?
Indeed. Thanks.
>
> fix off-by-one in error path
>
> --- a/drivers/rtc/rtc-v3020.c~rtc-v3020-add-ability-to-access-v3020-chip-with-gpios-fix
> +++ a/drivers/rtc/rtc-v3020.c
> @@ -136,7 +136,7 @@ static int v3020_gpio_map(struct v3020 *
> return 0;
>
> err_request:
> - for (; i >= 0; i--)
> + while (--i >= 0)
> gpio_free(v3020_gpio[i].gpio);
>
> return err;
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
--
Sincerely yours,
Mike.
prev parent reply other threads:[~2009-03-03 6:16 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-02 11:40 [PATCH] rtc-v3020: add ability to access v3020 chip with GPIOs Mike Rapoport
2009-03-02 11:40 ` [PATCH] rtc-v3020: coding style cleanup Mike Rapoport
2009-03-02 11:43 ` Alessandro Zummo
2009-03-02 11:40 ` [PATCH] rtc-v3020: add ability to access v3020 chip with GPIOs Mike Rapoport
2009-03-02 11:47 ` Alessandro Zummo
2009-03-02 12:18 ` Mike Rapoport
2009-03-03 21:08 ` David Brownell
2009-03-08 10:03 ` Mike Rapoport
2009-03-19 21:25 ` David Brownell
2009-03-02 22:36 ` Andrew Morton
2009-03-03 6:16 ` Mike Rapoport [this message]
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=49ACCB2E.8020400@compulab.co.il \
--to=mike@compulab.co.il \
--cc=akpm@linux-foundation.org \
--cc=alessandro.zummo@towertech.it \
--cc=david-b@pacbell.net \
--cc=linux-kernel@vger.kernel.org \
--cc=raph@8d.com \
--cc=rtc-linux@googlegroups.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