From patchwork Thu Feb 1 17:59:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 126563 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1933134ljc; Thu, 1 Feb 2018 09:59:27 -0800 (PST) X-Google-Smtp-Source: AH8x226o3rHBhGPSeM0xy5/W+sdBR2qHaHOsok/CvVtYRo+mKuOZYwHoltxp5pbVU3t7etV7pFh7 X-Received: by 2002:a17:902:aa95:: with SMTP id d21-v6mr22729247plr.16.1517507967347; Thu, 01 Feb 2018 09:59:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517507967; cv=none; d=google.com; s=arc-20160816; b=yBFsqfWxbonfQVCJYVLzOnEEn0YbOJAm+INIkvFswGWbPEU6w03PSB26yAqTk3kd43 dnpOrYB8BVQHgz91nSbUvbMPUM58Lwe/wp0IlZlgfa0YYudY7BcK4CTUCzlV2v63IOvU oLyEl846mILRnPOXEn/CphC3gpwt4i9WEjfhRBF4rE2ErywpDnPFVxNlIP4Pad9iOh5S jCH4OmH5V/1mBDOxH8sy32Y9KSS8NRH45IFZiJxtSyp18hlY/sTyWFUvh9TmAp0tzOXr wAf1FXMKiTEYXuY4nFGtZGR1aoQsalb32afYb3l/GFn2uJLT/CM+2MPh62/96ywn4vwZ aWXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=/RRtoybYzH7ooJuVfiGWT40qSHBRWX0RSsCCXW2ui1Y=; b=dndkAgLct+XhWOKnwXh4j3LHpWaWA8YSXRsDzpJsnUdH9p5OmwQuqP8snWHFemTkS/ w2cp1ibBa5Rp2HIXnVyWYK9hIOWpF5sFQp3VAv3nsmm3kUQZqM7A+bFp4ZEQjgF0vFtl MkN2t5Vn2G5ui4175yhmNhd3yKoE9IVATg6UHBWB148f4IcJZLQdMdYlGWcCiYhL3UwH xvBZchGTcF2/wuhB/lgKwnOrsvhCdDbkx3BsiCuxNyQgZlHwPm7jdj8YLnnWdMTBCOFX 7EoUtmfunO9tWwO23a7ivBIhglDO4IFYjM201SyiM6JgxdRiZkJ4JOMoysDHRlQNP2V6 5xgw== ARC-Authentication-Results: i=1; mx.google.com; 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 e5-v6si84883plb.636.2018.02.01.09.59.27; Thu, 01 Feb 2018 09:59:27 -0800 (PST) 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; 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 S1752734AbeBAR7Z (ORCPT + 28 others); Thu, 1 Feb 2018 12:59:25 -0500 Received: from mail-ot0-f194.google.com ([74.125.82.194]:46996 "EHLO mail-ot0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751913AbeBAR7Y (ORCPT ); Thu, 1 Feb 2018 12:59:24 -0500 Received: by mail-ot0-f194.google.com with SMTP id f56so1312518otj.13 for ; Thu, 01 Feb 2018 09:59:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=/RRtoybYzH7ooJuVfiGWT40qSHBRWX0RSsCCXW2ui1Y=; b=qOVxrbep4oHcoL8orlLpGenLmNALx0aawhviR/dVWuEqPOh6CbEqKzYi180LSTq/zJ p9RaHxQ/E0mXn/s5A20GFeCmUBJmxRkmaIJ87XWl8kV29hsxbSKOqn6SDs1H0KaJN4x1 2Oufd1yvQq+TGwTP1huNazr8kq702/oCrjV8I9Nf6pJO8i0qe2KJW4lLvwpM62/WcMyx MkvPrLPV7OlcdIOBaHbJNZQydJV99PtRVjzdcGqho5nPbF1MJqD+EtgNUTd3Ao3TRHzV fJHadNZNOthvrk0qJ4fJu50bYhV4Swwb9tmA3R8yY4APNSxa6v0VEYt2TWhJgy9YznrX nQXg== X-Gm-Message-State: AKwxytedSnGU+enZ1timI1MG71Q6Cmsosyo7yk9o/cIcFC1P9/k4goXC bilxvKC6mZ0fonp/DOdlgg== X-Received: by 10.157.26.112 with SMTP id u45mr29460426otu.327.1517507963521; Thu, 01 Feb 2018 09:59:23 -0800 (PST) Received: from xps15.herring.priv (216-188-254-6.dyn.grandenetworks.net. [216.188.254.6]) by smtp.googlemail.com with ESMTPSA id x81sm66654oix.4.2018.02.01.09.59.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Feb 2018 09:59:23 -0800 (PST) From: Rob Herring To: Michael Ellerman Cc: linux-kernel@vger.kernel.org, Benjamin Herrenschmidt , Paul Mackerras , linuxppc-dev Subject: [PATCH v2] powerpc: pseries: use of_irq_get helper in request_event_sources_irqs Date: Thu, 1 Feb 2018 11:59:22 -0600 Message-Id: <20180201175922.18930-1-robh@kernel.org> X-Mailer: git-send-email 2.14.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of calling both of_irq_parse_one and irq_create_of_mapping, call of_irq_get instead which does essentially the same thing. of_irq_get also calls irq_find_host for deferred probe support, but this should be fine as irq_create_of_mapping also calls that internally. This gets us closer to making the former 2 functions static. In the process of simplifying request_event_sources_irqs, combine the the pr_err and WARN_ON calls to just a WARN(). Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Michael Ellerman Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Rob Herring --- v2: - Fix infinite loop - Use of_irq_get instead to irq_of_parse_and_map to preserve handling of errors - Combine pr_err and WARN_ON calls to single WARN arch/powerpc/platforms/pseries/event_sources.c | 40 +++++++++----------------- 1 file changed, 13 insertions(+), 27 deletions(-) -- 2.14.1 diff --git a/arch/powerpc/platforms/pseries/event_sources.c b/arch/powerpc/platforms/pseries/event_sources.c index 6eeb0d4bab61..446ef104fb3a 100644 --- a/arch/powerpc/platforms/pseries/event_sources.c +++ b/arch/powerpc/platforms/pseries/event_sources.c @@ -16,7 +16,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include +#include +#include #include "pseries.h" @@ -24,34 +25,19 @@ void request_event_sources_irqs(struct device_node *np, irq_handler_t handler, const char *name) { - int i, index, count = 0; - struct of_phandle_args oirq; - unsigned int virqs[16]; + int i, virq, rc; - /* First try to do a proper OF tree parsing */ - for (index = 0; of_irq_parse_one(np, index, &oirq) == 0; - index++) { - if (count > 15) - break; - virqs[count] = irq_create_of_mapping(&oirq); - if (!virqs[count]) { - pr_err("event-sources: Unable to allocate " - "interrupt number for %pOF\n", - np); - WARN_ON(1); - } else { - count++; - } - } + for (i = 0; i < 16; i++) { + virq = of_irq_get(np, i); + if (virq < 0) + return; + if (WARN(!virq, "event-sources: Unable to allocate " + "interrupt number for %pOF\n", np)) + continue; - /* Now request them */ - for (i = 0; i < count; i++) { - if (request_irq(virqs[i], handler, 0, name, NULL)) { - pr_err("event-sources: Unable to request interrupt " - "%d for %pOF\n", virqs[i], np); - WARN_ON(1); + rc = request_irq(virq, handler, 0, name, NULL); + if (WARN(rc, "event-sources: Unable to request interrupt %d for %pOF\n", + virq, np)) return; - } } } -