* [PATCH 1/1] HID: hiddev: remove a duplicated check
@ 2019-12-24 3:51 Zhen Lei
2020-01-14 9:16 ` Leizhen (ThunderTown)
0 siblings, 1 reply; 4+ messages in thread
From: Zhen Lei @ 2019-12-24 3:51 UTC (permalink / raw)
To: Jiri Kosina, Benjamin Tissoires, linux-usb, linux-input
Cc: Zhen Lei, Hillf Danton
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:
--
1.8.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] HID: hiddev: remove a duplicated check
2019-12-24 3:51 [PATCH 1/1] HID: hiddev: remove a duplicated check Zhen Lei
@ 2020-01-14 9:16 ` Leizhen (ThunderTown)
2020-01-14 14:19 ` Jiri Kosina
0 siblings, 1 reply; 4+ messages in thread
From: Leizhen (ThunderTown) @ 2020-01-14 9:16 UTC (permalink / raw)
To: Jiri Kosina, Benjamin Tissoires, linux-usb, linux-input; +Cc: Hillf Danton
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:
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] HID: hiddev: remove a duplicated check
2020-01-14 9:16 ` Leizhen (ThunderTown)
@ 2020-01-14 14:19 ` Jiri Kosina
2020-01-15 2:58 ` Leizhen (ThunderTown)
0 siblings, 1 reply; 4+ messages in thread
From: Jiri Kosina @ 2020-01-14 14:19 UTC (permalink / raw)
To: Leizhen (ThunderTown)
Cc: Benjamin Tissoires, linux-usb, linux-input, Hillf Danton
On Tue, 14 Jan 2020, Leizhen (ThunderTown) wrote:
> 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.
This code no longer exists after refactoring that happened in commit
18a1b06e5b91d47.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] HID: hiddev: remove a duplicated check
2020-01-14 14:19 ` Jiri Kosina
@ 2020-01-15 2:58 ` Leizhen (ThunderTown)
0 siblings, 0 replies; 4+ messages in thread
From: Leizhen (ThunderTown) @ 2020-01-15 2:58 UTC (permalink / raw)
To: Jiri Kosina; +Cc: Benjamin Tissoires, linux-usb, linux-input, Hillf Danton
On 2020/1/14 22:19, Jiri Kosina wrote:
> On Tue, 14 Jan 2020, Leizhen (ThunderTown) wrote:
>
>> 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.
>
> This code no longer exists after refactoring that happened in commit
> 18a1b06e5b91d47.
OK
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-01-15 2:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-24 3:51 [PATCH 1/1] HID: hiddev: remove a duplicated check Zhen Lei
2020-01-14 9:16 ` Leizhen (ThunderTown)
2020-01-14 14:19 ` Jiri Kosina
2020-01-15 2:58 ` Leizhen (ThunderTown)
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).