[PATCH] HID: use assign_bit() where applicable

Peng Fan (OSS) posted 1 patch 6 days, 8 hours ago
drivers/hid/hid-apple.c       | 5 +----
drivers/hid/usbhid/hid-core.c | 6 ++----
2 files changed, 3 insertions(+), 8 deletions(-)
[PATCH] HID: use assign_bit() where applicable
Posted by Peng Fan (OSS) 6 days, 8 hours ago
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