From patchwork Tue Dec 22 14:44:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58917 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3278313lbb; Tue, 22 Dec 2015 06:45:00 -0800 (PST) X-Received: by 10.98.9.156 with SMTP id 28mr36113115pfj.83.1450795500735; Tue, 22 Dec 2015 06:45:00 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c7si19043393pfj.114.2015.12.22.06.45.00; Tue, 22 Dec 2015 06:45:00 -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 S1753680AbbLVOpA (ORCPT + 4 others); Tue, 22 Dec 2015 09:45:00 -0500 Received: from mail-lf0-f52.google.com ([209.85.215.52]:36507 "EHLO mail-lf0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752917AbbLVOo7 (ORCPT ); Tue, 22 Dec 2015 09:44:59 -0500 Received: by mail-lf0-f52.google.com with SMTP id z124so125760729lfa.3 for ; Tue, 22 Dec 2015 06:44:59 -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=/zAcAfNlxuQR+t396vhm/wkoA7tq6BtkHQDVvDh3PEk=; b=dsrD5C8C5QoPkTZZEZhAknIR1H0RhATSwfYZNH25NaVlFZVMpVAG1dufoZ5LkAYnhB YBCNDCyNQfKwkkoqfhS1uHMxyPXMcfUwjEGd4k1UoLHh3f7f3qTdjPvtW3lHiwsQDz/H vKKrg/vi7yRxu8KIKCMdHkHSYE+wyoOcpJjio= 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=/zAcAfNlxuQR+t396vhm/wkoA7tq6BtkHQDVvDh3PEk=; b=adPhFrxg5Ztqd86E1NEfAh6gFfKt+dNYiNeKUbTwtaO7srYwsXfpsmJrE26wzj40yA HtjDl/cAxOmNoZywPW2ymZIPPGiyn3/yDYkDL7lxUJK2mmPZ5+GILyHJ10IqSYCdzYC+ htyhdXF7LMQ+CDxAy5eZQr2GwndU2B5fSBdpHnKAL3roNQQ3oorFlSAzjcLMnU3tP7mh dplHLU7CRUvfCPsIh64z8yQEeS3pNsXvLonTvNwi22ZpREkeCKsaD2vjrYmArGcqfMN/ gB4oi2uCiWwnb6BdbiyxrThDgm1JorJVU3gx3RolTadwPheHVvuMYtUagC8Fge30hr2X 38mw== X-Gm-Message-State: ALoCoQnvn85pExAvKAqJhH9swiKpR3QyxSePWU4Z9exityfsF7/kbHnCRbtTdT8y7F5LJbcltfWrPztuRaUcb+c6Hmc3YakskQ== X-Received: by 10.25.24.156 with SMTP id 28mr2642491lfy.27.1450795498332; Tue, 22 Dec 2015 06:44:58 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id l81sm5867407lfb.40.2015.12.22.06.44.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:44:57 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Guan Xuetao Cc: Linus Walleij Subject: [PATCH 44/54] unicore: gpio: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:44:53 +0100 Message-Id: <1450795493-27900-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: Guan Xuetao Signed-off-by: Linus Walleij --- For unicore32: as mentioned in 00/54: either apply this directly or ACK it and I will take it into the GPIO tree. --- arch/unicore32/kernel/gpio.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/arch/unicore32/kernel/gpio.c b/arch/unicore32/kernel/gpio.c index cb12ec39552c..5ab23794ea17 100644 --- a/arch/unicore32/kernel/gpio.c +++ b/arch/unicore32/kernel/gpio.c @@ -52,7 +52,7 @@ device_initcall(puv3_gpio_leds_init); static int puv3_gpio_get(struct gpio_chip *chip, unsigned offset) { - return readl(GPIO_GPLR) & GPIO_GPIO(offset); + return !!(readl(GPIO_GPLR) & GPIO_GPIO(offset)); } static void puv3_gpio_set(struct gpio_chip *chip, unsigned offset, int value)