lkml.org 
[lkml]   [2008]   [Feb]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    SubjectRe: [PATCH] Define a NO_GPIO macro to compare against and to use as an invalid GPIO
    Date
    On Thursday 31 January 2008, Guennadi Liakhovetski wrote:
    > As discussed on i2c mailing list with David Brownell, and number
    > outside of the 0...MAX_INT range is invalid as a GPIO number.
    > Define a macro, similar to NO_IRQ, to be used as a deliberate
    > invalid GPIO, rather than defining a is_valid_gpio() macro.

    Actually I thought that what you needed was an is_valid_gpio();
    your motivation was that you needed a predicate.

    The problem I have with a #define for a single such invalid GPIO
    number is that people will inevitably start to assume it's the
    only such number. In particular "if (gpio == NO_GPIO) ..."
    is by definition incorrect.

    So I'd really rather see a predicate like is_valid_gpio().

    If you want to designate one value for use as an initializer,
    then I'd rather see a simple

    #define NO_GPIO (-EINVAL)

    without any option for arch-specific overrides ... along with a
    comment that this is only *one* of the numerous values which
    will fail is_valid_gpio().

    - Dave



    >
    > Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@pengutronix.de>
    >
    > ---
    >
    > As gpiolib doesn't seem to have an own mailing list, sending it directly
    > to LKML.
    >
    > include/asm-generic/gpio.h | 4 ++++
    > 1 files changed, 4 insertions(+), 0 deletions(-)
    >
    > diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
    > index f29a502..806b86c 100644
    > --- a/include/asm-generic/gpio.h
    > +++ b/include/asm-generic/gpio.h
    > @@ -16,6 +16,10 @@
    > #define ARCH_NR_GPIOS 256
    > #endif
    >
    > +#ifndef NO_GPIO
    > +#define NO_GPIO ((unsigned int)-1)
    > +#endif
    > +
    > struct seq_file;
    >
    > /**
    > --
    > 1.5.3.4
    >




    \
     
     \ /
      Last update: 2008-02-09 00:47    [W:0.021 / U:0.844 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site