MIPS: Optimize get_user and put_user for 64-bit
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / mips / au1000 / common / gpio.c
index 0b658f1db4cedde3021e4eea3916091b36e4ab87..e660ddd611c465dc6665ecf7d1346f82a5e77b98 100644 (file)
  *     others have a second one : GPIO2
  */
 
-#include <linux/init.h>
-#include <linux/io.h>
-#include <linux/types.h>
 #include <linux/module.h>
 
-#include <asm/addrspace.h>
-
 #include <asm/mach-au1x00/au1000.h>
 #include <asm/gpio.h>
 
@@ -53,7 +48,7 @@ static void au1xxx_gpio2_write(unsigned gpio, int value)
 {
        gpio -= AU1XXX_GPIO_BASE;
 
-       gpio2->output = (GPIO2_OUTPUT_ENABLE_MASK << gpio) | (value << gpio);
+       gpio2->output = (GPIO2_OUTPUT_ENABLE_MASK << gpio) | ((!!value) << gpio);
 }
 
 static int au1xxx_gpio2_direction_input(unsigned gpio)
@@ -66,7 +61,8 @@ static int au1xxx_gpio2_direction_input(unsigned gpio)
 static int au1xxx_gpio2_direction_output(unsigned gpio, int value)
 {
        gpio -= AU1XXX_GPIO_BASE;
-       gpio2->dir = (0x01 << gpio) | (value << gpio);
+       gpio2->dir |= 0x01 << gpio;
+       gpio2->output = (GPIO2_OUTPUT_ENABLE_MASK << gpio) | ((!!value) << gpio);
        return 0;
 }
 
@@ -74,7 +70,7 @@ static int au1xxx_gpio2_direction_output(unsigned gpio, int value)
 
 static int au1xxx_gpio1_read(unsigned gpio)
 {
-       return ((gpio1->pinstaterd >> gpio) & 0x01);
+       return (gpio1->pinstaterd >> gpio) & 0x01;
 }
 
 static void au1xxx_gpio1_write(unsigned gpio, int value)
@@ -95,6 +91,7 @@ static int au1xxx_gpio1_direction_input(unsigned gpio)
 static int au1xxx_gpio1_direction_output(unsigned gpio, int value)
 {
        gpio1->trioutclr = (0x01 & gpio);
+       au1xxx_gpio1_write(gpio, value);
        return 0;
 }
 
@@ -109,7 +106,6 @@ int au1xxx_gpio_get_value(unsigned gpio)
        else
                return au1xxx_gpio1_read(gpio);
 }
-
 EXPORT_SYMBOL(au1xxx_gpio_get_value);
 
 void au1xxx_gpio_set_value(unsigned gpio, int value)
@@ -123,7 +119,6 @@ void au1xxx_gpio_set_value(unsigned gpio, int value)
        else
                au1xxx_gpio1_write(gpio, value);
 }
-
 EXPORT_SYMBOL(au1xxx_gpio_set_value);
 
 int au1xxx_gpio_direction_input(unsigned gpio)
@@ -137,7 +132,6 @@ int au1xxx_gpio_direction_input(unsigned gpio)
 
        return au1xxx_gpio1_direction_input(gpio);
 }
-
 EXPORT_SYMBOL(au1xxx_gpio_direction_input);
 
 int au1xxx_gpio_direction_output(unsigned gpio, int value)
@@ -151,5 +145,4 @@ int au1xxx_gpio_direction_output(unsigned gpio, int value)
 
        return au1xxx_gpio1_direction_output(gpio, value);
 }
-
 EXPORT_SYMBOL(au1xxx_gpio_direction_output);