From patchwork Mon May 2 11:15:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 67006 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp1020320qge; Mon, 2 May 2016 04:15:10 -0700 (PDT) X-Received: by 10.66.186.238 with SMTP id fn14mr23375002pac.6.1462187710568; Mon, 02 May 2016 04:15:10 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g66si14773309pfb.195.2016.05.02.04.15.10; Mon, 02 May 2016 04:15:10 -0700 (PDT) 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; dkim=neutral (body hash did not verify) header.i=@linaro.org; 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; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753698AbcEBLPJ (ORCPT + 4 others); Mon, 2 May 2016 07:15:09 -0400 Received: from mail-lf0-f43.google.com ([209.85.215.43]:35983 "EHLO mail-lf0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753614AbcEBLPJ (ORCPT ); Mon, 2 May 2016 07:15:09 -0400 Received: by mail-lf0-f43.google.com with SMTP id u64so183690696lff.3 for ; Mon, 02 May 2016 04:15:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=lsv/X2seJAhyZkv3Ifps9EDWMuGKXXReh8us37o9r8w=; b=BSSJM8oUw27XdLKl8ttdSWCF7swfC+wvuyznDteIuB+U3wr18kzDR8Us2Ydqy12uZK 8CJ9R2Q/nIKSq6dJjbp07Ew2ToG+R0bg3alc5nyEe9V/og1MIdr5L9YyO/b8dRag2FFT gkIurb2Nlov0qKSGwiUXXdyh29y9baMXA7qmk= 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=lsv/X2seJAhyZkv3Ifps9EDWMuGKXXReh8us37o9r8w=; b=TdeuKL6wdMzNdnPqndAIZc65pwtmR/F1M34qWO+5qa2Q1us7JD5cw2wRmASbVGNqY/ xOM1mFne6EuNpT72St1SocaqgV9DVSpy+sGgLEZ1p9BL3v35D4J1KiWv0jyBMfg6nDpO HRsfpCUi3ZBTb3PIBW7IPZoUHSAwZaH3Wz+etLGjBYOFzZmAcq+dm749iU//cMmST07x qF83vy0Xd0m7GgJQYZewYJ6EDT6QbinhDCQ09QNWFLhH4YrtI/rY+8/kOXKcU9NHk4IC gfuIVXe04CeaK8cp7ltGcwS2HsZASdwXA7iFB2yuq+xnYoGBTX02BDQGv+KHyMuKd9U9 m77w== X-Gm-Message-State: AOPr4FXG8OQOSrPQQ1hCk+psCsSpctCCG2LHFsLzuOVnDGN+BNusMqQkD5ZiDUxqiRJJJhoF X-Received: by 10.112.142.7 with SMTP id rs7mr10103675lbb.53.1462187707355; Mon, 02 May 2016 04:15:07 -0700 (PDT) Received: from localhost.localdomain ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id z8sm4087959lbv.42.2016.05.02.04.15.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 May 2016 04:15:06 -0700 (PDT) From: Linus Walleij To: linux-gpio@vger.kernel.org, Alexandre Courbot Cc: Linus Walleij , Geert Uytterhoeven Subject: [PATCH] gpio: make gpiod_to_irq() return negative for NO_IRQ Date: Mon, 2 May 2016 13:15:02 +0200 Message-Id: <1462187702-7450-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.4.11 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org If a translation returns zero, that means NO_IRQ, so we should return an error since the function is documented to return a negative code on error. Cc: Geert Uytterhoeven Reported-by: Geert Uytterhoeven Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) -- 2.4.11 -- 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/gpiolib.c b/drivers/gpio/gpiolib.c index 340b021a3782..a68c6d732818 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1999,13 +1999,22 @@ EXPORT_SYMBOL_GPL(gpiod_cansleep); */ int gpiod_to_irq(const struct gpio_desc *desc) { - struct gpio_chip *chip; - int offset; + struct gpio_chip *chip; + int offset; VALIDATE_DESC(desc); chip = desc->gdev->chip; offset = gpio_chip_hwgpio(desc); - return chip->to_irq ? chip->to_irq(chip, offset) : -ENXIO; + if (chip->to_irq) { + int retirq = chip->to_irq(chip, offset); + + /* Zero means NO_IRQ */ + if (!retirq) + return -ENXIO; + + return retirq; + } + return -ENXIO; } EXPORT_SYMBOL_GPL(gpiod_to_irq);