aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2018-01-04 13:58:48 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2018-02-02 19:50:21 -0500
commitb28bad65c1fec47076ebee88b51b0dafa31f5065 (patch)
treeac386beb534ad96de356ad25c16a0c201d67e977 /drivers/input
parentd5e0d9187abd5e3ce23884c375c4b36f403e42be (diff)
Input: libps2 - use u8 for byte data
Instead of using unsigned char for the byte data switch to using u8. Also use unsigned int for the command codes and timeouts, and have ps2_handle_ack() and ps2_handle_response() return bool instead of int, as they do not return error codes but rather signal whether a byte was handled or not handled. ps2_is_keyboard_id() now returns bool as well. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/serio/libps2.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/drivers/input/serio/libps2.c b/drivers/input/serio/libps2.c
index 21aea5169a99..c3712f0a47b5 100644
--- a/drivers/input/serio/libps2.c
+++ b/drivers/input/serio/libps2.c
@@ -34,7 +34,7 @@ MODULE_LICENSE("GPL");
34 * ps2_sendbyte() can only be called from a process context. 34 * ps2_sendbyte() can only be called from a process context.
35 */ 35 */
36 36
37int ps2_sendbyte(struct ps2dev *ps2dev, unsigned char byte, int timeout) 37int ps2_sendbyte(struct ps2dev *ps2dev, u8 byte, unsigned int timeout)
38{ 38{
39 serio_pause_rx(ps2dev->serio); 39 serio_pause_rx(ps2dev->serio);
40 ps2dev->nak = 1; 40 ps2dev->nak = 1;
@@ -75,7 +75,7 @@ EXPORT_SYMBOL(ps2_end_command);
75 * and discards them. 75 * and discards them.
76 */ 76 */
77 77
78void ps2_drain(struct ps2dev *ps2dev, int maxbytes, int timeout) 78void ps2_drain(struct ps2dev *ps2dev, size_t maxbytes, unsigned int timeout)
79{ 79{
80 if (maxbytes > sizeof(ps2dev->cmdbuf)) { 80 if (maxbytes > sizeof(ps2dev->cmdbuf)) {
81 WARN_ON(1); 81 WARN_ON(1);
@@ -102,9 +102,9 @@ EXPORT_SYMBOL(ps2_drain);
102 * known keyboard IDs. 102 * known keyboard IDs.
103 */ 103 */
104 104
105int ps2_is_keyboard_id(char id_byte) 105bool ps2_is_keyboard_id(u8 id_byte)
106{ 106{
107 static const char keyboard_ids[] = { 107 static const u8 keyboard_ids[] = {
108 0xab, /* Regular keyboards */ 108 0xab, /* Regular keyboards */
109 0xac, /* NCD Sun keyboard */ 109 0xac, /* NCD Sun keyboard */
110 0x2b, /* Trust keyboard, translated */ 110 0x2b, /* Trust keyboard, translated */
@@ -123,7 +123,8 @@ EXPORT_SYMBOL(ps2_is_keyboard_id);
123 * completion. 123 * completion.
124 */ 124 */
125 125
126static int ps2_adjust_timeout(struct ps2dev *ps2dev, int command, int timeout) 126static int ps2_adjust_timeout(struct ps2dev *ps2dev,
127 unsigned int command, unsigned int timeout)
127{ 128{
128 switch (command) { 129 switch (command) {
129 case PS2_CMD_RESET_BAT: 130 case PS2_CMD_RESET_BAT:
@@ -178,11 +179,11 @@ static int ps2_adjust_timeout(struct ps2dev *ps2dev, int command, int timeout)
178 * ps2_command() can only be called from a process context 179 * ps2_command() can only be called from a process context
179 */ 180 */
180 181
181int __ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command) 182int __ps2_command(struct ps2dev *ps2dev, u8 *param, unsigned int command)
182{ 183{
183 int timeout; 184 unsigned int timeout;
184 int send = (command >> 12) & 0xf; 185 unsigned int send = (command >> 12) & 0xf;
185 int receive = (command >> 8) & 0xf; 186 unsigned int receive = (command >> 8) & 0xf;
186 int rc = -1; 187 int rc = -1;
187 int i; 188 int i;
188 189
@@ -256,7 +257,7 @@ int __ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command)
256} 257}
257EXPORT_SYMBOL(__ps2_command); 258EXPORT_SYMBOL(__ps2_command);
258 259
259int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command) 260int ps2_command(struct ps2dev *ps2dev, u8 *param, unsigned int command)
260{ 261{
261 int rc; 262 int rc;
262 263
@@ -286,7 +287,7 @@ EXPORT_SYMBOL(ps2_init);
286 * to properly process ACK/NAK of a command from a PS/2 device. 287 * to properly process ACK/NAK of a command from a PS/2 device.
287 */ 288 */
288 289
289int ps2_handle_ack(struct ps2dev *ps2dev, unsigned char data) 290bool ps2_handle_ack(struct ps2dev *ps2dev, u8 data)
290{ 291{
291 switch (data) { 292 switch (data) {
292 case PS2_RET_ACK: 293 case PS2_RET_ACK:
@@ -318,7 +319,7 @@ int ps2_handle_ack(struct ps2dev *ps2dev, unsigned char data)
318 } 319 }
319 /* Fall through */ 320 /* Fall through */
320 default: 321 default:
321 return 0; 322 return false;
322 } 323 }
323 324
324 if (!ps2dev->nak) { 325 if (!ps2dev->nak) {
@@ -333,7 +334,7 @@ int ps2_handle_ack(struct ps2dev *ps2dev, unsigned char data)
333 if (data != PS2_RET_ACK) 334 if (data != PS2_RET_ACK)
334 ps2_handle_response(ps2dev, data); 335 ps2_handle_response(ps2dev, data);
335 336
336 return 1; 337 return true;
337} 338}
338EXPORT_SYMBOL(ps2_handle_ack); 339EXPORT_SYMBOL(ps2_handle_ack);
339 340
@@ -343,7 +344,7 @@ EXPORT_SYMBOL(ps2_handle_ack);
343 * waiting for completion of the command. 344 * waiting for completion of the command.
344 */ 345 */
345 346
346int ps2_handle_response(struct ps2dev *ps2dev, unsigned char data) 347bool ps2_handle_response(struct ps2dev *ps2dev, u8 data)
347{ 348{
348 if (ps2dev->cmdcnt) 349 if (ps2dev->cmdcnt)
349 ps2dev->cmdbuf[--ps2dev->cmdcnt] = data; 350 ps2dev->cmdbuf[--ps2dev->cmdcnt] = data;
@@ -359,7 +360,7 @@ int ps2_handle_response(struct ps2dev *ps2dev, unsigned char data)
359 wake_up(&ps2dev->wait); 360 wake_up(&ps2dev->wait);
360 } 361 }
361 362
362 return 1; 363 return true;
363} 364}
364EXPORT_SYMBOL(ps2_handle_response); 365EXPORT_SYMBOL(ps2_handle_response);
365 366