From: Bharat Bhushan <Bharat.Bhushan@nxp.com>
To: benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au,
oss@buserror.net, galak@kernel.crashing.org,
mark.rutland@arm.com, kstewart@linuxfoundation.org,
gregkh@linuxfoundation.org, devicetree@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Cc: robh@kernel.org, keescook@chromium.org,
tyreld@linux.vnet.ibm.com, joe@perches.com,
Bharat Bhushan <Bharat.Bhushan@nxp.com>
Subject: [RFC 1/5] powerpc/mpic: move last irq logic to function
Date: Fri, 27 Jul 2018 15:17:57 +0530 [thread overview]
Message-ID: <1532684881-19310-2-git-send-email-Bharat.Bhushan@nxp.com> (raw)
In-Reply-To: <1532684881-19310-1-git-send-email-Bharat.Bhushan@nxp.com>
This function just moves the last-irq calculation
logic to a function, while no change in logic.
Signed-off-by: Bharat Bhushan <Bharat.Bhushan@nxp.com>
---
arch/powerpc/sysdev/mpic.c | 52 +++++++++++++++++++++++++++++-----------------
1 file changed, 33 insertions(+), 19 deletions(-)
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 353b439..b6803bc 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -1210,6 +1210,36 @@ u32 fsl_mpic_primary_get_version(void)
return 0;
}
+static int mpic_get_last_irq_source(struct mpic *mpic,
+ unsigned int irq_count,
+ unsigned int isu_size)
+{
+ u32 last_irq;
+ u32 greg_feature;
+
+ /*
+ * Read feature register. For non-ISU MPICs, num sources as well. On
+ * ISU MPICs, sources are counted as ISUs are added
+ */
+ greg_feature = mpic_read(mpic->gregs, MPIC_INFO(GREG_FEATURE_0));
+
+ /*
+ * By default, the last source number comes from the MPIC, but the
+ * device-tree and board support code can override it on buggy hw.
+ * If we get passed an isu_size (multi-isu MPIC) then we use that
+ * as a default instead of the value read from the HW.
+ */
+ last_irq = (greg_feature & MPIC_GREG_FEATURE_LAST_SRC_MASK)
+ >> MPIC_GREG_FEATURE_LAST_SRC_SHIFT;
+ if (isu_size)
+ last_irq = isu_size * MPIC_MAX_ISU - 1;
+ of_property_read_u32(mpic->node, "last-interrupt-source", &last_irq);
+ if (irq_count)
+ last_irq = irq_count - 1;
+
+ return last_irq;
+}
+
struct mpic * __init mpic_alloc(struct device_node *node,
phys_addr_t phys_addr,
unsigned int flags,
@@ -1451,25 +1481,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
0x1000);
}
- /*
- * Read feature register. For non-ISU MPICs, num sources as well. On
- * ISU MPICs, sources are counted as ISUs are added
- */
- greg_feature = mpic_read(mpic->gregs, MPIC_INFO(GREG_FEATURE_0));
-
- /*
- * By default, the last source number comes from the MPIC, but the
- * device-tree and board support code can override it on buggy hw.
- * If we get passed an isu_size (multi-isu MPIC) then we use that
- * as a default instead of the value read from the HW.
- */
- last_irq = (greg_feature & MPIC_GREG_FEATURE_LAST_SRC_MASK)
- >> MPIC_GREG_FEATURE_LAST_SRC_SHIFT;
- if (isu_size)
- last_irq = isu_size * MPIC_MAX_ISU - 1;
- of_property_read_u32(mpic->node, "last-interrupt-source", &last_irq);
- if (irq_count)
- last_irq = irq_count - 1;
+ last_irq = mpic_get_last_irq_source(mpic, irq_count, isu_size);
/* Initialize main ISU if none provided */
if (!isu_size) {
@@ -1495,6 +1507,8 @@ struct mpic * __init mpic_alloc(struct device_node *node,
if (mpic->irqhost == NULL)
return NULL;
+ greg_feature = mpic_read(mpic->gregs, MPIC_INFO(GREG_FEATURE_0));
+
/* Display version */
switch (greg_feature & MPIC_GREG_FEATURE_VERSION_MASK) {
case 1:
--
1.9.3
next prev parent reply other threads:[~2018-07-27 9:47 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-27 9:47 [RFC 0/5] powerpc/mpic: Add non-contiguous interrupt sources Bharat Bhushan
2018-07-27 9:47 ` Bharat Bhushan [this message]
2018-07-27 9:47 ` [RFC 2/5] powerpc/mpic: Rework last source irq calculation logic Bharat Bhushan
2018-07-27 9:47 ` [RFC 3/5] powerpc/mpic: Add support for non-contiguous irq ranges Bharat Bhushan
2018-08-07 18:09 ` Rob Herring
2018-08-07 21:03 ` Scott Wood
2018-08-08 3:37 ` Bharat Bhushan
2018-08-08 5:50 ` Scott Wood
2018-08-08 5:57 ` Bharat Bhushan
2018-07-27 9:48 ` [RFC 4/5] powerpc/mpic: Boot print supported interrupt ranges Bharat Bhushan
2018-07-27 9:48 ` [RFC 5/5] powerpc/fsl: Add supported-irq-ranges for P2020 Bharat Bhushan
2018-08-07 21:13 ` Scott Wood
2018-08-08 3:44 ` Bharat Bhushan
2018-08-08 5:55 ` Scott Wood
2018-08-08 6:28 ` Bharat Bhushan
2018-08-08 17:57 ` Scott Wood
2018-08-09 3:28 ` Bharat Bhushan
2018-08-09 6:11 ` Scott Wood
2018-08-09 7:04 ` Bharat Bhushan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1532684881-19310-2-git-send-email-Bharat.Bhushan@nxp.com \
--to=bharat.bhushan@nxp.com \
--cc=benh@kernel.crashing.org \
--cc=devicetree@vger.kernel.org \
--cc=galak@kernel.crashing.org \
--cc=gregkh@linuxfoundation.org \
--cc=joe@perches.com \
--cc=keescook@chromium.org \
--cc=kstewart@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mark.rutland@arm.com \
--cc=mpe@ellerman.id.au \
--cc=oss@buserror.net \
--cc=paulus@samba.org \
--cc=robh@kernel.org \
--cc=tyreld@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).