From patchwork Mon Jul 27 21:47:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 500856 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 217F71402B8 for ; Tue, 28 Jul 2015 07:49:31 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=HKs+Dan+; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0DAB04BBA9; Mon, 27 Jul 2015 23:49:28 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lJ1DWIGSdjFw; Mon, 27 Jul 2015 23:49:27 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 196684BBAD; Mon, 27 Jul 2015 23:49:05 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9985C4BB22 for ; Mon, 27 Jul 2015 23:48:54 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ya6pBptp_Uw7 for ; Mon, 27 Jul 2015 23:48:54 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-ig0-f178.google.com (mail-ig0-f178.google.com [209.85.213.178]) by theia.denx.de (Postfix) with ESMTPS id 48AB54BB20 for ; Mon, 27 Jul 2015 23:48:52 +0200 (CEST) Received: by igbpg9 with SMTP id pg9so111378002igb.0 for ; Mon, 27 Jul 2015 14:48:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=V1PecqOPB0whsTF/t6/yD1WKTOohBK61y9IJRTqNlIM=; b=HKs+Dan+t0yirhFok7I7RNy4OL7nf71Xx4+KItTizqCrczfKGicDUoXeIYlVlK15GG oBm58CQUAs+TDzuQ6okWSym5VqXawNhaM1AhiN9Laxj4u+MDqRvqsUHQSaRzB30SpG+g /r/fhRDdvV43tSuZKd0RxEE24S+jbx3CjBsmpZb0+Yiu60CZtYaO6dDyP3zlEirNQ9XU 63sUmcQ5MVLwf4ppXCQq0Ag/ybYKHSSQ/sUZ+bf2x79Fcjj9eu+vC6wuTo863QZMivAl jVJkLva/Bm0pfoxI3hDj0b9yfNzrJCPxFoyPRQIcSX3OfB4L+rwtfdyFGQI8nMA2i6j3 Bcww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=V1PecqOPB0whsTF/t6/yD1WKTOohBK61y9IJRTqNlIM=; b=RR15h+TObad9Ou2txz76p/B1NrPJx1aUElu/kSF55BhRJ/WKYI508ZSX5fxBZqXdeQ wZAJ4fLO9IaMeZ3LDIiR91XO0kmwZJS1BVjVbZpd405mx6agJcb47oc2cLUoO+urTmGY Ua/VL1wtIOlLKvqM5QPXZkphx96qvbABwaUYN6Ju2JFNgFMlFVu7WfawUTjIOi2lN2XE EyvQHFx/E73eWYYlTPoE0sUwPs5QHie5ar+n1lF5hjM2YFeIy63jS6twEmTyjhOoQece xi8OGVOY04i73VGM0Lv3hHhTp4MjdxlskleChziDojOylC9bkGQjvFOChUF6zLAdVuKk 4Zbw== X-Gm-Message-State: ALoCoQmbewZ/hdJXGdhy9NcFv2TzPWapkVM5sCMNIJwvBHOXdtEsXLG8WsKGEeHLdWa8YOPH9arD X-Received: by 10.50.61.179 with SMTP id q19mr107876igr.24.1438033731234; Mon, 27 Jul 2015 14:48:51 -0700 (PDT) Received: from kaki.bld.corp.google.com ([172.29.216.32]) by smtp.gmail.com with ESMTPSA id ht6sm6943112igb.11.2015.07.27.14.48.48 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Jul 2015 14:48:49 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id BDB102218A8; Mon, 27 Jul 2015 15:48:46 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 27 Jul 2015 15:47:27 -0600 Message-Id: <1438033652-30435-12-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.5.0.rc2.392.g76e840b In-Reply-To: <1438033652-30435-1-git-send-email-sjg@chromium.org> References: <1438033652-30435-1-git-send-email-sjg@chromium.org> Cc: Graeme Russ , Tom Rini Subject: [U-Boot] [PATCH 11/15] x86: Tidy up the PIRQ routing code a little X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This code could use a little tightening up. There is some repetition and an odd use of fdtdec_get_int_array(). Signed-off-by: Simon Glass --- arch/x86/cpu/irq.c | 40 +++++++++++++--------------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/arch/x86/cpu/irq.c b/arch/x86/cpu/irq.c index 97dd000..9d1128a 100644 --- a/arch/x86/cpu/irq.c +++ b/arch/x86/cpu/irq.c @@ -125,10 +125,10 @@ static int create_pirq_routing_table(void) return -EINVAL; } - ret = fdtdec_get_int_array(blob, node, "intel,pirq-link", - &irq_router.link_base, 1); - if (ret) + ret = fdtdec_get_int(blob, node, "intel,pirq-link", -1); + if (ret == -1) return ret; + irq_router.link_base = ret; irq_router.irq_mask = fdtdec_get_int(blob, node, "intel,pirq-mask", PIRQ_BITMAP); @@ -156,18 +156,13 @@ static int create_pirq_routing_table(void) } cell = fdt_getprop(blob, node, "intel,pirq-routing", &len); - if (!cell) - return -EINVAL; - - if ((len % sizeof(struct pirq_routing)) == 0) - count = len / sizeof(struct pirq_routing); - else + if (!cell || len % sizeof(struct pirq_routing)) return -EINVAL; + count = len / sizeof(struct pirq_routing); - rt = malloc(sizeof(struct irq_routing_table)); + rt = calloc(1, sizeof(struct irq_routing_table)); if (!rt) return -ENOMEM; - memset((char *)rt, 0, sizeof(struct irq_routing_table)); /* Populate the PIRQ table fields */ rt->signature = PIRQ_SIGNATURE; @@ -181,7 +176,8 @@ static int create_pirq_routing_table(void) slot_base = rt->slots; /* Now fill in the irq_info entries in the PIRQ table */ - for (i = 0; i < count; i++) { + for (i = 0; i < count; + i++, cell += sizeof(struct pirq_routing) / sizeof(u32)) { struct pirq_routing pr; pr.bdf = fdt_addr_to_cpu(cell[0]); @@ -212,25 +208,15 @@ static int create_pirq_routing_table(void) if (slot->irq[pr.pin - 1].link != LINK_N2V(pr.pirq, irq_router.link_base)) debug("WARNING: Inconsistent PIRQ routing information\n"); - - cell += sizeof(struct pirq_routing) / - sizeof(u32); - continue; - } else { - debug("writing INT%c\n", 'A' + pr.pin - 1); - fill_irq_info(slot, PCI_BUS(pr.bdf), - PCI_DEV(pr.bdf), pr.pin, pr.pirq); - cell += sizeof(struct pirq_routing) / - sizeof(u32); continue; } + } else { + slot = slot_base + irq_entries; } - - slot = slot_base + irq_entries; - fill_irq_info(slot, PCI_BUS(pr.bdf), PCI_DEV(pr.bdf), - pr.pin, pr.pirq); + debug("writing INT%c\n", 'A' + pr.pin - 1); + fill_irq_info(slot, PCI_BUS(pr.bdf), PCI_DEV(pr.bdf), pr.pin, + pr.pirq); irq_entries++; - cell += sizeof(struct pirq_routing) / sizeof(u32); } rt->size = irq_entries * sizeof(struct irq_info) + 32;