From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDA84C33CB1 for ; Tue, 14 Jan 2020 09:16:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B05CB2084D for ; Tue, 14 Jan 2020 09:16:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726379AbgANJQW (ORCPT ); Tue, 14 Jan 2020 04:16:22 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:51092 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725820AbgANJQW (ORCPT ); Tue, 14 Jan 2020 04:16:22 -0500 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 5A532F973300C3E58AB3; Tue, 14 Jan 2020 17:16:19 +0800 (CST) Received: from [127.0.0.1] (10.133.215.186) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.439.0; Tue, 14 Jan 2020 17:16:18 +0800 Subject: Re: [PATCH 1/1] HID: hiddev: remove a duplicated check To: Jiri Kosina , Benjamin Tissoires , linux-usb , linux-input CC: Hillf Danton References: <20191224035117.98816-1-thunder.leizhen@huawei.com> From: "Leizhen (ThunderTown)" Message-ID: <50fd522f-e276-420c-3c6a-0f193bc16ca2@huawei.com> Date: Tue, 14 Jan 2020 17:16:17 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20191224035117.98816-1-thunder.leizhen@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.133.215.186] X-CFilter-Loop: Reflected Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org 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 > --- > 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: >