* [PATCH] gpiolib: don't compare an unsigned for >= 0
@ 2015-08-18 16:02 Dirk Behme
2015-08-30 5:13 ` Dirk Behme
2015-10-02 8:57 ` Linus Walleij
0 siblings, 2 replies; 5+ messages in thread
From: Dirk Behme @ 2015-08-18 16:02 UTC (permalink / raw)
To: linux-gpio; +Cc: Dirk Behme
The parameter offset is an unsigned, so it makes no sense to compare
it for >= 0. Fix the compiler warning regarding this by removing this
comparison.
As the macro GPIO_OFFSET_VALID is only used at this single place, simplify
the code by dropping the macro completely and dropping the invert, too.
No functional change.
Signed-off-by: Dirk Behme <dirk.behme@gmail.com>
---
drivers/gpio/gpiolib.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index bf4bd1d..9841b05 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -47,8 +47,6 @@
*/
DEFINE_SPINLOCK(gpio_lock);
-#define GPIO_OFFSET_VALID(chip, offset) (offset >= 0 && offset < chip->ngpio)
-
static DEFINE_MUTEX(gpio_lookup_lock);
static LIST_HEAD(gpio_lookup_list);
LIST_HEAD(gpio_chips);
@@ -914,7 +912,7 @@ const char *gpiochip_is_requested(struct gpio_chip *chip, unsigned offset)
{
struct gpio_desc *desc;
- if (!GPIO_OFFSET_VALID(chip, offset))
+ if (offset >= chip->ngpio)
return NULL;
desc = &chip->desc[offset];
--
2.5.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] gpiolib: don't compare an unsigned for >= 0
2015-08-18 16:02 [PATCH] gpiolib: don't compare an unsigned for >= 0 Dirk Behme
@ 2015-08-30 5:13 ` Dirk Behme
2015-08-31 4:44 ` Alexandre Courbot
2015-10-02 8:57 ` Linus Walleij
1 sibling, 1 reply; 5+ messages in thread
From: Dirk Behme @ 2015-08-30 5:13 UTC (permalink / raw)
To: Linus Walleij, Alexandre Courbot; +Cc: linux-gpio
On 18.08.2015 18:02, Dirk Behme wrote:
> The parameter offset is an unsigned, so it makes no sense to compare
> it for >= 0. Fix the compiler warning regarding this by removing this
> comparison.
>
> As the macro GPIO_OFFSET_VALID is only used at this single place, simplify
> the code by dropping the macro completely and dropping the invert, too.
>
> No functional change.
>
> Signed-off-by: Dirk Behme <dirk.behme@gmail.com>
> ---
> drivers/gpio/gpiolib.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index bf4bd1d..9841b05 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -47,8 +47,6 @@
> */
> DEFINE_SPINLOCK(gpio_lock);
>
> -#define GPIO_OFFSET_VALID(chip, offset) (offset >= 0 && offset < chip->ngpio)
> -
> static DEFINE_MUTEX(gpio_lookup_lock);
> static LIST_HEAD(gpio_lookup_list);
> LIST_HEAD(gpio_chips);
> @@ -914,7 +912,7 @@ const char *gpiochip_is_requested(struct gpio_chip *chip, unsigned offset)
> {
> struct gpio_desc *desc;
>
> - if (!GPIO_OFFSET_VALID(chip, offset))
> + if (offset >= chip->ngpio)
> return NULL;
>
> desc = &chip->desc[offset];
What do you think about this? Could this be applied?
Best regards
Dirk
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gpiolib: don't compare an unsigned for >= 0
2015-08-30 5:13 ` Dirk Behme
@ 2015-08-31 4:44 ` Alexandre Courbot
2015-09-23 9:41 ` Dirk Behme
0 siblings, 1 reply; 5+ messages in thread
From: Alexandre Courbot @ 2015-08-31 4:44 UTC (permalink / raw)
To: Dirk Behme; +Cc: Linus Walleij, linux-gpio@vger.kernel.org
On Sun, Aug 30, 2015 at 2:13 PM, Dirk Behme <dirk.behme@gmail.com> wrote:
> On 18.08.2015 18:02, Dirk Behme wrote:
>>
>> The parameter offset is an unsigned, so it makes no sense to compare
>> it for >= 0. Fix the compiler warning regarding this by removing this
>> comparison.
>>
>> As the macro GPIO_OFFSET_VALID is only used at this single place, simplify
>> the code by dropping the macro completely and dropping the invert, too.
>>
>> No functional change.
>>
>> Signed-off-by: Dirk Behme <dirk.behme@gmail.com>
>> ---
>> drivers/gpio/gpiolib.c | 4 +---
>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
>> index bf4bd1d..9841b05 100644
>> --- a/drivers/gpio/gpiolib.c
>> +++ b/drivers/gpio/gpiolib.c
>> @@ -47,8 +47,6 @@
>> */
>> DEFINE_SPINLOCK(gpio_lock);
>>
>> -#define GPIO_OFFSET_VALID(chip, offset) (offset >= 0 && offset <
>> chip->ngpio)
>> -
>> static DEFINE_MUTEX(gpio_lookup_lock);
>> static LIST_HEAD(gpio_lookup_list);
>> LIST_HEAD(gpio_chips);
>> @@ -914,7 +912,7 @@ const char *gpiochip_is_requested(struct gpio_chip
>> *chip, unsigned offset)
>> {
>> struct gpio_desc *desc;
>>
>> - if (!GPIO_OFFSET_VALID(chip, offset))
>> + if (offset >= chip->ngpio)
>> return NULL;
>>
>> desc = &chip->desc[offset];
>
>
>
> What do you think about this? Could this be applied?
Looks good to me.
Acked-by: Alexandre Courbot <acourbot@nvidia.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gpiolib: don't compare an unsigned for >= 0
2015-08-31 4:44 ` Alexandre Courbot
@ 2015-09-23 9:41 ` Dirk Behme
0 siblings, 0 replies; 5+ messages in thread
From: Dirk Behme @ 2015-09-23 9:41 UTC (permalink / raw)
To: Alexandre Courbot, Linus Walleij; +Cc: linux-gpio@vger.kernel.org
On 31.08.2015 06:44, Alexandre Courbot wrote:
> On Sun, Aug 30, 2015 at 2:13 PM, Dirk Behme <dirk.behme@gmail.com> wrote:
>> On 18.08.2015 18:02, Dirk Behme wrote:
>>>
>>> The parameter offset is an unsigned, so it makes no sense to compare
>>> it for >= 0. Fix the compiler warning regarding this by removing this
>>> comparison.
>>>
>>> As the macro GPIO_OFFSET_VALID is only used at this single place, simplify
>>> the code by dropping the macro completely and dropping the invert, too.
>>>
>>> No functional change.
>>>
>>> Signed-off-by: Dirk Behme <dirk.behme@gmail.com>
>>> ---
>>> drivers/gpio/gpiolib.c | 4 +---
>>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
>>> index bf4bd1d..9841b05 100644
>>> --- a/drivers/gpio/gpiolib.c
>>> +++ b/drivers/gpio/gpiolib.c
>>> @@ -47,8 +47,6 @@
>>> */
>>> DEFINE_SPINLOCK(gpio_lock);
>>>
>>> -#define GPIO_OFFSET_VALID(chip, offset) (offset >= 0 && offset <
>>> chip->ngpio)
>>> -
>>> static DEFINE_MUTEX(gpio_lookup_lock);
>>> static LIST_HEAD(gpio_lookup_list);
>>> LIST_HEAD(gpio_chips);
>>> @@ -914,7 +912,7 @@ const char *gpiochip_is_requested(struct gpio_chip
>>> *chip, unsigned offset)
>>> {
>>> struct gpio_desc *desc;
>>>
>>> - if (!GPIO_OFFSET_VALID(chip, offset))
>>> + if (offset >= chip->ngpio)
>>> return NULL;
>>>
>>> desc = &chip->desc[offset];
>>
>>
>>
>> What do you think about this? Could this be applied?
>
> Looks good to me.
>
> Acked-by: Alexandre Courbot <acourbot@nvidia.com>
Ping, could this be applied, then?
Best regards
Dirk
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gpiolib: don't compare an unsigned for >= 0
2015-08-18 16:02 [PATCH] gpiolib: don't compare an unsigned for >= 0 Dirk Behme
2015-08-30 5:13 ` Dirk Behme
@ 2015-10-02 8:57 ` Linus Walleij
1 sibling, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2015-10-02 8:57 UTC (permalink / raw)
To: Dirk Behme; +Cc: linux-gpio@vger.kernel.org
On Tue, Aug 18, 2015 at 9:02 AM, Dirk Behme <dirk.behme@gmail.com> wrote:
> The parameter offset is an unsigned, so it makes no sense to compare
> it for >= 0. Fix the compiler warning regarding this by removing this
> comparison.
>
> As the macro GPIO_OFFSET_VALID is only used at this single place, simplify
> the code by dropping the macro completely and dropping the invert, too.
>
> No functional change.
>
> Signed-off-by: Dirk Behme <dirk.behme@gmail.com>
Patch applied with Alexandre's ACK.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-10-02 8:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-18 16:02 [PATCH] gpiolib: don't compare an unsigned for >= 0 Dirk Behme
2015-08-30 5:13 ` Dirk Behme
2015-08-31 4:44 ` Alexandre Courbot
2015-09-23 9:41 ` Dirk Behme
2015-10-02 8:57 ` Linus Walleij
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).