* [PATCH 5.10.y-cip 1/2] of: Change of_machine_is_compatible() to return bool
2026-08-28 1:51 [PATCH 5.10.y-cip 0/2] Fix for module build in ohci-platform.c Nobuhiro Iwamatsu
@ 2026-08-28 1:51 ` Nobuhiro Iwamatsu
2026-08-28 1:51 ` [PATCH 5.10.y-cip 2/2] of: Reimplement of_machine_is_compatible() using of_machine_compatible_match() Nobuhiro Iwamatsu
2026-08-30 6:46 ` [PATCH 5.10.y-cip 0/2] Fix for module build in ohci-platform.c Pavel Machek
2 siblings, 0 replies; 5+ messages in thread
From: Nobuhiro Iwamatsu @ 2026-08-28 1:51 UTC (permalink / raw)
To: cip-dev; +Cc: pavel, uli, claudiu.beznea.uj, Nobuhiro Iwamatsu
From: Michael Ellerman <mpe@ellerman.id.au>
commit cefdb366dcbe97908b6055595a15bf7689556bf8 upstream.
of_machine_is_compatible() currently returns a positive integer if it
finds a match. However none of the callers ever check the value, they
all treat it as a true/false.
So change of_machine_is_compatible() to return bool, which will allow
the implementation to be changed in a subsequent patch.
Suggested-by: Rob Herring <robh@kernel.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20231214103152.12269-2-mpe@ellerman.id.au
Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.x90@mail.toshiba>
---
drivers/of/base.c | 5 ++---
include/linux/of.h | 2 +-
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 3c92edc3d17f7..ca3e6e4bb2ec3 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -582,10 +582,9 @@ 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.
+ * Return: true if the root node has the given value in its compatible property.
*/
-int of_machine_is_compatible(const char *compat)
+bool of_machine_is_compatible(const char *compat)
{
struct device_node *root;
int rc = 0;
diff --git a/include/linux/of.h b/include/linux/of.h
index 5f4dd8db7a674..3726ae11430b1 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -399,7 +399,7 @@ extern int of_alias_get_alias_list(const struct of_device_id *matches,
const char *stem, unsigned long *bitmap,
unsigned int nbits);
-extern int of_machine_is_compatible(const char *compat);
+extern bool of_machine_is_compatible(const char *compat);
bool of_machine_compatible_match(const char *const *compats);
extern int of_add_property(struct device_node *np, struct property *prop);
--
2.39.5
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 5.10.y-cip 2/2] of: Reimplement of_machine_is_compatible() using of_machine_compatible_match()
2026-08-28 1:51 [PATCH 5.10.y-cip 0/2] Fix for module build in ohci-platform.c Nobuhiro Iwamatsu
2026-08-28 1:51 ` [PATCH 5.10.y-cip 1/2] of: Change of_machine_is_compatible() to return bool Nobuhiro Iwamatsu
@ 2026-08-28 1:51 ` Nobuhiro Iwamatsu
2026-08-30 6:46 ` [PATCH 5.10.y-cip 0/2] Fix for module build in ohci-platform.c Pavel Machek
2 siblings, 0 replies; 5+ messages in thread
From: Nobuhiro Iwamatsu @ 2026-08-28 1:51 UTC (permalink / raw)
To: cip-dev; +Cc: pavel, uli, claudiu.beznea.uj, Nobuhiro Iwamatsu
From: Christophe Leroy <christophe.leroy@csgroup.eu>
commit 1ac8205f907517a306b661212496fedce79d7cc5 upstream.
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>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20231214103152.12269-3-mpe@ellerman.id.au
Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.x90@mail.toshiba>
Fixes: 22cb10519e8f (”of: Add of_machine_compatible_match()“)
---
drivers/of/base.c | 21 +--------------------
include/linux/of.h | 14 +++++++++++++-
2 files changed, 14 insertions(+), 21 deletions(-)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index ca3e6e4bb2ec3..896df5acf6931 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -577,26 +577,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: true if the root node has the given value in its compatible property.
- */
-bool 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 3726ae11430b1..32be78c366a30 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -399,9 +399,21 @@ extern int of_alias_get_alias_list(const struct of_device_id *matches,
const char *stem, unsigned long *bitmap,
unsigned int nbits);
-extern bool 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: true if the root node has the given value in its compatible property.
+ */
+static inline bool of_machine_is_compatible(const char *compat)
+{
+ const char *compats[] = { compat, NULL };
+
+ return of_machine_compatible_match(compats);
+}
+
extern int of_add_property(struct device_node *np, struct property *prop);
extern int of_remove_property(struct device_node *np, struct property *prop);
extern int of_update_property(struct device_node *np, struct property *newprop);
--
2.39.5
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 5.10.y-cip 0/2] Fix for module build in ohci-platform.c
2026-08-28 1:51 [PATCH 5.10.y-cip 0/2] Fix for module build in ohci-platform.c Nobuhiro Iwamatsu
2026-08-28 1:51 ` [PATCH 5.10.y-cip 1/2] of: Change of_machine_is_compatible() to return bool Nobuhiro Iwamatsu
2026-08-28 1:51 ` [PATCH 5.10.y-cip 2/2] of: Reimplement of_machine_is_compatible() using of_machine_compatible_match() Nobuhiro Iwamatsu
@ 2026-08-30 6:46 ` Pavel Machek
2026-09-01 5:26 ` [cip-dev] " nobuhiro.iwamatsu.x90
2 siblings, 1 reply; 5+ messages in thread
From: Pavel Machek @ 2026-08-30 6:46 UTC (permalink / raw)
To: Nobuhiro Iwamatsu; +Cc: cip-dev, pavel, uli, claudiu.beznea.uj
[-- Attachment #1: Type: text/plain, Size: 413 bytes --]
Hi!
> The commit “22cb10519e8f (”of: Add of_machine_compatible_match()“)”,
> which was backported to 5.10.y-cip, causes an error when building the
> module in ohci-platform.c.
> This fixes an issue with of_machine_compatible_match().
This looks okay to me.
Reviewed-by: Pavel Machek <pavel@nabladev.com>
Best regards,
Pavel
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread* RE: [cip-dev] [PATCH 5.10.y-cip 0/2] Fix for module build in ohci-platform.c
2026-08-30 6:46 ` [PATCH 5.10.y-cip 0/2] Fix for module build in ohci-platform.c Pavel Machek
@ 2026-09-01 5:26 ` nobuhiro.iwamatsu.x90
0 siblings, 0 replies; 5+ messages in thread
From: nobuhiro.iwamatsu.x90 @ 2026-09-01 5:26 UTC (permalink / raw)
To: pavel; +Cc: cip-dev, uli, claudiu.beznea.uj
Hi Pavel,
> -----Original Message-----
> From: cip-dev@lists.cip-project.org <cip-dev@lists.cip-project.org> On
> Behalf Of Pavel Machek via lists.cip-project.org
> Sent: Sunday, August 30, 2026 3:47 PM
> To: iwamatsu nobuhiro(岩松 信洋 □DITC○CPT)
> <nobuhiro.iwamatsu.x90@mail.toshiba>
> Cc: cip-dev@lists.cip-project.org; pavel@nabladev.com; uli@fpond.eu;
> claudiu.beznea.uj@bp.renesas.com
> Subject: Re: [cip-dev] [PATCH 5.10.y-cip 0/2] Fix for module build in
> ohci-platform.c
>
> Hi!
>
> > The commit “22cb10519e8f (”of: Add of_machine_compatible_match()“)”,
> > which was backported to 5.10.y-cip, causes an error when building the
> > module in ohci-platform.c.
> > This fixes an issue with of_machine_compatible_match().
>
> This looks okay to me.
>
> Reviewed-by: Pavel Machek <pavel@nabladev.com>
Thanks for your review. Applied, thanks!
Best regards,
Nobuhiro
^ permalink raw reply [flat|nested] 5+ messages in thread