From patchwork Tue Dec 22 14:28:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58896 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3268951lbb; Tue, 22 Dec 2015 06:28:21 -0800 (PST) X-Received: by 10.66.185.225 with SMTP id ff1mr25405744pac.97.1450794501848; Tue, 22 Dec 2015 06:28:21 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ez9si4868056pab.20.2015.12.22.06.28.21; Tue, 22 Dec 2015 06:28:21 -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 S932798AbbLVO2V (ORCPT + 4 others); Tue, 22 Dec 2015 09:28:21 -0500 Received: from mail-lf0-f50.google.com ([209.85.215.50]:35720 "EHLO mail-lf0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932797AbbLVO2U (ORCPT ); Tue, 22 Dec 2015 09:28:20 -0500 Received: by mail-lf0-f50.google.com with SMTP id l133so129794523lfd.2 for ; Tue, 22 Dec 2015 06:28: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=lDEIaO2JKAVpiGCcSa7aiuUhfs6xnr8fbVcHeVd0IRc=; b=YsaO0w71L6Xy4dZRs/V54fWDhYOxLcurr2E72ZW6zo5hOh0mfUIqhtcsFZWEgX1VfA ZHMxss0Zxp2Djm89NI1Cm0eCeGCNowHwIeyS0USEByhlYcNpvjYvVYXlke7e2sjMKIe3 fNzrPxdFXBhyUgUC/ZCd27jnPd3UchEjfE9ZA= 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=lDEIaO2JKAVpiGCcSa7aiuUhfs6xnr8fbVcHeVd0IRc=; b=NqLAq2bFKvOgt/WSB2Y+Bn3T+v7pXqmh9FZjB36ml1z+nXOmaR8j7CHTk5t7eI+o2R aq18EfQcC6E4uKsBGjj2CFsvReCRVB4xRzndI+M46siHdeGPyWUFHNctBC2lM+TOQ4fy IUzHaehf8oFIrnt7anL+LsAU7KYz9oofwzbR0lbDVo77gtoIENwpV/AywYjA06CKTRSi G3X0AJ6iuZ9zKDHTMwMKrQzljuT5T2yFs7UWvCabeFbUzM1Vg3nvJRo8YzH3XkewzwQm R3VRL/AmLbktnxxjWzj2B2x4yEjPRdVeNFojoWFmOOebNUTX5mKRuR3G+Y34JQ9IE9/x 368A== X-Gm-Message-State: ALoCoQklJRwZdD4XKHq/6bepmx0mUjxnMXhUYAlMgaNk7qKif/QyjC3lwFoobxFTMI6YryRqKMjHMNY+EyCBb9njeZIjAsCvzA== X-Received: by 10.25.40.205 with SMTP id o196mr9221166lfo.116.1450794499375; Tue, 22 Dec 2015 06:28:19 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id xt2sm5668783lbb.47.2015.12.22.06.28.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:28:18 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Lars Poeschel Cc: Linus Walleij Subject: [PATCH 23/54] gpio: viperboard: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:28:15 +0100 Message-Id: <1450794495-23585-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: Lars Poeschel Signed-off-by: Linus Walleij --- drivers/gpio/gpio-viperboard.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-viperboard.c b/drivers/gpio/gpio-viperboard.c index 26e7edb74f42..7667e77dd52e 100644 --- a/drivers/gpio/gpio-viperboard.c +++ b/drivers/gpio/gpio-viperboard.c @@ -95,7 +95,7 @@ static int vprbrd_gpioa_get(struct gpio_chip *chip, /* if io is set to output, just return the saved value */ if (gpio->gpioa_out & (1 << offset)) - return gpio->gpioa_val & (1 << offset); + return !!(gpio->gpioa_val & (1 << offset)); mutex_lock(&vb->lock);