Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp21064imm; Tue, 18 Sep 2018 15:42:17 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZw4rUdfXJGVtSOt0jmn27mE756b4AvWp70yNRv/7E+GXdrCi3Jeg3rVxPztUHr3bJXkEbF X-Received: by 2002:a17:902:b282:: with SMTP id u2-v6mr30687593plr.123.1537310537619; Tue, 18 Sep 2018 15:42:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537310537; cv=none; d=google.com; s=arc-20160816; b=M/ZeJXEmSHc7q5ypEbYFtOQ5GfzQEQPF2jcBnyivm31Bfks1rKPNAdjQT8mQjUaLiX p/HflhlUoT9K/Ebl6WiAR/hV6UvlVdjVJjpuzwtXxUo47LlJKgOk5nAnvUWiVMrEyYY3 8JpL3nrFRs4hsUwfgIegz28wMb1zu0HlZUJK7DU1H/pqrVmTQitobqtQSUPSrw8XI1q/ F8BDDrA7h+kTzRgLPZvH2jOZZjutUdHosYiI89A26i7lUFbz0w3BZBlaCD4xw7SpK4OO qRyY5bc/nj2xKypG9e9eWwbb4mjdU3zyqVrEjb/Ypwcjj3lfqqrqUVHhf7w1sBDb7lka 4Wpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=6XC9qos4DZLy1LQLFohTxMuo6P6SyCh2w8zZgGWmYjY=; b=NvwmBmFovG73qolaD6zpOX8yFrIzV9RIljsux/m/X1rkF/pk2xrueViNnyLWlEb3Ti RyCQQdFrmgEHOIQj2HZ30L0AZ6YKHUwHgjQj8VPGVvgzNr+4A2UKnalVs5V25ALM7URI r8fn5QeRk60XbD6SuvFLNQoIMUZOuW45oohAFP3+Z1mVBQLpHnBjGp2g5HtossyUmzW8 O/qzfE06uSdjs9DKVH27eAix99yuVGSarTu363DO3tZbCtSmA16rZfbBmRYXUMOp03J+ UTHDiLGgHfRDmFNyEFpZb3YpDBappysAaI5Z3xbTMm/l39C3dqfOIbYTAxi1SrwMQCEk Vg9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YdPnNX+s; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d2-v6si20695929pgu.106.2018.09.18.15.42.00; Tue, 18 Sep 2018 15:42:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YdPnNX+s; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727298AbeISEPJ (ORCPT + 99 others); Wed, 19 Sep 2018 00:15:09 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:56134 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725973AbeISEPJ (ORCPT ); Wed, 19 Sep 2018 00:15:09 -0400 Received: by mail-it0-f65.google.com with SMTP id d10-v6so5657834itj.5 for ; Tue, 18 Sep 2018 15:40:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6XC9qos4DZLy1LQLFohTxMuo6P6SyCh2w8zZgGWmYjY=; b=YdPnNX+skeYKBY10DpJ/gj/xzB2EQNCSV5TmF0UtC3g63foJhfMF2T8d+I6WmfvBMn dUfToRfDkU1YtmApzPu+2qvm/sos0XtlMH+MeQWHJP84yrKTHGrRXYkCaQV0gcaxGboC I9CsqXDlF2os0Rx9jyAUP8kZaPF2jtLIPeSYo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6XC9qos4DZLy1LQLFohTxMuo6P6SyCh2w8zZgGWmYjY=; b=ALKAyQjnfM+MNwxkuTcXX3rvvJqv6+E/4PXQ3AiXqkUXynpbCvfoXdoRQmtDpQwMW0 NY60elhTS1KUIo2geQRB3M610426hejHC5DwFLUWazc3XMdGam1kC4wYD/tFNzpfEiK+ /BqbwdDKtEPJRkxyvmvw0YtS+SZwxkY33XjYNCaHFQjdI/KVd6G/mFPiQj5kWH9oQTQB 5igaQtmDHUFa8ZlODltVGMFffDbLjaCX99533EBpUD9MiFjpG15gMUQ+pt2xhQ26JrLk U4n1r/9GDS60FN24TpzYncFIVtIaPXNEE+11+DeCV3HO7bzJRM7uCHWYZSOIF49MujnU h4Pg== X-Gm-Message-State: APzg51Ar2tdWOw34oWK6FpsgFBI5vwh/1TYHbP9xKDxKhH0eWaBE6pa6 V5GviXMpnlT4TxFOzd5LoFF72r5iz0jKcPzqzVcwcw== X-Received: by 2002:a24:9d84:: with SMTP id f126-v6mr19194347itd.130.1537310423295; Tue, 18 Sep 2018 15:40:23 -0700 (PDT) MIME-Version: 1.0 References: <20180914070839.4667-1-ricardo.ribalda@gmail.com> <20180914070839.4667-2-ricardo.ribalda@gmail.com> In-Reply-To: <20180914070839.4667-2-ricardo.ribalda@gmail.com> From: Linus Walleij Date: Tue, 18 Sep 2018 15:40:10 -0700 Message-ID: Subject: Re: [PATCH] gpiolib: Show correct direction from the beginning To: Ricardo Ribalda Delgado , Timur Tabi , Stephen Boyd Cc: "open list:GPIO SUBSYSTEM" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 14, 2018 at 12:08 AM Ricardo Ribalda Delgado wrote: > Current code assumes that the direction is input if direction_input > function is set. > This might not be the case on GPIOs with programmable direction. > > Signed-off-by: Ricardo Ribalda Delgado > --- > drivers/gpio/gpiolib.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c > index a57300c1d649..af853749e0bb 100644 > --- a/drivers/gpio/gpiolib.c > +++ b/drivers/gpio/gpiolib.c > @@ -1352,7 +1352,12 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data, > * 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; > + if (chip->get_direction) > + desc->flags = !chip->get_direction(chip, i) ? > + (1 << FLAG_IS_OUT) : 0; > + else > + desc->flags = !chip->direction_input ? > + (1 << FLAG_IS_OUT) : 0; We used to do this. But it breaks Qualcomm hardware. commit 1ca2a92b2a99323f666f1b669b7484df4bda05e4 Author: Timur Tabi Date: Wed Dec 20 13:10:31 2017 -0600 Revert "gpio: set up initial state from .get_direction()" 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 Signed-off-by: Linus Walleij Yours, Linus Walleij