tty: use assign_bit() where applicable

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>
Link: https://patch.msgid.link/20260918141842.3023147-1-peng.fan@oss.nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Peng Fan 2026-09-18 22:18:41 +08:00 committed by Greg Kroah-Hartman
parent 3f4e628905
commit 857f31656f
2 changed files with 2 additions and 8 deletions

View File

@ -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;
}

View File

@ -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);