Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp593797imm; Wed, 23 May 2018 02:13:25 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqY+ZMs+rh5oIPPNw8Jy/qFW1uGOqgMXh1t3BWxqHYw8eE3L5rQqiicmudPBeH2XsuZUTig X-Received: by 2002:a17:902:a4:: with SMTP id a33-v6mr2105504pla.346.1527066805774; Wed, 23 May 2018 02:13:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527066805; cv=none; d=google.com; s=arc-20160816; b=e378s2JV1Vsp/puPRampFKqbZRriaRrG2JPdHLBJyDTWx/1g5Ch8pflKzYOVP7Wst2 k2/hwpO5HQuhqq1lpxjbxxcCC3Ja8WZrZ8B4OQUcPBdqN5mApJRYrsQhHpfxO8NiG66w mzJDvmCMw2/V1Fvi3O37yr/ufeWJWUg1cAsbKA7wYdCbOqnUMQNHpRyLtE+2LIr4Vt3r XX1O/KGby9dBwNJ9nSjA7JG9Asa60kYFTCdnz4KmlubitwsO90K+UxnDuD08t1xFoVm4 K9jwHsqZzZL8BFhTHz80cLBFu4cn/zMEJxLn1TQZbBSphoryz9eokyJIsAt7su3HghpQ gqtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organisation:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=BKOJnGBGaE/j1YuQwUDbD1avXOHPVol5QonV+F9ihCc=; b=pzN/49QS9g630tBnakUomCRxD4LFcQkflTElY1TCV9+r85p/QJT8IXMl0u0V/cT2/M Ii2N+elLXOd9KGOhkjM+IN//YLu7cVKjitWxY3YSk1/OupIYM8SBcmBPfH10G+9Uw0Vs 8Zs6II4uTJoZ/b9uJPv+NoOjbDm570RHNQcmuWYr91u1tSQJrFuGFGYSAyJzFDuTrSMQ 1Hf5/nd9A/D+VrjDHsdfJ8BpsJs/ZtN1nFMd3/gc9uOUbafw09XIWWdVy/Nl8WISILIm vwmF0oVU++Pwb9zLu18j393V7fp7EAjZL0zUviJNNju1M8n/tL9mxBJry6+vsyp8/bEV bpQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@verge.net.au header.s=mail header.b=OPEu9P49; 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 w9-v6si19004594plk.28.2018.05.23.02.13.11; Wed, 23 May 2018 02:13:25 -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=fail header.i=@verge.net.au header.s=mail header.b=OPEu9P49; 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 S932201AbeEWJM0 (ORCPT + 99 others); Wed, 23 May 2018 05:12:26 -0400 Received: from kirsty.vergenet.net ([202.4.237.240]:57416 "EHLO kirsty.vergenet.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754395AbeEWJMY (ORCPT ); Wed, 23 May 2018 05:12:24 -0400 Received: from reginn.horms.nl (watermunt.horms.nl [80.127.179.77]) by kirsty.vergenet.net (Postfix) with ESMTPA id 89C1C25B790; Wed, 23 May 2018 19:12:22 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=verge.net.au; s=mail; t=1527066742; bh=0NLDqZ0FT3nTTxy0cpJTuHi1fXZARKU5A7XKTz9cnGk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OPEu9P497AkhHvPrTm8t0ntKStHSg4ASi+VuAY3o8dGqyHSn/XWfLW3NjNKZpiLWS gQMVWTYjo8D0xa42Fqyiy9vPe/5aOmx3jORjgTxMgL/zDjkgcmUX5d2Q8BX03qNCiS o+69JAYwwRBo2a5XNvEJZWqhi1f5imED36CKBi58= Received: by reginn.horms.nl (Postfix, from userid 7100) id 5C51E94345B; Wed, 23 May 2018 11:12:20 +0200 (CEST) Date: Wed, 23 May 2018 11:12:20 +0200 From: Simon Horman To: Phil Edworthy Cc: Andy Shevchenko , Hoan Tran , Linus Walleij , Lee Jones , Michel Pollet , linux-gpio@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] gpio: dwapb: Rework support for 1 interrupt per port A GPIO Message-ID: <20180523091220.jfguqui75rup5qpl@verge.net.au> References: <1527065564-9127-1-git-send-email-phil.edworthy@renesas.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1527065564-9127-1-git-send-email-phil.edworthy@renesas.com> Organisation: Horms Solutions BV User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 23, 2018 at 09:52:44AM +0100, Phil Edworthy wrote: > Treat DT and ACPI the same as much as possible. Note that we can't use > platform_get_irq() to get the DT interrupts as they are in the port > sub-node and hence do not have an associated platform device. > > This also fixes a problem introduced with error checking when calling > platform_get_irq(). What is the problem? In general I think fixes should be in separate patches. > > Signed-off-by: Phil Edworthy > --- > drivers/gpio/gpio-dwapb.c | 53 ++++++++++++++++++++--------------------------- > 1 file changed, 22 insertions(+), 31 deletions(-) > > diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c > index 7dcd06b..15b4154 100644 > --- a/drivers/gpio/gpio-dwapb.c > +++ b/drivers/gpio/gpio-dwapb.c > @@ -444,7 +444,7 @@ static void dwapb_configure_irqs(struct dwapb_gpio *gpio, > int i; > > for (i = 0; i < pp->ngpio; i++) { > - if (pp->irq[i]) > + if (pp->irq[i] >= 0) > irq_set_chained_handler_and_data(pp->irq[i], > dwapb_irq_handler, gpio); > } > @@ -562,7 +562,7 @@ dwapb_gpio_get_pdata(struct device *dev) > struct dwapb_platform_data *pdata; > struct dwapb_port_property *pp; > int nports; > - int i; > + int i, j; > > nports = device_get_child_node_count(dev); > if (nports == 0) > @@ -580,6 +580,8 @@ dwapb_gpio_get_pdata(struct device *dev) > > i = 0; > device_for_each_child_node(dev, fwnode) { > + struct device_node *np = NULL; > + > pp = &pdata->properties[i++]; > pp->fwnode = fwnode; > > @@ -599,46 +601,35 @@ dwapb_gpio_get_pdata(struct device *dev) > pp->ngpio = 32; > } > > + pp->irq_shared = false; > + pp->gpio_base = -1; > + > /* > * Only port A can provide interrupts in all configurations of > * the IP. > */ > - if (dev->of_node && pp->idx == 0 && > - fwnode_property_read_bool(fwnode, > - "interrupt-controller")) { > - struct device_node *np = to_of_node(fwnode); > - unsigned int j; > - > - /* > - * The IP has configuration options to allow a single > - * combined interrupt or one per gpio. If one per gpio, > - * some might not be used. > - */ > - for (j = 0; j < pp->ngpio; j++) { > - int irq = of_irq_get(np, j); > - if (irq < 0) > - continue; > - > - pp->irq[j] = irq; > - pp->has_irq = true; > - } > + if (pp->idx != 0) > + continue; > > - if (!pp->has_irq) > - dev_warn(dev, "no irq for port%d\n", pp->idx); > + if (dev->of_node && fwnode_property_read_bool(fwnode, > + "interrupt-controller")) { > + np = to_of_node(fwnode); > } > > - if (has_acpi_companion(dev) && pp->idx == 0) { > - unsigned int j; > + for (j = 0; j < pp->ngpio; j++) { > + pp->irq[j] = -ENXIO; > > - for (j = 0; j < pp->ngpio; j++) { > + if (np) > + pp->irq[j] = of_irq_get(np, j); > + else if (has_acpi_companion(dev)) > pp->irq[j] = platform_get_irq(to_platform_device(dev), j); > - if (pp->irq[j]) > - pp->has_irq = true; > - } > + > + if (pp->irq[j] >= 0) > + pp->has_irq = true; > } > > - pp->irq_shared = false; > - pp->gpio_base = -1; > + if (!pp->has_irq) > + dev_warn(dev, "no irq for port%d\n", pp->idx); > } > > return pdata; > -- > 2.7.4 >