diff mbox

[v2,1/4] HID: cp2112: remove various hid_out_raw_report calls

Message ID 1394054334-20438-2-git-send-email-benjamin.tissoires@redhat.com (mailing list archive)
State New, archived
Delegated to: Jiri Kosina
Headers show

Commit Message

Benjamin Tissoires March 5, 2014, 9:18 p.m. UTC
hid_out_raw_report is going to be obsoleted as it is not part of the
unified HID low level transport documentation
(Documentation/hid/hid-transport.txt)

  hid_output_raw_report(hdev, buf, sizeof(buf), HID_FEATURE_REPORT);
is strictly equivalent to:
  hid_hw_raw_request(hdev, buf[0], buf, sizeof(buf),
		HID_FEATURE_REPORT, HID_REQ_SET_REPORT);

So use the new api.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---

no changes since v1

 drivers/hid/hid-cp2112.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

David Herrmann March 7, 2014, 9:47 a.m. UTC | #1
Hi

On Wed, Mar 5, 2014 at 10:18 PM, Benjamin Tissoires
<benjamin.tissoires@redhat.com> wrote:
> hid_out_raw_report is going to be obsoleted as it is not part of the
> unified HID low level transport documentation
> (Documentation/hid/hid-transport.txt)
>
>   hid_output_raw_report(hdev, buf, sizeof(buf), HID_FEATURE_REPORT);
> is strictly equivalent to:
>   hid_hw_raw_request(hdev, buf[0], buf, sizeof(buf),
>                 HID_FEATURE_REPORT, HID_REQ_SET_REPORT);

This time you might be right that feature-reports always put the
report-id into the first byte, but I'd still prefer if we avoid using
this. Besides, the code is much nicer imho if we pass the ID directly,
see below..

>
> So use the new api.
>
> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> ---
>
> no changes since v1
>
>  drivers/hid/hid-cp2112.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c
> index 1025982..860db694 100644
> --- a/drivers/hid/hid-cp2112.c
> +++ b/drivers/hid/hid-cp2112.c
> @@ -185,8 +185,8 @@ static int cp2112_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
>         buf[1] &= ~(1 << offset);
>         buf[2] = gpio_push_pull;
>
> -       ret = hdev->hid_output_raw_report(hdev, buf, sizeof(buf),
> -                                         HID_FEATURE_REPORT);
> +       ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(buf),
> +                                HID_FEATURE_REPORT, HID_REQ_SET_REPORT);

buf[0] => CP2112_GPIO_CONFIG

>         if (ret < 0) {
>                 hid_err(hdev, "error setting GPIO config: %d\n", ret);
>                 return ret;
> @@ -207,8 +207,8 @@ static void cp2112_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
>         buf[1] = value ? 0xff : 0;
>         buf[2] = 1 << offset;
>
> -       ret = hdev->hid_output_raw_report(hdev, buf, sizeof(buf),
> -                                         HID_FEATURE_REPORT);
> +       ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(buf),
> +                                HID_FEATURE_REPORT, HID_REQ_SET_REPORT);

Here buf[0] seems fine as it is set explicitly just 3 lines above to
CP2112_GPIO_SET.

>         if (ret < 0)
>                 hid_err(hdev, "error setting GPIO values: %d\n", ret);
>  }
> @@ -253,8 +253,8 @@ static int cp2112_gpio_direction_output(struct gpio_chip *chip,
>         buf[1] |= 1 << offset;
>         buf[2] = gpio_push_pull;
>
> -       ret = hdev->hid_output_raw_report(hdev, buf, sizeof(buf),
> -                                         HID_FEATURE_REPORT);
> +       ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(buf),
> +                                HID_FEATURE_REPORT, HID_REQ_SET_REPORT);

Here an explicit CP2112_GPIO_CONFIG seems nicer, imho.

Thanks
David

