From mboxrd@z Thu Jan 1 00:00:00 1970 From: Grant Likely Subject: Re: [RFC] [PATCH 2/3] of: add of_irq_count: Count the number of IRQs a node present Date: Wed, 29 May 2013 23:33:40 +0100 Message-ID: <20130529223340.68EC13E16F4@localhost> References: <20130528145219.GA30411@game.jcrosoft.org> <1369753729-12997-1-git-send-email-plagnioj@jcrosoft.com> <1369753729-12997-2-git-send-email-plagnioj@jcrosoft.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1369753729-12997-2-git-send-email-plagnioj-sclMFOaUSTBWk0Htik3J/w@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: devicetree-discuss-bounces+gldd-devicetree-discuss=m.gmane.org-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org Sender: "devicetree-discuss" To: Jean-Christophe PLAGNIOL-VILLARD , devicetree-discuss-mnsaURCQ41sdnm+yROfE0A@public.gmane.org Cc: Rob Herring , Ralf Baechle List-Id: devicetree@vger.kernel.org On Tue, 28 May 2013 17:08:48 +0200, Jean-Christophe PLAGNIOL-VILLARD wrote: > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD > Cc: Grant Likely > Cc: Rob Herring > Cc: Arnd Bergmann > Cc: Linus Walleij > Cc: Benjamin Herrenschmidt > Cc: Ralf Baechle > Cc: Nicolas Ferre > --- > drivers/of/irq.c | 15 +++++++++++++++ > include/linux/of_irq.h | 1 + > 2 files changed, 16 insertions(+) > > diff --git a/drivers/of/irq.c b/drivers/of/irq.c > index d1c5825..4426223 100644 > --- a/drivers/of/irq.c > +++ b/drivers/of/irq.c > @@ -362,6 +362,21 @@ int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) > EXPORT_SYMBOL_GPL(of_irq_to_resource); > > /** > + * of_irq_count - Count the number of IRQs a node uses > + * @dev: pointer to device tree node > + */ > +int of_irq_count(struct device_node *dev) Following on from my comment on patch 1/3, How about "of_irq_count_entries()"? > +{ > + struct of_irq oirq; > + int nr = 0; > + > + while (!of_irq_map_one(dev, nr, &oirq)) > + nr++; The concept is good, but this ends up being very inefficient. It would be better to take the relevant parts out of of_irq_map_one() to retrieve the value of #interrupt-cells and compare it to the size of the interrupts property. g.