Message ID | 1392055139-19631-13-git-send-email-benjamin.tissoires@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Delegated to: | Jiri Kosina |
Headers | show |
Hi On Mon, Feb 10, 2014 at 6:58 PM, Benjamin Tissoires <benjamin.tissoires@redhat.com> wrote: > Remove hid_output_raw_report() call as it is not a ll_driver callbacj, > and switch to the hid_hw_* implementation. USB-HID used to fallback > into SET_REPORT when there were no output interrupt endpoint, > so emulating this if hid_hw_output_report() returns -ENOSYS. > > Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> > --- > drivers/hid/hidraw.c | 22 +++++++++++++++++----- > 1 file changed, 17 insertions(+), 5 deletions(-) > > diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c > index f8708c9..704718b 100644 > --- a/drivers/hid/hidraw.c > +++ b/drivers/hid/hidraw.c > @@ -123,10 +123,8 @@ static ssize_t hidraw_send_report(struct file *file, const char __user *buffer, > > dev = hidraw_table[minor]->hid; > > - if (!dev->hid_output_raw_report) { > - ret = -ENODEV; > - goto out; > - } > + if (!dev->ll_driver->raw_request || !dev->ll_driver->output_report) > + return -ENODEV; You still have a "goto out;" above (not visible in the patch). The error paths look quite ugly now. I'd prefer consistency here, so either keep the jump or fix the error-path above, too. Otherwise looks good. Reviewed-by: David Herrmann <dh.herrmann@gmail.com> Thanks David > > if (count > HID_MAX_BUFFER_SIZE) { > hid_warn(dev, "pid %d passed too large report\n", > @@ -153,7 +151,21 @@ static ssize_t hidraw_send_report(struct file *file, const char __user *buffer, > goto out_free; > } > > - ret = hid_output_raw_report(dev, buf, count, report_type); > + if (report_type == HID_OUTPUT_REPORT) { > + ret = hid_hw_output_report(dev, buf, count); > + /* > + * compatibility with old implementation of USB-HID and I2C-HID: > + * if the device does not support receiving output reports, > + * on an interrupt endpoint, then fallback to the SET_REPORT > + * HID command. > + */ > + if (ret != -ENOSYS) > + goto out_free; > + } > + > + ret = hid_hw_raw_request(dev, buf[0], buf, count, report_type, > + HID_REQ_SET_REPORT); > + > out_free: > kfree(buf); > out: > -- > 1.8.3.1 > -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Feb 12, 2014 at 5:49 AM, David Herrmann <dh.herrmann@gmail.com> wrote: > Hi > > On Mon, Feb 10, 2014 at 6:58 PM, Benjamin Tissoires > <benjamin.tissoires@redhat.com> wrote: >> Remove hid_output_raw_report() call as it is not a ll_driver callbacj, >> and switch to the hid_hw_* implementation. USB-HID used to fallback >> into SET_REPORT when there were no output interrupt endpoint, >> so emulating this if hid_hw_output_report() returns -ENOSYS. >> >> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> >> --- >> drivers/hid/hidraw.c | 22 +++++++++++++++++----- >> 1 file changed, 17 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c >> index f8708c9..704718b 100644 >> --- a/drivers/hid/hidraw.c >> +++ b/drivers/hid/hidraw.c >> @@ -123,10 +123,8 @@ static ssize_t hidraw_send_report(struct file *file, const char __user *buffer, >> >> dev = hidraw_table[minor]->hid; >> >> - if (!dev->hid_output_raw_report) { >> - ret = -ENODEV; >> - goto out; >> - } >> + if (!dev->ll_driver->raw_request || !dev->ll_driver->output_report) >> + return -ENODEV; > > You still have a "goto out;" above (not visible in the patch). The > error paths look quite ugly now. I'd prefer consistency here, so > either keep the jump or fix the error-path above, too. Otherwise looks > good. ok, will use "goto out" in the v2 then. Cheers, Benjamin > > Reviewed-by: David Herrmann <dh.herrmann@gmail.com> > > Thanks > David > >> >> if (count > HID_MAX_BUFFER_SIZE) { >> hid_warn(dev, "pid %d passed too large report\n", >> @@ -153,7 +151,21 @@ static ssize_t hidraw_send_report(struct file *file, const char __user *buffer, >> goto out_free; >> } >> >> - ret = hid_output_raw_report(dev, buf, count, report_type); >> + if (report_type == HID_OUTPUT_REPORT) { >> + ret = hid_hw_output_report(dev, buf, count); >> + /* >> + * compatibility with old implementation of USB-HID and I2C-HID: >> + * if the device does not support receiving output reports, >> + * on an interrupt endpoint, then fallback to the SET_REPORT >> + * HID command. >> + */ >> + if (ret != -ENOSYS) >> + goto out_free; >> + } >> + >> + ret = hid_hw_raw_request(dev, buf[0], buf, count, report_type, >> + HID_REQ_SET_REPORT); >> + >> out_free: >> kfree(buf); >> out: >> -- >> 1.8.3.1 >> -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c index f8708c9..704718b 100644 --- a/drivers/hid/hidraw.c +++ b/drivers/hid/hidraw.c @@ -123,10 +123,8 @@ static ssize_t hidraw_send_report(struct file *file, const char __user *buffer, dev = hidraw_table[minor]->hid; - if (!dev->hid_output_raw_report) { - ret = -ENODEV; - goto out; - } + if (!dev->ll_driver->raw_request || !dev->ll_driver->output_report) + return -ENODEV; if (count > HID_MAX_BUFFER_SIZE) { hid_warn(dev, "pid %d passed too large report\n", @@ -153,7 +151,21 @@ static ssize_t hidraw_send_report(struct file *file, const char __user *buffer, goto out_free; } - ret = hid_output_raw_report(dev, buf, count, report_type); + if (report_type == HID_OUTPUT_REPORT) { + ret = hid_hw_output_report(dev, buf, count); + /* + * compatibility with old implementation of USB-HID and I2C-HID: + * if the device does not support receiving output reports, + * on an interrupt endpoint, then fallback to the SET_REPORT + * HID command. + */ + if (ret != -ENOSYS) + goto out_free; + } + + ret = hid_hw_raw_request(dev, buf[0], buf, count, report_type, + HID_REQ_SET_REPORT); + out_free: kfree(buf); out:
Remove hid_output_raw_report() call as it is not a ll_driver callbacj, and switch to the hid_hw_* implementation. USB-HID used to fallback into SET_REPORT when there were no output interrupt endpoint, so emulating this if hid_hw_output_report() returns -ENOSYS. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> --- drivers/hid/hidraw.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)