From patchwork Mon Jul 17 23:43:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 9846479 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8E69C6037F for ; Mon, 17 Jul 2017 23:47:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A759B267EC for ; Mon, 17 Jul 2017 23:47:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C3FF269E2; Mon, 17 Jul 2017 23:47:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3250A267EC for ; Mon, 17 Jul 2017 23:47:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Lht9YxQClNIszf2rQGjnkZ/IBk46TQ9DbaWpMFtWEec=; b=MIw+1WA29D1bEDnoEmejczE6Z0 0DNE7eqj3AIUiEUscLICXYrjOm9ccmMM9sWAO8iJoOEnXHnnu8hLSvpCk+ZyUxAdWl0WIfv6Npv8+ /PgWO3qvAzLPXk82+N6IT7Qx00mqIxnY7hTHsWXnFEU9AYs+lAgTTTyxJ0Flo4BjTOJ4otfoA2WZP 1VALy1Tqfm/JGspnXqD1DWCnPLPcbK4FdRxK/bu7tzAbmLUMIHK+HkZpJviXixAsBeVlvGfCYBbT7 VofCsE2yFDRW+tlBO9rn7S/bMz9htQXNmMwds+Bhq1uNaZavDuYJjFxLNbH65bu51Ofe7Fqew6I2O 5Bi1Lp8A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dXFjY-0003iX-K6; Mon, 17 Jul 2017 23:47:24 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dXFgh-0001Al-Ev for linux-arm-kernel@lists.infradead.org; Mon, 17 Jul 2017 23:44:31 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id F148F6087F; Mon, 17 Jul 2017 23:44:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1500335047; bh=BWwThiAxnOLafsUmyltQ4eTMKVlXZLVTS4fofBhLPj4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zb2x3oeRfsch57Sg4mXz/Bxlz3jqUReM3nNYTCIfbHyuiCr/WgaeKXegqNvxqmDjS NffgChGzT/4rsukR6fd4StLTO5maowVAARwzP3iv7l2H6PM1T2jfMYptgxOp4z/yi3 RpB3yRy2t1qrk9guEWtQiXJfjpIqYKToBT1WFky4= Received: from timur-ubuntu.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: timur@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id A65B8607A7; Mon, 17 Jul 2017 23:44:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1500335046; bh=BWwThiAxnOLafsUmyltQ4eTMKVlXZLVTS4fofBhLPj4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NW+mrmzDmeefZC89CQmloDHZKxfLvNzh5E61p4O9SzTDIx+ZCo75L/GDJ3hpawyAA xAmmiqWEskMNjWh4U98+xnnzaXdPlh6H1uNcasHdQdvqBb0L5ydty+1ex1OI4+wCTG AjqSiQoEStdAkkuzXwOybTFX4+UMVpyCEUNJwRr0= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org A65B8607A7 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=timur@codeaurora.org From: Timur Tabi To: andy.gross@linaro.org, david.brown@linaro.org, Linus Walleij , Bjorn Andersson , linux-gpio@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/3] gliolib: request the gpio before querying its direction Date: Mon, 17 Jul 2017 18:43:59 -0500 Message-Id: <1500335041-32711-2-git-send-email-timur@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1500335041-32711-1-git-send-email-timur@codeaurora.org> References: <1500335041-32711-1-git-send-email-timur@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170717_164427_636658_163A361B X-CRM114-Status: GOOD ( 12.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: timur@codeaurora.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Before querying a GPIO to determine its direction, the GPIO should be formally requested. This allows the GPIO driver to block access to unavailable GPIOs, which makes it easier for some drivers to support sparse GPIO maps. Signed-off-by: Timur Tabi --- drivers/gpio/gpiolib.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 9568708..3b4e1e8 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1202,6 +1202,14 @@ int gpiochip_add_data(struct gpio_chip *chip, void *data) struct gpio_desc *desc = &gdev->descs[i]; desc->gdev = gdev; + + if (chip->request) { + status = chip->request(chip, i); + if (status < 0) + /* The GPIO is unavailable, so skip it */ + continue; + } + /* * REVISIT: most hardware initializes GPIOs as inputs * (often with pullups enabled) so power usage is @@ -1227,6 +1235,9 @@ int gpiochip_add_data(struct gpio_chip *chip, void *data) */ set_bit(FLAG_IS_OUT, &desc->flags); } + + if (chip->free) + chip->free(chip, i); } #ifdef CONFIG_PINCTRL