From: "Sébastien Szymanski" <sebastien.szymanski@armadeus.com>
To: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Jiri Kosina <jikos@kernel.org>,
Julien Boibessot <julien.boibessot@armadeus.com>
Subject: Re: [PATCH 3/3] HID: cp2112: fix broken gpio_direction_input callback
Date: Mon, 6 Nov 2017 14:58:46 +0100 [thread overview]
Message-ID: <cb980f5f-48a0-8de0-f01d-5a90720797d6@armadeus.com> (raw)
In-Reply-To: <20171106081120.GC9728@mail.corp.redhat.com>
On 11/06/2017 09:11 AM, Benjamin Tissoires wrote:
> On Nov 02 2017 or thereabouts, Sébastien Szymanski wrote:
>> When everything goes smoothly, ret is set to 0 which makes the function
>> to return EIO error.
>>
>> Fixes: 8e9faa15469e ("HID: cp2112: fix gpio-callback error handling")
>> Signed-off-by: Sébastien Szymanski <sebastien.szymanski@armadeus.com>
>> ---
>> drivers/hid/hid-cp2112.c | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c
>> index 28e3c18..f7754a6 100644
>> --- a/drivers/hid/hid-cp2112.c
>> +++ b/drivers/hid/hid-cp2112.c
>> @@ -205,12 +205,13 @@ static int cp2112_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
>> ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf,
>> CP2112_GPIO_CONFIG_LENGTH, HID_FEATURE_REPORT,
>> HID_REQ_SET_REPORT);
>> - if (ret < 0) {
>> + if (ret != CP2112_GPIO_CONFIG_LENGTH) {
>
> Ack for this.
As explained in the interface specification, the device doesn't answer
to set reports, so the transfer should be CP2112_GPIO_CONFIG_LENGTH (5)
bytes.
>
>> hid_err(hdev, "error setting GPIO config: %d\n", ret);
>> goto exit;
>> }
>>
>> - ret = 0;
>> + mutex_unlock(&dev->lock);
>> + return 0;
>
> Wouldn't it be better to just turn
> - return ret < 0 ? ret : -EIO;
> into
> + return ret <= 0 ? ret : -EIO;
> at the end of the function?
Well, the commit I mentioned in the Fixes tag, changes from
- return ret <= 0 ? ret : -EIO;
to
+ return ret < 0 ? ret : -EIO;
because ret being 0 could mean that one of the hid_hw_raw_request
returned 0.
Regards,
>
> I'd rather keep the same exit path in both cases, error or success.
>
> Cheers,
> Benjamin
>
>
>>
>> exit:
>> mutex_unlock(&dev->lock);
>> --
>> 2.7.3
>>
--
Sébastien Szymanski
Software engineer, Armadeus Systems
Tel: +33 (0)9 72 29 41 44
Fax: +33 (0)9 72 28 79 26
next prev parent reply other threads:[~2017-11-06 17:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-02 11:12 [PATCH 1/3] HID: cp2112: fix interface specification URL Sébastien Szymanski
2017-11-02 11:12 ` [PATCH 2/3] HID: cp2112: add HIDRAW dependency Sébastien Szymanski
2017-11-06 8:12 ` Benjamin Tissoires
2017-11-02 11:12 ` [PATCH 3/3] HID: cp2112: fix broken gpio_direction_input callback Sébastien Szymanski
2017-11-06 8:11 ` Benjamin Tissoires
2017-11-06 13:58 ` Sébastien Szymanski [this message]
2017-11-06 17:43 ` Benjamin Tissoires
2017-11-09 11:45 ` [PATCH 1/3] HID: cp2112: fix interface specification URL Jiri Kosina
2017-11-10 9:05 ` Sébastien Szymanski
2017-11-10 10:04 ` Jiri Kosina
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cb980f5f-48a0-8de0-f01d-5a90720797d6@armadeus.com \
--to=sebastien.szymanski@armadeus.com \
--cc=benjamin.tissoires@redhat.com \
--cc=jikos@kernel.org \
--cc=julien.boibessot@armadeus.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).