Commit ab7373bf authored by Hendrik Brueckner's avatar Hendrik Brueckner Committed by Martin Schwidefsky

s390/ctrlchar: improve handling of magic sysrequests

Extract the sysrq handling from the ctrlchar_handle() into a separate
function that can be directly used by other users.

Introduce a new sysrq_work structure to embed the work_struct and to
specify the magic sysrq function to be invoked.
Signed-off-by: default avatarHendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent de9c35f3
...@@ -14,15 +14,21 @@ ...@@ -14,15 +14,21 @@
#include "ctrlchar.h" #include "ctrlchar.h"
#ifdef CONFIG_MAGIC_SYSRQ #ifdef CONFIG_MAGIC_SYSRQ
static int ctrlchar_sysrq_key; static struct sysrq_work ctrlchar_sysrq;
static void static void
ctrlchar_handle_sysrq(struct work_struct *work) ctrlchar_handle_sysrq(struct work_struct *work)
{ {
handle_sysrq(ctrlchar_sysrq_key); struct sysrq_work *sysrq = container_of(work, struct sysrq_work, work);
handle_sysrq(sysrq->key);
} }
static DECLARE_WORK(ctrlchar_work, ctrlchar_handle_sysrq); void schedule_sysrq_work(struct sysrq_work *sw)
{
INIT_WORK(&sw->work, ctrlchar_handle_sysrq);
schedule_work(&sw->work);
}
#endif #endif
...@@ -51,8 +57,8 @@ ctrlchar_handle(const unsigned char *buf, int len, struct tty_struct *tty) ...@@ -51,8 +57,8 @@ ctrlchar_handle(const unsigned char *buf, int len, struct tty_struct *tty)
#ifdef CONFIG_MAGIC_SYSRQ #ifdef CONFIG_MAGIC_SYSRQ
/* racy */ /* racy */
if (len == 3 && buf[1] == '-') { if (len == 3 && buf[1] == '-') {
ctrlchar_sysrq_key = buf[2]; ctrlchar_sysrq.key = buf[2];
schedule_work(&ctrlchar_work); schedule_sysrq_work(&ctrlchar_sysrq);
return CTRLCHAR_SYSRQ; return CTRLCHAR_SYSRQ;
} }
#endif #endif
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
*/ */
#include <linux/tty.h> #include <linux/tty.h>
#include <linux/sysrq.h>
#include <linux/workqueue.h>
extern unsigned int extern unsigned int
ctrlchar_handle(const unsigned char *buf, int len, struct tty_struct *tty); ctrlchar_handle(const unsigned char *buf, int len, struct tty_struct *tty);
...@@ -17,3 +19,13 @@ ctrlchar_handle(const unsigned char *buf, int len, struct tty_struct *tty); ...@@ -17,3 +19,13 @@ ctrlchar_handle(const unsigned char *buf, int len, struct tty_struct *tty);
#define CTRLCHAR_SYSRQ (3 << 8) #define CTRLCHAR_SYSRQ (3 << 8)
#define CTRLCHAR_MASK (~0xffu) #define CTRLCHAR_MASK (~0xffu)
#ifdef CONFIG_MAGIC_SYSRQ
struct sysrq_work {
int key;
struct work_struct work;
};
void schedule_sysrq_work(struct sysrq_work *sw);
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment