From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rob Herring Subject: Re: [PATCH 4/9] of/irq: Introduce of_irq_get() Date: Mon, 16 Sep 2013 16:24:47 -0500 Message-ID: <5237771F.1060908@gmail.com> References: <1379320326-13241-1-git-send-email-treding@nvidia.com> <1379320326-13241-5-git-send-email-treding@nvidia.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1379320326-13241-5-git-send-email-treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> Sender: linux-tegra-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Thierry Reding Cc: Greg Kroah-Hartman , Linus Walleij , Stephen Warren , Wolfram Sang , Grant Likely , Benjamin Herrenschmidt , Thomas Gleixner , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: devicetree@vger.kernel.org On 09/16/2013 03:32 AM, Thierry Reding wrote: > This is a version of irq_of_parse_and_map() that propagates the precise > error code instead of returning 0 for all errors. It will be used in > subsequent patches to allow further propagation of error codes. > > To avoid code duplication, implement irq_of_parse_and_map() as a wrapper > around the new of_irq_get(). *_get typically also implies some reference counting which I don't believe this does. I don't think having 2 functions with completely different names doing the same thing with only a different calling convention is good either. So I would keep the old name and the names aligned. > Signed-off-by: Thierry Reding > --- > drivers/of/irq.c | 21 +++++++++++++++++---- > include/linux/of_irq.h | 3 +++ > 2 files changed, 20 insertions(+), 4 deletions(-) > > diff --git a/drivers/of/irq.c b/drivers/of/irq.c > index 5f44388..8225289 100644 > --- a/drivers/of/irq.c > +++ b/drivers/of/irq.c > @@ -26,6 +26,20 @@ > #include > #include > > +int of_irq_get(struct device_node *dev, unsigned int index, unsigned int *virqp) > +{ > + struct of_irq oirq; > + int ret; > + > + ret = of_irq_map_one(dev, index, &oirq); > + if (ret) > + return ret; > + > + return __irq_create_of_mapping(oirq.controller, oirq.specifier, > + oirq.size, virqp); > +} > +EXPORT_SYMBOL_GPL(of_irq_get); > + > /** > * irq_of_parse_and_map - Parse and map an interrupt into linux virq space > * @dev: Device node of the device whose interrupt is to be mapped > @@ -36,13 +50,12 @@ > */ > unsigned int irq_of_parse_and_map(struct device_node *dev, int index) > { > - struct of_irq oirq; > + unsigned int virq; > > - if (of_irq_map_one(dev, index, &oirq)) > + if (of_irq_get(dev, index, &virq)) > return 0; > > - return irq_create_of_mapping(oirq.controller, oirq.specifier, > - oirq.size); > + return virq; This can be an inline and written more concisely: { unsigned int virq; return (of_irq_get(dev, index, &virq) < 0) ? 0 : virq; } Rob