diff options
-rw-r--r-- | drivers/tty/hvc/hvc_console.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c index eb255e807c06..a2a2645b296c 100644 --- a/drivers/tty/hvc/hvc_console.c +++ b/drivers/tty/hvc/hvc_console.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/list.h> | 31 | #include <linux/list.h> |
32 | #include <linux/module.h> | 32 | #include <linux/module.h> |
33 | #include <linux/major.h> | 33 | #include <linux/major.h> |
34 | #include <linux/atomic.h> | ||
34 | #include <linux/sysrq.h> | 35 | #include <linux/sysrq.h> |
35 | #include <linux/tty.h> | 36 | #include <linux/tty.h> |
36 | #include <linux/tty_flip.h> | 37 | #include <linux/tty_flip.h> |
@@ -70,6 +71,9 @@ static struct task_struct *hvc_task; | |||
70 | /* Picks up late kicks after list walk but before schedule() */ | 71 | /* Picks up late kicks after list walk but before schedule() */ |
71 | static int hvc_kicked; | 72 | static int hvc_kicked; |
72 | 73 | ||
74 | /* hvc_init is triggered from hvc_alloc, i.e. only when actually used */ | ||
75 | static atomic_t hvc_needs_init __read_mostly = ATOMIC_INIT(-1); | ||
76 | |||
73 | static int hvc_init(void); | 77 | static int hvc_init(void); |
74 | 78 | ||
75 | #ifdef CONFIG_MAGIC_SYSRQ | 79 | #ifdef CONFIG_MAGIC_SYSRQ |
@@ -842,7 +846,7 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, int data, | |||
842 | int i; | 846 | int i; |
843 | 847 | ||
844 | /* We wait until a driver actually comes along */ | 848 | /* We wait until a driver actually comes along */ |
845 | if (!hvc_driver) { | 849 | if (atomic_inc_not_zero(&hvc_needs_init)) { |
846 | int err = hvc_init(); | 850 | int err = hvc_init(); |
847 | if (err) | 851 | if (err) |
848 | return ERR_PTR(err); | 852 | return ERR_PTR(err); |