gpio: move gpio_is_valid to gpio.h
gpio < 0 means invalid too Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
5043fc33ac
commit
8a299c53bb
|
@ -4,17 +4,8 @@
|
||||||
|
|
||||||
static LIST_HEAD(chip_list);
|
static LIST_HEAD(chip_list);
|
||||||
|
|
||||||
#define ARCH_NR_GPIOS 256
|
|
||||||
|
|
||||||
static struct gpio_chip *gpio_desc[ARCH_NR_GPIOS];
|
static struct gpio_chip *gpio_desc[ARCH_NR_GPIOS];
|
||||||
|
|
||||||
static int gpio_is_valid(unsigned gpio)
|
|
||||||
{
|
|
||||||
if (gpio < ARCH_NR_GPIOS)
|
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void gpio_set_value(unsigned gpio, int value)
|
void gpio_set_value(unsigned gpio, int value)
|
||||||
{
|
{
|
||||||
struct gpio_chip *chip = gpio_desc[gpio];
|
struct gpio_chip *chip = gpio_desc[gpio];
|
||||||
|
|
|
@ -1,6 +1,17 @@
|
||||||
#ifndef __ASM_GENERIC_GPIO_H
|
#ifndef __ASM_GENERIC_GPIO_H
|
||||||
#define __ASM_GENERIC_GPIO_H
|
#define __ASM_GENERIC_GPIO_H
|
||||||
|
|
||||||
|
#define ARCH_NR_GPIOS 256
|
||||||
|
|
||||||
|
static inline int gpio_is_valid(int gpio)
|
||||||
|
{
|
||||||
|
if (gpio < 0)
|
||||||
|
return 0;
|
||||||
|
if (gpio < ARCH_NR_GPIOS)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void gpio_set_value(unsigned gpio, int value);
|
void gpio_set_value(unsigned gpio, int value);
|
||||||
int gpio_get_value(unsigned gpio);
|
int gpio_get_value(unsigned gpio);
|
||||||
int gpio_direction_output(unsigned gpio, int value);
|
int gpio_direction_output(unsigned gpio, int value);
|
||||||
|
|
Loading…
Reference in New Issue