From patchwork Wed Jul 12 08:18:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 702673 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74528C001DF for ; Wed, 12 Jul 2023 08:23:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231210AbjGLIXe (ORCPT ); Wed, 12 Jul 2023 04:23:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231359AbjGLIWr (ORCPT ); Wed, 12 Jul 2023 04:22:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A33564487; Wed, 12 Jul 2023 01:18:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E5D576168A; Wed, 12 Jul 2023 08:18:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42503C433CA; Wed, 12 Jul 2023 08:18:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689149896; bh=AnR6U7SNoPqjubiusL5iLkGLY4N6OAzOKEM7mQdl/ck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RJXJcRTDyCjTcjykoHcORmeLIiu1SQyvAzuB4QGFcbkFmsOKaBWT14DIkRTZcBYOe OiNGq/2iwCvqCI2myJFdd3YiGV3kBEEuhSgqiNS6/BhYPjL+bCig/mYx7ORJXW6pHB AhU7nG5PSdR2szqpsUcTX6oYPS2Qzkg3vyDZ0/+eN3YE4pjaK8zM9jE2fUi9+SDXZG DPrzJ4mG+T00swI5yaVrhe4fBSzGqtPcUfjmyXA3N4m0ly6+I2lXoscsUF0we18lgn oZMVOx7woNKa0INW/EyaVe1kcW6de4PuI00eo6unr/MZ1M8ObVXhHmhjJNjWQmeXXW 66eUkeFC0umhw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 01/10] tty: sysrq: rename and re-type i in sysrq_handle_loglevel() Date: Wed, 12 Jul 2023 10:18:02 +0200 Message-ID: <20230712081811.29004-2-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230712081811.29004-1-jirislaby@kernel.org> References: <20230712081811.29004-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org 'i' is a too generic name for something which carries a 'loglevel'. Name it as such and make it 'u8', the same as key will become in the next patches. Note that we are not stripping any high bits away, 'key' is given only 8bit values. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/sysrq.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c index e1df63a88aac..13465e4cca9b 100644 --- a/drivers/tty/sysrq.c +++ b/drivers/tty/sysrq.c @@ -100,12 +100,11 @@ __setup("sysrq_always_enabled", sysrq_always_enabled_setup); static void sysrq_handle_loglevel(int key) { - int i; + u8 loglevel = key - '0'; - i = key - '0'; console_loglevel = CONSOLE_LOGLEVEL_DEFAULT; - pr_info("Loglevel set to %d\n", i); - console_loglevel = i; + pr_info("Loglevel set to %u\n", loglevel); + console_loglevel = loglevel; } static const struct sysrq_key_op sysrq_loglevel_op = { .handler = sysrq_handle_loglevel, From patchwork Wed Jul 12 08:18:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 702676 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8AF2EB64DA for ; Wed, 12 Jul 2023 08:22:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232448AbjGLIWh (ORCPT ); Wed, 12 Jul 2023 04:22:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231782AbjGLIV7 (ORCPT ); Wed, 12 Jul 2023 04:21:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 993AD420F; Wed, 12 Jul 2023 01:18:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3B6F8616FD; Wed, 12 Jul 2023 08:18:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C566DC433C9; Wed, 12 Jul 2023 08:18:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689149903; bh=aPoElTgjGbSrd8e+m9++rB6wqYEsgyiFO1f3IrEJLOI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vekh3P2DJbF1vAx4+/+h3UE5Op6AgqlZK+bi7K+AbyvmX1++OvWSqRj9dIaxqkKqt Wsz7lCu+A0276BBjlPsadfVJrKKws3P8y+AntJqKUbpOM3Ux+1n+p6gqP74kIojyvb YDkfaIuY7gVRpWBAHbf4A0kluifndW/d1IzhCWJqOlliw1hEMyNeG4Pv4cyacaIu/x DiQu9gAkaRWqhCwwkWiVDfSZ/WTnYlhj81XWQa/jFdLpecdeviCg7Uf+8d0aggzDo7 6rsDG5G+qp/IHtk9o5qiYN7w2Qs6czld0MZ4KNaVWzZr2ZOjjgdOYqJCRdAMxiFuSF KzBptVXdt+Zyg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Richard Henderson , Ivan Kokshaysky , Matt Turner , Huacai Chen , WANG Xuerui , Thomas Bogendoerfer , Michael Ellerman , Nicholas Piggin , Christophe Leroy , "David S. Miller" , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Jason Wessel , Daniel Thompson , Douglas Anderson , "Rafael J. Wysocki" , Len Brown , Pavel Machek , "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang Subject: [PATCH 02/10] tty: sysrq: switch sysrq handlers from int to u8 Date: Wed, 12 Jul 2023 10:18:03 +0200 Message-ID: <20230712081811.29004-3-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230712081811.29004-1-jirislaby@kernel.org> References: <20230712081811.29004-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org The passed parameter to sysrq handlers is a key (a character). So change the type from 'int' to 'u8'. Let it specifically be 'u8' for two reasons: * unsigned: unsigned values come from the upper layers (devices) and the tty layer assumes unsigned on most places, and * 8-bit: as that what's supposed to be one day in all the layers built on the top of tty. (Currently, we use mostly 'unsigned char' and somewhere still only 'char'. (But that also translates to the former thanks to -funsigned-char.)) Signed-off-by: Jiri Slaby (SUSE) Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Matt Turner Cc: Huacai Chen Cc: WANG Xuerui Cc: Thomas Bogendoerfer Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Christophe Leroy Cc: "David S. Miller" Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Thomas Zimmermann Cc: David Airlie Cc: Daniel Vetter Cc: Jason Wessel Cc: Daniel Thompson Cc: Douglas Anderson Cc: "Rafael J. Wysocki" Cc: Len Brown Cc: Pavel Machek Cc: "Paul E. McKenney" Cc: Frederic Weisbecker Cc: Neeraj Upadhyay Cc: Joel Fernandes Cc: Josh Triplett Cc: Boqun Feng Cc: Steven Rostedt Cc: Mathieu Desnoyers Cc: Lai Jiangshan Cc: Zqiang --- arch/alpha/kernel/setup.c | 2 +- arch/loongarch/kernel/sysrq.c | 2 +- arch/mips/kernel/sysrq.c | 2 +- arch/powerpc/xmon/xmon.c | 2 +- arch/sparc/kernel/process_64.c | 4 ++-- drivers/gpu/drm/drm_fb_helper.c | 2 +- drivers/tty/sysrq.c | 40 ++++++++++++++++----------------- include/linux/sysrq.h | 2 +- kernel/debug/debug_core.c | 2 +- kernel/power/poweroff.c | 2 +- kernel/rcu/tree_stall.h | 2 +- 11 files changed, 31 insertions(+), 31 deletions(-) diff --git a/arch/alpha/kernel/setup.c b/arch/alpha/kernel/setup.c index b650ff1cb022..91fb3714ebc2 100644 --- a/arch/alpha/kernel/setup.c +++ b/arch/alpha/kernel/setup.c @@ -422,7 +422,7 @@ register_cpus(void) arch_initcall(register_cpus); #ifdef CONFIG_MAGIC_SYSRQ -static void sysrq_reboot_handler(int unused) +static void sysrq_reboot_handler(u8 unused) { machine_halt(); } diff --git a/arch/loongarch/kernel/sysrq.c b/arch/loongarch/kernel/sysrq.c index 366baef72d29..e663c10fa39c 100644 --- a/arch/loongarch/kernel/sysrq.c +++ b/arch/loongarch/kernel/sysrq.c @@ -43,7 +43,7 @@ static void sysrq_tlbdump_othercpus(struct work_struct *dummy) static DECLARE_WORK(sysrq_tlbdump, sysrq_tlbdump_othercpus); #endif -static void sysrq_handle_tlbdump(int key) +static void sysrq_handle_tlbdump(u8 key) { sysrq_tlbdump_single(NULL); #ifdef CONFIG_SMP diff --git a/arch/mips/kernel/sysrq.c b/arch/mips/kernel/sysrq.c index 9c1a2019113b..2e98049fe783 100644 --- a/arch/mips/kernel/sysrq.c +++ b/arch/mips/kernel/sysrq.c @@ -44,7 +44,7 @@ static void sysrq_tlbdump_othercpus(struct work_struct *dummy) static DECLARE_WORK(sysrq_tlbdump, sysrq_tlbdump_othercpus); #endif -static void sysrq_handle_tlbdump(int key) +static void sysrq_handle_tlbdump(u8 key) { sysrq_tlbdump_single(NULL); #ifdef CONFIG_SMP diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c index ee17270d35d0..3b6f524c790e 100644 --- a/arch/powerpc/xmon/xmon.c +++ b/arch/powerpc/xmon/xmon.c @@ -3991,7 +3991,7 @@ static void xmon_init(int enable) } #ifdef CONFIG_MAGIC_SYSRQ -static void sysrq_handle_xmon(int key) +static void sysrq_handle_xmon(u8 key) { if (xmon_is_locked_down()) { clear_all_bpt(); diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c index b51d8fb0ecdc..4dee88af403f 100644 --- a/arch/sparc/kernel/process_64.c +++ b/arch/sparc/kernel/process_64.c @@ -295,7 +295,7 @@ void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) #ifdef CONFIG_MAGIC_SYSRQ -static void sysrq_handle_globreg(int key) +static void sysrq_handle_globreg(u8 key) { trigger_all_cpu_backtrace(); } @@ -370,7 +370,7 @@ static void pmu_snapshot_all_cpus(void) spin_unlock_irqrestore(&global_cpu_snapshot_lock, flags); } -static void sysrq_handle_globpmu(int key) +static void sysrq_handle_globpmu(u8 key) { pmu_snapshot_all_cpus(); } diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 61a5d450cc20..d612133e2cf7 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -301,7 +301,7 @@ static void drm_fb_helper_restore_work_fn(struct work_struct *ignored) static DECLARE_WORK(drm_fb_helper_restore_work, drm_fb_helper_restore_work_fn); -static void drm_fb_helper_sysrq(int dummy1) +static void drm_fb_helper_sysrq(u8 dummy1) { schedule_work(&drm_fb_helper_restore_work); } diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c index 13465e4cca9b..1271a82c0887 100644 --- a/drivers/tty/sysrq.c +++ b/drivers/tty/sysrq.c @@ -98,7 +98,7 @@ static int __init sysrq_always_enabled_setup(char *str) __setup("sysrq_always_enabled", sysrq_always_enabled_setup); -static void sysrq_handle_loglevel(int key) +static void sysrq_handle_loglevel(u8 key) { u8 loglevel = key - '0'; @@ -114,7 +114,7 @@ static const struct sysrq_key_op sysrq_loglevel_op = { }; #ifdef CONFIG_VT -static void sysrq_handle_SAK(int key) +static void sysrq_handle_SAK(u8 key) { struct work_struct *SAK_work = &vc_cons[fg_console].SAK_work; @@ -131,7 +131,7 @@ static const struct sysrq_key_op sysrq_SAK_op = { #endif #ifdef CONFIG_VT -static void sysrq_handle_unraw(int key) +static void sysrq_handle_unraw(u8 key) { vt_reset_unicode(fg_console); } @@ -146,7 +146,7 @@ static const struct sysrq_key_op sysrq_unraw_op = { #define sysrq_unraw_op (*(const struct sysrq_key_op *)NULL) #endif /* CONFIG_VT */ -static void sysrq_handle_crash(int key) +static void sysrq_handle_crash(u8 key) { /* release the RCU read lock before crashing */ rcu_read_unlock(); @@ -160,7 +160,7 @@ static const struct sysrq_key_op sysrq_crash_op = { .enable_mask = SYSRQ_ENABLE_DUMP, }; -static void sysrq_handle_reboot(int key) +static void sysrq_handle_reboot(u8 key) { lockdep_off(); local_irq_enable(); @@ -175,7 +175,7 @@ static const struct sysrq_key_op sysrq_reboot_op = { const struct sysrq_key_op *__sysrq_reboot_op = &sysrq_reboot_op; -static void sysrq_handle_sync(int key) +static void sysrq_handle_sync(u8 key) { emergency_sync(); } @@ -186,7 +186,7 @@ static const struct sysrq_key_op sysrq_sync_op = { .enable_mask = SYSRQ_ENABLE_SYNC, }; -static void sysrq_handle_show_timers(int key) +static void sysrq_handle_show_timers(u8 key) { sysrq_timer_list_show(); } @@ -197,7 +197,7 @@ static const struct sysrq_key_op sysrq_show_timers_op = { .action_msg = "Show clockevent devices & pending hrtimers (no others)", }; -static void sysrq_handle_mountro(int key) +static void sysrq_handle_mountro(u8 key) { emergency_remount(); } @@ -209,7 +209,7 @@ static const struct sysrq_key_op sysrq_mountro_op = { }; #ifdef CONFIG_LOCKDEP -static void sysrq_handle_showlocks(int key) +static void sysrq_handle_showlocks(u8 key) { debug_show_all_locks(); } @@ -249,7 +249,7 @@ static void sysrq_showregs_othercpus(struct work_struct *dummy) static DECLARE_WORK(sysrq_showallcpus, sysrq_showregs_othercpus); -static void sysrq_handle_showallcpus(int key) +static void sysrq_handle_showallcpus(u8 key) { /* * Fall back to the workqueue based printing if the @@ -282,7 +282,7 @@ static const struct sysrq_key_op sysrq_showallcpus_op = { #define sysrq_showallcpus_op (*(const struct sysrq_key_op *)NULL) #endif -static void sysrq_handle_showregs(int key) +static void sysrq_handle_showregs(u8 key) { struct pt_regs *regs = NULL; @@ -299,7 +299,7 @@ static const struct sysrq_key_op sysrq_showregs_op = { .enable_mask = SYSRQ_ENABLE_DUMP, }; -static void sysrq_handle_showstate(int key) +static void sysrq_handle_showstate(u8 key) { show_state(); show_all_workqueues(); @@ -311,7 +311,7 @@ static const struct sysrq_key_op sysrq_showstate_op = { .enable_mask = SYSRQ_ENABLE_DUMP, }; -static void sysrq_handle_showstate_blocked(int key) +static void sysrq_handle_showstate_blocked(u8 key) { show_state_filter(TASK_UNINTERRUPTIBLE); } @@ -325,7 +325,7 @@ static const struct sysrq_key_op sysrq_showstate_blocked_op = { #ifdef CONFIG_TRACING #include -static void sysrq_ftrace_dump(int key) +static void sysrq_ftrace_dump(u8 key) { ftrace_dump(DUMP_ALL); } @@ -339,7 +339,7 @@ static const struct sysrq_key_op sysrq_ftrace_dump_op = { #define sysrq_ftrace_dump_op (*(const struct sysrq_key_op *)NULL) #endif -static void sysrq_handle_showmem(int key) +static void sysrq_handle_showmem(u8 key) { show_mem(); } @@ -369,7 +369,7 @@ static void send_sig_all(int sig) read_unlock(&tasklist_lock); } -static void sysrq_handle_term(int key) +static void sysrq_handle_term(u8 key) { send_sig_all(SIGTERM); console_loglevel = CONSOLE_LOGLEVEL_DEBUG; @@ -400,7 +400,7 @@ static void moom_callback(struct work_struct *ignored) static DECLARE_WORK(moom_work, moom_callback); -static void sysrq_handle_moom(int key) +static void sysrq_handle_moom(u8 key) { schedule_work(&moom_work); } @@ -412,7 +412,7 @@ static const struct sysrq_key_op sysrq_moom_op = { }; #ifdef CONFIG_BLOCK -static void sysrq_handle_thaw(int key) +static void sysrq_handle_thaw(u8 key) { emergency_thaw_all(); } @@ -426,7 +426,7 @@ static const struct sysrq_key_op sysrq_thaw_op = { #define sysrq_thaw_op (*(const struct sysrq_key_op *)NULL) #endif -static void sysrq_handle_kill(int key) +static void sysrq_handle_kill(u8 key) { send_sig_all(SIGKILL); console_loglevel = CONSOLE_LOGLEVEL_DEBUG; @@ -438,7 +438,7 @@ static const struct sysrq_key_op sysrq_kill_op = { .enable_mask = SYSRQ_ENABLE_SIGNAL, }; -static void sysrq_handle_unrt(int key) +static void sysrq_handle_unrt(u8 key) { normalize_rt_tasks(); } diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h index 3a582ec7a2f1..bb8d07814b0e 100644 --- a/include/linux/sysrq.h +++ b/include/linux/sysrq.h @@ -30,7 +30,7 @@ #define SYSRQ_ENABLE_RTNICE 0x0100 struct sysrq_key_op { - void (* const handler)(int); + void (* const handler)(u8); const char * const help_msg; const char * const action_msg; const int enable_mask; diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index d5e9ccde3ab8..621037a0aa87 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c @@ -968,7 +968,7 @@ static int __init opt_kgdb_con(char *str) early_param("kgdbcon", opt_kgdb_con); #ifdef CONFIG_MAGIC_SYSRQ -static void sysrq_handle_dbg(int key) +static void sysrq_handle_dbg(u8 key) { if (!dbg_io_ops) { pr_crit("ERROR: No KGDB I/O module available\n"); diff --git a/kernel/power/poweroff.c b/kernel/power/poweroff.c index 562aa0e450ed..1f306f158696 100644 --- a/kernel/power/poweroff.c +++ b/kernel/power/poweroff.c @@ -23,7 +23,7 @@ static void do_poweroff(struct work_struct *dummy) static DECLARE_WORK(poweroff_work, do_poweroff); -static void handle_poweroff(int key) +static void handle_poweroff(u8 key) { /* run sysrq poweroff on boot cpu */ schedule_work_on(cpumask_first(cpu_online_mask), &poweroff_work); diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h index b10b8349bb2a..6f06dc12904a 100644 --- a/kernel/rcu/tree_stall.h +++ b/kernel/rcu/tree_stall.h @@ -1035,7 +1035,7 @@ static bool sysrq_rcu; module_param(sysrq_rcu, bool, 0444); /* Dump grace-period-request information due to commandeered sysrq. */ -static void sysrq_show_rcu(int key) +static void sysrq_show_rcu(u8 key) { show_rcu_gp_kthreads(); } From patchwork Wed Jul 12 08:18:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 702672 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B56BEB64DD for ; Wed, 12 Jul 2023 08:24:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232498AbjGLIYW (ORCPT ); Wed, 12 Jul 2023 04:24:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232959AbjGLIXW (ORCPT ); Wed, 12 Jul 2023 04:23:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEEB42D79; Wed, 12 Jul 2023 01:19:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 475B2616F5; Wed, 12 Jul 2023 08:18:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E66BC433C7; Wed, 12 Jul 2023 08:18:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689149906; bh=V1/NAcLOoOa408WI8W7uk/rZlfmxwm9QHIbOEt5OwRU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=orYkW1njU+RHfilaABGyP3E8fD2KCKvgMlwDZ/xaDUL61kCYDr5IJGu1yuTGgcUdS c8FS53v7/jFz+7J3sBg7e6wAJuRIF7Bs9PWsN0jH29ZRH+CpUUjiSUvgFFLhZo33Iw JL9mfrVzDgQ0LQJvxBwyIvdZHR65ES/qNNn1k65UmLGrqFanhSybws+xGmS0NtRZOS 0csZKoT1L6PP2ybXfrD77GiEdpNoK0HgnKPc8PWv8SaIpmstBhyalJV9Kp8PIrDktX RX8AqE5I5FNNdzu3qcniAlfryHJ8VQ8j7GDn10CfL4IPRw42kEfPJcqfyX8B4poB+G hReKvcMeHEFWw== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 04/10] tty: sysrq: use switch in sysrq_key_table_key2index() Date: Wed, 12 Jul 2023 10:18:05 +0200 Message-ID: <20230712081811.29004-5-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230712081811.29004-1-jirislaby@kernel.org> References: <20230712081811.29004-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Using switch with range cases makes the code more aligned and readable. Expand also that 36 as explicit addition of 10 + 26 to make the source of the constant more obvious. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/sysrq.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c index ccf429ba348e..23198e3f1461 100644 --- a/drivers/tty/sysrq.c +++ b/drivers/tty/sysrq.c @@ -532,17 +532,16 @@ static const struct sysrq_key_op *sysrq_key_table[62] = { /* key2index calculation, -1 on invalid index */ static int sysrq_key_table_key2index(u8 key) { - int retval; - - if ((key >= '0') && (key <= '9')) - retval = key - '0'; - else if ((key >= 'a') && (key <= 'z')) - retval = key + 10 - 'a'; - else if ((key >= 'A') && (key <= 'Z')) - retval = key + 36 - 'A'; - else - retval = -1; - return retval; + switch (key) { + case '0' ... '9': + return key - '0'; + case 'a' ... 'z': + return key - 'a' + 10; + case 'A' ... 'Z': + return key - 'A' + 10 + 26; + default: + return -1; + } } /* From patchwork Wed Jul 12 08:18:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 702674 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8DF8EB64D9 for ; Wed, 12 Jul 2023 08:23:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230155AbjGLIXd (ORCPT ); Wed, 12 Jul 2023 04:23:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232240AbjGLIWU (ORCPT ); Wed, 12 Jul 2023 04:22:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BDC4421D; Wed, 12 Jul 2023 01:18:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C9C81616DA; Wed, 12 Jul 2023 08:18:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DA18C433C8; Wed, 12 Jul 2023 08:18:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689149908; bh=Ci3nRAs35p4iqwTNouGnDja3Fdyihy2hLFK9/UOdi0E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ve2HDbqBkJFugEVGTp+DU5ufx78fAZlMogYPKGzPvJjLqRROjjYSV4dNQp14fW5Ey q41aHA34c47yw2I9AETg9HSxeWTxIlFoKSduMosTEZ4t3BhLDGUvcSWl4h2TkK1Bqt TPiSKWBg8IUo0cNJq1HRnyuWVpqcxHSrCwUrPh/U6vGq0tlMdpO1JZJO7m5zBt9ClJ o7y+9Ya8s33VRnQm6o7h/hPoA7dBu498JzV90Gq1GJhFi91H1a9tfSU/XLCfUWPzk3 K5LrYxz6N70sbLUpb74Vvb74J4Z4nWQor3eWjMFUaPya/ocIiWlsM3xYTc/kxo/xBv npPGxaEpoiDmg== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 05/10] serial: convert uart sysrq handling to u8 Date: Wed, 12 Jul 2023 10:18:06 +0200 Message-ID: <20230712081811.29004-6-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230712081811.29004-1-jirislaby@kernel.org> References: <20230712081811.29004-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Propagate u8 from the sysrq code further up to serial's uart_handle_sysrq_char() and friends. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/serial/serial_core.c | 4 ++-- include/linux/serial_core.h | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 831d033611e6..7e37db9adbd4 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3505,7 +3505,7 @@ void uart_insert_char(struct uart_port *port, unsigned int status, EXPORT_SYMBOL_GPL(uart_insert_char); #ifdef CONFIG_MAGIC_SYSRQ_SERIAL -static const char sysrq_toggle_seq[] = CONFIG_MAGIC_SYSRQ_SERIAL_SEQUENCE; +static const u8 sysrq_toggle_seq[] = CONFIG_MAGIC_SYSRQ_SERIAL_SEQUENCE; static void uart_sysrq_on(struct work_struct *w) { @@ -3528,7 +3528,7 @@ static DECLARE_WORK(sysrq_enable_work, uart_sysrq_on); * Returns: %false if @ch is out of enabling sequence and should be * handled some other way, %true if @ch was consumed. */ -bool uart_try_toggle_sysrq(struct uart_port *port, unsigned int ch) +bool uart_try_toggle_sysrq(struct uart_port *port, u8 ch) { int sysrq_toggle_seq_len = strlen(sysrq_toggle_seq); diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 6d58c57acdaa..14dd85ee849e 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -569,7 +569,7 @@ struct uart_port { struct serial_port_device *port_dev; /* serial core port device */ unsigned long sysrq; /* sysrq timeout */ - unsigned int sysrq_ch; /* char for sysrq */ + u8 sysrq_ch; /* char for sysrq */ unsigned char has_sysrq; unsigned char sysrq_seq; /* index in sysrq_toggle_seq */ @@ -910,9 +910,9 @@ void uart_xchar_out(struct uart_port *uport, int offset); #ifdef CONFIG_MAGIC_SYSRQ_SERIAL #define SYSRQ_TIMEOUT (HZ * 5) -bool uart_try_toggle_sysrq(struct uart_port *port, unsigned int ch); +bool uart_try_toggle_sysrq(struct uart_port *port, u8 ch); -static inline int uart_handle_sysrq_char(struct uart_port *port, unsigned int ch) +static inline int uart_handle_sysrq_char(struct uart_port *port, u8 ch) { if (!port->sysrq) return 0; @@ -931,7 +931,7 @@ static inline int uart_handle_sysrq_char(struct uart_port *port, unsigned int ch return 0; } -static inline int uart_prepare_sysrq_char(struct uart_port *port, unsigned int ch) +static inline int uart_prepare_sysrq_char(struct uart_port *port, u8 ch) { if (!port->sysrq) return 0; @@ -952,7 +952,7 @@ static inline int uart_prepare_sysrq_char(struct uart_port *port, unsigned int c static inline void uart_unlock_and_check_sysrq(struct uart_port *port) { - int sysrq_ch; + u8 sysrq_ch; if (!port->has_sysrq) { spin_unlock(&port->lock); @@ -971,7 +971,7 @@ static inline void uart_unlock_and_check_sysrq(struct uart_port *port) static inline void uart_unlock_and_check_sysrq_irqrestore(struct uart_port *port, unsigned long flags) { - int sysrq_ch; + u8 sysrq_ch; if (!port->has_sysrq) { spin_unlock_irqrestore(&port->lock, flags); @@ -987,11 +987,11 @@ static inline void uart_unlock_and_check_sysrq_irqrestore(struct uart_port *port handle_sysrq(sysrq_ch); } #else /* CONFIG_MAGIC_SYSRQ_SERIAL */ -static inline int uart_handle_sysrq_char(struct uart_port *port, unsigned int ch) +static inline int uart_handle_sysrq_char(struct uart_port *port, u8 ch) { return 0; } -static inline int uart_prepare_sysrq_char(struct uart_port *port, unsigned int ch) +static inline int uart_prepare_sysrq_char(struct uart_port *port, u8 ch) { return 0; } From patchwork Wed Jul 12 08:18:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 702675 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 639C0C0015E for ; Wed, 12 Jul 2023 08:23:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233030AbjGLIXb (ORCPT ); Wed, 12 Jul 2023 04:23:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232488AbjGLIWT (ORCPT ); Wed, 12 Jul 2023 04:22:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7D77421A; Wed, 12 Jul 2023 01:18:35 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5BCA0615C3; Wed, 12 Jul 2023 08:18:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF87FC433C9; Wed, 12 Jul 2023 08:18:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689149909; bh=ScFNHJKoC6BpXI9oEWAZOHBoeKXX3SlhqkfMHYY9sAU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HU4sclBY8YX9MdgHWS+CmlcQRJIHcji3LEX03h/DyMxFrJ9TdFqMRsBwZlfDJmVTD GrEWD2NpRhBa5u0wCQNeD2wHl2k6kNrY9oCUWabqufOX0bRCw+1VO1Jb8R3hTUXyQl M7MZcJERe703a/S7ZeWSmhFVVDfyuhE9fn9Ss8MmKbSBS0vJDqQYEVHqTRcrLHK9Xx ZKatHwqRQquQtWZDyAf0ZXdpfpAQIKYMnE0g9l9EN3f4MA8rO3bkQrEvdkwox41TGv DvpMlve2SOB10b2/Nvk48Vj6sLZwEZsOQd6ZGICUOcHFDv+dL3ANN+3dmgDM/zq3RK +TmBueQoiqV/w== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" Subject: [PATCH 06/10] serial: make uart_insert_char() accept u8s Date: Wed, 12 Jul 2023 10:18:07 +0200 Message-ID: <20230712081811.29004-7-jirislaby@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230712081811.29004-1-jirislaby@kernel.org> References: <20230712081811.29004-1-jirislaby@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Both the character and flag are 8-bit values. So switch from unsigned ints to u8s. The drivers will be cleaned up in the next round. Signed-off-by: Jiri Slaby (SUSE) --- drivers/tty/serial/serial_core.c | 2 +- include/linux/serial_core.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 7e37db9adbd4..bef507cb804c 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -3486,7 +3486,7 @@ EXPORT_SYMBOL_GPL(uart_handle_cts_change); * @flag: flag for the character (see TTY_NORMAL and friends) */ void uart_insert_char(struct uart_port *port, unsigned int status, - unsigned int overrun, unsigned int ch, unsigned int flag) + unsigned int overrun, u8 ch, u8 flag) { struct tty_port *tport = &port->state->port; diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 14dd85ee849e..105d2cdc0126 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h @@ -903,7 +903,7 @@ void uart_handle_dcd_change(struct uart_port *uport, bool active); void uart_handle_cts_change(struct uart_port *uport, bool active); void uart_insert_char(struct uart_port *port, unsigned int status, - unsigned int overrun, unsigned int ch, unsigned int flag); + unsigned int overrun, u8 ch, u8 flag); void uart_xchar_out(struct uart_port *uport, int offset);