From mboxrd@z Thu Jan 1 00:00:00 1970 From: Timur Tabi Subject: Re: [PATCH 0/2] [v5] pinctrl: qcom: add support for sparse GPIOs Date: Fri, 22 Sep 2017 08:37:07 -0500 Message-ID: <255ad0dc-2d16-ae7f-0b45-500e23cff1a4@codeaurora.org> References: <1504798409-32041-1-git-send-email-timur@codeaurora.org> <20170919070422.GI3349@codeaurora.org> <1ecdf6ee-5098-15d3-f85e-66b39a6c25f9@codeaurora.org> <619f48d2-59c7-c090-4ace-9e8db9f92064@codeaurora.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from smtp.codeaurora.org ([198.145.29.96]:50242 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751877AbdIVNhK (ORCPT ); Fri, 22 Sep 2017 09:37:10 -0400 In-Reply-To: Content-Language: en-US Sender: linux-gpio-owner@vger.kernel.org List-Id: linux-gpio@vger.kernel.org To: Linus Walleij Cc: Stephen Boyd , Andy Gross , David Brown , anjiandi@codeaurora.org, Bjorn Andersson , "linux-gpio@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-arm-msm@vger.kernel.org" , "thierry.reding@gmail.com" , Mika Westerberg , Andy Shevchenko On 09/22/2017 08:29 AM, Linus Walleij wrote: > > What is your response to Stephen's comment: > >> [Stephen Boyd] >> Perhaps we can add another hook for our purposes here that >> tells gpiolib that the gpio is not usable and to skip it. The >> semantics would be clear, it's just about probing availability of >> this pin as a gpio and doesn't mux any pins. > I think this kind of related to my response (after I realized it > was not just about IRQs): We already have 95% of this. We can already specify individual pin ranges, and the vast majority of the code recognizes the ranges. There is only one small loophole, and that's in gpiochip_add_data(). The for-loop iterates over all GPIOs: 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. */ I believe the real problem is that this for-loop should be moved from gpiochip_add_data() into some other function that is called *after* the pin ranges are defined. We can put it in gpiochip_add_pin_range(), maybe. My patch covers the loophole by adding a check inside get_direction(). If we fix gpiochip_add_data(), I can remove that patch. However, I think that change is risky and will require a lot of testing and review. -- Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.