Skip to content

Commit a1389f5

Browse files
tq-schiffermBartosz Golaszewski
authored andcommitted
gpio: tqmx86: introduce tqmx86_gpio_clrsetbits() helper
Add a helper for the common read-modify-write pattern (only used in tqmx86_gpio_irq_config() initially). No functional change intended. Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com> Link: https://lore.kernel.org/r/f60ec3cc1386d4527ebb864d1b069683473b7a5a.1734001247.git.matthias.schiffer@ew.tq-group.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
1 parent 2abb6e5 commit a1389f5

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

drivers/gpio/gpio-tqmx86.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@ static void tqmx86_gpio_write(struct tqmx86_gpio_data *gd, u8 val,
6666
iowrite8(val, gd->io_base + reg);
6767
}
6868

69+
static void tqmx86_gpio_clrsetbits(struct tqmx86_gpio_data *gpio,
70+
u8 clr, u8 set, unsigned int reg)
71+
__must_hold(&gpio->spinlock)
72+
{
73+
u8 val = tqmx86_gpio_read(gpio, reg);
74+
75+
val &= ~clr;
76+
val |= set;
77+
78+
tqmx86_gpio_write(gpio, val, reg);
79+
}
80+
6981
static int tqmx86_gpio_get(struct gpio_chip *chip, unsigned int offset)
7082
{
7183
struct tqmx86_gpio_data *gpio = gpiochip_get_data(chip);
@@ -118,7 +130,7 @@ static int tqmx86_gpio_get_direction(struct gpio_chip *chip,
118130
static void tqmx86_gpio_irq_config(struct tqmx86_gpio_data *gpio, int hwirq)
119131
__must_hold(&gpio->spinlock)
120132
{
121-
u8 type = TQMX86_INT_TRIG_NONE, gpiic;
133+
u8 type = TQMX86_INT_TRIG_NONE;
122134
int gpiic_irq = hwirq - TQMX86_NGPO;
123135

124136
if (gpio->irq_type[hwirq] & TQMX86_INT_UNMASKED) {
@@ -130,10 +142,10 @@ static void tqmx86_gpio_irq_config(struct tqmx86_gpio_data *gpio, int hwirq)
130142
: TQMX86_INT_TRIG_RISING;
131143
}
132144

133-
gpiic = tqmx86_gpio_read(gpio, TQMX86_GPIIC);
134-
gpiic &= ~TQMX86_GPIIC_MASK(gpiic_irq);
135-
gpiic |= TQMX86_GPIIC_CONFIG(gpiic_irq, type);
136-
tqmx86_gpio_write(gpio, gpiic, TQMX86_GPIIC);
145+
tqmx86_gpio_clrsetbits(gpio,
146+
TQMX86_GPIIC_MASK(gpiic_irq),
147+
TQMX86_GPIIC_CONFIG(gpiic_irq, type),
148+
TQMX86_GPIIC);
137149
}
138150

139151
static void tqmx86_gpio_irq_mask(struct irq_data *data)

0 commit comments

Comments
 (0)