From patchwork Thu Dec 17 09:21:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58533 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp244559lbb; Thu, 17 Dec 2015 01:21:27 -0800 (PST) X-Received: by 10.67.5.2 with SMTP id ci2mr70211528pad.47.1450344086948; Thu, 17 Dec 2015 01:21:26 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 11si11266340pfb.15.2015.12.17.01.21.26; Thu, 17 Dec 2015 01:21:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-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-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755857AbbLQJVZ (ORCPT + 4 others); Thu, 17 Dec 2015 04:21:25 -0500 Received: from mail-lf0-f49.google.com ([209.85.215.49]:35022 "EHLO mail-lf0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755690AbbLQJVU (ORCPT ); Thu, 17 Dec 2015 04:21:20 -0500 Received: by mail-lf0-f49.google.com with SMTP id l133so47233252lfd.2 for ; Thu, 17 Dec 2015 01:21:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=vNjWzWON0O0e/TatZfgIoDo/w6H8hHijvfpzkoj+PK4=; b=d1qihCCQpHILraNzeRdJvQZqVTtITWVmRjlkc/Grhrhs42v036xYmgZaA2dBWZGHTU ZV3yVmYr/oTFE93UgCTKKFxCEy12lKMLmfGcHPziu3ykWUpkyLaKafb1D8d99rXOAvWw /P6JG3BvdEtWsFzN+AYKmLqfnUWZQAMHW27P0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=vNjWzWON0O0e/TatZfgIoDo/w6H8hHijvfpzkoj+PK4=; b=ArKh5nl9JKLne3fs7V4xDtufJ6v3+Ku9M/E3PmCMuxsVaiXSaSbnjLIaRjeG5gpNR8 yoUIftUP9jJXbZHxJKNcZl/HojNZE+XMhRtxeGNhARvwyUqT1YjEiS4EPMwSbHbzwEt3 NW2J3ZBa2FHMZhimBd5wQWZWCkmx6rLsqK6p+Z10kTcIs5vMYoMFnyTLBERP3gSzF7OC Ic8OCl9gi4ytFBtotINan67DU1IGGBQJgz0QrtMo5PbvMZVkp3Qnj+O3zbJaiONDxXFD XZvhRNnOTVp98fLgCH1Mz2NoTooe0PfP4RykGlsh+5ZYiAUOeLySDpCMrKxonyYRCCaB 4vdw== X-Gm-Message-State: ALoCoQnJkRLUJgV9xvdgJdRbFVEa+boHWugFm/vSRTNtUnOf/bWNmaVRBCLEuJAO2xtZarFUnZKBnChmnMzWAQU6afScX8XC1g== X-Received: by 10.25.155.207 with SMTP id d198mr21993250lfe.93.1450344079072; Thu, 17 Dec 2015 01:21:19 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id qb3sm1729904lbb.39.2015.12.17.01.21.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Dec 2015 01:21:18 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Alexandre Courbot , Michael Trimarchi Cc: Linus Walleij , stable@vger.kernel.org, Bjorn Andersson , Vladimir Zapolskiy Subject: [PATCH] gpio: revert get() to non-errorprogating behaviour Date: Thu, 17 Dec 2015 10:21:11 +0100 Message-Id: <1450344071-7169-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.4.3 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org commit e20538b82f1ffcc06e68feb117f24f211cff7a4d "gpio: Propagate errors from chip->get()" started to propagate errors from the .get() functions since we can get errors from the infrastructure of e.g. slowbus GPIO expanders. However it turns out a bunch of drivers relied on the core to clamp the value, so we need to revert to the old behaviour and go over all drivers and fix them to conform to the expectations of the core before we go back to propagating the error code. Cc: stable@vger.kernel.org Cc: Bjorn Andersson Cc: Vladimir Zapolskiy Reported-by: Michael Trimarchi Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 2a91f3287e3b..4e4c3083ae56 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1279,7 +1279,13 @@ static int _gpiod_get_raw_value(const struct gpio_desc *desc) chip = desc->chip; offset = gpio_chip_hwgpio(desc); value = chip->get ? chip->get(chip, offset) : -EIO; - value = value < 0 ? value : !!value; + /* + * FIXME: fix all drivers to clamp to [0,1] or return negative, + * then change this to: + * value = value < 0 ? value : !!value; + * so we can properly propagate error codes. + */ + value = !!value; trace_gpio_value(desc_to_gpio(desc), 1, value); return value; }