mbox series

[v1,0/2] gpio: xilinx: Replace custom bitmap APIs

Message ID 20250204190218.243537-1-andriy.shevchenko@linux.intel.com
Headers show
Series gpio: xilinx: Replace custom bitmap APIs | expand

Message

Andy Shevchenko Feb. 4, 2025, 7 p.m. UTC
Relatively recently bitmap APIs gain a few new calls which may help
to convert the GPIO Xilinx driver to use them and become shorter and
nicer. This mini-series does exactly that.

Andy Shevchenko (2):
  gpio: xilinx: Use better bitmap APIs where appropriate
  gpio: xilinx: Replace custom variants of bitmap_read()/bitmap_write()

 drivers/gpio/gpio-xilinx.c | 96 ++++++++++++++------------------------
 1 file changed, 34 insertions(+), 62 deletions(-)

Comments

Andy Shevchenko Feb. 5, 2025, 9:15 a.m. UTC | #1
On Tue, Feb 04, 2025 at 09:00:48PM +0200, Andy Shevchenko wrote:
> Relatively recently bitmap APIs were expanded by introduction of
> bitmap_read() and bitmap_write(). These APIs are generic ones
> that may replace custom functions in this driver, i.e. xgpio_get_value32()
> and xgpio_set_value32(). Do replace them.

...

> @@ -386,13 +371,14 @@ static void xgpio_irq_mask(struct irq_data *irq_data)
>  	struct xgpio_instance *chip = irq_data_get_irq_chip_data(irq_data);
>  	int irq_offset = irqd_to_hwirq(irq_data);
>  	unsigned long bit = find_nth_bit(chip->map, 64, irq_offset);
> +	unsigned long old_enable = bitmap_read(chip->enable, round_down(bit, 32), 32);
>  	u32 mask = BIT(bit / 32), temp;
>  
>  	raw_spin_lock_irqsave(&chip->gpio_lock, flags);
>  
>  	__clear_bit(bit, chip->enable);
>  
> -	if (xgpio_get_value32(chip->enable, bit) == 0) {
> +	if (old_enable == 0) {

Oh, this one is incorrect.

>  		/* Disable per channel interrupt */
>  		temp = xgpio_readreg(chip->regs + XGPIO_IPIER_OFFSET);
>  		temp &= ~mask;