From patchwork Mon Feb 9 06:11:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Courbot X-Patchwork-Id: 437785 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 999AC14011D for ; Mon, 9 Feb 2015 17:11:46 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758994AbbBIGLp (ORCPT ); Mon, 9 Feb 2015 01:11:45 -0500 Received: from mail-ig0-f180.google.com ([209.85.213.180]:57703 "EHLO mail-ig0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752801AbbBIGLo (ORCPT ); Mon, 9 Feb 2015 01:11:44 -0500 Received: by mail-ig0-f180.google.com with SMTP id b16so14301720igk.1; Sun, 08 Feb 2015 22:11:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=1HxQuijdjk4rn43p5aDFy+JKtO3n9oWasbgFpn0RHYQ=; b=u7aCAdvT650wVCd5fYIsEMwhYzjA1qa7t1socKhp28su3aJ4fYIz1VlcP0ATWHvoNO XKzHnvhK9bPUPB2NG9mGULa946Sj70XkefbTJVUfPreqGqsrzmnLacdTD0OiNJhNZ6b9 u5Dyqr6Ed9pSlRgxIPvV7dZHJxDo9OLYlHuTbz5NyGU/apSkM07nCdtAwjaAHnpw0kl8 D6Fxphf5lKkx37lVdnbeTAVdzztGm7HlBaoTMY8xhF01BwSS7roiYSxqRZ2ZvLGv8Ld2 s+t8olqIxEHKqm9uconpOSJwFu2yDyWmTXaVoWbScu6O/T39JI55gu3xNq8+af4kXdkD D0TQ== X-Received: by 10.42.21.78 with SMTP id j14mr24277408icb.43.1423462303576; Sun, 08 Feb 2015 22:11:43 -0800 (PST) MIME-Version: 1.0 Received: by 10.64.252.202 with HTTP; Sun, 8 Feb 2015 22:11:23 -0800 (PST) In-Reply-To: References: From: Alexandre Courbot Date: Mon, 9 Feb 2015 15:11:23 +0900 Message-ID: Subject: Re: gpio-pxa: getting GPIOs by devicetree phandle broken To: Tyler Hall Cc: "linux-gpio@vger.kernel.org" , "devicetree@vger.kernel.org" , Daniel Mack , Hans Holmberg , Linus Walleij , Linux Kernel Mailing List , Howard Cochran , Robert Jarzmik Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Adding Robert who reported the same thing. On Sat, Feb 7, 2015 at 6:28 AM, Tyler Hall wrote: > Hi, > > Commit 7b8792b ("gpiolib: of: Correct error handling in > of_get_named_gpiod_flags") seems to break the ability to use DT > bindings to reference this driver's GPIOs by phandle for banks above > the first. > > The issue is that gpio-pxa registers multiple gpio chips - one for > each bank - but they're all associated with the same DT node. The new > behavior in of_gpiochip_find_and_xlate() causes gpiochip_find() to > bail after the first chip matches and its xlate function fails. > Previously it would try all chips associated with the phandle and > pxa_gpio_of_xlate() would fail until it was called with the correct > gpiochip. > > I think the new behavior of of_gpiochip_find_and_xlate() is reasonable, > so I see a couple ways of fixing gpio-pxa. > > 1. Require child nodes in DT for each bank This would break DT compatibility. > 2. Refactor gpio-pxa to only register one gpiochip Sounds better, especially since this would reflect the hardware more accurately. One DT node should translate into one GPIO chip. The problem is that I'm afraid several other drivers are doing the same thing and thus are now similarly broken. The following is also likely to work as a workaround, but I would not go as far as saying this should be taken as a fix. Hans, since you wrote 7b8792b, could we have your input on this? return true; --- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 08261f2b3a82..a09095531b00 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -45,14 +45,16 @@ static int of_gpiochip_find_and_xlate(struct gpio_chip *gc, void *data) return false; ret = gc->of_xlate(gc, &gg_data->gpiospec, gg_data->flags); - if (ret < 0) { + if (ret == -EPROBE_DEFER) { /* We've found the gpio chip, but the translation failed. * Return true to stop looking and return the translation * error via out_gpio */ gg_data->out_gpio = ERR_PTR(ret); return true; - } + } else if (ret < 0) { + return false; + } gg_data->out_gpio = gpiochip_get_desc(gc, ret);