From patchwork Thu Jul 27 18:19:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 9867443 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 224006038F for ; Thu, 27 Jul 2017 18:20:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 12D0B2861E for ; Thu, 27 Jul 2017 18:20:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 115A32887E; Thu, 27 Jul 2017 18:20:25 +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,RCVD_IN_DNSWL_NONE 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 7909F2861E for ; Thu, 27 Jul 2017 18:20:23 +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=tb8MX+id7YmaAmIxo530h3LuYP 8X3Hk+hEii4Uhng89MKZV+fNTmFqRccAxaWyt0YPRvfM5lRvpxfLuDGqaJ1rgYAyW7TlzaJ3uhE9G s3MKRgqCMzHcTyej1HXWnPifakOqdTFJRk3BjJI6LECayBLYvJU1aqixGdz3XQ+dHcSIuS3VrUWJN PdZ8UXu14xyz9agjmvd7H/8jbC6AwTBtfiYRRlHPOKwpO6Il5amS909Z4GG1YWnO6v7bXtRLUmEdf ZTNGQ2OcdQuK3BJhrCkqe5jvU3Rsht/WxjDLsx8uEbYiNe1VBY6Dd9BccDN9FdmjWUjTSl6DTrBPf otfdGOnA==; 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 1danON-0005Jo-FU; Thu, 27 Jul 2017 18:20:11 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1danO2-0004ho-I5 for linux-arm-kernel@lists.infradead.org; Thu, 27 Jul 2017 18:19:52 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id D3EC7609F7; Thu, 27 Jul 2017 18:19:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1501179570; bh=BWwThiAxnOLafsUmyltQ4eTMKVlXZLVTS4fofBhLPj4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CLVBGk0LHZV2Ds6a9EQi1M7q8EVrwMPNIG9rdtjIvvhxnXybMPMAsWw3Q65jy/ONY O2r8qfP6qTA6c7dxs5X83AqEjFV9Py170W9iNHDkY234BRnI37dIf1EeHzCt6uo0cM QOvPALYFCWiLQYIQMaXHI7G0ON+2cqDBnxpPGnCQ= 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 8B7646080A; Thu, 27 Jul 2017 18:19:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1501179570; bh=BWwThiAxnOLafsUmyltQ4eTMKVlXZLVTS4fofBhLPj4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CLVBGk0LHZV2Ds6a9EQi1M7q8EVrwMPNIG9rdtjIvvhxnXybMPMAsWw3Q65jy/ONY O2r8qfP6qTA6c7dxs5X83AqEjFV9Py170W9iNHDkY234BRnI37dIf1EeHzCt6uo0cM QOvPALYFCWiLQYIQMaXHI7G0ON+2cqDBnxpPGnCQ= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 8B7646080A 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: Thu, 27 Jul 2017 13:19:23 -0500 Message-Id: <1501179565-26466-2-git-send-email-timur@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1501179565-26466-1-git-send-email-timur@codeaurora.org> References: <1501179565-26466-1-git-send-email-timur@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170727_111950_686981_592CACC6 X-CRM114-Status: GOOD ( 12.86 ) 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