Received: by 10.223.164.202 with SMTP id h10csp149963wrb; Fri, 10 Nov 2017 04:10:04 -0800 (PST) X-Google-Smtp-Source: AGs4zMZqoHMyK098pqTpdLf1DhZSmUazM7Wduc+FeiZQOyElfdAj1eK4y5uVpLCo9eygtewDdfS6 X-Received: by 10.99.115.28 with SMTP id o28mr140538pgc.340.1510315804207; Fri, 10 Nov 2017 04:10:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510315804; cv=none; d=google.com; s=arc-20160816; b=JdaFuNdO47BUV9R7/sITWDxmwkxzaOhHt1RWGgcta/DYMAVcJTs39qEgnsyCXTyoiR spLedzOjZIICCgzDnpJgcsMcifv5BrQuW63gEAsoKf0pvBIAOpGPdQmad7IhhnO8xUJw bqGkQSL8UZkN+A7FA6EgSRGxU7nQcFSqNZ6eQlFoLWMYJc6S5pHNzbK39UEdABqUnlxy E3l3EZ7KwJHnRbCNKbnl6m0U68kD3qTlOewx3H65XzV9jrpVYyZeh/q/4v3shuRXWC53 4ed1MnEPcyi/v/kBNWIb6CeWHUFDbDbtb/x09rxAybU+PbByG/s1P4jqm7wLsgNyt3PF MRCQ== 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:mime-version :message-id:date:subject:cc:to:from:arc-authentication-results; bh=VCIRQRthrK1c6cB1Acd0J+eCYJd5/PCB+1epRcsShzE=; b=ws5iXwRu2Zj2zlRtmM0rEnAFpJi3QJfg61v7gJcJzSsm+J5rkgL6pKsVNWNBpsZBlb 3KpvzBElvZ7WphRLnhAvYE+OsgRLecIaw5pl8jeyFjUTxH40gJ3ncJt4gViLeh0S3DKt vwoKC1sIYxwgmnUYu7smPbbqDzM0OOYAdWF3i+1X1fNjpJvo4gCzBvzaNHdLxe48Dmaj T+U1psDsrlsdKLLqneTZJMUvpcXEs2uYbdawxxXSMs2jU7SJBlEyUyPdJ2+lthKidLHn aZzdq7PXyrFq0N8SKgVdlB8yIEl2lfmxWcuSXHXEwczVLhGnsh2DL1E5a+UOVO/CDfOp v29A== 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 a1si8984448pll.504.2017.11.10.04.09.52; Fri, 10 Nov 2017 04:10:04 -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 S1752196AbdKJMJK (ORCPT + 82 others); Fri, 10 Nov 2017 07:09:10 -0500 Received: from 7.mo4.mail-out.ovh.net ([178.33.253.54]:36730 "EHLO 7.mo4.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751250AbdKJMJI (ORCPT ); Fri, 10 Nov 2017 07:09:08 -0500 X-Greylist: delayed 8347 seconds by postgrey-1.27 at vger.kernel.org; Fri, 10 Nov 2017 07:09:08 EST Received: from player772.ha.ovh.net (b6.ovh.net [213.186.33.56]) by mo4.mail-out.ovh.net (Postfix) with ESMTP id CD190F2DF6 for ; Fri, 10 Nov 2017 10:42:26 +0100 (CET) Received: from localhost.localdomain (124.149.193.77.rev.sfr.net [77.193.149.124]) (Authenticated sender: sebastien.szymanski@armadeus.com) by player772.ha.ovh.net (Postfix) with ESMTPSA id 3FE35740698; Fri, 10 Nov 2017 09:53:13 +0100 (CET) From: =?UTF-8?q?S=C3=A9bastien=20Szymanski?= To: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Benjamin Tissoires , Jiri Kosina , Julien Boibessot , =?UTF-8?q?S=C3=A9bastien=20Szymanski?= Subject: [PATCH v2 3/3] HID: cp2112: fix broken gpio_direction_input callback Date: Fri, 10 Nov 2017 10:01:43 +0100 Message-Id: <1510304503-30830-1-git-send-email-sebastien.szymanski@armadeus.com> X-Mailer: git-send-email 2.7.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 7565484426850423878 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedttddrieefgddtiecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- Changes in v2: - rework error handling to have only one exit path as suggested by Benjamin Tissoires drivers/hid/hid-cp2112.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c index 28e3c18..68cdc96 100644 --- a/drivers/hid/hid-cp2112.c +++ b/drivers/hid/hid-cp2112.c @@ -196,6 +196,8 @@ static int cp2112_gpio_direction_input(struct gpio_chip *chip, unsigned offset) HID_REQ_GET_REPORT); if (ret != CP2112_GPIO_CONFIG_LENGTH) { hid_err(hdev, "error requesting GPIO config: %d\n", ret); + if (ret >= 0) + ret = -EIO; goto exit; } @@ -205,8 +207,10 @@ 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) { hid_err(hdev, "error setting GPIO config: %d\n", ret); + if (ret >= 0) + ret = -EIO; goto exit; } @@ -214,7 +218,7 @@ static int cp2112_gpio_direction_input(struct gpio_chip *chip, unsigned offset) exit: mutex_unlock(&dev->lock); - return ret < 0 ? ret : -EIO; + return ret; } static void cp2112_gpio_set(struct gpio_chip *chip, unsigned offset, int value) -- 2.7.3 From 1583673939203835560@xxx Fri Nov 10 10:19:21 +0000 2017 X-GM-THRID: 1582957135433209798 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread