Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp248650imm; Tue, 18 Sep 2018 21:04:57 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaqYvcOfL4dRwnnv9uRrTScj/hccZAYqqOGdGN9oqbbXxeUHD/QoqPVaBYTbPdiKkvwKAB2 X-Received: by 2002:a63:5660:: with SMTP id g32-v6mr29615916pgm.227.1537329897243; Tue, 18 Sep 2018 21:04:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537329897; cv=none; d=google.com; s=arc-20160816; b=LSKEvY8ofd1+5upHZz6yxxScR8BPf0Eif/o3IStvYah0Y2SQF1PnRos4O+cHwtYZ8T Gb7Mj7v48BvNHmiikuqWG4AOd+mgv3zP1GRy1H0BV87b1PGx+q9OpY4AeM7fG+7RAxvo cFAa0B2zglIdUndtI8K9wGOCX8OuF7uuCjWujL+4rZ6EMjexnrsidBp4UU0oGZ5bw9vT InWX2d1hAitNxVUYDkMn3yMIKZrncqaxQv8RePigN39EE11UvQuJR0A5mjCeRN9x33eF K7h2rtqvdj0VIv1yCL8/8Eb7WNeUUOKj6+XL0o4WYwnXdMwlVkr7rPK9eybtEPkott9n /dIg== 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=aG7ZklE/LQJ/WhEnFh6VPV+D9L0jQ1iZ3dCHA2GNV/o=; b=xeoXcfEh/Phikn82uUP0bNHD8JJ3fw0ZmjfOWGliKxLGYlq5jbGbSFsPDRhhylZmxE NurfCAJqTYVsZNTE6aHfLsRaMMF/1jbHXFx3MaweVlT6QCXmz8MBHGAoESApTkyAHtSP aIRCuVoNfsO+Q10eVpI4b+EWDA5DrIU8KP2zG4mL67I0F/X0ymLs59U62/UjD+f8Grkp BvGIGZMSsPW+iVLRNg+mG5dDkUDOlhokyHeWorULjA6uf6vk99XWtJhCl1w3fo0Plsa+ EceT6mIC747ROAY2+JgJ44RF3RDM7kmgiddzHrE9vLjdpB8wqK9kieetXza79WnlJA3Z d/3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="mM2g/MqC"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p29-v6si552039pgd.442.2018.09.18.21.04.40; Tue, 18 Sep 2018 21:04:57 -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=@gmail.com header.s=20161025 header.b="mM2g/MqC"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728021AbeISJkd (ORCPT + 99 others); Wed, 19 Sep 2018 05:40:33 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:44687 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725870AbeISJkd (ORCPT ); Wed, 19 Sep 2018 05:40:33 -0400 Received: by mail-lf1-f66.google.com with SMTP id g24-v6so3817540lfb.11; Tue, 18 Sep 2018 21:04:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=aG7ZklE/LQJ/WhEnFh6VPV+D9L0jQ1iZ3dCHA2GNV/o=; b=mM2g/MqC2LH2/KpZBTv5e0zHNLiYw9GlznNNpwjlST6gBkKN8wReT5F07ivtbhZuF+ 8L70H5AM3/Ko6WJ/iKBgsUFS0q5TIJpqvP12izQWEaxg/9TCHRYGIeR1ckEye+uwJUNE hzQoWrxNzkoaDzYSs4pVq0ma63XVpmbnB+LxTfJ1+7MjxuuB/icHYfquSG3/R1WFOY67 MhUZHeD28dEDeXVkFdHhX+SEnWMuDfUAQ99ymzEO60D4ajsCbLGGMwsA0h4H6clUiZtf VRYSjjmMnwMhLYFfGk/1C3ajob1gWYS+fJ1xCx5vuSxeYCcSpqJOgQ9HosQba6FlL3gC mzhg== 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=aG7ZklE/LQJ/WhEnFh6VPV+D9L0jQ1iZ3dCHA2GNV/o=; b=XTJnUu1ZJUExcfjLOlwZ/MFaWo2MIPgy5jgTjTsp1gdmw/P1vTFI7so9pTxNjqE/El C8r1FnRuhVmwUPZS9iZkDBQHLXQYSbXr0JXCS86PSx6R2Eyj19MhtT8/3NGTEHU2+yzF 08eOwG9NR3PL6Qy2k6Cwx1wDz4cY9MgihclsGQ6iGjW3a3ji/QTrV6u195VGe+9v9jUu wZyh0okpgPXqPWA0yC8BtxXGwlQ5b2z2Qx/qog0hY5Z7fkYQRLl/0lfqvjXgE5rd6uXc froimv8YnTOQMvtNVCU6yTpu7sVOX7/8pGcf/ctUs5RL3lQEZT3Omr1FnY6MlPfHQGr0 3MqA== X-Gm-Message-State: APzg51DtTC63BPQ2xRnZsYHB9JPUOAUVTt1f5mxjVxznTS7kQWVSzYsk /DPIdkm/7+LWqbWLYNBYd+nuirOI4vZFAcfOCZl+Yg== X-Received: by 2002:a19:4e51:: with SMTP id c78-v6mr7568287lfb.79.1537329873893; Tue, 18 Sep 2018 21:04:33 -0700 (PDT) MIME-Version: 1.0 References: <20180914070839.4667-1-ricardo.ribalda@gmail.com> <20180914070839.4667-2-ricardo.ribalda@gmail.com> In-Reply-To: From: Ricardo Ribalda Delgado Date: Wed, 19 Sep 2018 06:04:17 +0200 Message-ID: Subject: Re: [PATCH] gpiolib: Show correct direction from the beginning To: Linus Walleij Cc: Timur Tabi , swboyd@chromium.org, linux-gpio@vger.kernel.org, LKML 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 Hi Linus On Wed, Sep 19, 2018 at 12:40 AM Linus Walleij wrote: > > 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. And should't that be tacked in qcom hardware with something like: if (!priv->initialized) return INPUT; if you or Timur point me to the harware that was crashing I would not mind looking into that, but the current situations seems to me like a hack. Other option would be to implement a new function get_direction_fast() (the name could be better). I can also try to implement something in that direction if you want. Thanks for your review. > > 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 -- Ricardo Ribalda