Commit d3cc1000 authored by Dmitry Torokhov's avatar Dmitry Torokhov

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: default avatarTim Schumacher <timschumi@gmx.de>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 8a25e058
...@@ -166,7 +166,8 @@ static void iforce_report_hats_buttons(struct iforce *iforce, u8 *data) ...@@ -166,7 +166,8 @@ static void iforce_report_hats_buttons(struct iforce *iforce, u8 *data)
} }
} }
void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data) void iforce_process_packet(struct iforce *iforce,
u8 packet_id, u8 *data, size_t len)
{ {
struct input_dev *dev = iforce->dev; struct input_dev *dev = iforce->dev;
int i, j; int i, j;
...@@ -176,14 +177,14 @@ void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data) ...@@ -176,14 +177,14 @@ void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data)
if (!iforce->type) if (!iforce->type)
return; return;
switch (HI(cmd)) { switch (packet_id) {
case 0x01: /* joystick position data */ case 0x01: /* joystick position data */
input_report_abs(dev, ABS_X, (__s16) (((__s16)data[1] << 8) | data[0])); input_report_abs(dev, ABS_X, (__s16) (((__s16)data[1] << 8) | data[0]));
input_report_abs(dev, ABS_Y, (__s16) (((__s16)data[3] << 8) | data[2])); input_report_abs(dev, ABS_Y, (__s16) (((__s16)data[3] << 8) | data[2]));
input_report_abs(dev, ABS_THROTTLE, 255 - data[4]); input_report_abs(dev, ABS_THROTTLE, 255 - data[4]);
if (LO(cmd) >= 8 && test_bit(ABS_RUDDER ,dev->absbit)) if (len >= 8 && test_bit(ABS_RUDDER ,dev->absbit))
input_report_abs(dev, ABS_RUDDER, (__s8)data[7]); input_report_abs(dev, ABS_RUDDER, (__s8)data[7]);
iforce_report_hats_buttons(iforce, data); iforce_report_hats_buttons(iforce, data);
...@@ -217,7 +218,7 @@ void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data) ...@@ -217,7 +218,7 @@ void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data)
input_report_ff_status(dev, i, FF_STATUS_STOPPED); input_report_ff_status(dev, i, FF_STATUS_STOPPED);
} }
for (j = 3; j < LO(cmd); j += 2) for (j = 3; j < len; j += 2)
mark_core_as_ready(iforce, data[j] | (data[j + 1] << 8)); mark_core_as_ready(iforce, data[j] | (data[j + 1] << 8));
break; break;
......
...@@ -163,16 +163,16 @@ static irqreturn_t iforce_serio_irq(struct serio *serio, ...@@ -163,16 +163,16 @@ static irqreturn_t iforce_serio_irq(struct serio *serio,
} }
if (iforce_serio->idx == iforce_serio->len) { if (iforce_serio->idx == iforce_serio->len) {
u16 cmd = (iforce_serio->id << 8) | iforce_serio->idx;
/* Handle command completion */ /* Handle command completion */
if (iforce_serio->expect_packet == iforce_serio->id) { if (iforce_serio->expect_packet == iforce_serio->id) {
iforce_serio->expect_packet = 0; iforce_serio->expect_packet = 0;
iforce->ecmd = cmd; iforce->ecmd = (iforce_serio->id << 8) |
iforce_serio->idx;
memcpy(iforce->edata, iforce->data, IFORCE_MAX_LENGTH); memcpy(iforce->edata, iforce->data, IFORCE_MAX_LENGTH);
} }
iforce_process_packet(iforce, cmd, iforce->data); iforce_process_packet(iforce, iforce_serio->id,
iforce->data, iforce_serio->len);
iforce_serio->pkt = 0; iforce_serio->pkt = 0;
iforce_serio->id = 0; iforce_serio->id = 0;
......
...@@ -170,8 +170,8 @@ static void iforce_usb_irq(struct urb *urb) ...@@ -170,8 +170,8 @@ static void iforce_usb_irq(struct urb *urb)
goto exit; goto exit;
} }
iforce_process_packet(iforce, iforce_process_packet(iforce, iforce->data[0],
(iforce->data[0] << 8) | (urb->actual_length - 1), iforce->data + 1); iforce->data + 1, urb->actual_length - 1);
exit: exit:
status = usb_submit_urb(urb, GFP_ATOMIC); status = usb_submit_urb(urb, GFP_ATOMIC);
......
...@@ -147,7 +147,8 @@ int iforce_init_device(struct device *parent, u16 bustype, ...@@ -147,7 +147,8 @@ int iforce_init_device(struct device *parent, u16 bustype,
/* iforce-packets.c */ /* iforce-packets.c */
int iforce_control_playback(struct iforce*, u16 id, unsigned int); int iforce_control_playback(struct iforce*, u16 id, unsigned int);
void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data); void iforce_process_packet(struct iforce *iforce,
u8 packet_id, u8 *data, size_t len);
int iforce_send_packet(struct iforce *iforce, u16 cmd, unsigned char* data); int iforce_send_packet(struct iforce *iforce, u16 cmd, unsigned char* data);
void iforce_dump_packet(struct iforce *iforce, char *msg, u16 cmd, unsigned char *data); void iforce_dump_packet(struct iforce *iforce, char *msg, u16 cmd, unsigned char *data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment