From patchwork Tue Dec 22 14:49:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58927 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3280946lbb; Tue, 22 Dec 2015 06:49:48 -0800 (PST) X-Received: by 10.66.55.72 with SMTP id q8mr36185749pap.136.1450795788089; Tue, 22 Dec 2015 06:49:48 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rw4si3032809pac.72.2015.12.22.06.49.47; Tue, 22 Dec 2015 06:49:48 -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 S932691AbbLVOtr (ORCPT + 4 others); Tue, 22 Dec 2015 09:49:47 -0500 Received: from mail-lf0-f43.google.com ([209.85.215.43]:33084 "EHLO mail-lf0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753466AbbLVOtq (ORCPT ); Tue, 22 Dec 2015 09:49:46 -0500 Received: by mail-lf0-f43.google.com with SMTP id p203so132083641lfa.0 for ; Tue, 22 Dec 2015 06:49:46 -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=HCqGn9/RUuEEmCH59akaWSEq2dBKhZGMPYPliddYX8I=; b=MPyDWtt5iPyrTy5DRkkwQ+Z/i9899z+8wAI/lUWHeuJDevJLOGbbIBWbx5otx6SSoQ HWksMYA39diSQSP6zIMQrbgs2nVnSzY3//dyvZsuSTKaSfNcnTK8v+fFnlu/6O+eEGyr QKf3/vxXqZE6sB0wJ0BYkBtcYmS8V74U5rcjY= 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=HCqGn9/RUuEEmCH59akaWSEq2dBKhZGMPYPliddYX8I=; b=N6qMVLltc8NQkrbyyFzP/Fl/X2wNTa2PdiS5xy4Wvxmpt0C1ClUspMedKU823rEJSu MBKBUfY7HvD71vPMZ9IjCUo7ecCsceIdIOfy+eBSKaexwk+yt2Hs4jKmPxOVags13EyF QPXeIIvT8tj+xRNfepzikHC/kj7vmi5QzqP2E2t28OWxk4sxblh2JUIBcl2vNKU5karb NfqxMiYEALuJTxUxB3OxOOQt9ozHokuiygDGx5/A4XNPg4s0/5tPkjDTJHci+qbT/HNM KKPuYGK915De4g+mTu7GCxvT4Hj4bbq5U62fvvLBDGDPIDNGr9uTjg6jYa3QR3jTP9y4 7jOA== X-Gm-Message-State: ALoCoQlCJ8tSRr6DOPaMLuBUBIgFnTYv6gmJDEmPhVHe/81xoWGzeDnTA5OC6T/xmJ3zy2oqycEZ7cGEggRJGSTQctMmf2azhA== X-Received: by 10.25.17.7 with SMTP id g7mr932554lfi.106.1450795785477; Tue, 22 Dec 2015 06:49:45 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id m21sm3229688lfm.38.2015.12.22.06.49.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:49:44 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Florian Tobias Schandinat , Tomi Valkeinen Cc: Linus Walleij Subject: [PATCH 51/54] fbdev: via-gpio: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:49:41 +0100 Message-Id: <1450795781-28534-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: Florian Tobias Schandinat Cc: Tomi Valkeinen Signed-off-by: Linus Walleij --- Tomi: as mentioned in 00/54: either apply this directly or ACK it and I will take it into the GPIO tree. --- drivers/video/fbdev/via/via-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/drivers/video/fbdev/via/via-gpio.c b/drivers/video/fbdev/via/via-gpio.c index 6f433b8cee12..3d3544036bc1 100644 --- a/drivers/video/fbdev/via/via-gpio.c +++ b/drivers/video/fbdev/via/via-gpio.c @@ -142,7 +142,7 @@ static int via_gpio_get(struct gpio_chip *chip, unsigned int nr) gpio = cfg->active_gpios[nr]; reg = via_read_reg(VIASR, gpio->vg_port_index); spin_unlock_irqrestore(&cfg->vdev->reg_lock, flags); - return reg & (0x04 << gpio->vg_mask_shift); + return !!(reg & (0x04 << gpio->vg_mask_shift)); }