From: Albert H. <he...@us...> - 2009-03-02 18:34:05
|
Update of /cvsroot/gc-linux/linux/drivers/gpio In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv503/drivers/gpio Modified Files: gpiolib.c Log Message: [PATCH] gpiolib: add gpio_direction_is_output From: Albert Herranz <alb...@ya...> Date: Sun, 1 Mar 2009 19:10:07 +0100 Subject: [PATCH] gpiolib: add gpio_direction_is_output Add a function to determine if a given gpio has been already configured as an output. This is handy for drivers that require changing multiple times the direction of a gpio and want to easily avoid redundant direction changes. Signed-off-by: Albert Herranz <alb...@ya...> Index: gpiolib.c =================================================================== RCS file: /cvsroot/gc-linux/linux/drivers/gpio/gpiolib.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** gpiolib.c 2 Mar 2009 18:33:09 -0000 1.1 --- gpiolib.c 2 Mar 2009 18:33:59 -0000 1.2 *************** *** 997,1000 **** --- 997,1018 ---- EXPORT_SYMBOL_GPL(gpio_direction_output); + /** + * gpio_direction_is_output - tell if a gpio is configured as an output + * @gpio: gpio in question + * + * Returns a negative errno if the given gpio is not valid. + * Returns a positive non-zero if the gpio is configured as an output. + * Returns zero otherwise. + */ + int gpio_direction_is_output(unsigned gpio) + { + struct gpio_desc *desc = &gpio_desc[gpio]; + + if (!gpio_is_valid(gpio)) + return -EINVAL; + + return test_bit(FLAG_IS_OUT, &desc->flags); + } + EXPORT_SYMBOL_GPL(gpio_direction_is_output); /* I/O calls are only valid after configuration completed; the relevant |