* [PATCH] tty: use assign_bit() where applicable
@ 2026-09-18 14:18 Peng Fan (OSS)
2026-09-18 14:27 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Peng Fan (OSS) @ 2026-09-18 14:18 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby; +Cc: linux-kernel, Peng Fan, linux-serial
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.
Done with Coccinelle semantic patch.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/tty/pty.c | 5 +----
drivers/tty/sysrq.c | 5 +----
2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
index cc7f7091ed9a..9a37008c4e91 100644
--- a/drivers/tty/pty.c
+++ b/drivers/tty/pty.c
@@ -138,10 +138,7 @@ static int pty_set_lock(struct tty_struct *tty, int __user *arg)
if (get_user(val, arg))
return -EFAULT;
- if (val)
- set_bit(TTY_PTY_LOCK, &tty->flags);
- else
- clear_bit(TTY_PTY_LOCK, &tty->flags);
+ assign_bit(TTY_PTY_LOCK, &tty->flags, val);
return 0;
}
diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index c2e4b31b699a..f4571d05b496 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -911,10 +911,7 @@ static bool sysrq_handle_keypress(struct sysrq_state *sysrq,
* keyboard state so we can release keys that have been
* pressed before entering SysRq mode.
*/
- if (value)
- set_bit(code, sysrq->key_down);
- else
- clear_bit(code, sysrq->key_down);
+ assign_bit(code, sysrq->key_down, value);
if (was_active)
schedule_work(&sysrq->reinject_work);
--
2.51.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-18 14:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-18 14:18 [PATCH] tty: use assign_bit() where applicable Peng Fan (OSS)
2026-09-18 14:27 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox