From: Syed Nayyar Waris <syednwaris@gmail.com>
To: linus.walleij@linaro.org
Cc: andriy.shevchenko@linux.intel.com, vilhelm.gray@gmail.com,
rrichter@marvell.com, bgolaszewski@baylibre.com,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v9 3/4] gpio: thunderx: Utilize for_each_set_clump macro
Date: Sat, 27 Jun 2020 13:43:08 +0530 [thread overview]
Message-ID: <585554e7f141ddf36c885cebaa98028854b2ebec.1593243081.git.syednwaris@gmail.com> (raw)
In-Reply-To: <cover.1593243079.git.syednwaris@gmail.com>
This patch reimplements the thunderx_gpio_set_multiple function in
drivers/gpio/gpio-thunderx.c to use the new for_each_set_clump macro.
Instead of looping for each bank in thunderx_gpio_set_multiple
function, now we can skip bank which is not set and save cycles.
Cc: Robert Richter <rrichter@marvell.com>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Syed Nayyar Waris <syednwaris@gmail.com>
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
---
Changes in v9:
- No change.
Changes in v8:
- No change.
Changes in v7:
- No change.
Changes in v6:
- No change.
Changes in v5:
- No change.
Changes in v4:
- Minor change: Inline value '64' in code for better code readability.
Changes in v3:
- Change datatype of some variables from u64 to unsigned long
in function thunderx_gpio_set_multiple.
Changes in v2:
- No change.
drivers/gpio/gpio-thunderx.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/gpio/gpio-thunderx.c b/drivers/gpio/gpio-thunderx.c
index 9f66deab46ea..58c9bb25a377 100644
--- a/drivers/gpio/gpio-thunderx.c
+++ b/drivers/gpio/gpio-thunderx.c
@@ -275,12 +275,15 @@ static void thunderx_gpio_set_multiple(struct gpio_chip *chip,
unsigned long *bits)
{
int bank;
- u64 set_bits, clear_bits;
+ unsigned long set_bits, clear_bits, gpio_mask;
+ unsigned long offset;
+
struct thunderx_gpio *txgpio = gpiochip_get_data(chip);
- for (bank = 0; bank <= chip->ngpio / 64; bank++) {
- set_bits = bits[bank] & mask[bank];
- clear_bits = ~bits[bank] & mask[bank];
+ for_each_set_clump(offset, gpio_mask, mask, chip->ngpio, 64) {
+ bank = offset / 64;
+ set_bits = bits[bank] & gpio_mask;
+ clear_bits = ~bits[bank] & gpio_mask;
writeq(set_bits, txgpio->register_base + (bank * GPIO_2ND_BANK) + GPIO_TX_SET);
writeq(clear_bits, txgpio->register_base + (bank * GPIO_2ND_BANK) + GPIO_TX_CLR);
}
--
2.26.2
next prev parent reply other threads:[~2020-06-27 8:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-27 8:09 [PATCH v9 0/4] Introduce the for_each_set_clump macro Syed Nayyar Waris
2020-06-27 8:13 ` Syed Nayyar Waris [this message]
2020-06-27 8:14 ` [PATCH v9 4/4] gpio: xilinx: Utilize generic bitmap_get_value and _set_value Syed Nayyar Waris
2020-07-08 12:54 ` William Breathitt Gray
2020-07-10 8:04 ` [PATCH v9 0/4] Introduce the for_each_set_clump macro Syed Nayyar Waris
2020-07-16 12:49 ` Linus Walleij
2020-08-31 15:37 ` Syed Nayyar Waris
2020-09-11 22:54 ` William Breathitt Gray
2020-09-29 12:45 ` Linus Walleij
2020-09-29 13:07 ` William Breathitt Gray
2020-09-29 13:14 ` Andy Shevchenko
2020-09-30 9:29 ` Linus Walleij
2020-10-02 20:58 ` Syed Nayyar Waris
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=585554e7f141ddf36c885cebaa98028854b2ebec.1593243081.git.syednwaris@gmail.com \
--to=syednwaris@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bgolaszewski@baylibre.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rrichter@marvell.com \
--cc=vilhelm.gray@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).