From: "Leizhen (ThunderTown)" <thunder.leizhen@huawei.com>
To: Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <benjamin.tissoires@redhat.com>,
linux-usb <linux-usb@vger.kernel.org>,
linux-input <linux-input@vger.kernel.org>
Cc: Hillf Danton <hdanton@sina.com>
Subject: Re: [PATCH 1/1] HID: hiddev: remove a duplicated check
Date: Tue, 14 Jan 2020 17:16:17 +0800 [thread overview]
Message-ID: <50fd522f-e276-420c-3c6a-0f193bc16ca2@huawei.com> (raw)
In-Reply-To: <20191224035117.98816-1-thunder.leizhen@huawei.com>
Does no one pay attention to this problem? Although there is no
functional problem, but it seems confusing.
if (!list->hiddev->exist) { <---------
res = -ENODEV; |
goto bail_unlock; |
} |
if (!list->hiddev->open++) |
if (list->hiddev->exist) { <--------- //It's always true.
On 2019/12/24 11:51, Zhen Lei wrote:
> After commit 9c09b214f30e ("HID: hiddev: avoid opening a disconnected
> device"), the original check "list->hiddev->exist" become unnecessary.
>
> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
> ---
> drivers/hid/usbhid/hiddev.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
> index e421cdf2d1a4ec5..e04cf95fca094a8 100644
> --- a/drivers/hid/usbhid/hiddev.c
> +++ b/drivers/hid/usbhid/hiddev.c
> @@ -292,16 +292,16 @@ static int hiddev_open(struct inode *inode, struct file *file)
> res = -ENODEV;
> goto bail_unlock;
> }
> - if (!list->hiddev->open++)
> - if (list->hiddev->exist) {
> - struct hid_device *hid = hiddev->hid;
> - res = hid_hw_power(hid, PM_HINT_FULLON);
> - if (res < 0)
> - goto bail_unlock;
> - res = hid_hw_open(hid);
> - if (res < 0)
> - goto bail_normal_power;
> - }
> + if (!list->hiddev->open++) {
> + struct hid_device *hid = hiddev->hid;
> +
> + res = hid_hw_power(hid, PM_HINT_FULLON);
> + if (res < 0)
> + goto bail_unlock;
> + res = hid_hw_open(hid);
> + if (res < 0)
> + goto bail_normal_power;
> + }
> mutex_unlock(&hiddev->existancelock);
> return 0;
> bail_normal_power:
>
next prev parent reply other threads:[~2020-01-14 9:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-24 3:51 [PATCH 1/1] HID: hiddev: remove a duplicated check Zhen Lei
2020-01-14 9:16 ` Leizhen (ThunderTown) [this message]
2020-01-14 14:19 ` Jiri Kosina
2020-01-15 2:58 ` Leizhen (ThunderTown)
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=50fd522f-e276-420c-3c6a-0f193bc16ca2@huawei.com \
--to=thunder.leizhen@huawei.com \
--cc=benjamin.tissoires@redhat.com \
--cc=hdanton@sina.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-usb@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).