From patchwork Tue Dec 22 14:23:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58890 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3266088lbb; Tue, 22 Dec 2015 06:23:07 -0800 (PST) X-Received: by 10.98.75.77 with SMTP id y74mr35621090pfa.115.1450794187333; Tue, 22 Dec 2015 06:23:07 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xk9si4644477pab.38.2015.12.22.06.23.07; Tue, 22 Dec 2015 06:23:07 -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 S1754633AbbLVOXG (ORCPT + 4 others); Tue, 22 Dec 2015 09:23:06 -0500 Received: from mail-lb0-f182.google.com ([209.85.217.182]:34020 "EHLO mail-lb0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754630AbbLVOXF (ORCPT ); Tue, 22 Dec 2015 09:23:05 -0500 Received: by mail-lb0-f182.google.com with SMTP id pv2so45954691lbb.1 for ; Tue, 22 Dec 2015 06:23:04 -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=JN4jEQRaj6uWqDmu0DYIsQyH7/OhKv8Bh713M0yDh4I=; b=kGh3qxxDeeVHBJRTZeIoEb9unoYLRuEJWLgCkDUDmmNtHqT5pguOPqx3l8chzbKY5T BLMy7qz+aWUFsQaaL7tbqQM8kgrZqWtJIcVRRSDv2sGvs7FKZGdoCV/MmrHKxVduxFmH SuZ5UBd/lgUQSo5b75EgpMl44HnRc1j0Sap+4= 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=JN4jEQRaj6uWqDmu0DYIsQyH7/OhKv8Bh713M0yDh4I=; b=Pnw48f1e7QMGE4CpQz0u5zDDXF8f+xrpUs1EBL/EgWFEuYwTq3EWbmupT50HG9MknR as1iaBviC7STw/FyAP0gtuBKjcg4XoIc3RZsWLIU73MGikDOPUvlk1SgaiXCayU2RD6K bkB607rYsgoFEBcDAPwJTZ+xw9pX+KawBQFR8usx3BM/0+zOPeMUjBVCZqqLOQegehy7 ibrW3ZvRXXO2U0OLN/Sl4qJs0MKEXI9MXFvHV6csMAEN+V9sUbiN62yPIx2q1y+cphHj N75fPDw2fo6+TfYCx0AmyIwPr5zO6ZE49OVXdoKhkQl+LY8CFQ/sJ/hCF1x220fz4gpS E6Sw== X-Gm-Message-State: ALoCoQnWKm7EYKOZPVb4CllGeiyWEUhEQAvq1ehyUX8rVCFLl5wdahKDh5KzsuScoz+e6GvPRQqz7/Bd1JyORRL/S/wZNvz1IA== X-Received: by 10.112.147.4 with SMTP id tg4mr6576548lbb.121.1450794183476; Tue, 22 Dec 2015 06:23:03 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id li2sm5675419lbc.29.2015.12.22.06.23.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:23:02 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Wei Chen Cc: Linus Walleij Subject: [PATCH 17/54] gpio: sx150x: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:23:00 +0100 Message-Id: <1450794180-23186-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 starts to propagate the error code from the I2C transaction as the end of the series adds support for that. Cc: Wei Chen Signed-off-by: Linus Walleij --- drivers/gpio/gpio-sx150x.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-sx150x.c b/drivers/gpio/gpio-sx150x.c index 2d882964b309..04d4f2c2928a 100644 --- a/drivers/gpio/gpio-sx150x.c +++ b/drivers/gpio/gpio-sx150x.c @@ -344,7 +344,7 @@ static int sx150x_gpio_get(struct gpio_chip *gc, unsigned offset) mutex_unlock(&chip->lock); } - return status; + return (status < 0) ? status : !!status; } static void sx150x_gpio_set(struct gpio_chip *gc, unsigned offset, int val)