* [PATCH] i2c: i2c-sh_mobile irq rollback fix
@ 2010-08-02 7:16 Magnus Damm
2010-08-04 7:44 ` Paul Mundt
2010-08-10 13:18 ` Jean Delvare
0 siblings, 2 replies; 7+ messages in thread
From: Magnus Damm @ 2010-08-02 7:16 UTC (permalink / raw)
To: linux-i2c; +Cc: khali, Magnus Damm, lethal, linux-sh
From: Magnus Damm <damm@opensource.se>
Update the i2c-sh_mobile driver to properly free
interrupts. The function sh_mobile_i2c_hook_irqs()
is fixed so module both unload and load are working
as expected.
Signed-off-by: Magnus Damm <damm@opensource.se>
---
drivers/i2c/busses/i2c-sh_mobile.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
--- 0001/drivers/i2c/busses/i2c-sh_mobile.c
+++ work/drivers/i2c/busses/i2c-sh_mobile.c 2010-08-02 15:14:48.000000000 +0900
@@ -538,15 +538,17 @@ static int sh_mobile_i2c_hook_irqs(struc
{
struct resource *res;
int ret = -ENXIO;
- int q, m;
- int k = 0;
- int n = 0;
+ int n, k = 0;
while ((res = platform_get_resource(dev, IORESOURCE_IRQ, k))) {
for (n = res->start; hook && n <= res->end; n++) {
if (request_irq(n, sh_mobile_i2c_isr, IRQF_DISABLED,
- dev_name(&dev->dev), dev))
+ dev_name(&dev->dev), dev)) {
+ for (n--; n >= res->start; n--)
+ free_irq(n, dev);
+
goto rollback;
+ }
}
k++;
}
@@ -554,16 +556,17 @@ static int sh_mobile_i2c_hook_irqs(struc
if (hook)
return k > 0 ? 0 : -ENOENT;
- k--;
ret = 0;
rollback:
- for (q = k; k >= 0; k--) {
- for (m = n; m >= res->start; m--)
- free_irq(m, dev);
+ k--;
+
+ while (k >= 0) {
+ res = platform_get_resource(dev, IORESOURCE_IRQ, k);
+ for (n = res->start; n <= res->end; n++)
+ free_irq(n, dev);
- res = platform_get_resource(dev, IORESOURCE_IRQ, k - 1);
- m = res->end;
+ k--;
}
return ret;
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] i2c: i2c-sh_mobile irq rollback fix
2010-08-02 7:16 [PATCH] i2c: i2c-sh_mobile irq rollback fix Magnus Damm
@ 2010-08-04 7:44 ` Paul Mundt
2010-08-10 13:18 ` Jean Delvare
1 sibling, 0 replies; 7+ messages in thread
From: Paul Mundt @ 2010-08-04 7:44 UTC (permalink / raw)
To: Magnus Damm; +Cc: linux-i2c, khali, linux-sh
On Mon, Aug 02, 2010 at 04:16:37PM +0900, Magnus Damm wrote:
> From: Magnus Damm <damm@opensource.se>
>
> Update the i2c-sh_mobile driver to properly free
> interrupts. The function sh_mobile_i2c_hook_irqs()
> is fixed so module both unload and load are working
> as expected.
>
> Signed-off-by: Magnus Damm <damm@opensource.se>
Applied, thanks.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] i2c: i2c-sh_mobile irq rollback fix
2010-08-02 7:16 [PATCH] i2c: i2c-sh_mobile irq rollback fix Magnus Damm
2010-08-04 7:44 ` Paul Mundt
@ 2010-08-10 13:18 ` Jean Delvare
[not found] ` <20100810151828.36a77cc3-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-08-31 22:27 ` Ben Dooks
1 sibling, 2 replies; 7+ messages in thread
From: Jean Delvare @ 2010-08-10 13:18 UTC (permalink / raw)
To: Magnus Damm
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, lethal-M7jkjyW5wf5g9hUCZPvPmw,
linux-sh-u79uwXL29TY76Z2rM5mHXA
On Mon, 02 Aug 2010 16:16:37 +0900, Magnus Damm wrote:
> From: Magnus Damm <damm-yzvPICuk2ACczHhG9Qg4qA@public.gmane.org>
>
> Update the i2c-sh_mobile driver to properly free
> interrupts. The function sh_mobile_i2c_hook_irqs()
> is fixed so module both unload and load are working
> as expected.
>
> Signed-off-by: Magnus Damm <damm-yzvPICuk2ACczHhG9Qg4qA@public.gmane.org>
> ---
>
> drivers/i2c/busses/i2c-sh_mobile.c | 23 +++++++++++++----------
> 1 file changed, 13 insertions(+), 10 deletions(-)
>
> --- 0001/drivers/i2c/busses/i2c-sh_mobile.c
> +++ work/drivers/i2c/busses/i2c-sh_mobile.c 2010-08-02 15:14:48.000000000 +0900
> @@ -538,15 +538,17 @@ static int sh_mobile_i2c_hook_irqs(struc
> {
> struct resource *res;
> int ret = -ENXIO;
> - int q, m;
> - int k = 0;
> - int n = 0;
> + int n, k = 0;
You can't really hope to get the code right with such variable names.
--
Jean Delvare
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] i2c: i2c-sh_mobile irq rollback fix
[not found] ` <20100810151828.36a77cc3-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
@ 2010-08-16 1:59 ` Magnus Damm
[not found] ` <AANLkTikQuCX7YC1tQ5MvwBdgxg1LE6k9f98-3M8khBJ6-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: Magnus Damm @ 2010-08-16 1:59 UTC (permalink / raw)
To: Jean Delvare
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, lethal-M7jkjyW5wf5g9hUCZPvPmw,
linux-sh-u79uwXL29TY76Z2rM5mHXA
On Tue, Aug 10, 2010 at 10:18 PM, Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org> wrote:
> On Mon, 02 Aug 2010 16:16:37 +0900, Magnus Damm wrote:
>> From: Magnus Damm <damm-yzvPICuk2ACczHhG9Qg4qA@public.gmane.org>
>>
>> Update the i2c-sh_mobile driver to properly free
>> interrupts. The function sh_mobile_i2c_hook_irqs()
>> is fixed so module both unload and load are working
>> as expected.
>>
>> Signed-off-by: Magnus Damm <damm-yzvPICuk2ACczHhG9Qg4qA@public.gmane.org>
>> ---
>>
>> drivers/i2c/busses/i2c-sh_mobile.c | 23 +++++++++++++----------
>> 1 file changed, 13 insertions(+), 10 deletions(-)
>>
>> --- 0001/drivers/i2c/busses/i2c-sh_mobile.c
>> +++ work/drivers/i2c/busses/i2c-sh_mobile.c 2010-08-02 15:14:48.000000000 +0900
>> @@ -538,15 +538,17 @@ static int sh_mobile_i2c_hook_irqs(struc
>> {
>> struct resource *res;
>> int ret = -ENXIO;
>> - int q, m;
>> - int k = 0;
>> - int n = 0;
>> + int n, k = 0;
>
> You can't really hope to get the code right with such variable names.
And your suggestion is...? If you see something wrong with the code
please let me know.
Thanks,
/ magnus
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] i2c: i2c-sh_mobile irq rollback fix
[not found] ` <AANLkTikQuCX7YC1tQ5MvwBdgxg1LE6k9f98-3M8khBJ6-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2010-08-16 6:24 ` Jean Delvare
[not found] ` <20100816082427.626ea303-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
0 siblings, 1 reply; 7+ messages in thread
From: Jean Delvare @ 2010-08-16 6:24 UTC (permalink / raw)
To: Magnus Damm
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, lethal-M7jkjyW5wf5g9hUCZPvPmw,
linux-sh-u79uwXL29TY76Z2rM5mHXA
On Mon, 16 Aug 2010 10:59:06 +0900, Magnus Damm wrote:
> On Tue, Aug 10, 2010 at 10:18 PM, Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org> wrote:
> > On Mon, 02 Aug 2010 16:16:37 +0900, Magnus Damm wrote:
> >> From: Magnus Damm <damm-yzvPICuk2ACczHhG9Qg4qA@public.gmane.org>
> >>
> >> Update the i2c-sh_mobile driver to properly free
> >> interrupts. The function sh_mobile_i2c_hook_irqs()
> >> is fixed so module both unload and load are working
> >> as expected.
> >>
> >> Signed-off-by: Magnus Damm <damm-yzvPICuk2ACczHhG9Qg4qA@public.gmane.org>
> >> ---
> >>
> >> drivers/i2c/busses/i2c-sh_mobile.c | 23 +++++++++++++----------
> >> 1 file changed, 13 insertions(+), 10 deletions(-)
> >>
> >> --- 0001/drivers/i2c/busses/i2c-sh_mobile.c
> >> +++ work/drivers/i2c/busses/i2c-sh_mobile.c 2010-08-02 15:14:48.000000000 +0900
> >> @@ -538,15 +538,17 @@ static int sh_mobile_i2c_hook_irqs(struc
> >> {
> >> struct resource *res;
> >> int ret = -ENXIO;
> >> - int q, m;
> >> - int k = 0;
> >> - int n = 0;
> >> + int n, k = 0;
> >
> > You can't really hope to get the code right with such variable names.
>
> And your suggestion is...? If you see something wrong with the code
> please let me know.
Nothing specific. I'm just trying to make you realize that one-letter
variable names don't carry any meaning and thus make the code harder to
write, read and debug.
--
Jean Delvare
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] i2c: i2c-sh_mobile irq rollback fix
[not found] ` <20100816082427.626ea303-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
@ 2010-08-16 7:34 ` Magnus Damm
0 siblings, 0 replies; 7+ messages in thread
From: Magnus Damm @ 2010-08-16 7:34 UTC (permalink / raw)
To: Jean Delvare
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, lethal-M7jkjyW5wf5g9hUCZPvPmw,
linux-sh-u79uwXL29TY76Z2rM5mHXA
On Mon, Aug 16, 2010 at 3:24 PM, Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org> wrote:
> On Mon, 16 Aug 2010 10:59:06 +0900, Magnus Damm wrote:
>> On Tue, Aug 10, 2010 at 10:18 PM, Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org> wrote:
>> > On Mon, 02 Aug 2010 16:16:37 +0900, Magnus Damm wrote:
>> >> From: Magnus Damm <damm-yzvPICuk2ACczHhG9Qg4qA@public.gmane.org>
>> >>
>> >> Update the i2c-sh_mobile driver to properly free
>> >> interrupts. The function sh_mobile_i2c_hook_irqs()
>> >> is fixed so module both unload and load are working
>> >> as expected.
>> >>
>> >> Signed-off-by: Magnus Damm <damm-yzvPICuk2ACczHhG9Qg4qA@public.gmane.org>
>> >> ---
>> >>
>> >> drivers/i2c/busses/i2c-sh_mobile.c | 23 +++++++++++++----------
>> >> 1 file changed, 13 insertions(+), 10 deletions(-)
>> >>
>> >> --- 0001/drivers/i2c/busses/i2c-sh_mobile.c
>> >> +++ work/drivers/i2c/busses/i2c-sh_mobile.c 2010-08-02 15:14:48.000000000 +0900
>> >> @@ -538,15 +538,17 @@ static int sh_mobile_i2c_hook_irqs(struc
>> >> {
>> >> struct resource *res;
>> >> int ret = -ENXIO;
>> >> - int q, m;
>> >> - int k = 0;
>> >> - int n = 0;
>> >> + int n, k = 0;
>> >
>> > You can't really hope to get the code right with such variable names.
>>
>> And your suggestion is...? If you see something wrong with the code
>> please let me know.
>
> Nothing specific. I'm just trying to make you realize that one-letter
> variable names don't carry any meaning and thus make the code harder to
> write, read and debug.
Yes, I admit that four one-letter variables in a single function is
begging for trouble. Having one or two one-letter variable names is
not so bad IMO.
I guess one-letter variable names is my attempt to stick to pure
function and avoid going in the direction of endless coding style
discussions. =)
Cheers,
/ magnus
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] i2c: i2c-sh_mobile irq rollback fix
2010-08-10 13:18 ` Jean Delvare
[not found] ` <20100810151828.36a77cc3-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
@ 2010-08-31 22:27 ` Ben Dooks
1 sibling, 0 replies; 7+ messages in thread
From: Ben Dooks @ 2010-08-31 22:27 UTC (permalink / raw)
To: Jean Delvare; +Cc: Magnus Damm, linux-i2c, lethal, linux-sh
On Tue, Aug 10, 2010 at 03:18:28PM +0200, Jean Delvare wrote:
> On Mon, 02 Aug 2010 16:16:37 +0900, Magnus Damm wrote:
> > From: Magnus Damm <damm@opensource.se>
> >
> > Update the i2c-sh_mobile driver to properly free
> > interrupts. The function sh_mobile_i2c_hook_irqs()
> > is fixed so module both unload and load are working
> > as expected.
> >
> > Signed-off-by: Magnus Damm <damm@opensource.se>
> > ---
> >
> > drivers/i2c/busses/i2c-sh_mobile.c | 23 +++++++++++++----------
> > 1 file changed, 13 insertions(+), 10 deletions(-)
> >
> > --- 0001/drivers/i2c/busses/i2c-sh_mobile.c
> > +++ work/drivers/i2c/busses/i2c-sh_mobile.c 2010-08-02 15:14:48.000000000 +0900
> > @@ -538,15 +538,17 @@ static int sh_mobile_i2c_hook_irqs(struc
> > {
> > struct resource *res;
> > int ret = -ENXIO;
> > - int q, m;
> > - int k = 0;
> > - int n = 0;
> > + int n, k = 0;
>
> You can't really hope to get the code right with such variable names.
I agree, this isn't very readable. If possible, please have a rethink
of the code. You may also want to start using devm_ to track your
resources.
--
Ben
Q: What's a light-year?
A: One-third less calories than a regular year.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-08-31 22:27 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-02 7:16 [PATCH] i2c: i2c-sh_mobile irq rollback fix Magnus Damm
2010-08-04 7:44 ` Paul Mundt
2010-08-10 13:18 ` Jean Delvare
[not found] ` <20100810151828.36a77cc3-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-08-16 1:59 ` Magnus Damm
[not found] ` <AANLkTikQuCX7YC1tQ5MvwBdgxg1LE6k9f98-3M8khBJ6-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-08-16 6:24 ` Jean Delvare
[not found] ` <20100816082427.626ea303-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-08-16 7:34 ` Magnus Damm
2010-08-31 22:27 ` Ben Dooks
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).