From patchwork Mon Oct 30 20:49: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: 10033127 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 764A6600C5 for ; Mon, 30 Oct 2017 20:50:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 692672887D for ; Mon, 30 Oct 2017 20:50:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5DB9F28973; Mon, 30 Oct 2017 20:50:11 +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 074C728971 for ; Mon, 30 Oct 2017 20:50:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932424AbdJ3UuJ (ORCPT ); Mon, 30 Oct 2017 16:50:09 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:43990 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932153AbdJ3UuI (ORCPT ); Mon, 30 Oct 2017 16:50:08 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 052FB607C7; Mon, 30 Oct 2017 20:50:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1509396608; bh=tccmR0NiooqLnGQrvu0DrzMxsOfjVTNy0f/jZ/hu2EE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OE8dDwM3ydCOs7yVwhuwSSn/gwvyf6F+WhQ75+Bw2qXzVksGB7koOqgwfZ10eQiLg HilRsEYx2X8PJfj0jlT7+BD6vS4NdC3ldlUHs3jf7WLgWH/JSoO4SgrF9wsW8Vx18r ra4mTDttXUJk09GgRxkxSPUa9KOto+1fZWBlsMw4= 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 99992607B5; Mon, 30 Oct 2017 20:50:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1509396607; bh=tccmR0NiooqLnGQrvu0DrzMxsOfjVTNy0f/jZ/hu2EE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K2hjpoQpT9rZpGuuLTeyo7h2xDTmHQeFuaiNSrGiveUCnuotNxkaDpHYE1qyYeog4 mLct2zowN6/0JZGxko3xcevQ1l92T5UBZg6ywn6G3uzReJnz4neY2bCWb8hAJR69Ck U+4NqdqXbhAxgYGC1s/BxSPCFA5q05bU43EupIgU= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 99992607B5 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: linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, Linus Walleij , Andy Shevchenko , Mika Westerberg , thierry.reding@gmail.com, Stephen Boyd , david.brown@linaro.org, andy.gross@linaro.org, Bjorn Andersson Cc: timur@codeaurora.org Subject: [PATCH 1/4] Revert "gpio: set up initial state from .get_direction()" Date: Mon, 30 Oct 2017 15:49:59 -0500 Message-Id: <1509396602-1936-2-git-send-email-timur@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1509396602-1936-1-git-send-email-timur@codeaurora.org> References: <1509396602-1936-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 This reverts commit 72d3200061776264941be1b5a9bb8e926b3b30a5. We cannot blindly query the direction of all GPIOs when the pins are first registered. The get_direction callback normally triggers a read/write to hardware, but we shouldn't be touching the hardware for an individual GPIO until after it's been properly requested. --- drivers/gpio/gpiolib.c | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index eb80dac4e26a..60553af4c004 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1221,31 +1221,14 @@ int gpiochip_add_data(struct gpio_chip *chip, void *data) struct gpio_desc *desc = &gdev->descs[i]; desc->gdev = gdev; - /* - * REVISIT: most hardware initializes GPIOs as inputs - * (often with pullups enabled) so power usage is - * minimized. Linux code should set the gpio direction - * first thing; but until it does, and in case - * chip->get_direction is not set, we may expose the - * wrong direction in sysfs. - */ - - if (chip->get_direction) { - /* - * If we have .get_direction, set up the initial - * direction flag from the hardware. - */ - int dir = chip->get_direction(chip, i); - if (!dir) - set_bit(FLAG_IS_OUT, &desc->flags); - } else if (!chip->direction_input) { - /* - * If the chip lacks the .direction_input callback - * we logically assume all lines are outputs. - */ - set_bit(FLAG_IS_OUT, &desc->flags); - } + /* REVISIT: most hardware initializes GPIOs as inputs (often + * with pullups enabled) so power usage is minimized. Linux + * code should set the gpio direction first thing; but until + * it does, and in case chip->get_direction is not set, we may + * expose the wrong direction in sysfs. + */ + desc->flags = !chip->direction_input ? (1 << FLAG_IS_OUT) : 0; } #ifdef CONFIG_PINCTRL