Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757566AbcJXVbs (ORCPT ); Mon, 24 Oct 2016 17:31:48 -0400 Received: from vern.gendns.com ([206.190.152.46]:34182 "EHLO vern.gendns.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756454AbcJXVbq (ORCPT ); Mon, 24 Oct 2016 17:31:46 -0400 Subject: Re: [RFC] gpio: of: fix GPIO drivers with multiple gpio_chip for a single node To: Masahiro Yamada , linux-gpio@vger.kernel.org References: <1477295033-6008-1-git-send-email-yamada.masahiro@socionext.com> Cc: Linus Walleij , Vladimir Zapolskiy , Alexandre Courbot , linux-kernel@vger.kernel.org, Axel Haslam , Sekhar Nori , Kevin Hilman From: David Lechner Message-ID: <5caabb44-3c32-fc6d-e0e0-a063cd665c52@lechnology.com> Date: Mon, 24 Oct 2016 16:31:44 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <1477295033-6008-1-git-send-email-yamada.masahiro@socionext.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1379 Lines: 30 On 10/24/2016 02:43 AM, Masahiro Yamada wrote: > Sylvain Lemieux reports the LPC32xx GPIO driver is broken since > commit 762c2e46c059 ("gpio: of: remove of_gpiochip_and_xlate() and > struct gg_data"). Probably, gpio-etraxfs.c and gpio-davinci.c are > broken as well. > > Those drivers register multiple gpio_chip that are associated to a > single OF node, and their own .of_xlate() checks if the passed > gpio_chip is valid. > > Now, the problem is of_find_gpiochip_by_node() returns the first > gpio_chip found to match the given node. So, .of_xlate() fails, > except for the first GPIO bank. > > Reverting the commit could be a solution, but I do not want to go > back to the mess of struct gg_data. Another solution here is to > take the match by a node pointer and the success of .of_xlate(). > It is a bit clumsy to call .of_xlate twice; for gpio_chip matching > and for really getting the gpio_desc index. Perhaps, the long-term > goal might be to convert drivers to single chip registration, but > this commit will solve the problem until then. > > Signed-off-by: Masahiro Yamada > Reported-by: This fixes gpio-davinci. Tested on LEGO MINDSTORMS EV3 (I included the chip->of_xlate(chip, gpiospec, NULL) >= 0 suggestion from Sylvain Lemieux when I tested). Tested-By: David Lechner