Linux Input/HID development
 help / color / mirror / Atom feed
From: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
To: Jiri Kosina <jikos@kernel.org>, Benjamin Tissoires <bentiss@kernel.org>
Cc: linux-kernel@vger.kernel.org, Peng Fan <peng.fan@nxp.com>,
	linux-input@vger.kernel.org, linux-usb@vger.kernel.org
Subject: [PATCH] HID: use assign_bit() where applicable
Date: Fri, 18 Sep 2026 22:15:43 +0800	[thread overview]
Message-ID: <20260918141544.3022797-1-peng.fan@oss.nxp.com> (raw)

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


                 reply	other threads:[~2026-09-18 14:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260918141544.3022797-1-peng.fan@oss.nxp.com \
    --to=peng.fan@oss.nxp.com \
    --cc=bentiss@kernel.org \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=peng.fan@nxp.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