aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHendrik Brueckner <brueckner@linux.vnet.ibm.com>2015-08-18 11:42:39 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2015-08-26 11:20:44 -0400
commitab7373bf235ede864a72f0d2f8f9a21a1748c4a2 (patch)
tree3c4f4cc4965006f31f5556bc2c4d4f3c8633e8b4
parentde9c35f32410c225c585535a321ce591ea001645 (diff)
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: Hendrik Brueckner <brueckner@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
-rw-r--r--drivers/s390/char/ctrlchar.c16
-rw-r--r--drivers/s390/char/ctrlchar.h12
2 files changed, 23 insertions, 5 deletions
diff --git a/drivers/s390/char/ctrlchar.c b/drivers/s390/char/ctrlchar.c
index 8de2deb176d7..f7d92584b993 100644
--- a/drivers/s390/char/ctrlchar.c
+++ b/drivers/s390/char/ctrlchar.c
@@ -14,15 +14,21 @@
14#include "ctrlchar.h" 14#include "ctrlchar.h"
15 15
16#ifdef CONFIG_MAGIC_SYSRQ 16#ifdef CONFIG_MAGIC_SYSRQ
17static int ctrlchar_sysrq_key; 17static struct sysrq_work ctrlchar_sysrq;
18 18
19static void 19static void
20ctrlchar_handle_sysrq(struct work_struct *work) 20ctrlchar_handle_sysrq(struct work_struct *work)
21{ 21{
22 handle_sysrq(ctrlchar_sysrq_key); 22 struct sysrq_work *sysrq = container_of(work, struct sysrq_work, work);
23
24 handle_sysrq(sysrq->key);
23} 25}
24 26
25static DECLARE_WORK(ctrlchar_work, ctrlchar_handle_sysrq); 27void schedule_sysrq_work(struct sysrq_work *sw)
28{
29 INIT_WORK(&sw->work, ctrlchar_handle_sysrq);
30 schedule_work(&sw->work);
31}
26#endif 32#endif
27 33
28 34
@@ -51,8 +57,8 @@ ctrlchar_handle(const unsigned char *buf, int len, struct tty_struct *tty)
51#ifdef CONFIG_MAGIC_SYSRQ 57#ifdef CONFIG_MAGIC_SYSRQ
52 /* racy */ 58 /* racy */
53 if (len == 3 && buf[1] == '-') { 59 if (len == 3 && buf[1] == '-') {
54 ctrlchar_sysrq_key = buf[2]; 60 ctrlchar_sysrq.key = buf[2];
55 schedule_work(&ctrlchar_work); 61 schedule_sysrq_work(&ctrlchar_sysrq);
56 return CTRLCHAR_SYSRQ; 62 return CTRLCHAR_SYSRQ;
57 } 63 }
58#endif 64#endif
diff --git a/drivers/s390/char/ctrlchar.h b/drivers/s390/char/ctrlchar.h
index 1a53552f4981..59c2d6e55e55 100644
--- a/drivers/s390/char/ctrlchar.h
+++ b/drivers/s390/char/ctrlchar.h
@@ -7,6 +7,8 @@
7 */ 7 */
8 8
9#include <linux/tty.h> 9#include <linux/tty.h>
10#include <linux/sysrq.h>
11#include <linux/workqueue.h>
10 12
11extern unsigned int 13extern unsigned int
12ctrlchar_handle(const unsigned char *buf, int len, struct tty_struct *tty); 14ctrlchar_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#define CTRLCHAR_SYSRQ (3 << 8) 19#define CTRLCHAR_SYSRQ (3 << 8)
18 20
19#define CTRLCHAR_MASK (~0xffu) 21#define CTRLCHAR_MASK (~0xffu)
22
23
24#ifdef CONFIG_MAGIC_SYSRQ
25struct sysrq_work {
26 int key;
27 struct work_struct work;
28};
29
30void schedule_sysrq_work(struct sysrq_work *sw);
31#endif