From: florian Date: Mon, 27 Aug 2007 10:36:29 +0000 (+0000) Subject: Make the architecture gpio more readable X-Git-Url: https://git.rohieb.name/openwrt.git/commitdiff_plain/2fddc9a43851291fd9bc4569694f082c9d27f88d?hp=a1da927102dcfe5b92d26c4395c1c2306671b7b7 Make the architecture gpio more readable git-svn-id: svn://svn.openwrt.org/openwrt/trunk@8504 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- diff --git a/target/linux/rdc-2.6/files/arch/i386/mach-rdc/gpio.c b/target/linux/rdc-2.6/files/arch/i386/mach-rdc/gpio.c index 28a33db07..2c3886771 100644 --- a/target/linux/rdc-2.6/files/arch/i386/mach-rdc/gpio.c +++ b/target/linux/rdc-2.6/files/arch/i386/mach-rdc/gpio.c @@ -15,8 +15,12 @@ #include #include -#define RDC3210_CFGREG_ADDR 0x0CF8 -#define RDC3210_CFGREG_DATA 0x0CFC +#include + +static inline int rdc_gpio_is_valid(unsigned gpio) +{ + return ((gpio > RDC_MAX_GPIO) ? 0 : 1); +} static unsigned int rdc_gpio_read(unsigned gpio) { @@ -47,7 +51,8 @@ static void rdc_gpio_write(unsigned int val) int rdc_gpio_get_value(unsigned gpio) { - return (gpio>0x3A?-EINVAL:(int)rdc_gpio_read(gpio)); + if (rdc_gpio_is_valid(gpio)) + return (int)rdc_gpio_read(gpio); } EXPORT_SYMBOL(rdc_gpio_get_value); @@ -55,7 +60,9 @@ void rdc_gpio_set_value(unsigned gpio, int value) { unsigned int val; - if (gpio > 0x3A) return; + if (!rdc_gpio_is_valid(gpio)) + return; + val = rdc_gpio_read(gpio); if (value)