From: Rob Herring <robh@kernel.org>
To: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: devicetree@vger.kernel.org, Frank Rowand <frowand.list@gmail.com>,
linux-kernel@vger.kernel.org, Nicholas Piggin <npiggin@gmail.com>,
linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v1 2/4] of: Reimplement of_machine_is_compatible() using of_machine_compatible_match()
Date: Thu, 7 Dec 2023 14:26:41 -0600 [thread overview]
Message-ID: <20231207202641.GA3351234-robh@kernel.org> (raw)
In-Reply-To: <ea64ede738fe51d46ab6be6aa1fc74029372f6e9.1701878821.git.christophe.leroy@csgroup.eu>
On Wed, Dec 06, 2023 at 05:13:33PM +0100, Christophe Leroy wrote:
> of_machine_compatible_match() works with a table of strings.
> of_machine_is_compatible() is a simplier version with only one string.
>
> Re-implement of_machine_is_compatible() by setting a table of strings
> with a single string then using of_machine_compatible_match().
>
> Suggested-by: Rob Herring <robh+dt@kernel.org>
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
> drivers/of/base.c | 22 +---------------------
> include/linux/of.h | 15 ++++++++++++++-
> 2 files changed, 15 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 9020be2eb4d5..73c3a754bad1 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -414,27 +414,7 @@ bool of_machine_compatible_match(const char *const *compats)
>
> return rc != 0;
> }
> -
> -/**
> - * of_machine_is_compatible - Test root of device tree for a given compatible value
> - * @compat: compatible string to look for in root node's compatible property.
> - *
> - * Return: A positive integer if the root node has the given value in its
> - * compatible property.
> - */
> -int of_machine_is_compatible(const char *compat)
> -{
> - struct device_node *root;
> - int rc = 0;
> -
> - root = of_find_node_by_path("/");
> - if (root) {
> - rc = of_device_is_compatible(root, compat);
> - of_node_put(root);
> - }
> - return rc;
> -}
> -EXPORT_SYMBOL(of_machine_is_compatible);
> +EXPORT_SYMBOL(of_machine_compatible_match);
>
> /**
> * __of_device_is_available - check if a device is available for use
> diff --git a/include/linux/of.h b/include/linux/of.h
> index e3418babc203..a0f70be5007f 100644
> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -402,9 +402,22 @@ extern void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align));
> extern int of_alias_get_id(struct device_node *np, const char *stem);
> extern int of_alias_get_highest_id(const char *stem);
>
> -extern int of_machine_is_compatible(const char *compat);
> bool of_machine_compatible_match(const char *const *compats);
>
> +/**
> + * of_machine_is_compatible - Test root of device tree for a given compatible value
> + * @compat: compatible string to look for in root node's compatible property.
> + *
> + * Return: A positive integer if the root node has the given value in its
> + * compatible property.
There is a subtle change that we really only return true/false instead
of a score. In a quick scan, I don't see any callers caring. Lots of
places we could use a list of compatibles instead though. Maybe this
should just return a bool instead of int? Either way:
Reviewed-by: Rob Herring <robh@kernel.org>
WARNING: multiple messages have this Message-ID (diff)
From: Rob Herring <robh@kernel.org>
To: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>,
Frank Rowand <frowand.list@gmail.com>,
linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH v1 2/4] of: Reimplement of_machine_is_compatible() using of_machine_compatible_match()
Date: Thu, 7 Dec 2023 14:26:41 -0600 [thread overview]
Message-ID: <20231207202641.GA3351234-robh@kernel.org> (raw)
In-Reply-To: <ea64ede738fe51d46ab6be6aa1fc74029372f6e9.1701878821.git.christophe.leroy@csgroup.eu>
On Wed, Dec 06, 2023 at 05:13:33PM +0100, Christophe Leroy wrote:
> of_machine_compatible_match() works with a table of strings.
> of_machine_is_compatible() is a simplier version with only one string.
>
> Re-implement of_machine_is_compatible() by setting a table of strings
> with a single string then using of_machine_compatible_match().
>
> Suggested-by: Rob Herring <robh+dt@kernel.org>
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
> drivers/of/base.c | 22 +---------------------
> include/linux/of.h | 15 ++++++++++++++-
> 2 files changed, 15 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 9020be2eb4d5..73c3a754bad1 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -414,27 +414,7 @@ bool of_machine_compatible_match(const char *const *compats)
>
> return rc != 0;
> }
> -
> -/**
> - * of_machine_is_compatible - Test root of device tree for a given compatible value
> - * @compat: compatible string to look for in root node's compatible property.
> - *
> - * Return: A positive integer if the root node has the given value in its
> - * compatible property.
> - */
> -int of_machine_is_compatible(const char *compat)
> -{
> - struct device_node *root;
> - int rc = 0;
> -
> - root = of_find_node_by_path("/");
> - if (root) {
> - rc = of_device_is_compatible(root, compat);
> - of_node_put(root);
> - }
> - return rc;
> -}
> -EXPORT_SYMBOL(of_machine_is_compatible);
> +EXPORT_SYMBOL(of_machine_compatible_match);
>
> /**
> * __of_device_is_available - check if a device is available for use
> diff --git a/include/linux/of.h b/include/linux/of.h
> index e3418babc203..a0f70be5007f 100644
> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -402,9 +402,22 @@ extern void of_alias_scan(void * (*dt_alloc)(u64 size, u64 align));
> extern int of_alias_get_id(struct device_node *np, const char *stem);
> extern int of_alias_get_highest_id(const char *stem);
>
> -extern int of_machine_is_compatible(const char *compat);
> bool of_machine_compatible_match(const char *const *compats);
>
> +/**
> + * of_machine_is_compatible - Test root of device tree for a given compatible value
> + * @compat: compatible string to look for in root node's compatible property.
> + *
> + * Return: A positive integer if the root node has the given value in its
> + * compatible property.
There is a subtle change that we really only return true/false instead
of a score. In a quick scan, I don't see any callers caring. Lots of
places we could use a list of compatibles instead though. Maybe this
should just return a bool instead of int? Either way:
Reviewed-by: Rob Herring <robh@kernel.org>
next prev parent reply other threads:[~2023-12-07 20:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-06 16:13 [PATCH v1 1/4] of: Add of_machine_compatible_match() Christophe Leroy
2023-12-06 16:13 ` Christophe Leroy
2023-12-06 16:13 ` [PATCH v1 2/4] of: Reimplement of_machine_is_compatible() using of_machine_compatible_match() Christophe Leroy
2023-12-06 16:13 ` Christophe Leroy
2023-12-07 20:26 ` Rob Herring [this message]
2023-12-07 20:26 ` Rob Herring
2023-12-06 16:13 ` [PATCH v1 3/4] powerpc/machdep: Define 'compatibles' property in ppc_md and use it Christophe Leroy
2023-12-06 16:13 ` Christophe Leroy
2023-12-07 20:15 ` Rob Herring
2023-12-07 20:15 ` Rob Herring
2023-12-06 16:13 ` [PATCH v1 4/4] powerpc: Stop using of_root Christophe Leroy
2023-12-06 16:13 ` Christophe Leroy
2023-12-07 20:15 ` Rob Herring
2023-12-07 20:15 ` Rob Herring
2023-12-07 20:16 ` [PATCH v1 1/4] of: Add of_machine_compatible_match() Rob Herring
2023-12-07 20:16 ` Rob Herring
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=20231207202641.GA3351234-robh@kernel.org \
--to=robh@kernel.org \
--cc=christophe.leroy@csgroup.eu \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=npiggin@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.