Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5173631yba; Tue, 30 Apr 2019 10:16:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqx6v5QBn8lTP9FZNYK9/lWmSiOI4lx09HPU3NCyItYXMnQk48rm7YHhdoR8vE4broCE2JJT X-Received: by 2002:a63:360e:: with SMTP id d14mr67855338pga.188.1556644585638; Tue, 30 Apr 2019 10:16:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556644585; cv=none; d=google.com; s=arc-20160816; b=BxCaKG4YhzdfR6tlG/HG+xFKVUuohir9ertvKq3kkxQ3AJk7Zi/wyxvx7ew+uI3Cne ktOYfGr55VhCO5X5+9WArn5Wlzio818zf4ZGuF263qRma1zlKmH7TP3+i4eIdgxDT1tl MCZcx4JMCiJl20CK7vk028Kv87OChc3PtKhSeFgKYsmYWjJrdF4n0PKUgN4ytCMYWP7M OEvscqdoB4r3ly0WKPT7K/ds7xcpCvY6dlR3+4m+oMG3s5WCKEptLNCNuQxZXlOhVzGl rKvFM7tZSvEGWcRCTNssim8ucFXBt+9xggGkVnlOL78X1y8YnF1zkxCFlxWnFFEd1ehV 6UeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=A7G/2KqxzWbTnXWEeSBLCU6DxyGDCeHI1S20L1RVAek=; b=OsoBiFaVj0ygxDUl+4XNUbfpaMONUK8JNQoVX7j4w6D5eO3zQqfPOnjZbIR2535K5J R/sj7KiL8EXmotw7gMDmlp84Mu/gkWUy1FT9i+lvdQ6Axj3tErTEXtpM01S4bTDmditS js5uvbCoDddisJcSLD5K4NpG0XDDDs63E/YCOBcE8ICli1yO2KNAWUCu0roeAe5MPUlH dGFKVBa6HD/dhNAYBrtN7B+GZWKwOV5cwNlAP+u/9iTZGcE+MvyoaO747CMIo6MZ+5zI nvPjE83G2PSTLM69TmeHafxBjLtQeAS++y4Z+L4mm1NfvshhYaLvvZZEAizeWUwlTQka cElw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=jaHONJag; 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 h11si35470413pgv.163.2019.04.30.10.16.08; Tue, 30 Apr 2019 10:16:25 -0700 (PDT) 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; dkim=pass header.i=@c-s.fr header.s=mail header.b=jaHONJag; 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 S1726894AbfD3ROP (ORCPT + 99 others); Tue, 30 Apr 2019 13:14:15 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:57191 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726608AbfD3ROO (ORCPT ); Tue, 30 Apr 2019 13:14:14 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 44tp6C0br5z9v1kD; Tue, 30 Apr 2019 19:14:11 +0200 (CEST) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=jaHONJag; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id 28SLzoUUzGbw; Tue, 30 Apr 2019 19:14:11 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 44tp6B6dMTz9v1kB; Tue, 30 Apr 2019 19:14:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1556644450; bh=A7G/2KqxzWbTnXWEeSBLCU6DxyGDCeHI1S20L1RVAek=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=jaHONJagi6eI3MX1rdfK9DvAXTJkyerHUQjLKdbaUtvJNKk5z0ocxab5JJgVi86L5 Etpb3NORzRIkuPSFgW8Prlik24h43ZjpW/I9nX4HXSLdJMDzy7O+YJt3mvlUq2WgVX tv0cNM+egOUkeAwRFOTtEKUq/Otwx9PD2jgiuC7s= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id A2F3E8B8F3; Tue, 30 Apr 2019 19:14:12 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id 2aqvcPYnRHU3; Tue, 30 Apr 2019 19:14:12 +0200 (CEST) Received: from PO15451 (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id F40AD8B8DF; Tue, 30 Apr 2019 19:14:11 +0200 (CEST) Subject: Re: [PATCH 3/5] soc/fsl/qe: qe.c: introduce qe_get_device_node helper To: Rasmus Villemoes , Qiang Zhao , Li Yang Cc: Valentin Longchamp , "linux-kernel@vger.kernel.org" , Scott Wood , Rasmus Villemoes , Rob Herring , "linuxppc-dev@lists.ozlabs.org" , "linux-arm-kernel@lists.infradead.org" References: <20190430133615.25721-1-rasmus.villemoes@prevas.dk> <20190430133615.25721-4-rasmus.villemoes@prevas.dk> From: Christophe Leroy Message-ID: <263abc47-3334-01b5-49ca-2d876a9ea537@c-s.fr> Date: Tue, 30 Apr 2019 19:14:11 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190430133615.25721-4-rasmus.villemoes@prevas.dk> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 30/04/2019 à 15:36, Rasmus Villemoes a écrit : > The 'try of_find_compatible_node(NULL, NULL, "fsl,qe"), fall back to > of_find_node_by_type(NULL, "qe")' pattern is repeated five > times. Factor it into a common helper. > > Signed-off-by: Rasmus Villemoes Reviewed-by: Christophe Leroy > --- > drivers/soc/fsl/qe/qe.c | 71 +++++++++++++++++------------------------ > 1 file changed, 29 insertions(+), 42 deletions(-) > > diff --git a/drivers/soc/fsl/qe/qe.c b/drivers/soc/fsl/qe/qe.c > index d0393f83145c..aff9d1373529 100644 > --- a/drivers/soc/fsl/qe/qe.c > +++ b/drivers/soc/fsl/qe/qe.c > @@ -56,6 +56,20 @@ static unsigned int qe_num_of_snum; > > static phys_addr_t qebase = -1; > > +static struct device_node *qe_get_device_node(void) > +{ > + struct device_node *qe; > + > + /* > + * Newer device trees have an "fsl,qe" compatible property for the QE > + * node, but we still need to support older device trees. > + */ > + qe = of_find_compatible_node(NULL, NULL, "fsl,qe"); > + if (qe) > + return qe; > + return of_find_node_by_type(NULL, "qe"); > +} > + > static phys_addr_t get_qe_base(void) > { > struct device_node *qe; > @@ -65,12 +79,9 @@ static phys_addr_t get_qe_base(void) > if (qebase != -1) > return qebase; > > - qe = of_find_compatible_node(NULL, NULL, "fsl,qe"); > - if (!qe) { > - qe = of_find_node_by_type(NULL, "qe"); > - if (!qe) > - return qebase; > - } > + qe = qe_get_device_node(); > + if (!qe) > + return qebase; > > ret = of_address_to_resource(qe, 0, &res); > if (!ret) > @@ -164,12 +175,9 @@ unsigned int qe_get_brg_clk(void) > if (brg_clk) > return brg_clk; > > - qe = of_find_compatible_node(NULL, NULL, "fsl,qe"); > - if (!qe) { > - qe = of_find_node_by_type(NULL, "qe"); > - if (!qe) > - return brg_clk; > - } > + qe = qe_get_device_node(); > + if (!qe) > + return brg_clk; > > prop = of_get_property(qe, "brg-frequency", &size); > if (prop && size == sizeof(*prop)) > @@ -563,16 +571,9 @@ struct qe_firmware_info *qe_get_firmware_info(void) > > initialized = 1; > > - /* > - * Newer device trees have an "fsl,qe" compatible property for the QE > - * node, but we still need to support older device trees. > - */ > - qe = of_find_compatible_node(NULL, NULL, "fsl,qe"); > - if (!qe) { > - qe = of_find_node_by_type(NULL, "qe"); > - if (!qe) > - return NULL; > - } > + qe = qe_get_device_node(); > + if (!qe) > + return NULL; > > /* Find the 'firmware' child node */ > fw = of_get_child_by_name(qe, "firmware"); > @@ -618,16 +619,9 @@ unsigned int qe_get_num_of_risc(void) > unsigned int num_of_risc = 0; > const u32 *prop; > > - qe = of_find_compatible_node(NULL, NULL, "fsl,qe"); > - if (!qe) { > - /* Older devices trees did not have an "fsl,qe" > - * compatible property, so we need to look for > - * the QE node by name. > - */ > - qe = of_find_node_by_type(NULL, "qe"); > - if (!qe) > - return num_of_risc; > - } > + qe = qe_get_device_node(); > + if (!qe) > + return num_of_risc; > > prop = of_get_property(qe, "fsl,qe-num-riscs", &size); > if (prop && size == sizeof(*prop)) > @@ -647,16 +641,9 @@ unsigned int qe_get_num_of_snums(void) > const u32 *prop; > > num_of_snums = 28; /* The default number of snum for threads is 28 */ > - qe = of_find_compatible_node(NULL, NULL, "fsl,qe"); > - if (!qe) { > - /* Older devices trees did not have an "fsl,qe" > - * compatible property, so we need to look for > - * the QE node by name. > - */ > - qe = of_find_node_by_type(NULL, "qe"); > - if (!qe) > - return num_of_snums; > - } > + qe = qe_get_device_node(); > + if (!qe) > + return num_of_snums; > > prop = of_get_property(qe, "fsl,qe-num-snums", &size); > if (prop && size == sizeof(*prop)) { >