diff options
author | Javier Martinez Canillas <javier@dowhile0.org> | 2014-04-26 20:00:50 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2014-05-03 15:16:24 -0400 |
commit | bea415041c28907d721f0647b3b80f613f0c4d37 (patch) | |
tree | c167aa8bf703c5a18c56ef20b52bdd6d7a6e6888 /drivers/gpio/gpio-pl061.c | |
parent | b1e9fec2b8690b153b0b9ebbe9dfe6a246d55e4a (diff) |
gpio: pl061: use BIT() macro instead of shifting bits
Using the BIT() macro instead of shifting bits
makes the code less error prone and also more readable.
Signed-off-by: Javier Martinez Canillas <javier@dowhile0.org>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-pl061.c')
-rw-r--r-- | drivers/gpio/gpio-pl061.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c index 84553d35bdfa..84b49cfb81a8 100644 --- a/drivers/gpio/gpio-pl061.c +++ b/drivers/gpio/gpio-pl061.c | |||
@@ -87,7 +87,7 @@ static int pl061_direction_input(struct gpio_chip *gc, unsigned offset) | |||
87 | 87 | ||
88 | spin_lock_irqsave(&chip->lock, flags); | 88 | spin_lock_irqsave(&chip->lock, flags); |
89 | gpiodir = readb(chip->base + GPIODIR); | 89 | gpiodir = readb(chip->base + GPIODIR); |
90 | gpiodir &= ~(1 << offset); | 90 | gpiodir &= ~(BIT(offset)); |
91 | writeb(gpiodir, chip->base + GPIODIR); | 91 | writeb(gpiodir, chip->base + GPIODIR); |
92 | spin_unlock_irqrestore(&chip->lock, flags); | 92 | spin_unlock_irqrestore(&chip->lock, flags); |
93 | 93 | ||
@@ -105,16 +105,16 @@ static int pl061_direction_output(struct gpio_chip *gc, unsigned offset, | |||
105 | return -EINVAL; | 105 | return -EINVAL; |
106 | 106 | ||
107 | spin_lock_irqsave(&chip->lock, flags); | 107 | spin_lock_irqsave(&chip->lock, flags); |
108 | writeb(!!value << offset, chip->base + (1 << (offset + 2))); | 108 | writeb(!!value << offset, chip->base + (BIT(offset + 2))); |
109 | gpiodir = readb(chip->base + GPIODIR); | 109 | gpiodir = readb(chip->base + GPIODIR); |
110 | gpiodir |= 1 << offset; | 110 | gpiodir |= BIT(offset); |
111 | writeb(gpiodir, chip->base + GPIODIR); | 111 | writeb(gpiodir, chip->base + GPIODIR); |
112 | 112 | ||
113 | /* | 113 | /* |
114 | * gpio value is set again, because pl061 doesn't allow to set value of | 114 | * gpio value is set again, because pl061 doesn't allow to set value of |
115 | * a gpio pin before configuring it in OUT mode. | 115 | * a gpio pin before configuring it in OUT mode. |
116 | */ | 116 | */ |
117 | writeb(!!value << offset, chip->base + (1 << (offset + 2))); | 117 | writeb(!!value << offset, chip->base + (BIT(offset + 2))); |
118 | spin_unlock_irqrestore(&chip->lock, flags); | 118 | spin_unlock_irqrestore(&chip->lock, flags); |
119 | 119 | ||
120 | return 0; | 120 | return 0; |
@@ -124,14 +124,14 @@ static int pl061_get_value(struct gpio_chip *gc, unsigned offset) | |||
124 | { | 124 | { |
125 | struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); | 125 | struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); |
126 | 126 | ||
127 | return !!readb(chip->base + (1 << (offset + 2))); | 127 | return !!readb(chip->base + (BIT(offset + 2))); |
128 | } | 128 | } |
129 | 129 | ||
130 | static void pl061_set_value(struct gpio_chip *gc, unsigned offset, int value) | 130 | static void pl061_set_value(struct gpio_chip *gc, unsigned offset, int value) |
131 | { | 131 | { |
132 | struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); | 132 | struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); |
133 | 133 | ||
134 | writeb(!!value << offset, chip->base + (1 << (offset + 2))); | 134 | writeb(!!value << offset, chip->base + (BIT(offset + 2))); |
135 | } | 135 | } |
136 | 136 | ||
137 | static int pl061_irq_type(struct irq_data *d, unsigned trigger) | 137 | static int pl061_irq_type(struct irq_data *d, unsigned trigger) |
@@ -206,7 +206,7 @@ static void pl061_irq_mask(struct irq_data *d) | |||
206 | { | 206 | { |
207 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 207 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
208 | struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); | 208 | struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); |
209 | u8 mask = 1 << (irqd_to_hwirq(d) % PL061_GPIO_NR); | 209 | u8 mask = BIT(irqd_to_hwirq(d) % PL061_GPIO_NR); |
210 | u8 gpioie; | 210 | u8 gpioie; |
211 | 211 | ||
212 | spin_lock(&chip->lock); | 212 | spin_lock(&chip->lock); |
@@ -219,7 +219,7 @@ static void pl061_irq_unmask(struct irq_data *d) | |||
219 | { | 219 | { |
220 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); | 220 | struct gpio_chip *gc = irq_data_get_irq_chip_data(d); |
221 | struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); | 221 | struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc); |
222 | u8 mask = 1 << (irqd_to_hwirq(d) % PL061_GPIO_NR); | 222 | u8 mask = BIT(irqd_to_hwirq(d) % PL061_GPIO_NR); |
223 | u8 gpioie; | 223 | u8 gpioie; |
224 | 224 | ||
225 | spin_lock(&chip->lock); | 225 | spin_lock(&chip->lock); |
@@ -301,9 +301,9 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id) | |||
301 | 301 | ||
302 | for (i = 0; i < PL061_GPIO_NR; i++) { | 302 | for (i = 0; i < PL061_GPIO_NR; i++) { |
303 | if (pdata) { | 303 | if (pdata) { |
304 | if (pdata->directions & (1 << i)) | 304 | if (pdata->directions & (BIT(i))) |
305 | pl061_direction_output(&chip->gc, i, | 305 | pl061_direction_output(&chip->gc, i, |
306 | pdata->values & (1 << i)); | 306 | pdata->values & (BIT(i))); |
307 | else | 307 | else |
308 | pl061_direction_input(&chip->gc, i); | 308 | pl061_direction_input(&chip->gc, i); |
309 | } | 309 | } |
@@ -330,7 +330,7 @@ static int pl061_suspend(struct device *dev) | |||
330 | chip->csave_regs.gpio_ie = readb(chip->base + GPIOIE); | 330 | chip->csave_regs.gpio_ie = readb(chip->base + GPIOIE); |
331 | 331 | ||
332 | for (offset = 0; offset < PL061_GPIO_NR; offset++) { | 332 | for (offset = 0; offset < PL061_GPIO_NR; offset++) { |
333 | if (chip->csave_regs.gpio_dir & (1 << offset)) | 333 | if (chip->csave_regs.gpio_dir & (BIT(offset))) |
334 | chip->csave_regs.gpio_data |= | 334 | chip->csave_regs.gpio_data |= |
335 | pl061_get_value(&chip->gc, offset) << offset; | 335 | pl061_get_value(&chip->gc, offset) << offset; |
336 | } | 336 | } |
@@ -344,10 +344,10 @@ static int pl061_resume(struct device *dev) | |||
344 | int offset; | 344 | int offset; |
345 | 345 | ||
346 | for (offset = 0; offset < PL061_GPIO_NR; offset++) { | 346 | for (offset = 0; offset < PL061_GPIO_NR; offset++) { |
347 | if (chip->csave_regs.gpio_dir & (1 << offset)) | 347 | if (chip->csave_regs.gpio_dir & (BIT(offset))) |
348 | pl061_direction_output(&chip->gc, offset, | 348 | pl061_direction_output(&chip->gc, offset, |
349 | chip->csave_regs.gpio_data & | 349 | chip->csave_regs.gpio_data & |
350 | (1 << offset)); | 350 | (BIT(offset))); |
351 | else | 351 | else |
352 | pl061_direction_input(&chip->gc, offset); | 352 | pl061_direction_input(&chip->gc, offset); |
353 | } | 353 | } |