[PATCH v1 4/5] gpio: xilinx: Switch to use bitmap APIs
Andy Shevchenko
andriy.shevchenko at linux.intel.com
Thu Apr 8 16:08:08 BST 2021
On Thu, Apr 08, 2021 at 05:56:00PM +0300, Andy Shevchenko wrote:
> It seems that Xilinx GPIO driver operates with bit arrays longer than 32 and
> thus can leverage bitmap APIs for that. It makes code better to understand.
>
> The ->probe() function is modified to try read properties for both channels
> since is_dual check makes only sense for the amount of pins used for the second
> channel. On top of that kzalloc() guarantees zero initial values for the fields
> in the private data structure, hence drop unneeded conditionals and assignments.
>
> The change is inspired by Syed Nayyar Waris' ideas about bitmap API extension.
As I was afraid in the cover letter, I found some mistakes already.
In any case, I'll wait for the comments and test of other patches if possible.
Out of curiosity, below I point out the issues.
...
> + return bitmap_bitremap(gpio, chip->sw_map, chip->hw_map, chip->gc.ngpio);
Seems we have to use 64 instead of ngpio here.
...
> + bitmap_replace(state, chip->state, hw_bits, hw_mask, gc->ngpio);
Ditto.
...
> + bitmap_copy(chip->state, state, gc->ngpio);
Ditto.
...
> + for_each_set_bit(bit, all, 64)
> + generic_handle_irq(irq_find_mapping(gc->irq.domain, bit));
Here should be used gpio actually and ngpio IIUC.
--
With Best Regards,
Andy Shevchenko
More information about the linux-arm-kernel
mailing list