From patchwork Tue Dec 22 14:09:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58874 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3257875lbb; Tue, 22 Dec 2015 06:09:39 -0800 (PST) X-Received: by 10.66.65.109 with SMTP id w13mr35618623pas.142.1450793379065; Tue, 22 Dec 2015 06:09:39 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id mk9si4781301pab.101.2015.12.22.06.09.38; Tue, 22 Dec 2015 06:09:39 -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 S1753767AbbLVOJi (ORCPT + 4 others); Tue, 22 Dec 2015 09:09:38 -0500 Received: from mail-lf0-f45.google.com ([209.85.215.45]:34321 "EHLO mail-lf0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752088AbbLVOJh (ORCPT ); Tue, 22 Dec 2015 09:09:37 -0500 Received: by mail-lf0-f45.google.com with SMTP id y184so129788348lfc.1 for ; Tue, 22 Dec 2015 06:09:37 -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=ei6+BTmKAX/qTXpYlk6X/iChZW53QWm8l4Ct1O/gico=; b=bKlOQyLYWTDQbKa85oCMn0Z81BfII/FzXY1+Ea1YhgRHr6fVdo9dMZdyxDLIvsFZBP umY3vOvCeKLjgayEAnPdDJUfKf2Lt5LwBrPANkUWswL6gMNDMaJgLz4BVJasC23Rw9WZ QoLiTDSqM77mJn/I8nuQm6ONk3F73Yfp1ASR4= 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=ei6+BTmKAX/qTXpYlk6X/iChZW53QWm8l4Ct1O/gico=; b=gvulWv76TZypzXjNY74JB4CvQcyZsYXD1RpLl17d30wJtGkVxey9GYUQufXunxcbnV xIfgbiKBwPWxrmbYU19Z01LbdmDlRIGCb4ND4ZtTzqYBbUMj7zKeBHqv1VjMpXteaVuX SYBKLED4F7kS4gphNNXy8pvXwpa9FFbOLko3NfLfQj+s8Ba+2bBogmE4q7QRWN2XtCrH dAbd7EPkJ6e/NEPR8fp8zzgA8x9zgf9MqBgrHaTw027nZ66uRQKzJgEZ25EsAMYczAIK vE/SyMvOEYfkTd3UiwlZcxp/N9PJ2kRicVrHuoJY7FgaI/7FFii4S+w+OmOTAcWaO8EZ DG/g== X-Gm-Message-State: ALoCoQl1zRN/0pddDUPP15mCPL9/YXghIm/Ju43mROWbDEpgplULuFQon6QmDC+VKiHQSkEbVxJevMVenSkKnQsTE8M2664gyA== X-Received: by 10.25.91.210 with SMTP id p201mr8728783lfb.37.1450793376540; Tue, 22 Dec 2015 06:09:36 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id p69sm5792288lfe.42.2015.12.22.06.09.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:09:35 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Ashish Jangam Cc: Linus Walleij Subject: [PATCH 01/54] gpio: da9052: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:09:31 +0100 Message-Id: <1450793371-21804-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: Ashish Jangam Signed-off-by: Linus Walleij --- drivers/gpio/gpio-da9052.c | 9 +++------ 1 file changed, 3 insertions(+), 6 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/gpio/gpio-da9052.c b/drivers/gpio/gpio-da9052.c index 2e9578ec0ca1..38bd8f122bfc 100644 --- a/drivers/gpio/gpio-da9052.c +++ b/drivers/gpio/gpio-da9052.c @@ -89,15 +89,12 @@ static int da9052_gpio_get(struct gpio_chip *gc, unsigned offset) DA9052_STATUS_D_REG); if (ret < 0) return ret; - if (ret & (1 << DA9052_GPIO_SHIFT_COUNT(offset))) - return 1; - else - return 0; + return !!(ret & (1 << DA9052_GPIO_SHIFT_COUNT(offset))); case DA9052_OUTPUT_PUSHPULL: if (da9052_gpio_port_odd(offset)) - return ret & DA9052_GPIO_ODD_PORT_MODE; + return !!(ret & DA9052_GPIO_ODD_PORT_MODE); else - return ret & DA9052_GPIO_EVEN_PORT_MODE; + return !!(ret & DA9052_GPIO_EVEN_PORT_MODE); default: return -EINVAL; }