Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH] HID: use assign_bit() where applicable
@ 2026-09-18 14:15 Peng Fan (OSS)
  0 siblings, 0 replies; only message in thread
From: Peng Fan (OSS) @ 2026-09-18 14:15 UTC (permalink / raw)
  To: Jiri Kosina, Benjamin Tissoires
  Cc: linux-kernel, Peng Fan, linux-input, linux-usb

From: Peng Fan <peng.fan@nxp.com>

Convert open-coded if/else with set_bit/clear_bit and their
non-atomic __set_bit/__clear_bit variants to the assign_bit/__assign_bit
API.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/hid/hid-apple.c       | 5 +----
 drivers/hid/usbhid/hid-core.c | 6 ++----
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
index f6134c5820ff..dc5915e69243 100644
--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@ -578,10 +578,7 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
 			trans = apple_find_translation(powerbook_numlock_keys, code);
 
 			if (trans) {
-				if (value)
-					set_bit(code, asc->pressed_numlock);
-				else
-					clear_bit(code, asc->pressed_numlock);
+				assign_bit(code, asc->pressed_numlock, value);
 
 				code = trans->to;
 			}
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index 96b0181cf819..6eb48ef8d496 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -292,10 +292,8 @@ static void hid_irq_in(struct urb *urb)
 			 * because most keyboards don't wake up when
 			 * a key is released
 			 */
-			if (hid_check_keys_pressed(hid))
-				set_bit(HID_KEYS_PRESSED, &usbhid->iofl);
-			else
-				clear_bit(HID_KEYS_PRESSED, &usbhid->iofl);
+			assign_bit(HID_KEYS_PRESSED, &usbhid->iofl,
+				   hid_check_keys_pressed(hid));
 		}
 		break;
 	case -EPIPE:		/* stall */
-- 
2.51.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-18 14:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-18 14:15 [PATCH] HID: use assign_bit() where applicable Peng Fan (OSS)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox