mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@c-s.fr>
To: Rasmus Villemoes <rasmus.villemoes@prevas.dk>,
	Qiang Zhao <qiang.zhao@nxp.com>, Li Yang <leoyang.li@nxp.com>
Cc: Valentin Longchamp <valentin.longchamp@keymile.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Scott Wood <oss@buserror.net>,
	Rasmus Villemoes <Rasmus.Villemoes@prevas.se>,
	Rob Herring <robh+dt@kernel.org>,
	"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 3/5] soc/fsl/qe: qe.c: introduce qe_get_device_node helper
Date: Tue, 30 Apr 2019 19:14:11 +0200	[thread overview]
Message-ID: <263abc47-3334-01b5-49ca-2d876a9ea537@c-s.fr> (raw)
In-Reply-To: <20190430133615.25721-4-rasmus.villemoes@prevas.dk>



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 <rasmus.villemoes@prevas.dk>

Reviewed-by: Christophe Leroy <christophe.leroy@c-s.fr>


> ---
>   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)) {
> 

  reply	other threads:[~2019-04-30 17:14 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-30 13:36 [PATCH RESEND 0/5] soc/fsl/qe: cleanups and new DT binding Rasmus Villemoes
2019-04-30 13:36 ` [PATCH 1/5] soc/fsl/qe: qe.c: drop useless static qualifier Rasmus Villemoes
2019-04-30 17:03   ` Christophe Leroy
2019-04-30 13:36 ` [PATCH 2/5] soc/fsl/qe: qe.c: reduce static memory footprint by 1.7K Rasmus Villemoes
2019-04-30 17:12   ` Christophe Leroy
2019-05-01  5:51     ` Rasmus Villemoes
2019-04-30 13:36 ` [PATCH 3/5] soc/fsl/qe: qe.c: introduce qe_get_device_node helper Rasmus Villemoes
2019-04-30 17:14   ` Christophe Leroy [this message]
2019-04-30 13:36 ` [PATCH 4/5] soc/fsl/qe: qe.c: support fsl,qe-snums property Rasmus Villemoes
2019-04-30 17:19   ` Christophe Leroy
2019-05-01  6:00     ` Rasmus Villemoes
2019-04-30 13:36 ` [PATCH 5/5] soc/fsl/qe: qe.c: fold qe_get_num_of_snums into qe_snums_init Rasmus Villemoes
2019-04-30 17:27   ` Christophe Leroy
2019-05-01  9:29 ` [PATCH v2 0/6] soc/fsl/qe: cleanups and new DT binding Rasmus Villemoes
2019-05-01  9:29   ` [PATCH v2 1/6] soc/fsl/qe: qe.c: drop useless static qualifier Rasmus Villemoes
2019-05-01  9:29   ` [PATCH v2 2/6] soc/fsl/qe: qe.c: reduce static memory footprint by 1.7K Rasmus Villemoes
2019-05-02  4:51     ` Christophe Leroy
2019-05-01  9:29   ` [PATCH v2 3/6] soc/fsl/qe: qe.c: introduce qe_get_device_node helper Rasmus Villemoes
2019-05-01  9:29   ` [PATCH v2 4/6] dt-bindings: soc/fsl: qe: document new fsl,qe-snums binding Rasmus Villemoes
2019-05-01 15:12     ` Joakim Tjernlund
2019-05-01 18:47       ` Rasmus Villemoes
2019-05-01 21:00     ` Rob Herring
2019-05-01  9:29   ` [PATCH v2 5/6] soc/fsl/qe: qe.c: support fsl,qe-snums property Rasmus Villemoes
2019-05-02  4:52     ` Christophe Leroy
2019-05-01  9:29   ` [PATCH v2 6/6] soc/fsl/qe: qe.c: fold qe_get_num_of_snums into qe_snums_init Rasmus Villemoes
2019-05-02  4:54     ` Christophe Leroy
2019-05-09  2:35     ` [EXT] " Qiang Zhao
2019-05-13 11:14   ` [PATCH v3 0/6] soc/fsl/qe: cleanups and new DT binding Rasmus Villemoes
2019-05-13 11:14     ` [PATCH v3 1/6] soc/fsl/qe: qe.c: drop useless static qualifier Rasmus Villemoes
2019-05-13 11:14     ` [PATCH v3 2/6] soc/fsl/qe: qe.c: reduce static memory footprint by 1.7K Rasmus Villemoes
2019-05-13 11:14     ` [PATCH v3 3/6] soc/fsl/qe: qe.c: introduce qe_get_device_node helper Rasmus Villemoes
2019-05-13 11:14     ` [PATCH v3 4/6] dt-bindings: soc/fsl: qe: document new fsl,qe-snums binding Rasmus Villemoes
2019-05-13 11:39       ` Joakim Tjernlund
2019-05-13 17:51       ` Rob Herring
2019-05-13 11:15     ` [PATCH v3 5/6] soc/fsl/qe: qe.c: support fsl,qe-snums property Rasmus Villemoes
2019-05-13 11:15     ` [PATCH v3 6/6] soc/fsl/qe: qe.c: fold qe_get_num_of_snums into qe_snums_init Rasmus Villemoes
2019-06-03 19:53     ` [PATCH v3 0/6] soc/fsl/qe: cleanups and new DT binding Rasmus Villemoes
2019-06-03 19:55       ` Leo Li
2019-06-04 20:29     ` Li Yang

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=263abc47-3334-01b5-49ca-2d876a9ea537@c-s.fr \
    --to=christophe.leroy@c-s.fr \
    --cc=Rasmus.Villemoes@prevas.se \
    --cc=leoyang.li@nxp.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=oss@buserror.net \
    --cc=qiang.zhao@nxp.com \
    --cc=rasmus.villemoes@prevas.dk \
    --cc=robh+dt@kernel.org \
    --cc=valentin.longchamp@keymile.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

all inboxes | Powered by JetHome®