linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kent Gibson <warthog618@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: "Linus Walleij" <linus.walleij@linaro.org>,
	"Bartosz Golaszewski" <bartosz.golaszewski@linaro.org>,
	"Yury Norov" <yury.norov@gmail.com>,
	linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	"Shubhrajyoti Datta" <shubhrajyoti.datta@amd.com>,
	"Srinivas Neeli" <srinivas.neeli@amd.com>,
	"Michal Simek" <michal.simek@amd.com>,
	"Bartosz Golaszewski" <brgl@bgdev.pl>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
	"Marek Behún" <kabel@kernel.org>
Subject: Re: [PATCH v1 4/5] gpio: xilinx: Replace bitmap_bitremap() calls
Date: Tue, 26 Sep 2023 18:41:00 +0800	[thread overview]
Message-ID: <ZRK1PA2vZBdfAozG@sol> (raw)
In-Reply-To: <20230926052007.3917389-5-andriy.shevchenko@linux.intel.com>

On Tue, Sep 26, 2023 at 08:20:06AM +0300, Andy Shevchenko wrote:
> We have sparse and dence masks of the line mappings based on

dense

> 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

vice

> 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.
> 

And dense again.

Cheers,
Kent.

> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/gpio/gpio-xilinx.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> 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]);
> -- 
> 2.40.0.1.gaa8946217a0b
> 

  reply	other threads:[~2023-09-26 10:41 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-26  5:20 [PATCH v1 0/5] bitmap: get rid of bitmap_remap() and bitmap_biremap() uses Andy Shevchenko
2023-09-26  5:20 ` [PATCH v1 1/5] lib/test_bitmap: Excape space symbols when printing input string Andy Shevchenko
2023-09-26 10:35   ` Kent Gibson
2023-09-26 10:39     ` Kent Gibson
2023-09-26  5:20 ` [PATCH v1 2/5] lib/bitmap: Introduce bitmap_scatter() and bitmap_gather() helpers Andy Shevchenko
2023-09-27  0:25   ` Yury Norov
2023-09-27  2:10     ` Yury Norov
2023-09-27 12:10       ` Andy Shevchenko
2023-09-27 12:02     ` Andy Shevchenko
2023-10-02  4:06       ` Yury Norov
2023-10-02  8:23         ` Andy Shevchenko
2023-09-26  5:20 ` [PATCH v1 3/5] gpio: xilinx: Switch to use new bitmap_scatter() helper Andy Shevchenko
2023-09-26  5:20 ` [PATCH v1 4/5] gpio: xilinx: Replace bitmap_bitremap() calls Andy Shevchenko
2023-09-26 10:41   ` Kent Gibson [this message]
2023-09-26 11:11     ` Andy Shevchenko
2023-09-26 11:17       ` Kent Gibson
2023-09-26  5:20 ` [PATCH v1 5/5] gpiolib: cdev: Utilize more bitmap APIs Andy Shevchenko
2023-09-27  0:46   ` Yury Norov
2023-09-27  6:48     ` Kent Gibson
2023-09-27  1:32   ` Kent Gibson
2023-09-27 12:17     ` Andy Shevchenko
2023-09-27 13:49       ` Kent Gibson
2023-09-27 13:59         ` Andy Shevchenko
2023-09-27 14:23           ` Kent Gibson
2023-10-02  9:05             ` Andy Shevchenko
2023-10-02  9:25               ` Kent Gibson
2023-10-02  9:32                 ` Andy Shevchenko
2023-10-02  9:42                   ` Kent Gibson
2023-09-26  8:52 ` [PATCH v1 0/5] bitmap: get rid of bitmap_remap() and bitmap_biremap() uses Linus Walleij
2023-09-26 11:16   ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZRK1PA2vZBdfAozG@sol \
    --to=warthog618@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=andy@kernel.org \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=kabel@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=michal.simek@amd.com \
    --cc=shubhrajyoti.datta@amd.com \
    --cc=srinivas.neeli@amd.com \
    --cc=yury.norov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).