From patchwork Mon Jul 24 15:14:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 108588 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp3963055obm; Mon, 24 Jul 2017 08:14:51 -0700 (PDT) X-Received: by 10.98.32.195 with SMTP id m64mr16243461pfj.66.1500909291798; Mon, 24 Jul 2017 08:14:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500909291; cv=none; d=google.com; s=arc-20160816; b=yNEhfN7CQt02hD5S0ojkcKrq26E6b0bEEmBRvqV2INlKYEfAhBczRHKyaLd67cdjiM fLzYtue6KDBaKmUzbJwErsTO4LFvql6ByUGCwy06bC0wr8iQmpiw7N1TZLRS98OmIBEA 1FigyK8rys/y7/Rz2C/NCCdcyM1qOjfn1n3KzxmDHbjqhhx7pQI0/1vpZYyZH94HWFIT iCFXtEKSSpuZyUDkWjVc+a1UJj07/t6+6CperCQ8zfFsAPbJFKNn/pwQJcanxiiiq5MM 8QuiQkdFO2BHtxlh5QNr83CUE1mm02BvV8ki0puIRKeL9rUIqb7E9yIYSvoXdrUpeyEa Exgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=CHSwK97q6zvWGeOTU4oXUCGdsolOehcQ3MJ6jQhmQb4=; b=NQJzWCuAVBT02xU5/JIYrgAIpb+9rVcAWgOwmpF4Gu1qR/7yncHWQ+r36POGOAIMKZ fhtovtnPDECtBHjp6sAX/xtr0jy0sxcG425klNP3KvAPx88aqpqANZlkK2NH5Y5OhEeJ IsETJr8MtZw3AJGr8o4lnLnVF4MWLqagKFXYz7ckUnlwfwj7Wat4T4nQn59MNFMOFEFz RNLIz/6nvORj7nb3Q3QAumQg7uuknkVi05SKl9HpdyipcFuHw/ywRubP9R6DkxvUZ/Q2 WaQImaChWDX/7aBduqpa2JFvs5TVefFzLEY5Nub0iHlZZ4X2/cVFQESvCfdSpySHxTGh JVHw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 h6si6805324pfb.126.2017.07.24.08.14.51; Mon, 24 Jul 2017 08:14:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-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 devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932419AbdGXPOu (ORCPT + 7 others); Mon, 24 Jul 2017 11:14:50 -0400 Received: from mail-yw0-f194.google.com ([209.85.161.194]:37291 "EHLO mail-yw0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932582AbdGXPOo (ORCPT ); Mon, 24 Jul 2017 11:14:44 -0400 Received: by mail-yw0-f194.google.com with SMTP id h189so5165481ywf.4; Mon, 24 Jul 2017 08:14:43 -0700 (PDT) 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:in-reply-to :references; bh=sB7sq2xvL+FsIQUk0ovHYrhDxiuUl7Ts122JqQbOnH4=; b=NY5U291VWOcgPJ626UYcBLTABxis01fRR5/pr2ud8WxqdHtF0HMIgLGVR7djHuPsoL Qn+lAwZMi2gYNe/bmJHhh7YXWI+qSVehsN0kirn9tfWUd6vJ2pmes3GpLCxC0HYNfcCy 8WtJL3ZqQVAQevpHG7MNZNaiEX1ZM45erx9/61n+IUlYvI6ciNCMDojffhkM01JiOFB+ WYL/Z3/laRXvgnmL9swB4flMddT1XJ7nknzozJNleMxb57DkHbeechEsvHtRcg3dRxrN wINgtWB9xblg4ZLWprYSlOGnqv/OTDrHJkVXpknA5onSP+45b6w+85zy+SPf20X/DBDM QFxw== X-Gm-Message-State: AIVw112H/4Xehk88r6Q2gwKCUknULpOBSsbcznodNvlCOXLqwvl0SByW PH0NT/y38CEe/rEgTHY= X-Received: by 10.129.114.4 with SMTP id n4mr5811888ywc.250.1500909283389; Mon, 24 Jul 2017 08:14:43 -0700 (PDT) Received: from localhost.localdomain (24-223-123-72.static.usa-companies.net. [24.223.123.72]) by smtp.googlemail.com with ESMTPSA id g203sm4124870ywa.86.2017.07.24.08.14.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Jul 2017 08:14:42 -0700 (PDT) From: Rob Herring To: Frank Rowand , Sergei Shtylyov Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] of/irq: use of_property_read_u32_index to parse interrupts property Date: Mon, 24 Jul 2017 10:14:38 -0500 Message-Id: <20170724151438.7069-2-robh@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170724151438.7069-1-robh@kernel.org> References: <20170724151438.7069-1-robh@kernel.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Convert the interrupts property parsing to use the OF property API instead of open coding the parsing of the raw property value. This saves a number of LoC, and the result is easier to read. Signed-off-by: Rob Herring --- drivers/of/irq.c | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/of/irq.c b/drivers/of/irq.c index abbd252fe25b..aa2a60c8868e 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -292,8 +292,8 @@ EXPORT_SYMBOL_GPL(of_irq_parse_raw); int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_args *out_irq) { struct device_node *p; - const __be32 *intspec, *addr; - u32 intsize, intlen; + const __be32 *addr; + u32 intsize; int i, res; pr_debug("of_irq_parse_one: dev=%pOF, index=%d\n", device, index); @@ -311,15 +311,6 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar if (!res) return of_irq_parse_raw(addr, out_irq); - /* Get the interrupts property */ - intspec = of_get_property(device, "interrupts", &intlen); - if (intspec == NULL) - return -EINVAL; - - intlen /= sizeof(*intspec); - - pr_debug(" intspec=%d intlen=%d\n", be32_to_cpup(intspec), intlen); - /* Look for the interrupt parent. */ p = of_irq_find_parent(device); if (p == NULL) @@ -331,20 +322,21 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar goto out; } - pr_debug(" intsize=%d intlen=%d\n", intsize, intlen); - - /* Check index */ - if ((index + 1) * intsize > intlen) { - res = -EINVAL; - goto out; - } + pr_debug(" parent=%pOF, intsize=%d\n", p, intsize); /* Copy intspec into irq structure */ - intspec += index * intsize; out_irq->np = p; out_irq->args_count = intsize; - for (i = 0; i < intsize; i++) - out_irq->args[i] = be32_to_cpup(intspec++); + for (i = 0; i < intsize; i++) { + res = of_property_read_u32_index(device, "interrupts", + (index * intsize) + i, + out_irq->args + i); + if (res) + goto out; + } + + pr_debug(" intspec=%d\n", *out_irq->args); + /* Check if there are any interrupt-map translations to process */ res = of_irq_parse_raw(addr, out_irq);