Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp639975imm; Fri, 5 Oct 2018 09:20:17 -0700 (PDT) X-Google-Smtp-Source: ACcGV61uadk1GDbM0dzk0R2MQDQVpwIvEBNN5QtwlxlJFQ3GHZELp1MAWb8LIEWLw7F1qUaUn8MF X-Received: by 2002:a63:3c46:: with SMTP id i6-v6mr10786522pgn.286.1538756417776; Fri, 05 Oct 2018 09:20:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538756417; cv=none; d=google.com; s=arc-20160816; b=bqaaIiE3g0PtrLUuUoO0oM2JHALhl6s1zv76/SvhYhCkIYCxE74nVJ28RDYYeX0idI yvR9Tpmn0bzM/9fE8/Lfi7AasWgPZurcIRQWqvdzqlWYmkdEAvgYvxJIyvzeVpiwK6T8 ejNimhX4EucvB3BmXHXJ2oy1FShyCYF510UtvJoTxe7MeYsTCKDI2CSa+5cG09RCwFyr sw7g7yIxQzAdiJdwvcaxVaBQCvhPrNnwXdN5uFkQn7s9j5WelMKE4grXHZsd1+6+RrT8 SXUory3P9XM2xm9RSItCMlbjqkkslWwxFhQ4peFUpblY7uNqoZFABpSfjxMcN2OZedcf P23w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:dmarc-filter:dkim-signature :dkim-signature; bh=GbyV5zKA1RIK8I2opji9zay3l5CyDRip9czbQshmhAE=; b=ZU2vTUD8Qmo1lcYPSp+FwLJu9ounHELD4c/TB4w0h9mZ7Cp2cEPIZncR2bG06kE964 q6Eny3zVtGR8EOvP38Fj4RXqfVExkSzjSEf9HFxQfJ9Ho7x4XegQON42rCIVjQj9pJQv EfoVv2J4hRmSPeiZdKZal//ycjIzFd33daDPlLSFg7LvmFN/ZSPPvfgaHNTmkGZRr08r /f7K0D8EY0H1bXAZ/dgjdcgxAKegzc+vIB3xpEVKCb8F4IQ08Tr8szA16DDzFXZ4kDO7 y2YFkKUyzRGc0Aoce4m5fvhDL/8RehplQFT/tQY5qhl6rvtCj/ahYLL/jWYdTmfHCkQ7 4Tkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=KU5s3bBy; dkim=pass header.i=@codeaurora.org header.s=default header.b=N1K3eYRl; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j12-v6si6996029pgq.57.2018.10.05.09.20.02; Fri, 05 Oct 2018 09:20: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=@codeaurora.org header.s=default header.b=KU5s3bBy; dkim=pass header.i=@codeaurora.org header.s=default header.b=N1K3eYRl; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730405AbeJEXRZ (ORCPT + 99 others); Fri, 5 Oct 2018 19:17:25 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:50772 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730347AbeJEXRZ (ORCPT ); Fri, 5 Oct 2018 19:17:25 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id E378660C67; Fri, 5 Oct 2018 16:17:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1538756280; bh=jz3qw9RDsrEcd7fAVaj7VEtNs9pDSKtUdoUSu2jwhYk=; h=Subject:To:References:From:Date:In-Reply-To:From; b=KU5s3bByH71iwN6MWTblzigE3ze4EQueN2tbt8U48cTJYscnFYcmTQ8Dtx07zjC5e dDaAnnn/bwZElbMo5AR0oz0QzuIw+iRzCYP0Xz4mg0CpyBkpFfNdKMQLQ4k3fU5isq 6yjjvO4MOVeeAeAyFmBlHyyPxEwiWJdr4LFrhIVs= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED autolearn=no autolearn_force=no version=3.4.0 Received: from [10.226.60.81] (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: jhugo@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id B157460C67; Fri, 5 Oct 2018 16:17:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1538756277; bh=jz3qw9RDsrEcd7fAVaj7VEtNs9pDSKtUdoUSu2jwhYk=; h=Subject:To:References:From:Date:In-Reply-To:From; b=N1K3eYRlbrUJMTa6SakErc9y6UFeMjCZlTthiPFJuxauj+TnlpN1yOc1b5s3ej1yV w9qdhbhh6rSogj5WwEGmRAeJMcVMQXvMD5fNB55Bj9FNVsirwzess7MzRqCiu5IS56 /+hTxQChZIPZxT/OVjWOM8NS62vdz2DIE4PDdHOw= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B157460C67 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=jhugo@codeaurora.org Subject: Re: [PATCH v5 3/3] gpiolib: Show correct direction from the beginning To: Ricardo Ribalda Delgado , Linus Walleij , Timur Tabi , Stephen Boyd , linux-gpio , LKML References: <20181005065300.22882-1-ricardo.ribalda@gmail.com> <20181005065300.22882-3-ricardo.ribalda@gmail.com> From: Jeffrey Hugo Message-ID: <8d10f9b4-7ea9-7d27-478a-39982ba49587@codeaurora.org> Date: Fri, 5 Oct 2018 10:17:55 -0600 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181005065300.22882-3-ricardo.ribalda@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/5/2018 12:53 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 | 27 +++++++++++++-------------- > 1 file changed, 13 insertions(+), 14 deletions(-) > > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c > index 907019b67a58..e016b22658ff 100644 > --- a/drivers/gpio/gpiolib.c > +++ b/drivers/gpio/gpiolib.c > @@ -1349,20 +1349,6 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data, > > spin_unlock_irqrestore(&gpio_lock, flags); > > - for (i = 0; i < chip->ngpio; i++) { > - 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. > - */ > - desc->flags = !chip->direction_input ? (1 << FLAG_IS_OUT) : 0; > - } > - > #ifdef CONFIG_PINCTRL > INIT_LIST_HEAD(&gdev->pin_ranges); > #endif > @@ -1391,6 +1377,19 @@ int gpiochip_add_data_with_key(struct gpio_chip *chip, void *data, > if (status) > goto err_remove_chip; > > + for (i = 0; i < chip->ngpio; i++) { > + struct gpio_desc *desc = &gdev->descs[i]; > + > + desc->gdev = gdev; > + > + if (chip->get_direction && gpiochip_line_is_valid(chip, i)) > + desc->flags = !chip->get_direction(chip, i) ? > + (1 << FLAG_IS_OUT) : 0; > + else > + desc->flags = !chip->direction_input ? > + (1 << FLAG_IS_OUT) : 0; > + } > + > acpi_gpiochip_add(chip); > > machine_gpiochip_add(chip); > We have a successful boot this time. Timur I see: ubuntu@ubuntu:~$ dmesg | grep gpio [ 7.388887] gpiochip_find_base: found new base at 362 [ 7.433186] gpio gpiochip0: (QCOM8002:00): added GPIO chardev (254:0) [ 7.433218] gpiochip_setup_dev: registered GPIOs 362 to 511 on device: gpiochip0 (QCOM8002:00) [ 7.433222] gpio gpiochip0: (QCOM8002:00): created GPIO range 0->149 ==> QCOM8002:00 PIN 0->149 Looks like the driver is initing just fine to me. Is setting up the jumpers and running gpio-test warranted? -- Jeffrey Hugo Qualcomm Datacenter Technologies as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.