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: 9867437 X-Patchwork-Delegate: agross@codeaurora.org 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 91043603F9 for ; Thu, 27 Jul 2017 18:19:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83491287A8 for ; Thu, 27 Jul 2017 18:19:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 775B628870; Thu, 27 Jul 2017 18:19:34 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F304E287A8 for ; Thu, 27 Jul 2017 18:19:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751522AbdG0STc (ORCPT ); Thu, 27 Jul 2017 14:19:32 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:57360 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751446AbdG0STb (ORCPT ); Thu, 27 Jul 2017 14:19:31 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id B4452608EA; 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 Cc: timur@codeaurora.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> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.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