From: Rafal Prylowski <prylowski@metasoft.pl>
To: H Hartley Sweeten <hartleys@visionengravers.com>
Cc: "linux-ide@vger.kernel.org" <linux-ide@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"joao.ramos@inov.pt" <joao.ramos@inov.pt>,
"rmallon@gmail.com" <rmallon@gmail.com>,
Sergei Shtylyov <sshtylyov@mvista.com>,
"bzolnier@gmail.com" <bzolnier@gmail.com>
Subject: Re: [PATCH v2 2/3] ep93xx: IDE driver platform support code
Date: Wed, 04 Apr 2012 10:41:06 +0200 [thread overview]
Message-ID: <4F7C0922.1070200@metasoft.pl> (raw)
In-Reply-To: <ADE657CA350FB648AAC2C43247A983F0020698409DF4@AUSP01VMBX24.collaborationhost.net>
On 2012-04-03 19:41, H Hartley Sweeten wrote:
> On Tuesday, April 03, 2012 7:47 AM, Rafal Prylowski wrote:
>>
>> +int ep93xx_ide_acquire_gpio(struct platform_device *pdev)
>> +{
>> + int err;
>> + int i;
>> +
>> + for (i = 2; i < 8; i++) {
>> + err = gpio_request(EP93XX_GPIO_LINE_E(i), dev_name(&pdev->dev));
>> + if (err)
>> + goto fail_gpio_e;
>> + }
>> + for (i = 4; i < 8; i++) {
>> + err = gpio_request(EP93XX_GPIO_LINE_G(i), dev_name(&pdev->dev));
>> + if (err)
>> + goto fail_gpio_g;
>> + }
>> + for (i = 0; i < 8; i++) {
>> + err = gpio_request(EP93XX_GPIO_LINE_H(i), dev_name(&pdev->dev));
>> + if (err)
>> + goto fail_gpio_h;
>> + }
>> +
>> + /* GPIO ports E[7:2], G[7:4] and H used by IDE */
>> + ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_EONIDE |
>> + EP93XX_SYSCON_DEVCFG_GONIDE |
>> + EP93XX_SYSCON_DEVCFG_HONIDE);
>> + return 0;
>> +
>> +fail_gpio_h:
>> + for (--i; i >= 0; --i)
>> + gpio_free(EP93XX_GPIO_LINE_H(i));
>> + i = 8;
>> +fail_gpio_g:
>> + for (--i; i >= 4; --i)
>> + gpio_free(EP93XX_GPIO_LINE_G(i));
>> + i = 8;
>> +fail_gpio_e:
>> + for (--i; i >= 2; --i)
>> + gpio_free(EP93XX_GPIO_LINE_E(i));
>> + return err;
>> +}
>> +EXPORT_SYMBOL(ep93xx_ide_acquire_gpio);
[not related to my patch, but ep93xx keypad]:
Isn't ep93xx_keypad_acquire_gpio be more correct if we apply the following patch:
Index: linux-2.6/arch/arm/mach-ep93xx/core.c
===================================================================
--- linux-2.6.orig/arch/arm/mach-ep93xx/core.c
+++ linux-2.6/arch/arm/mach-ep93xx/core.c
@@ -734,7 +734,7 @@ int ep93xx_keypad_acquire_gpio(struct pl
fail_gpio_d:
gpio_free(EP93XX_GPIO_LINE_C(i));
fail_gpio_c:
- for ( ; i >= 0; --i) {
+ for (--i; i >= 0; --i) {
gpio_free(EP93XX_GPIO_LINE_C(i));
gpio_free(EP93XX_GPIO_LINE_D(i));
}
This way we don't double free EP93XX_GPIO_LINE_C(i), and don't free lines which were not
successfully acquired (I noticed this when writing my patch, which is based on
ep93xx_keypad_acquire/release_gpio).
Thanks,
RP
next prev parent reply other threads:[~2012-04-04 8:41 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-03 14:42 [PATCH v2 0/3] Add PATA host controller support for Cirrus Logic EP93xx CPU Rafal Prylowski
2012-04-03 14:45 ` [PATCH v2 1/3] PATA host controller driver for ep93xx Rafal Prylowski
2012-04-03 18:25 ` H Hartley Sweeten
2012-04-03 20:08 ` Arnd Bergmann
2012-04-03 20:37 ` H Hartley Sweeten
2012-04-04 12:50 ` Arnd Bergmann
2012-04-04 12:40 ` Rafal Prylowski
2012-04-04 13:23 ` Arnd Bergmann
2012-04-04 15:11 ` Rafal Prylowski
2012-04-04 15:16 ` Rafal Prylowski
2012-04-04 15:23 ` Arnd Bergmann
2012-04-05 7:52 ` Rafal Prylowski
2012-04-05 9:07 ` Rafal Prylowski
2012-04-04 7:39 ` Rafal Prylowski
2012-04-03 18:55 ` H Hartley Sweeten
2012-04-04 7:47 ` Rafal Prylowski
2012-04-03 14:47 ` [PATCH v2 2/3] ep93xx: IDE driver platform support code Rafal Prylowski
2012-04-03 17:41 ` H Hartley Sweeten
2012-04-04 8:41 ` Rafal Prylowski [this message]
2012-04-04 16:20 ` H Hartley Sweeten
2012-04-04 16:43 ` H Hartley Sweeten
2012-04-04 17:11 ` H Hartley Sweeten
2012-04-04 1:43 ` H Hartley Sweeten
2012-04-03 14:48 ` [PATCH v2 3/3] ep93xx: Add IDE support to edb93xx boards Rafal Prylowski
2012-04-03 17:44 ` H Hartley Sweeten
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=4F7C0922.1070200@metasoft.pl \
--to=prylowski@metasoft.pl \
--cc=bzolnier@gmail.com \
--cc=hartleys@visionengravers.com \
--cc=joao.ramos@inov.pt \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-ide@vger.kernel.org \
--cc=rmallon@gmail.com \
--cc=sshtylyov@mvista.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