Commit 08dc09fb authored by Dmitry Torokhov's avatar Dmitry Torokhov Committed by Vojtech Pavlik

input: Fix compilation warning in PID driver and generally

       repair force feedback effect erase routine that could
       never have worked.
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
Signed-off-by: default avatarVojtech Pavlik <vojtech@suse.cz>
parent 52a4cc74
......@@ -1010,10 +1010,10 @@ int hid_set_field(struct hid_field *field, unsigned offset, __s32 value)
}
/*
* Find a report with a specified HID usage.
* Find a report field with a specified HID usage.
*/
struct hid_report *hid_find_report_by_usage(struct hid_device *hid, __u32 wanted_usage, int type)
struct hid_field *hid_find_field_by_usage(struct hid_device *hid, __u32 wanted_usage, int type)
{
struct hid_report *report;
int i;
......@@ -1021,7 +1021,7 @@ struct hid_report *hid_find_report_by_usage(struct hid_device *hid, __u32 wanted
list_for_each_entry(report, &hid->report_enum[type].report_list, list)
for (i = 0; i < report->maxfield; i++)
if (report->field[i]->logical == wanted_usage)
return report;
return report->field[i];
return NULL;
}
......
......@@ -487,7 +487,7 @@ void hid_close(struct hid_device *);
int hid_set_field(struct hid_field *, unsigned, __s32);
void hid_submit_report(struct hid_device *, struct hid_report *, unsigned char dir);
void hid_init_reports(struct hid_device *hid);
struct hid_report *hid_find_report_by_usage(struct hid_device *hid, __u32 wanted_usage, int type);
struct hid_field *hid_find_field_by_usage(struct hid_device *hid, __u32 wanted_usage, int type);
int hid_wait_io(struct hid_device* hid);
......
......@@ -110,9 +110,8 @@ static void hid_pid_ctrl_playback(struct hid_device *hid,
static int hid_pid_erase(struct input_dev *dev, int id)
{
struct hid_device *hid = dev->private;
struct hid_field* field;
struct hid_report* report;
struct hid_ff_pid *pid = hid->ff_private;
struct hid_field *field;
unsigned long flags;
int ret;
......@@ -120,27 +119,20 @@ static int hid_pid_erase(struct input_dev *dev, int id)
return -EACCES;
/* Find report */
report = hid_find_report_by_usage(hid,
HID_UP_PID | FF_PID_USAGE_BLOCK_FREE, HID_OUTPUT_REPORT);
if (!report) {
dev_err(&hid->dev->dev, "couldn't find report\n");
return ret;
}
/* Find field */
field = (struct hid_field *) kmalloc(sizeof(struct hid_field), GFP_KERNEL);
field = hid_find_field_by_usage(hid, HID_UP_PID | FF_PID_USAGE_BLOCK_FREE,
HID_OUTPUT_REPORT);
if (!field) {
dev_err(&hid->dev->dev, "couldn't allocate field\n");
return -ENOMEM;
dev_err(&hid->dev->dev, "couldn't find report\n");
return -EIO;
}
ret = hid_set_field(field, ret, pid->effects[id].device_id);
ret = hid_set_field(field, 0, pid->effects[id].device_id);
if (ret) {
dev_err(&hid->dev->dev, "couldn't set field\n");
return ret;
}
hid_submit_report(hid, report, USB_DIR_OUT);
hid_submit_report(hid, field->report, USB_DIR_OUT);
spin_lock_irqsave(&pid->lock, flags);
hid_pid_ctrl_playback(hid, pid->effects + id, 0);
......
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