diff mbox series

[v1,4/5] gpio: xilinx: Replace bitmap_bitremap() calls

Message ID 20230926052007.3917389-5-andriy.shevchenko@linux.intel.com
State New
Headers show
Series bitmap: get rid of bitmap_remap() and bitmap_biremap() uses | expand

Commit Message

Andy Shevchenko Sept. 26, 2023, 5:20 a.m. UTC
We have sparse and dence masks of the line mappings based on
the view point (Linux numbering or hardware numbering). Since
the Linux side uses sequential bits for the mask, we can simply
convert a Linux number to the hardware one and vise versa by
counting set bits in the respective mask. Hence replace
bitmap_bitremap() calls by simpler equivalents.

With this done the dence mask is not needed and thus dropped.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpio-xilinx.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c
index f103c30cc74f..14ca3097563a 100644
--- a/drivers/gpio/gpio-xilinx.c
+++ b/drivers/gpio/gpio-xilinx.c
@@ -46,7 +46,6 @@ 
  * @gc: GPIO chip
  * @regs: register block
  * @hw_map: GPIO pin mapping on hardware side
- * @sw_map: GPIO pin mapping on software side
  * @state: GPIO write state shadow register
  * @last_irq_read: GPIO read state register from last interrupt
  * @dir: GPIO direction shadow register
@@ -62,7 +61,6 @@  struct xgpio_instance {
 	struct gpio_chip gc;
 	void __iomem *regs;
 	DECLARE_BITMAP(hw_map, 64);
-	DECLARE_BITMAP(sw_map, 64);
 	DECLARE_BITMAP(state, 64);
 	DECLARE_BITMAP(last_irq_read, 64);
 	DECLARE_BITMAP(dir, 64);
@@ -76,12 +74,12 @@  struct xgpio_instance {
 
 static inline int xgpio_from_bit(struct xgpio_instance *chip, int bit)
 {
-	return bitmap_bitremap(bit, chip->hw_map, chip->sw_map, 64);
+	return bitmap_weight(chip->hw_map, bit + 1);
 }
 
 static inline int xgpio_to_bit(struct xgpio_instance *chip, int gpio)
 {
-	return bitmap_bitremap(gpio, chip->sw_map, chip->hw_map, 64);
+	return find_nth_bit(chip->hw_map, 64, gpio);
 }
 
 static inline u32 xgpio_get_value32(const unsigned long *map, int bit)
@@ -619,9 +617,6 @@  static int xgpio_probe(struct platform_device *pdev)
 	if (width[1] > 32)
 		return -EINVAL;
 
-	/* Setup software pin mapping */
-	bitmap_set(chip->sw_map, 0, width[0] + width[1]);
-
 	/* Setup hardware pin mapping */
 	bitmap_set(chip->hw_map,  0, width[0]);
 	bitmap_set(chip->hw_map, 32, width[1]);