From patchwork Tue Dec 22 14:48:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58925 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3280132lbb; Tue, 22 Dec 2015 06:48:19 -0800 (PST) X-Received: by 10.66.139.131 with SMTP id qy3mr36375329pab.71.1450795699485; Tue, 22 Dec 2015 06:48:19 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 7si12582333pfl.182.2015.12.22.06.48.19; Tue, 22 Dec 2015 06:48:19 -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 S932549AbbLVOsS (ORCPT + 4 others); Tue, 22 Dec 2015 09:48:18 -0500 Received: from mail-lb0-f171.google.com ([209.85.217.171]:36562 "EHLO mail-lb0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932243AbbLVOsS (ORCPT ); Tue, 22 Dec 2015 09:48:18 -0500 Received: by mail-lb0-f171.google.com with SMTP id oh2so32281196lbb.3 for ; Tue, 22 Dec 2015 06:48:17 -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=PFrb/Elsphp3S0A+1e+SIA1jmXX1THIrRVZqqd6yjZs=; b=KWm7z+igOoLAG99X4yHFzgWzDNa0fIRFT//MziDZuvaFnzclG9sXvRCCUuBtiOrLes wAIjD3Enf1atzxgRxRJSoL6M7GhJNwyHxIcb49QE38d4fGwknPIOpoM58yCdFR7eySk2 mqf+U6QuJtmMx7nMqsYyPXRxlBQ9X6f5ghL6s= 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=PFrb/Elsphp3S0A+1e+SIA1jmXX1THIrRVZqqd6yjZs=; b=W8dJLXavInA1OJ2NCJaSw0AOkevXqFtyrGoJANcX8erIasIav3c1UL00IpkvtZEEKn +IhWkZxo4t9feYY+J07AZZ7zdb1WP46vOfEnI+bx9jCw/i4YM82iE124uOt0aSu4dhcf 1030F+V14xfbh4y0hSPDHBD2A9mjy0G/YjkjgnZ44FH083mwys9d1qHjYvH1rqs3WQkH /mVW6SezssVh18WNYY787fKK9WAciXY0Pxxao+ENSa2zcojIYmR10FFXl2MnfDOoGpA+ j01ujcsxXgS9mrn9ZpigL6BlV6zAslr+sGQL805p77K6RMyZI6hBDPKKUp5MCUuBszjs +FbA== X-Gm-Message-State: ALoCoQm32tNyyj4Ljo1z3ttPT7vCMKv1rSlUdN4S6d24cMbU8Xmc4uyzIoW6tG0Xzd5CGeE2N9M545cqnYlTmdyn4Xqp0MgbRw== X-Received: by 10.112.160.202 with SMTP id xm10mr7078895lbb.22.1450795696881; Tue, 22 Dec 2015 06:48:16 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id 130sm1650108lff.31.2015.12.22.06.48.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:48:16 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Lee Jones Cc: Linus Walleij Subject: [PATCH 49/54] mfd: tps65010: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:48:13 +0100 Message-Id: <1450795693-28364-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 As we want gpio_chip .get() calls to be able to return negative error codes and propagate to drivers, we need to go over all drivers and make sure their return values are clamped to [0,1]. We do this by using the ret = !!(val) design pattern. This also start to propagate the negative error code from the smbus call if there is one, as the last commit of this series will make the gpiolib core deal with that properly. Cc: Lee Jones Signed-off-by: Linus Walleij --- Lee: as mentioned in 00/54: either apply this directly or ACK it and I will take it into the GPIO tree. --- drivers/mfd/tps65010.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 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/mfd/tps65010.c b/drivers/mfd/tps65010.c index b96847491277..83e615ed100a 100644 --- a/drivers/mfd/tps65010.c +++ b/drivers/mfd/tps65010.c @@ -499,11 +499,11 @@ static int tps65010_gpio_get(struct gpio_chip *chip, unsigned offset) if (offset < 4) { value = i2c_smbus_read_byte_data(tps->client, TPS_DEFGPIO); if (value < 0) - return 0; + return value; if (value & (1 << (offset + 4))) /* output */ return !(value & (1 << offset)); else /* input */ - return (value & (1 << offset)); + return !!(value & (1 << offset)); } /* REVISIT we *could* report LED1/nPG and LED2 state ... */