From patchwork Tue Dec 22 14:19:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58885 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3264030lbb; Tue, 22 Dec 2015 06:19:36 -0800 (PST) X-Received: by 10.98.79.66 with SMTP id d63mr36144083pfb.34.1450793976370; Tue, 22 Dec 2015 06:19:36 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qg5si3447886pab.45.2015.12.22.06.19.36; Tue, 22 Dec 2015 06:19:36 -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 S1754577AbbLVOTf (ORCPT + 4 others); Tue, 22 Dec 2015 09:19:35 -0500 Received: from mail-lb0-f176.google.com ([209.85.217.176]:35335 "EHLO mail-lb0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754395AbbLVOTf (ORCPT ); Tue, 22 Dec 2015 09:19:35 -0500 Received: by mail-lb0-f176.google.com with SMTP id bc4so31909946lbc.2 for ; Tue, 22 Dec 2015 06:19:34 -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=tN0jzQ/kueQSr/Of+2Md1t3TXegR64smyOqR/jh0DkI=; b=cfFNhiogFBC0lAox4FrWp838weGRqoF1Kf6+W0Y9+mRb85eoLObE8DrnrwA1aS9LiH xbG217u1kqxC3t/4QQrRlGIO7Ip8chDx2rKtBYg/HVYmPDPcG/fjIY/Vf9OJc6jo4aVl mh91pn9uq3rNjgQuCVT2ncOfStdTv4RVr+1ng= 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=tN0jzQ/kueQSr/Of+2Md1t3TXegR64smyOqR/jh0DkI=; b=GwC+pMe7gOU2BM/NJ1mLADNsLEMp19sFYLjpZ84F44sVGvatDvAC2du53StDFxrIE0 UQIWEIIfQES50tpOuS3gmudR6XGPKTzHXtKLXd7BobcUy9KriXN5TID0Fywq7bqYGvIc /59yqinQURirumPdm/zojbFHl2xSOaCUIWgYHh0eBrb+NYOqdoUfbHUNjxt5vfvwsX1U TO1YuHqmKM058QwHtn9Uffax7wcrbscgOqA+6nN3LCInmcuLxZR5eU+Pb1g/WE+2gqik YDNU3ZEPWeCu2v6M+atXBHOB1AiwCBUb2ZXML2XlVJh2d+erpwIOHvGIe/16Lec1s1mh 6Pig== X-Gm-Message-State: ALoCoQkljxB9P5vQlPOYL707qkMFWv7vh9nVq8nINapkFE3WpwT69QT5t9ZROKY4pJUEoxqB+20J4h0qDa2pG/6r1F5JY3py6g== X-Received: by 10.112.134.66 with SMTP id pi2mr8471388lbb.83.1450793973537; Tue, 22 Dec 2015 06:19:33 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id rm5sm5648582lbb.20.2015.12.22.06.19.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:19:32 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Mathias Nyman Cc: Linus Walleij Subject: [PATCH 12/54] gpio: msic: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:19:30 +0100 Message-Id: <1450793970-22801-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. Cc: Mathias Nyman Signed-off-by: Linus Walleij --- drivers/gpio/gpio-msic.c | 2 +- 1 file changed, 1 insertion(+), 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/gpio-msic.c b/drivers/gpio/gpio-msic.c index fe9ef2bc981a..9a261acb0eed 100644 --- a/drivers/gpio/gpio-msic.c +++ b/drivers/gpio/gpio-msic.c @@ -143,7 +143,7 @@ static int msic_gpio_get(struct gpio_chip *chip, unsigned offset) if (ret < 0) return ret; - return r & MSIC_GPIO_DIN_MASK; + return !!(r & MSIC_GPIO_DIN_MASK); } static void msic_gpio_set(struct gpio_chip *chip, unsigned offset, int value)