diff options
| author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2018-08-09 20:50:39 -0400 |
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2019-06-23 02:55:22 -0400 |
| commit | d3cc100069f945a392d6cde5ea326bb686418193 (patch) | |
| tree | d791ffe72a6b45becb6dd47c6748d32c7b9b73a1 /drivers/input | |
| parent | 8a25e05890f155406171e8cb256177275bbf387f (diff) | |
Input: iforce - do not combine arguments for iforce_process_packet()
Current code combines packet type and data length into single argument to
iforce_process_packet() and then has to untangle it. It is much clearer to
simply use separate arguments.
Tested-by: Tim Schumacher <timschumi@gmx.de>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
| -rw-r--r-- | drivers/input/joystick/iforce/iforce-packets.c | 9 | ||||
| -rw-r--r-- | drivers/input/joystick/iforce/iforce-serio.c | 8 | ||||
| -rw-r--r-- | drivers/input/joystick/iforce/iforce-usb.c | 4 | ||||
| -rw-r--r-- | drivers/input/joystick/iforce/iforce.h | 3 |
4 files changed, 13 insertions, 11 deletions
diff --git a/drivers/input/joystick/iforce/iforce-packets.c b/drivers/input/joystick/iforce/iforce-packets.c index ffd1dd65deb8..35b7a5206977 100644 --- a/drivers/input/joystick/iforce/iforce-packets.c +++ b/drivers/input/joystick/iforce/iforce-packets.c | |||
| @@ -166,7 +166,8 @@ static void iforce_report_hats_buttons(struct iforce *iforce, u8 *data) | |||
| 166 | } | 166 | } |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data) | 169 | void iforce_process_packet(struct iforce *iforce, |
| 170 | u8 packet_id, u8 *data, size_t len) | ||
| 170 | { | 171 | { |
| 171 | struct input_dev *dev = iforce->dev; | 172 | struct input_dev *dev = iforce->dev; |
| 172 | int i, j; | 173 | int i, j; |
| @@ -176,14 +177,14 @@ void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data) | |||
| 176 | if (!iforce->type) | 177 | if (!iforce->type) |
| 177 | return; | 178 | return; |
| 178 | 179 | ||
| 179 | switch (HI(cmd)) { | 180 | switch (packet_id) { |
| 180 | 181 | ||
| 181 | case 0x01: /* joystick position data */ | 182 | case 0x01: /* joystick position data */ |
| 182 | input_report_abs(dev, ABS_X, (__s16) (((__s16)data[1] << 8) | data[0])); | 183 | input_report_abs(dev, ABS_X, (__s16) (((__s16)data[1] << 8) | data[0])); |
| 183 | input_report_abs(dev, ABS_Y, (__s16) (((__s16)data[3] << 8) | data[2])); | 184 | input_report_abs(dev, ABS_Y, (__s16) (((__s16)data[3] << 8) | data[2])); |
| 184 | input_report_abs(dev, ABS_THROTTLE, 255 - data[4]); | 185 | input_report_abs(dev, ABS_THROTTLE, 255 - data[4]); |
| 185 | 186 | ||
| 186 | if (LO(cmd) >= 8 && test_bit(ABS_RUDDER ,dev->absbit)) | 187 | if (len >= 8 && test_bit(ABS_RUDDER ,dev->absbit)) |
| 187 | input_report_abs(dev, ABS_RUDDER, (__s8)data[7]); | 188 | input_report_abs(dev, ABS_RUDDER, (__s8)data[7]); |
| 188 | 189 | ||
| 189 | iforce_report_hats_buttons(iforce, data); | 190 | iforce_report_hats_buttons(iforce, data); |
| @@ -217,7 +218,7 @@ void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data) | |||
| 217 | input_report_ff_status(dev, i, FF_STATUS_STOPPED); | 218 | input_report_ff_status(dev, i, FF_STATUS_STOPPED); |
| 218 | } | 219 | } |
| 219 | 220 | ||
| 220 | for (j = 3; j < LO(cmd); j += 2) | 221 | for (j = 3; j < len; j += 2) |
| 221 | mark_core_as_ready(iforce, data[j] | (data[j + 1] << 8)); | 222 | mark_core_as_ready(iforce, data[j] | (data[j + 1] << 8)); |
| 222 | 223 | ||
| 223 | break; | 224 | break; |
diff --git a/drivers/input/joystick/iforce/iforce-serio.c b/drivers/input/joystick/iforce/iforce-serio.c index 6c6411fbdc32..f8bf7d2aa59f 100644 --- a/drivers/input/joystick/iforce/iforce-serio.c +++ b/drivers/input/joystick/iforce/iforce-serio.c | |||
| @@ -163,16 +163,16 @@ static irqreturn_t iforce_serio_irq(struct serio *serio, | |||
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | if (iforce_serio->idx == iforce_serio->len) { | 165 | if (iforce_serio->idx == iforce_serio->len) { |
| 166 | u16 cmd = (iforce_serio->id << 8) | iforce_serio->idx; | ||
| 167 | |||
| 168 | /* Handle command completion */ | 166 | /* Handle command completion */ |
| 169 | if (iforce_serio->expect_packet == iforce_serio->id) { | 167 | if (iforce_serio->expect_packet == iforce_serio->id) { |
| 170 | iforce_serio->expect_packet = 0; | 168 | iforce_serio->expect_packet = 0; |
| 171 | iforce->ecmd = cmd; | 169 | iforce->ecmd = (iforce_serio->id << 8) | |
| 170 | iforce_serio->idx; | ||
| 172 | memcpy(iforce->edata, iforce->data, IFORCE_MAX_LENGTH); | 171 | memcpy(iforce->edata, iforce->data, IFORCE_MAX_LENGTH); |
| 173 | } | 172 | } |
| 174 | 173 | ||
| 175 | iforce_process_packet(iforce, cmd, iforce->data); | 174 | iforce_process_packet(iforce, iforce_serio->id, |
| 175 | iforce->data, iforce_serio->len); | ||
| 176 | 176 | ||
| 177 | iforce_serio->pkt = 0; | 177 | iforce_serio->pkt = 0; |
| 178 | iforce_serio->id = 0; | 178 | iforce_serio->id = 0; |
diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c index cefaa1c5abc7..b3743fde2a3a 100644 --- a/drivers/input/joystick/iforce/iforce-usb.c +++ b/drivers/input/joystick/iforce/iforce-usb.c | |||
| @@ -170,8 +170,8 @@ static void iforce_usb_irq(struct urb *urb) | |||
| 170 | goto exit; | 170 | goto exit; |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | iforce_process_packet(iforce, | 173 | iforce_process_packet(iforce, iforce->data[0], |
| 174 | (iforce->data[0] << 8) | (urb->actual_length - 1), iforce->data + 1); | 174 | iforce->data + 1, urb->actual_length - 1); |
| 175 | 175 | ||
| 176 | exit: | 176 | exit: |
| 177 | status = usb_submit_urb(urb, GFP_ATOMIC); | 177 | status = usb_submit_urb(urb, GFP_ATOMIC); |
diff --git a/drivers/input/joystick/iforce/iforce.h b/drivers/input/joystick/iforce/iforce.h index 3e3df83b9d77..ce3c6aead8b6 100644 --- a/drivers/input/joystick/iforce/iforce.h +++ b/drivers/input/joystick/iforce/iforce.h | |||
| @@ -147,7 +147,8 @@ int iforce_init_device(struct device *parent, u16 bustype, | |||
| 147 | 147 | ||
| 148 | /* iforce-packets.c */ | 148 | /* iforce-packets.c */ |
| 149 | int iforce_control_playback(struct iforce*, u16 id, unsigned int); | 149 | int iforce_control_playback(struct iforce*, u16 id, unsigned int); |
| 150 | void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data); | 150 | void iforce_process_packet(struct iforce *iforce, |
| 151 | u8 packet_id, u8 *data, size_t len); | ||
| 151 | int iforce_send_packet(struct iforce *iforce, u16 cmd, unsigned char* data); | 152 | int iforce_send_packet(struct iforce *iforce, u16 cmd, unsigned char* data); |
| 152 | void iforce_dump_packet(struct iforce *iforce, char *msg, u16 cmd, unsigned char *data); | 153 | void iforce_dump_packet(struct iforce *iforce, char *msg, u16 cmd, unsigned char *data); |
| 153 | 154 | ||
