Skip to content

Commit

Permalink
gpio: janz-ttl: Use BIT() macro
Browse files Browse the repository at this point in the history
This makes the code more readable by using the BIT() macro.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Linus Walleij committed Mar 19, 2018
1 parent 1c947b7 commit 96d0d03
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions drivers/gpio/gpio-janz-ttl.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <linux/io.h>
#include <linux/gpio/driver.h>
#include <linux/slab.h>
#include <linux/bitops.h>

#include <linux/mfd/janz.h>

Expand All @@ -33,9 +34,9 @@
#define MASTER_INT_CTL 0x00
#define MASTER_CONF_CTL 0x01

#define CONF_PAE (1 << 2)
#define CONF_PBE (1 << 7)
#define CONF_PCE (1 << 4)
#define CONF_PAE BIT(2)
#define CONF_PBE BIT(7)
#define CONF_PCE BIT(4)

struct ttl_control_regs {
__be16 portc;
Expand Down Expand Up @@ -74,7 +75,7 @@ static int ttl_get_value(struct gpio_chip *gpio, unsigned offset)
}

spin_lock(&mod->lock);
ret = *shadow & (1 << offset);
ret = *shadow & BIT(offset);
spin_unlock(&mod->lock);
return !!ret;
}
Expand All @@ -100,9 +101,9 @@ static void ttl_set_value(struct gpio_chip *gpio, unsigned offset, int value)

spin_lock(&mod->lock);
if (value)
*shadow |= (1 << offset);
*shadow |= BIT(offset);
else
*shadow &= ~(1 << offset);
*shadow &= ~BIT(offset);

iowrite16be(*shadow, port);
spin_unlock(&mod->lock);
Expand Down

0 comments on commit 96d0d03

Please sign in to comment.