From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <benjamin.tissoires@redhat.com>,
Andy Shevchenko <andy@kernel.org>
Subject: [PATCH v1 04/12] HID: cp2112: Switch to for_each_set_bit() to simplify the code
Date: Mon, 3 Jul 2023 21:52:14 +0300 [thread overview]
Message-ID: <20230703185222.50554-5-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20230703185222.50554-1-andriy.shevchenko@linux.intel.com>
It's cleaner to use for_each_set_bit() than open coding it.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/hid/hid-cp2112.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c
index 51399b231d36..fb4548feb0c8 100644
--- a/drivers/hid/hid-cp2112.c
+++ b/drivers/hid/hid-cp2112.c
@@ -16,6 +16,7 @@
* https://www.silabs.com/documents/public/application-notes/an495-cp2112-interface-specification.pdf
*/
+#include <linux/bitops.h>
#include <linux/gpio/consumer.h>
#include <linux/gpio/machine.h>
#include <linux/gpio/driver.h>
@@ -1100,7 +1101,6 @@ static void cp2112_gpio_poll_callback(struct work_struct *work)
gpio_poll_worker.work);
struct irq_data *d;
u8 gpio_mask;
- u8 virqs = (u8)dev->irq_mask;
u32 irq_type;
int irq, virq, ret;
@@ -1111,11 +1111,7 @@ static void cp2112_gpio_poll_callback(struct work_struct *work)
goto exit;
gpio_mask = ret;
-
- while (virqs) {
- virq = ffs(virqs) - 1;
- virqs &= ~BIT(virq);
-
+ for_each_set_bit(virq, &dev->irq_mask, 8) {
if (!dev->gc.to_irq)
break;
--
2.40.0.1.gaa8946217a0b
next prev parent reply other threads:[~2023-07-03 18:52 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-03 18:52 [PATCH v1 00/12] HID: cp2112: Cleanups and refactorings Andy Shevchenko
2023-07-03 18:52 ` [PATCH v1 01/12] lib/string_choices: Add str_write_read() helper Andy Shevchenko
2023-07-03 18:52 ` [PATCH v1 02/12] HID: cp2112: Use str_write_read() and str_read_write() Andy Shevchenko
2023-07-03 18:52 ` [PATCH v1 03/12] HID: cp2112: Make irq_chip immutable Andy Shevchenko
2023-07-03 18:52 ` Andy Shevchenko [this message]
2023-07-03 18:52 ` [PATCH v1 05/12] HID: cp2112: Don't call ->to_irq() explicitly Andy Shevchenko
2023-07-03 18:52 ` [PATCH v1 06/12] HID: cp2112: Remove dead code Andy Shevchenko
2023-08-26 18:29 ` Christophe JAILLET
2023-08-28 8:52 ` Andy Shevchenko
2023-07-03 18:52 ` [PATCH v1 07/12] HID: cp2112: Define maximum GPIO constant and use it Andy Shevchenko
2023-07-03 18:52 ` [PATCH v1 08/12] HID: cp2112: Define all GPIO mask " Andy Shevchenko
2023-07-03 18:52 ` [PATCH v1 09/12] HID: cp2112: Use BIT() in GPIO setter and getter Andy Shevchenko
2023-07-03 18:52 ` [PATCH v1 10/12] HID: cp2112: Use sysfs_emit() to instead of scnprintf() Andy Shevchenko
2023-07-03 18:52 ` [PATCH v1 11/12] HID: cp2112: Convert to DEVICE_ATTR_RW() Andy Shevchenko
2023-07-03 18:52 ` [PATCH v1 12/12] HID: cp2112: Use octal permissions Andy Shevchenko
2023-07-27 18:43 ` [PATCH v1 00/12] HID: cp2112: Cleanups and refactorings Andy Shevchenko
2023-08-04 6:40 ` Andy Shevchenko
2023-08-07 11:19 ` Jiri Kosina
2023-08-07 14:30 ` Andy Shevchenko
2023-08-14 9:28 ` Jiri Kosina
2023-08-21 8:11 ` Andy Shevchenko
2023-08-21 8:51 ` Benjamin Tissoires
2023-08-21 9:34 ` Andy Shevchenko
2023-08-21 9:35 ` Andy Shevchenko
2023-08-21 10:19 ` Benjamin Tissoires
2023-08-21 10:27 ` Benjamin Tissoires
2023-08-21 10:37 ` Andy Shevchenko
2023-08-21 13:56 ` Benjamin Tissoires
2023-08-21 10:32 ` Andy Shevchenko
2023-08-21 12:06 ` Benjamin Tissoires
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=20230703185222.50554-5-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=andy@kernel.org \
--cc=benjamin.tissoires@redhat.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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).