From: Syed Nayyar Waris <syednwaris@gmail.com>
To: akpm@linux-foundation.org
Cc: andriy.shevchenko@linux.intel.com, vilhelm.gray@gmail.com,
rrichter@marvell.com, linus.walleij@linaro.org,
bgolaszewski@baylibre.com, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 5/6] gpio: thunderx: Utilize for_each_set_clump macro
Date: Sun, 26 Apr 2020 00:36:24 +0530 [thread overview]
Message-ID: <9c5e25b982728467c5c681876d0e60e49dedb5fb.1587840670.git.syednwaris@gmail.com> (raw)
In-Reply-To: <cover.1587840667.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: Linus Walleij <linus.walleij@linaro.org>
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 v2:
- No change.
drivers/gpio/gpio-thunderx.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/gpio/gpio-thunderx.c b/drivers/gpio/gpio-thunderx.c
index 9f66dea..74aea25 100644
--- a/drivers/gpio/gpio-thunderx.c
+++ b/drivers/gpio/gpio-thunderx.c
@@ -275,12 +275,16 @@ static void thunderx_gpio_set_multiple(struct gpio_chip *chip,
unsigned long *bits)
{
int bank;
- u64 set_bits, clear_bits;
+ u64 set_bits, clear_bits, gpio_mask;
+ const unsigned long bank_size = 64;
+ 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, bank_size) {
+ bank = offset / bank_size;
+ 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.7.4
next prev parent reply other threads:[~2020-04-25 19:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-25 18:59 [PATCH v2 0/6] Introduce the for_each_set_clump macro Syed Nayyar Waris
2020-04-25 19:05 ` [PATCH v2 3/6] gpio: thermal: Utilize " Syed Nayyar Waris
2020-04-25 19:26 ` Lukas Wunner
2020-04-25 19:54 ` Syed Nayyar Waris
2020-04-25 19:06 ` Syed Nayyar Waris [this message]
2020-04-27 16:38 ` [PATCH v2 5/6] gpio: thunderx: " kbuild test robot
2020-04-27 18:27 ` kbuild test robot
2020-04-28 1:41 ` kbuild test robot
2020-04-25 19:06 ` [PATCH v2 6/6] gpio: xilinx: " 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=9c5e25b982728467c5c681876d0e60e49dedb5fb.1587840670.git.syednwaris@gmail.com \
--to=syednwaris@gmail.com \
--cc=akpm@linux-foundation.org \
--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).