gpio: drop bitmap_complement() where feasible
Subsystems (3)
v2 cover gpio: drop bitmap_complement() where feasible
The gpio drivers reproduce the following pattern:
bitmap_complement(tmp, data1, nbits); bitmap_and(dst, data2, tmp, nbits);
This can be done in a single pass:
bitmap_andnot(dst, data2, data1, nbits);
v1: https://lore.kernel.org/all/[email protected]/
v2:
- cleanup typos (Michal);
- split per individual drivers (Andy).
Yury Norov (2):
gpio: pca953x: drop bitmap_complement() where feasible
gpio: xilinx: drop bitmap_complement() where feasible
drivers/gpio/gpio-pca953x.c | 7 ++----- drivers/gpio/gpio-xilinx.c | 6 ++---- 2 files changed, 4 insertions(+), 9 deletions(-)
Signature · 1 line
2.51.0
PATCH v2 1/2 gpio: pca953x: drop bitmap_complement() where feasible
The driver reproduces the following pattern:
bitmap_complement(tmp, data1, nbits); bitmap_and(dst, data2, tmp, nbits);
This can be done in a single pass:
bitmap_andnot(dst, data2, data1, nbits);
--- drivers/gpio/gpio-pca953x.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/gpio/gpio-pca953x.c +2 -5
@@ -877,11 +877,9 @@ static void pca953x_irq_bus_sync_unlock(struct irq_data *d)bitmap_or (irq_mask, chip->irq_trig_fall, chip->irq_trig_raise, gc->ngpio);bitmap_or (irq_mask, irq_mask, chip->irq_trig_level_high, gc->ngpio);bitmap_or (irq_mask, irq_mask, chip->irq_trig_level_low, gc->ngpio); -bitmap_complement (reg_direction, reg_direction, gc->ngpio); -bitmap_and (irq_mask, irq_mask, reg_direction, gc->ngpio);/* Look for any newly setup interrupt */ -for_each_set_bit (level, irq_mask, gc->ngpio) +for_each_andnot_bit (level, irq_mask, reg_direction, gc->ngpio)pca953x_gpio_direction_input (&chip->gpio_chip, level);mutex_unlock (&chip->irq_lock);
@@ -1005,8 +1003,7 @@ static bool pca953x_irq_pending(struct pca953x_chip *chip, unsigned long *pendinbitmap_and (cur_stat, cur_stat, chip->irq_mask, gc->ngpio);bitmap_or (pending, pending, cur_stat, gc->ngpio); -bitmap_complement (cur_stat, new_stat, gc->ngpio); -bitmap_and (cur_stat, cur_stat, reg_direction, gc->ngpio); +bitmap_andnot (cur_stat, reg_direction, new_stat, gc->ngpio);bitmap_and (old_stat, cur_stat, chip->irq_trig_level_low, gc->ngpio);bitmap_and (old_stat, old_stat, chip->irq_mask, gc->ngpio);bitmap_or (pending, pending, old_stat, gc->ngpio);
Signature · 1 line
2.51.0
PATCH v2 2/2 gpio: xilinx: drop bitmap_complement() where feasible
In reply to Yury NorovThe drivers reproduces the following pattern:
bitmap_complement(tmp, data1, nbits); bitmap_and(dst, data2, tmp, nbits);
This can be done in a single pass:
bitmap_andnot(dst, data2, data1, nbits);
--- drivers/gpio/gpio-xilinx.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpio/gpio-xilinx.c +2 -4
@@ -495,13 +495,11 @@ static void xgpio_irqhandler(struct irq_desc *desc)xgpio_read_ch_all (chip,XGPIO_DATA_OFFSET , hw); -bitmap_complement (rising, chip->last_irq_read,64 ); -bitmap_and (rising, rising, hw,64 ); +bitmap_andnot (rising, hw, chip->last_irq_read,64 );bitmap_and (rising, rising, chip->enable,64 );bitmap_and (rising, rising, chip->rising_edge,64 ); -bitmap_complement (falling, hw,64 ); -bitmap_and (falling, falling, chip->last_irq_read,64 ); +bitmap_andnot (falling, chip->last_irq_read, hw,64 );bitmap_and (falling, falling, chip->enable,64 );bitmap_and (falling, falling, chip->falling_edge,64 );
Signature · 1 line
2.51.0
Re: [PATCH v2 2/2] gpio: xilinx: drop bitmap_complement() where feasible
Quoted 3 lines · Yury Norov
[Some people who received this message don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
The drivers reproduces the following pattern:
The driver reproduce
With that fix
Thanks,
Michal
Quoted 8 lines · Yury Norov
The gpio drivers reproduce the following pattern:
bitmap_complement(tmp, data1, nbits); bitmap_and(dst, data2, tmp, nbits);This can be done in a single pass:
[...]
Tweaked the grammar in commit messages and applied, thanks!
[1/2] gpio: pca953x: drop bitmap_complement() where feasible
https://git.kernel.org/brgl/c/a56604e397575647bfc425a8df176948577a364e [2/2] gpio: xilinx: drop bitmap_complement() where feasible https://git.kernel.org/brgl/c/2757a5b1bca76a1b6378496b669a2baf1faddec5
Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>