From patchwork Fri Dec 2 16:28:00 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyle Moffett X-Patchwork-Id: 128905 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 6F72F100B72 for ; Sat, 3 Dec 2011 03:29:49 +1100 (EST) Received: from border.exmeritus.com (border.exmeritus.com [IPv6:2002:46a7:f11a:ffff::]) by ozlabs.org (Postfix) with ESMTP id A372A100B25 for ; Sat, 3 Dec 2011 03:29:12 +1100 (EST) Received: from ysera.exmeritus.com (firewall2.exmeritus.com [10.13.38.2]) by border.exmeritus.com (Postfix) with ESMTP id C1434AC081; Fri, 2 Dec 2011 11:29:10 -0500 (EST) From: Kyle Moffett To: Benjamin Herrenschmidt Subject: [PATCH v3 03/10] powerpc/mpic: Assume a device-node was passed in mpic_alloc() Date: Fri, 2 Dec 2011 11:28:00 -0500 Message-Id: <1322843287-2745-4-git-send-email-Kyle.D.Moffett@boeing.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1322795058.3729.48.camel@pasglop> References: <1322795058.3729.48.camel@pasglop> Cc: linuxppc-dev , Paul Mackerras , Michael Ellerman , Kyle Moffett X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org All of the existing callers of mpic_alloc() pass in a non-NULL device-node pointer, so the checks for a NULL device-node may be removed. Signed-off-by: Kyle Moffett --- arch/powerpc/sysdev/mpic.c | 50 ++++++++++++++++++------------------------- 1 files changed, 21 insertions(+), 29 deletions(-) diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c index 8f24c6e..59564dc 100644 --- a/arch/powerpc/sysdev/mpic.c +++ b/arch/powerpc/sysdev/mpic.c @@ -1137,19 +1137,17 @@ struct mpic * __init mpic_alloc(struct device_node *node, unsigned int irq_count, const char *name) { - struct mpic *mpic; - u32 greg_feature; - const char *vers; - int i; - int intvec_top; + int i, psize, intvec_top; + struct mpic *mpic; + u32 greg_feature; + const char *vers; + const u32 *psrc; - /* - * If no phyiscal address was specified then all of the phyiscal - * addressing parameters must come from the device-tree. - */ - if (!phys_addr) { - BUG_ON(!node); + /* This code assumes that a non-NULL device node is passed in */ + BUG_ON(!node); + /* Pick the physical address from the device tree if unspecified */ + if (!phys_addr) { /* Check if it is DCR-based */ if (of_get_property(node, "dcr-reg", NULL)) { flags |= MPIC_USES_DCR; @@ -1211,28 +1209,22 @@ struct mpic * __init mpic_alloc(struct device_node *node, mpic->spurious_vec = intvec_top; /* Check for "big-endian" in device-tree */ - if (node && of_get_property(node, "big-endian", NULL) != NULL) + if (of_get_property(node, "big-endian", NULL) != NULL) mpic->flags |= MPIC_BIG_ENDIAN; - if (node && of_device_is_compatible(node, "fsl,mpic")) + if (of_device_is_compatible(node, "fsl,mpic")) mpic->flags |= MPIC_FSL; /* Look for protected sources */ - if (node) { - int psize; - unsigned int bits, mapsize; - const u32 *psrc = - of_get_property(node, "protected-sources", &psize); - if (psrc) { - psize /= 4; - bits = intvec_top + 1; - mapsize = BITS_TO_LONGS(bits) * sizeof(unsigned long); - mpic->protected = kzalloc(mapsize, GFP_KERNEL); - BUG_ON(mpic->protected == NULL); - for (i = 0; i < psize; i++) { - if (psrc[i] > intvec_top) - continue; - __set_bit(psrc[i], mpic->protected); - } + psrc = of_get_property(node, "protected-sources", &psize); + if (psrc) { + /* Allocate a bitmap with one bit per interrupt */ + unsigned int mapsize = BITS_TO_LONGS(intvec_top + 1); + mpic->protected = kzalloc(mapsize*sizeof(long), GFP_KERNEL); + BUG_ON(mpic->protected == NULL); + for (i = 0; i < psize/sizeof(u32); i++) { + if (psrc[i] > intvec_top) + continue; + __set_bit(psrc[i], mpic->protected); } }