gpio: twl6040: Use bitops
[linux-2.6-block.git] / drivers / gpio / gpio-twl6040.c
index c0c18c80abbd856cdca81fc2bf94afa9c5a67a55..77d50542bf61c4bf13941c99efb350dc0e46b6b2 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/irq.h>
 #include <linux/gpio/driver.h>
 #include <linux/platform_device.h>
+#include <linux/bitops.h>
 #include <linux/of.h>
 
 #include <linux/mfd/twl6040.h>
@@ -28,7 +29,7 @@ static int twl6040gpo_get(struct gpio_chip *chip, unsigned offset)
        if (ret < 0)
                return ret;
 
-       return (ret >> offset) & 1;
+       return !!(ret & BIT(offset));
 }
 
 static int twl6040gpo_direction_out(struct gpio_chip *chip, unsigned offset,
@@ -49,9 +50,9 @@ static void twl6040gpo_set(struct gpio_chip *chip, unsigned offset, int value)
                return;
 
        if (value)
-               gpoctl = ret | (1 << offset);
+               gpoctl = ret | BIT(offset);
        else
-               gpoctl = ret & ~(1 << offset);
+               gpoctl = ret & ~BIT(offset);
 
        twl6040_reg_write(twl6040, TWL6040_REG_GPOCTL, gpoctl);
 }