diff options
author | Nick Desaulniers <nick.desaulniers@gmail.com> | 2017-06-25 01:50:12 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2017-07-25 16:54:31 -0400 |
commit | dae1a432ab1fe79ae53129ededeaece35a2dc14d (patch) | |
tree | 970169d8f4593f98400ad92ce967a7fdb8bd9800 /drivers/input/mousedev.c | |
parent | 3dabc19acf79fa77e3a59a43b764b24d5be453be (diff) |
Input: mousedev - fix implicit conversion warning
Clang warns:
drivers/input/mousedev.c:653:63: error: implicit conversion from 'int'
to 'signed char' changes value from 200 to -56
[-Wconstant-conversion]
client->ps2[1] = 0x60; client->ps2[2] = 3; client->ps2[3] = 200;
~ ^~~
As the PS2 data is really a stream of bytes, let's switch to using u8 type
for it, which silences this warning.
Signed-off-by: Nick Desaulniers <nick.desaulniers@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/mousedev.c')
-rw-r--r-- | drivers/input/mousedev.c | 62 |
1 files changed, 34 insertions, 28 deletions
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c index 0e0ff84088fd..2d7f691ec71c 100644 --- a/drivers/input/mousedev.c +++ b/drivers/input/mousedev.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #define MOUSEDEV_MINORS 31 | 15 | #define MOUSEDEV_MINORS 31 |
16 | #define MOUSEDEV_MIX 63 | 16 | #define MOUSEDEV_MIX 63 |
17 | 17 | ||
18 | #include <linux/bitops.h> | ||
18 | #include <linux/sched.h> | 19 | #include <linux/sched.h> |
19 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
20 | #include <linux/poll.h> | 21 | #include <linux/poll.h> |
@@ -103,7 +104,7 @@ struct mousedev_client { | |||
103 | spinlock_t packet_lock; | 104 | spinlock_t packet_lock; |
104 | int pos_x, pos_y; | 105 | int pos_x, pos_y; |
105 | 106 | ||
106 | signed char ps2[6]; | 107 | u8 ps2[6]; |
107 | unsigned char ready, buffer, bufsiz; | 108 | unsigned char ready, buffer, bufsiz; |
108 | unsigned char imexseq, impsseq; | 109 | unsigned char imexseq, impsseq; |
109 | enum mousedev_emul mode; | 110 | enum mousedev_emul mode; |
@@ -291,11 +292,10 @@ static void mousedev_notify_readers(struct mousedev *mousedev, | |||
291 | } | 292 | } |
292 | 293 | ||
293 | client->pos_x += packet->dx; | 294 | client->pos_x += packet->dx; |
294 | client->pos_x = client->pos_x < 0 ? | 295 | client->pos_x = clamp_val(client->pos_x, 0, xres); |
295 | 0 : (client->pos_x >= xres ? xres : client->pos_x); | 296 | |
296 | client->pos_y += packet->dy; | 297 | client->pos_y += packet->dy; |
297 | client->pos_y = client->pos_y < 0 ? | 298 | client->pos_y = clamp_val(client->pos_y, 0, yres); |
298 | 0 : (client->pos_y >= yres ? yres : client->pos_y); | ||
299 | 299 | ||
300 | p->dx += packet->dx; | 300 | p->dx += packet->dx; |
301 | p->dy += packet->dy; | 301 | p->dy += packet->dy; |
@@ -571,44 +571,50 @@ static int mousedev_open(struct inode *inode, struct file *file) | |||
571 | return error; | 571 | return error; |
572 | } | 572 | } |
573 | 573 | ||
574 | static inline int mousedev_limit_delta(int delta, int limit) | 574 | static void mousedev_packet(struct mousedev_client *client, u8 *ps2_data) |
575 | { | ||
576 | return delta > limit ? limit : (delta < -limit ? -limit : delta); | ||
577 | } | ||
578 | |||
579 | static void mousedev_packet(struct mousedev_client *client, | ||
580 | signed char *ps2_data) | ||
581 | { | 575 | { |
582 | struct mousedev_motion *p = &client->packets[client->tail]; | 576 | struct mousedev_motion *p = &client->packets[client->tail]; |
577 | s8 dx, dy, dz; | ||
578 | |||
579 | dx = clamp_val(p->dx, -127, 127); | ||
580 | p->dx -= dx; | ||
581 | |||
582 | dy = clamp_val(p->dy, -127, 127); | ||
583 | p->dy -= dy; | ||
583 | 584 | ||
584 | ps2_data[0] = 0x08 | | 585 | ps2_data[0] = BIT(3); |
585 | ((p->dx < 0) << 4) | ((p->dy < 0) << 5) | (p->buttons & 0x07); | 586 | ps2_data[0] |= ((dx & BIT(7)) >> 3) | ((dy & BIT(7)) >> 2); |
586 | ps2_data[1] = mousedev_limit_delta(p->dx, 127); | 587 | ps2_data[0] |= p->buttons & 0x07; |
587 | ps2_data[2] = mousedev_limit_delta(p->dy, 127); | 588 | ps2_data[1] = dx; |
588 | p->dx -= ps2_data[1]; | 589 | ps2_data[2] = dy; |
589 | p->dy -= ps2_data[2]; | ||
590 | 590 | ||
591 | switch (client->mode) { | 591 | switch (client->mode) { |
592 | case MOUSEDEV_EMUL_EXPS: | 592 | case MOUSEDEV_EMUL_EXPS: |
593 | ps2_data[3] = mousedev_limit_delta(p->dz, 7); | 593 | dz = clamp_val(p->dz, -7, 7); |
594 | p->dz -= ps2_data[3]; | 594 | p->dz -= dz; |
595 | ps2_data[3] = (ps2_data[3] & 0x0f) | ((p->buttons & 0x18) << 1); | 595 | |
596 | ps2_data[3] = (dz & 0x0f) | ((p->buttons & 0x18) << 1); | ||
596 | client->bufsiz = 4; | 597 | client->bufsiz = 4; |
597 | break; | 598 | break; |
598 | 599 | ||
599 | case MOUSEDEV_EMUL_IMPS: | 600 | case MOUSEDEV_EMUL_IMPS: |
600 | ps2_data[0] |= | 601 | dz = clamp_val(p->dz, -127, 127); |
601 | ((p->buttons & 0x10) >> 3) | ((p->buttons & 0x08) >> 1); | 602 | p->dz -= dz; |
602 | ps2_data[3] = mousedev_limit_delta(p->dz, 127); | 603 | |
603 | p->dz -= ps2_data[3]; | 604 | ps2_data[0] |= ((p->buttons & 0x10) >> 3) | |
605 | ((p->buttons & 0x08) >> 1); | ||
606 | ps2_data[3] = dz; | ||
607 | |||
604 | client->bufsiz = 4; | 608 | client->bufsiz = 4; |
605 | break; | 609 | break; |
606 | 610 | ||
607 | case MOUSEDEV_EMUL_PS2: | 611 | case MOUSEDEV_EMUL_PS2: |
608 | default: | 612 | default: |
609 | ps2_data[0] |= | ||
610 | ((p->buttons & 0x10) >> 3) | ((p->buttons & 0x08) >> 1); | ||
611 | p->dz = 0; | 613 | p->dz = 0; |
614 | |||
615 | ps2_data[0] |= ((p->buttons & 0x10) >> 3) | | ||
616 | ((p->buttons & 0x08) >> 1); | ||
617 | |||
612 | client->bufsiz = 3; | 618 | client->bufsiz = 3; |
613 | break; | 619 | break; |
614 | } | 620 | } |
@@ -714,7 +720,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer, | |||
714 | { | 720 | { |
715 | struct mousedev_client *client = file->private_data; | 721 | struct mousedev_client *client = file->private_data; |
716 | struct mousedev *mousedev = client->mousedev; | 722 | struct mousedev *mousedev = client->mousedev; |
717 | signed char data[sizeof(client->ps2)]; | 723 | u8 data[sizeof(client->ps2)]; |
718 | int retval = 0; | 724 | int retval = 0; |
719 | 725 | ||
720 | if (!client->ready && !client->buffer && mousedev->exist && | 726 | if (!client->ready && !client->buffer && mousedev->exist && |