Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2341765ybz; Thu, 23 Apr 2020 16:21:58 -0700 (PDT) X-Google-Smtp-Source: APiQypLNa1flSSZS+jU8yhUc0lOE23f3rOHPwEl74UHfSo7Gs4ce4t1YbZvz3ctzgDqJDfv7Iljh X-Received: by 2002:a17:906:f208:: with SMTP id gt8mr4942938ejb.124.1587684118474; Thu, 23 Apr 2020 16:21:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587684118; cv=none; d=google.com; s=arc-20160816; b=z4/jlfC93/e5FIKxNtUtnPynZ4hZOceqMkuz8yWPUerKiYWmqBsd8dwX2Jz0T58G6v sfoVS/T0ULD6+maEB6I1oFMj3Mv8p+iNXwkKJpyPwdcscsugwZc3ldyEowQjUWLQXNw8 BoWgG2FmvmHNGTKBoBHSeBQ56bIzZ5+4fIxpxdsF/RHyZNHKsiURSZpvNtF9ccA2aG2U JbhM5RyJLTPwPAOjCHUbo33Sh14UW9C3ywi+giFaZh7EoGRikm0kiWe1fFTJHzLKjyJg mfef3TokttTa71TLUosfEGoHBkEiEqjCYAKchYaRVHqdQNIYDNPmrEPORmxta4haC4Qn tsXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=bf/7J8DSHYstZNlqItIA0XP5mSgjpDoFxM7GbYwvPU4=; b=tSxKEFinQg03+7Ou07GUTGpw60aBBWFhjjRa6ybT69tkheYJopyVvpitZ3Wtd+DwU8 Vz2zqMBCNbEt4xB3peRCP4w4A3/FXHQENt1JPmJCwtbsS70ZwOh9ooHmcJKjyOuPpU+G 0NxmBKv/ufMzImOgwhJtvEJh5S7vPcwwaZGX59chuoY+BSkJWjMMmwWxAAkezXZLr7sW AB5DmoadCy/w8JxPEke2Kj2LOM9oy7LT1LgLik4sBkx2dE2inrxz3OsZGjOru5A1jWCx 5IwB/F6fGaxZvB01/ul2SS0H/6YlkgztfgyVXFD+ZVafUovp/objD0bgjnUQWYfVwegA z3AQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id la2si2015865ejb.371.2020.04.23.16.21.35; Thu, 23 Apr 2020 16:21:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729046AbgDWXRt (ORCPT + 99 others); Thu, 23 Apr 2020 19:17:49 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:49214 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728303AbgDWXGk (ORCPT ); Thu, 23 Apr 2020 19:06:40 -0400 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1jRkvP-0004fi-PR; Fri, 24 Apr 2020 00:06:31 +0100 Received: from ben by deadeye with local (Exim 4.93) (envelope-from ) id 1jRkvO-00E6mQ-8u; Fri, 24 Apr 2020 00:06:30 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "Bartosz Golaszewski" , "Linus Walleij" , "Russell King" Date: Fri, 24 Apr 2020 00:05:19 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 092/245] gpiolib: fix up emulated open drain outputs In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.83-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Russell King commit 256efaea1fdc4e38970489197409a26125ee0aaa upstream. gpiolib has a corner case with open drain outputs that are emulated. When such outputs are outputting a logic 1, emulation will set the hardware to input mode, which will cause gpiod_get_direction() to report that it is in input mode. This is different from the behaviour with a true open-drain output. Unify the semantics here. Suggested-by: Linus Walleij Signed-off-by: Russell King Signed-off-by: Bartosz Golaszewski Signed-off-by: Ben Hutchings --- drivers/gpio/gpiolib.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -273,6 +273,14 @@ int gpiod_get_direction(const struct gpi chip = gpiod_to_chip(desc); offset = gpio_chip_hwgpio(desc); + /* + * Open drain emulation using input mode may incorrectly report + * input here, fix that up. + */ + if (test_bit(FLAG_OPEN_DRAIN, &desc->flags) && + test_bit(FLAG_IS_OUT, &desc->flags)) + return 0; + if (!chip->get_direction) return status;