diff options
Diffstat (limited to 'drivers/input/serio/libps2.c')
-rw-r--r-- | drivers/input/serio/libps2.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/drivers/input/serio/libps2.c b/drivers/input/serio/libps2.c index 3a95b508bf27..769ba65a585a 100644 --- a/drivers/input/serio/libps2.c +++ b/drivers/input/serio/libps2.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/interrupt.h> | 17 | #include <linux/interrupt.h> |
18 | #include <linux/input.h> | 18 | #include <linux/input.h> |
19 | #include <linux/serio.h> | 19 | #include <linux/serio.h> |
20 | #include <linux/i8042.h> | ||
20 | #include <linux/init.h> | 21 | #include <linux/init.h> |
21 | #include <linux/libps2.h> | 22 | #include <linux/libps2.h> |
22 | 23 | ||
@@ -54,6 +55,24 @@ int ps2_sendbyte(struct ps2dev *ps2dev, unsigned char byte, int timeout) | |||
54 | } | 55 | } |
55 | EXPORT_SYMBOL(ps2_sendbyte); | 56 | EXPORT_SYMBOL(ps2_sendbyte); |
56 | 57 | ||
58 | void ps2_begin_command(struct ps2dev *ps2dev) | ||
59 | { | ||
60 | mutex_lock(&ps2dev->cmd_mutex); | ||
61 | |||
62 | if (i8042_check_port_owner(ps2dev->serio)) | ||
63 | i8042_lock_chip(); | ||
64 | } | ||
65 | EXPORT_SYMBOL(ps2_begin_command); | ||
66 | |||
67 | void ps2_end_command(struct ps2dev *ps2dev) | ||
68 | { | ||
69 | if (i8042_check_port_owner(ps2dev->serio)) | ||
70 | i8042_unlock_chip(); | ||
71 | |||
72 | mutex_unlock(&ps2dev->cmd_mutex); | ||
73 | } | ||
74 | EXPORT_SYMBOL(ps2_end_command); | ||
75 | |||
57 | /* | 76 | /* |
58 | * ps2_drain() waits for device to transmit requested number of bytes | 77 | * ps2_drain() waits for device to transmit requested number of bytes |
59 | * and discards them. | 78 | * and discards them. |
@@ -66,7 +85,7 @@ void ps2_drain(struct ps2dev *ps2dev, int maxbytes, int timeout) | |||
66 | maxbytes = sizeof(ps2dev->cmdbuf); | 85 | maxbytes = sizeof(ps2dev->cmdbuf); |
67 | } | 86 | } |
68 | 87 | ||
69 | mutex_lock(&ps2dev->cmd_mutex); | 88 | ps2_begin_command(ps2dev); |
70 | 89 | ||
71 | serio_pause_rx(ps2dev->serio); | 90 | serio_pause_rx(ps2dev->serio); |
72 | ps2dev->flags = PS2_FLAG_CMD; | 91 | ps2dev->flags = PS2_FLAG_CMD; |
@@ -76,7 +95,8 @@ void ps2_drain(struct ps2dev *ps2dev, int maxbytes, int timeout) | |||
76 | wait_event_timeout(ps2dev->wait, | 95 | wait_event_timeout(ps2dev->wait, |
77 | !(ps2dev->flags & PS2_FLAG_CMD), | 96 | !(ps2dev->flags & PS2_FLAG_CMD), |
78 | msecs_to_jiffies(timeout)); | 97 | msecs_to_jiffies(timeout)); |
79 | mutex_unlock(&ps2dev->cmd_mutex); | 98 | |
99 | ps2_end_command(ps2dev); | ||
80 | } | 100 | } |
81 | EXPORT_SYMBOL(ps2_drain); | 101 | EXPORT_SYMBOL(ps2_drain); |
82 | 102 | ||
@@ -237,9 +257,9 @@ int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command) | |||
237 | { | 257 | { |
238 | int rc; | 258 | int rc; |
239 | 259 | ||
240 | mutex_lock(&ps2dev->cmd_mutex); | 260 | ps2_begin_command(ps2dev); |
241 | rc = __ps2_command(ps2dev, param, command); | 261 | rc = __ps2_command(ps2dev, param, command); |
242 | mutex_unlock(&ps2dev->cmd_mutex); | 262 | ps2_end_command(ps2dev); |
243 | 263 | ||
244 | return rc; | 264 | return rc; |
245 | } | 265 | } |