>         if (ret < 0) {
>                 hid_err(hdev, "error setting GPIO config: %d\n", ret);
>                 return ret;
> --
> 1.8.5.3
>
--
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
Benjamin Tissoires March 9, 2014, 3:23 a.m. UTC | #2
On Fri, Mar 7, 2014 at 4:47 AM, David Herrmann <dh.herrmann@gmail.com> wrote:
> Hi
>
> On Wed, Mar 5, 2014 at 10:18 PM, Benjamin Tissoires
> <benjamin.tissoires@redhat.com> wrote:
>> hid_out_raw_report is going to be obsoleted as it is not part of the
>> unified HID low level transport documentation
>> (Documentation/hid/hid-transport.txt)
>>
>>   hid_output_raw_report(hdev, buf, sizeof(buf), HID_FEATURE_REPORT);
>> is strictly equivalent to:
>>   hid_hw_raw_request(hdev, buf[0], buf, sizeof(buf),
>>                 HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
>
> This time you might be right that feature-reports always put the
> report-id into the first byte, but I'd still prefer if we avoid using
> this. Besides, the code is much nicer imho if we pass the ID directly,
> see below..

Yes you are completely right.

Will send a v3 ASAP.

Cheers,
Benjamin

>
>>
>> So use the new api.
>>
>> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
>> ---
>>
>> no changes since v1
>>
>>  drivers/hid/hid-cp2112.c | 12 ++++++------
>>  1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c
>> index 1025982..860db694 100644
>> --- a/drivers/hid/hid-cp2112.c
>> +++ b/drivers/hid/hid-cp2112.c
>> @@ -185,8 +185,8 @@ static int cp2112_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
>>         buf[1] &= ~(1 << offset);
>>         buf[2] = gpio_push_pull;
>>
>> -       ret = hdev->hid_output_raw_report(hdev, buf, sizeof(buf),
>> -                                         HID_FEATURE_REPORT);
>> +       ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(buf),
>> +                                HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
>
> buf[0] => CP2112_GPIO_CONFIG
>
>>         if (ret < 0) {
>>                 hid_err(hdev, "error setting GPIO config: %d\n", ret);
>>                 return ret;
>> @@ -207,8 +207,8 @@ static void cp2112_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
>>         buf[1] = value ? 0xff : 0;
>>         buf[2] = 1 << offset;
>>
>> -       ret = hdev->hid_output_raw_report(hdev, buf, sizeof(buf),
>> -                                         HID_FEATURE_REPORT);
>> +       ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(buf),
>> +                                HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
>
> Here buf[0] seems fine as it is set explicitly just 3 lines above to
> CP2112_GPIO_SET.
>
>>         if (ret < 0)
>>                 hid_err(hdev, "error setting GPIO values: %d\n", ret);
>>  }
>> @@ -253,8 +253,8 @@ static int cp2112_gpio_direction_output(struct gpio_chip *chip,
>>         buf[1] |= 1 << offset;
>>         buf[2] = gpio_push_pull;
>>
>> -       ret = hdev->hid_output_raw_report(hdev, buf, sizeof(buf),
>> -                                         HID_FEATURE_REPORT);
>> +       ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(buf),
>> +                                HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
>
> Here an explicit CP2112_GPIO_CONFIG seems nicer, imho.
>
> Thanks
> David
>
>>         if (ret < 0) {
>>                 hid_err(hdev, "error setting GPIO config: %d\n", ret);
>>                 return ret;
>> --
>> 1.8.5.3
>>
--
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 mbox

Patch

diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c
index 1025982..860db694 100644
--- a/drivers/hid/hid-cp2112.c
+++ b/drivers/hid/hid-cp2112.c
@@ -185,8 +185,8 @@  static int cp2112_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
 	buf[1] &= ~(1 << offset);
 	buf[2] = gpio_push_pull;
 
-	ret = hdev->hid_output_raw_report(hdev, buf, sizeof(buf),
-					  HID_FEATURE_REPORT);
+	ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(buf),
+				 HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
 	if (ret < 0) {
 		hid_err(hdev, "error setting GPIO config: %d\n", ret);
 		return ret;
@@ -207,8 +207,8 @@  static void cp2112_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
 	buf[1] = value ? 0xff : 0;
 	buf[2] = 1 << offset;
 
-	ret = hdev->hid_output_raw_report(hdev, buf, sizeof(buf),
-					  HID_FEATURE_REPORT);
+	ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(buf),
+				 HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
 	if (ret < 0)
 		hid_err(hdev, "error setting GPIO values: %d\n", ret);
 }
@@ -253,8 +253,8 @@  static int cp2112_gpio_direction_output(struct gpio_chip *chip,
 	buf[1] |= 1 << offset;
 	buf[2] = gpio_push_pull;
 
-	ret = hdev->hid_output_raw_report(hdev, buf, sizeof(buf),
-					  HID_FEATURE_REPORT);
+	ret = hid_hw_raw_request(hdev, buf[0], buf, sizeof(buf),
+				 HID_FEATURE_REPORT, HID_REQ_SET_REPORT);
 	if (ret < 0) {
 		hid_err(hdev, "error setting GPIO config: %d\n", ret);
 		return ret;