summaryrefslogtreecommitdiff
path: root/drivers/gpio/mxc_gpio.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpio/mxc_gpio.c')
-rw-r--r--drivers/gpio/mxc_gpio.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/gpio/mxc_gpio.c b/drivers/gpio/mxc_gpio.c
index df6bbbbc4b..f1b1c16b1b 100644
--- a/drivers/gpio/mxc_gpio.c
+++ b/drivers/gpio/mxc_gpio.c
@@ -34,6 +34,7 @@ enum mxc_gpio_direction {
MXC_GPIO_DIRECTION_OUT,
};
+#define GPIO_TO_PORT(n) (n / 32)
/* GPIO port description */
static unsigned long gpio_ports[] = {
@@ -53,7 +54,7 @@ static unsigned long gpio_ports[] = {
static int mxc_gpio_direction(unsigned int gpio,
enum mxc_gpio_direction direction)
{
- unsigned int port = gpio >> 5;
+ unsigned int port = GPIO_TO_PORT(gpio);
struct gpio_regs *regs;
u32 l;
@@ -80,7 +81,7 @@ static int mxc_gpio_direction(unsigned int gpio,
int gpio_set_value(unsigned gpio, int value)
{
- unsigned int port = gpio >> 5;
+ unsigned int port = GPIO_TO_PORT(gpio);
struct gpio_regs *regs;
u32 l;
@@ -103,7 +104,7 @@ int gpio_set_value(unsigned gpio, int value)
int gpio_get_value(unsigned gpio)
{
- unsigned int port = gpio >> 5;
+ unsigned int port = GPIO_TO_PORT(gpio);
struct gpio_regs *regs;
u32 val;
@@ -121,7 +122,7 @@ int gpio_get_value(unsigned gpio)
int gpio_request(unsigned gpio, const char *label)
{
- unsigned int port = gpio >> 5;
+ unsigned int port = GPIO_TO_PORT(gpio);
if (port >= ARRAY_SIZE(gpio_ports))
return -1;
return 0;
@@ -144,6 +145,5 @@ int gpio_direction_output(unsigned gpio, int value)
if (ret < 0)
return ret;
- gpio_set_value(gpio, value);
- return 0;
+ return gpio_set_value(gpio, value);
}