2011-05-25 19:08:27

by Christian Gmeiner

[permalink] [raw]
Subject: [PATCH] cs5535 mfgpt - fix wrong if condition

From: Christian Gmeiner <[email protected]>

This patch fixes the wrong if condition for the check if the
requested timer is available.

The bitmap avail is used to store if a timer is used already.
test_bit() is used to check if the requested timer is
available. If a bit in the avail bitmap is set it means that the
timer is available.

Signed-off-by: Christian Gmeiner <[email protected]>
---
drivers/misc/cs5535-mfgpt.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/misc/cs5535-mfgpt.c b/drivers/misc/cs5535-mfgpt.c
index e01e08c..bc685bf 100644
--- a/drivers/misc/cs5535-mfgpt.c
+++ b/drivers/misc/cs5535-mfgpt.c
@@ -174,7 +174,7 @@ struct cs5535_mfgpt_timer
*cs5535_mfgpt_alloc_timer(int timer_nr, int domain)
timer_nr = t < max ? (int) t : -1;
} else {
/* check if the requested timer's available */
- if (test_bit(timer_nr, mfgpt->avail))
+ if (!test_bit(timer_nr, mfgpt->avail))
timer_nr = -1;
}

--
1.7.5.rc3

--
Christian Gmeiner, MSc


2011-06-03 23:14:20

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH] cs5535 mfgpt - fix wrong if condition

On Wed, 25 May 2011 19:08:06 +0000
Christian Gmeiner <[email protected]> wrote:

> From: Christian Gmeiner <[email protected]>
>
> This patch fixes the wrong if condition for the check if the
> requested timer is available.
>
> The bitmap avail is used to store if a timer is used already.
> test_bit() is used to check if the requested timer is
> available. If a bit in the avail bitmap is set it means that the
> timer is available.
>
> Signed-off-by: Christian Gmeiner <[email protected]>
> ---
> drivers/misc/cs5535-mfgpt.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/misc/cs5535-mfgpt.c b/drivers/misc/cs5535-mfgpt.c
> index e01e08c..bc685bf 100644
> --- a/drivers/misc/cs5535-mfgpt.c
> +++ b/drivers/misc/cs5535-mfgpt.c
> @@ -174,7 +174,7 @@ struct cs5535_mfgpt_timer
> *cs5535_mfgpt_alloc_timer(int timer_nr, int domain)
> timer_nr = t < max ? (int) t : -1;
> } else {
> /* check if the requested timer's available */
> - if (test_bit(timer_nr, mfgpt->avail))
> + if (!test_bit(timer_nr, mfgpt->avail))
> timer_nr = -1;
> }
>

What were the runtime effects of this bug?

(Please always include this information in the changelog when fixing things)

Thanks.

2011-06-03 23:24:40

by Andres Salomon

[permalink] [raw]
Subject: Re: [PATCH] cs5535 mfgpt - fix wrong if condition

You're right, it's reversed.

Acked-by: Andres Salomon <[email protected]>



On Fri, 3 Jun 2011 16:14:15 -0700
Andrew Morton <[email protected]> wrote:

> On Wed, 25 May 2011 19:08:06 +0000
> Christian Gmeiner <[email protected]> wrote:
>
> > From: Christian Gmeiner <[email protected]>
> >
> > This patch fixes the wrong if condition for the check if the
> > requested timer is available.
> >
> > The bitmap avail is used to store if a timer is used already.
> > test_bit() is used to check if the requested timer is
> > available. If a bit in the avail bitmap is set it means that the
> > timer is available.
> >
> > Signed-off-by: Christian Gmeiner <[email protected]>
> > ---
> > drivers/misc/cs5535-mfgpt.c | 2 +-
> > 1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/drivers/misc/cs5535-mfgpt.c
> > b/drivers/misc/cs5535-mfgpt.c index e01e08c..bc685bf 100644
> > --- a/drivers/misc/cs5535-mfgpt.c
> > +++ b/drivers/misc/cs5535-mfgpt.c
> > @@ -174,7 +174,7 @@ struct cs5535_mfgpt_timer
> > *cs5535_mfgpt_alloc_timer(int timer_nr, int domain)
> > timer_nr = t < max ? (int) t : -1;
> > } else {
> > /* check if the requested timer's available */
> > - if (test_bit(timer_nr, mfgpt->avail))
> > + if (!test_bit(timer_nr, mfgpt->avail))
> > timer_nr = -1;
> > }
> >
>
> What were the runtime effects of this bug?
>

The runtime effect would be that allocating a specific timer always
fails (versus telling cs5535_mfgpt_alloc_timer to allocate the first
available timer, which works).


> (Please always include this information in the changelog when fixing
> things)
>
> Thanks.