From patchwork Tue Dec 22 14:47:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 58923 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3279816lbb; Tue, 22 Dec 2015 06:47:45 -0800 (PST) X-Received: by 10.98.9.2 with SMTP id e2mr34305418pfd.89.1450795665590; Tue, 22 Dec 2015 06:47:45 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 7si12582333pfl.182.2015.12.22.06.47.45; Tue, 22 Dec 2015 06:47:45 -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 S932670AbbLVOrp (ORCPT + 4 others); Tue, 22 Dec 2015 09:47:45 -0500 Received: from mail-lb0-f176.google.com ([209.85.217.176]:33702 "EHLO mail-lb0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932663AbbLVOro (ORCPT ); Tue, 22 Dec 2015 09:47:44 -0500 Received: by mail-lb0-f176.google.com with SMTP id sv6so25495767lbb.0 for ; Tue, 22 Dec 2015 06:47:43 -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=zA0j2j7x4Oiv+j98md22ypX1j00I8R+BlGSysh+g0qU=; b=gHKvNEA/fudLWyTDyunaVs30VYLjyBpoyDdhrOOm2r3IHSqnOcmQSLfoWBu7foEmMo rQvGhLRgM2GGk2YIOoyVzcne1V+ew2mBGLGkx7rF9/H7N8IqY0wvCJ/EIn8QRW1IfwWb bD5GnLAMLqfP+sahkvAzlqlSkUU5eHj0IpHIQ= 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=zA0j2j7x4Oiv+j98md22ypX1j00I8R+BlGSysh+g0qU=; b=WS2pgPgq4pePIz91BzqjxL/nCCZxkW1GAsEB6bUwtiQ7ELvbZPeozNY9xxSTHgWbhq A+Ba27eoi+P/axtJjwP3odG2SmFzXSGhdLEcTAn2JXSJ4mRiqLpzJ9DFR06HeMODKE9r 9KTVxc9aRINMOHAWGYiqlq0ckOk25RS3UDfmeQ2hVPs+7GH8WE1pxmLp4RxSDU6//Vtk o5PhSMm0g79Vi6qOrefoQApE1T6PHMbgL+IljGHeOXnhp+N1Fyu33qFoSCGd/IM0nDqC BnUcMoNPdJL809N1IQL0MmLO17nSiulr41Ei00x1jpf4aQTa3TGONvvMGgW6Q5CXaIrS 84Vw== X-Gm-Message-State: ALoCoQkTlxbZP/imwnt38K3DgXn8KR/qpBjCOALsUVIoGrY1bG6lJtNBfFkcBlwb4ax6Twlihmq3zB5rFmKPuudLnGM8VrMMxQ== X-Received: by 10.112.166.2 with SMTP id zc2mr2773997lbb.34.1450795663074; Tue, 22 Dec 2015 06:47:43 -0800 (PST) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id m21sm3228420lfm.38.2015.12.22.06.47.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2015 06:47:42 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Lee Jones Cc: Linus Walleij , Philipp Zabel Subject: [PATCH 47/54] mfd: htc-egpio: Be sure to clamp return value Date: Tue, 22 Dec 2015 15:47:39 +0100 Message-Id: <1450795659-28262-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: Lee Jones Cc: Philipp Zabel Signed-off-by: Linus Walleij --- Lee: as mentioned in 00/54: either apply this directly or ACK it and I will take it into the GPIO tree. --- drivers/mfd/htc-egpio.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/mfd/htc-egpio.c b/drivers/mfd/htc-egpio.c index d334e7d8a77d..c636b5f83cfb 100644 --- a/drivers/mfd/htc-egpio.c +++ b/drivers/mfd/htc-egpio.c @@ -163,7 +163,7 @@ static int egpio_get(struct gpio_chip *chip, unsigned offset) value = egpio_readw(ei, reg); pr_debug("readw(%p + %x) = %x\n", ei->base_addr, reg << ei->bus_shift, value); - return value & bit; + return !!(value & bit); } static int egpio_direction_input(struct gpio_chip *chip, unsigned offset)