Received: by 10.223.164.202 with SMTP id h10csp473142wrb; Mon, 6 Nov 2017 09:41:24 -0800 (PST) X-Google-Smtp-Source: ABhQp+QqLIuX2Km1hrcvHEQKq0HUMnFqDrHFovCEyi9pDX27ahnlNTaFoqHc0auLLawoWwPwEaoZ X-Received: by 10.84.149.102 with SMTP id b35mr15249248plh.331.1509990084281; Mon, 06 Nov 2017 09:41:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509990084; cv=none; d=google.com; s=arc-20160816; b=yG7/NGNqiOCdjz+0oMCpRzITfmjN6uwGCwdzFRnwZZV6wakPoGOuPR4duDOO+qOXG4 CeFcSSCFwcFQfFaFKB5+Fe0aifQgYgvJh5DxFPHB2qLvN3HmAHs4P0ZzqJhl5VlrCfJk 4m0Klm7i5IjwMAQAp6zKjNqWwmMOEk3oNeJZC2yEXDCmBtkYe2oxeCHgYDyociOHBpGO vMvvUZKhs07jMyOlqjL4lJ51METDvJ+XjQPCOuuNfduTl63BohjnlxEKAFw57mqaoUl4 h1QgxlqDsszoc0FWhzoCP0DxdN4M+BlyXmat4OwVfkMJkyPfI5XwtNZ6ssMVeJs9pO/m yrSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=PAfk7DkqAQUs5IBpjJ7tiSeZKPjZx1cuWyEpSGi6/Ik=; b=Vk1ydL7paWw9Io9r26cHFxpEfb1d5fOe5vmfjNMg0xuRp498fUkSSwSQ86Bfo3Una6 xNVU2WKzsCYpmZoTpHrTJItd9I87N0tErIihzvFUM/NxZM7HiO3gN/VwPvW701zwGqMk 60REpEr5VVhDxM8IbBYpBXPfaesadhFAFZJavSWlybkJPxdL66QkVQpf0tcjwoJRdMCW 0b5wVIFf3RV3vFOpLTQo2q7uHykOzkm9uPZoDlRqDFE6S++YKlB0ntbXDb8ZLl6C1887 U017NAmZojQb62QRy7MI9lxRuwqNZ0zMd6ZdhUfes5wyLyYswgScM+702ngsgSlRn2G8 Snng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w8si10519980plz.806.2017.11.06.09.41.10; Mon, 06 Nov 2017 09:41:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753732AbdKFRk3 (ORCPT + 95 others); Mon, 6 Nov 2017 12:40:29 -0500 Received: from 19.mo6.mail-out.ovh.net ([188.165.56.177]:48654 "EHLO 19.mo6.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751890AbdKFRk2 (ORCPT ); Mon, 6 Nov 2017 12:40:28 -0500 X-Greylist: delayed 8390 seconds by postgrey-1.27 at vger.kernel.org; Mon, 06 Nov 2017 12:40:27 EST Received: from player735.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo6.mail-out.ovh.net (Postfix) with ESMTP id 8CFC2113ADA for ; Mon, 6 Nov 2017 14:50:19 +0100 (CET) Received: from [192.168.0.106] (124.149.193.77.rev.sfr.net [77.193.149.124]) (Authenticated sender: sebastien.szymanski@armadeus.com) by player735.ha.ovh.net (Postfix) with ESMTPSA id AD3F91600AF; Mon, 6 Nov 2017 14:50:14 +0100 (CET) Subject: Re: [PATCH 3/3] HID: cp2112: fix broken gpio_direction_input callback To: Benjamin Tissoires Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Kosina , Julien Boibessot References: <1509621164-28830-1-git-send-email-sebastien.szymanski@armadeus.com> <1509621164-28830-3-git-send-email-sebastien.szymanski@armadeus.com> <20171106081120.GC9728@mail.corp.redhat.com> From: =?UTF-8?Q?S=c3=a9bastien_Szymanski?= Message-ID: Date: Mon, 6 Nov 2017 14:58:46 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171106081120.GC9728@mail.corp.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 7537618404588082206 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrheeggdehvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >> --- >> 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 From 1583303570973735331@xxx Mon Nov 06 08:12:30 +0000 2017 X-GM-THRID: 1582957135433209798 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread