public inbox for linux-serial@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tty/sysrq: make sysrq_replay_logs_op const and refactor sysrq_mask()
@ 2025-04-03  7:15 xiaopeitux
  2025-04-03  8:19 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: xiaopeitux @ 2025-04-03  7:15 UTC (permalink / raw)
  To: gregkh, jirislaby, linux-serial, linux-kernel; +Cc: Pei Xiao

From: Pei Xiao <xiaopei01@kylinos.cn>

Mark sysrq_replay_logs_op as const and simplify sysrq_mask().

Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
---
 drivers/tty/sysrq.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index f85ce02e4725..c2a26abcb8cd 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -71,9 +71,7 @@ static bool sysrq_on(void)
  */
 int sysrq_mask(void)
 {
-	if (sysrq_always_enabled)
-		return 1;
-	return sysrq_enabled;
+	return sysrq_always_enabled ? 1 : sysrq_enabled;
 }
 EXPORT_SYMBOL_GPL(sysrq_mask);
 
@@ -454,7 +452,7 @@ static void sysrq_handle_replay_logs(u8 key)
 {
 	console_try_replay_all();
 }
-static struct sysrq_key_op sysrq_replay_logs_op = {
+static const struct sysrq_key_op sysrq_replay_logs_op = {
 	.handler        = sysrq_handle_replay_logs,
 	.help_msg       = "replay-kernel-logs(R)",
 	.action_msg     = "Replay kernel logs on consoles",
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] tty/sysrq: make sysrq_replay_logs_op const and refactor sysrq_mask()
  2025-04-03  7:15 [PATCH] tty/sysrq: make sysrq_replay_logs_op const and refactor sysrq_mask() xiaopeitux
@ 2025-04-03  8:19 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2025-04-03  8:19 UTC (permalink / raw)
  To: xiaopeitux; +Cc: jirislaby, linux-serial, linux-kernel, Pei Xiao

On Thu, Apr 03, 2025 at 03:15:35PM +0800, xiaopeitux@foxmail.com wrote:
> From: Pei Xiao <xiaopei01@kylinos.cn>
> 
> Mark sysrq_replay_logs_op as const and simplify sysrq_mask().
> 
> Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
> ---
>  drivers/tty/sysrq.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
> index f85ce02e4725..c2a26abcb8cd 100644
> --- a/drivers/tty/sysrq.c
> +++ b/drivers/tty/sysrq.c
> @@ -71,9 +71,7 @@ static bool sysrq_on(void)
>   */
>  int sysrq_mask(void)
>  {
> -	if (sysrq_always_enabled)
> -		return 1;
> -	return sysrq_enabled;
> +	return sysrq_always_enabled ? 1 : sysrq_enabled;

That's not simpler, it's now harder to read and parse.  Only use ?: in C
for places it has to be used, not for stuff like this where it's more
obvious if you use an if () line.

We write code for people first, compilers second.

Also, you can't do two different things in the same commit, sorry.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-04-03  8:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-03  7:15 [PATCH] tty/sysrq: make sysrq_replay_logs_op const and refactor sysrq_mask() xiaopeitux
2025-04-03  8:19 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox