From patchwork Wed Dec 20 19:10:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 10126401 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 4E0BE6019C for ; Wed, 20 Dec 2017 19:11:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F159283C9 for ; Wed, 20 Dec 2017 19:11:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3213A28A3E; Wed, 20 Dec 2017 19:11:57 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable 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 D3EDD283C9 for ; Wed, 20 Dec 2017 19:11:56 +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=tvLdEbfF2nUsDQ7Sqji0yrNZzgxcHBdDztOFlItu8vo=; b=h2qeYPeLL9FiZJLB201xZLOZcC 0jS8tMskI5j8w6RkQFi6YZuuu9NKy32/0m0WpqTX8V2l4NFj440mZU/U0891VYRxRtnW9DB2VVtrl z67o/ecgYf+PJxIlbiUBGbjL6ZnTL4elXxIgpXAn/7S3zqvajfFHyccIKOKMtD6mNUMNUd0yJw3UL /aD76UpOzl+nmaifQY/5kskZUBfPf7R85zOkRz6YsrXlF70igwbxV22/Y7/WpMrm797OuBd9H06uT FGY2cNnFhKBF9iKE159FTB4IReQwp/OBJJLsdXfYH9aGY+AZHv0jznVy5hfBZLPW/29jd8pO74d+K S+XAFkgA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eRjmS-0005lm-Eh; Wed, 20 Dec 2017 19:11:52 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eRjlQ-000585-2n for linux-arm-kernel@lists.infradead.org; Wed, 20 Dec 2017 19:10:54 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 6C54D60710; Wed, 20 Dec 2017 19:10:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1513797038; bh=r0VJT90zV4wlWRceNG4hsyb9eDhZpO/LMJlMjXh/nnY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SQOBwQOUom646L6UvT/nfwpmggFG/ZHdRMjo9vnMkjCU2cv2VtVc5pB7Jlo7ZHmKp 3GdOOVdht8t6SOL6k2Lu1HLxJC2sl+JKKNw5TB6TxVdbIbD96uzhu+04YyXXhwmXLS zawr/r+jfLGCV6cRqVCJ7MP7iS3Nh2bU1aOpPt+Y= 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 E441860AFB; Wed, 20 Dec 2017 19:10:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1513797038; bh=r0VJT90zV4wlWRceNG4hsyb9eDhZpO/LMJlMjXh/nnY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SQOBwQOUom646L6UvT/nfwpmggFG/ZHdRMjo9vnMkjCU2cv2VtVc5pB7Jlo7ZHmKp 3GdOOVdht8t6SOL6k2Lu1HLxJC2sl+JKKNw5TB6TxVdbIbD96uzhu+04YyXXhwmXLS zawr/r+jfLGCV6cRqVCJ7MP7iS3Nh2bU1aOpPt+Y= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E441860AFB 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 , Varadarajan Narayanan , Archit Taneja Subject: [PATCH 1/3] [v2] Revert "gpio: set up initial state from .get_direction()" Date: Wed, 20 Dec 2017 13:10:31 -0600 Message-Id: <1513797033-9494-2-git-send-email-timur@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1513797033-9494-1-git-send-email-timur@codeaurora.org> References: <1513797033-9494-1-git-send-email-timur@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171220_111048_382305_F484896A X-CRM114-Status: GOOD ( 15.20 ) 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 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 claimed. Signed-off-by: Timur Tabi Reviewed-by: Stephen Boyd --- 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 aad84a6306c4..d21ad0bbbd0d 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1207,31 +1207,14 @@ int gpiochip_add_data_with_key(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