2023-06-09 15:59:49

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v2 2/3] device property: Implement device_is_compatible()

Some users want to use the struct device pointer to see if the
device is compatible in terms of Open Firmware specifications,
i.e. if it has a 'compatible' property and it matches to the
given value. Provide inline helper for the users.

Signed-off-by: Andy Shevchenko <[email protected]>
---
include/linux/property.h | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/include/linux/property.h b/include/linux/property.h
index 695053c60306..0222b77dd75c 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -85,6 +85,18 @@ bool fwnode_device_is_compatible(const struct fwnode_handle *fwnode, const char
return fwnode_property_match_string(fwnode, "compatible", compat) >= 0;
}

+/**
+ * device_is_compatible - match 'compatible' property of the device with a given string
+ * @dev: Pointer to the struct device
+ * @compat: The string to match 'compatible' property with
+ *
+ * Returns: true if matches, otherwise false.
+ */
+static inline bool device_is_compatible(const struct device *dev, const char *compat)
+{
+ return fwnode_device_is_compatible(dev_fwnode(dev), compat);
+}
+
int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
const char *prop, const char *nargs_prop,
unsigned int nargs, unsigned int index,
--
2.40.0.1.gaa8946217a0b



2023-06-12 09:29:43

by Sakari Ailus

[permalink] [raw]
Subject: Re: [PATCH v2 2/3] device property: Implement device_is_compatible()

Hi Andy,

On Fri, Jun 09, 2023 at 06:48:59PM +0300, Andy Shevchenko wrote:
> Some users want to use the struct device pointer to see if the
> device is compatible in terms of Open Firmware specifications,
> i.e. if it has a 'compatible' property and it matches to the
> given value. Provide inline helper for the users.
>
> Signed-off-by: Andy Shevchenko <[email protected]>

Reviewed-by: Sakari Ailus <[email protected]>

--
Sakari Ailus

2023-06-13 09:59:41

by Serge Semin

[permalink] [raw]
Subject: Re: [PATCH v2 2/3] device property: Implement device_is_compatible()

On Fri, Jun 09, 2023 at 06:48:59PM +0300, Andy Shevchenko wrote:
> Some users want to use the struct device pointer to see if the
> device is compatible in terms of Open Firmware specifications,
> i.e. if it has a 'compatible' property and it matches to the
> given value. Provide inline helper for the users.

IMO much useful wrapper. Thanks for the patch.
Reviewed-by: Serge Semin <[email protected]>

-Serge(y)

>
> Signed-off-by: Andy Shevchenko <[email protected]>
> ---
> include/linux/property.h | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/include/linux/property.h b/include/linux/property.h
> index 695053c60306..0222b77dd75c 100644
> --- a/include/linux/property.h
> +++ b/include/linux/property.h
> @@ -85,6 +85,18 @@ bool fwnode_device_is_compatible(const struct fwnode_handle *fwnode, const char
> return fwnode_property_match_string(fwnode, "compatible", compat) >= 0;
> }
>
> +/**
> + * device_is_compatible - match 'compatible' property of the device with a given string
> + * @dev: Pointer to the struct device
> + * @compat: The string to match 'compatible' property with
> + *
> + * Returns: true if matches, otherwise false.
> + */
> +static inline bool device_is_compatible(const struct device *dev, const char *compat)
> +{
> + return fwnode_device_is_compatible(dev_fwnode(dev), compat);
> +}
> +
> int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
> const char *prop, const char *nargs_prop,
> unsigned int nargs, unsigned int index,
> --
> 2.40.0.1.gaa8946217a0b
>
>


2023-06-13 15:33:50

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v2 2/3] device property: Implement device_is_compatible()

On Tue, Jun 13, 2023 at 12:45:08PM +0300, Serge Semin wrote:
> On Fri, Jun 09, 2023 at 06:48:59PM +0300, Andy Shevchenko wrote:
> > Some users want to use the struct device pointer to see if the
> > device is compatible in terms of Open Firmware specifications,
> > i.e. if it has a 'compatible' property and it matches to the
> > given value. Provide inline helper for the users.
>
> IMO much useful wrapper. Thanks for the patch.
> Reviewed-by: Serge Semin <[email protected]>

There is a v3. Do you mind to tag it as well?

--
With Best Regards,
Andy Shevchenko



2023-06-13 15:37:10

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v2 2/3] device property: Implement device_is_compatible()

On Tue, Jun 13, 2023 at 06:14:30PM +0300, Andy Shevchenko wrote:
> On Tue, Jun 13, 2023 at 12:45:08PM +0300, Serge Semin wrote:
> > On Fri, Jun 09, 2023 at 06:48:59PM +0300, Andy Shevchenko wrote:
> > > Some users want to use the struct device pointer to see if the
> > > device is compatible in terms of Open Firmware specifications,
> > > i.e. if it has a 'compatible' property and it matches to the
> > > given value. Provide inline helper for the users.
> >
> > IMO much useful wrapper. Thanks for the patch.
> > Reviewed-by: Serge Semin <[email protected]>
>
> There is a v3. Do you mind to tag it as well?

Ah, and thank you for review! Appreciate it.

--
With Best Regards,
Andy Shevchenko



2023-06-13 19:48:45

by Serge Semin

[permalink] [raw]
Subject: Re: [PATCH v2 2/3] device property: Implement device_is_compatible()

On Tue, Jun 13, 2023 at 06:14:51PM +0300, Andy Shevchenko wrote:
> On Tue, Jun 13, 2023 at 06:14:30PM +0300, Andy Shevchenko wrote:
> > On Tue, Jun 13, 2023 at 12:45:08PM +0300, Serge Semin wrote:
> > > On Fri, Jun 09, 2023 at 06:48:59PM +0300, Andy Shevchenko wrote:
> > > > Some users want to use the struct device pointer to see if the
> > > > device is compatible in terms of Open Firmware specifications,
> > > > i.e. if it has a 'compatible' property and it matches to the
> > > > given value. Provide inline helper for the users.
> > >
> > > IMO much useful wrapper. Thanks for the patch.
> > > Reviewed-by: Serge Semin <[email protected]>
> >
> > There is a v3. Do you mind to tag it as well?
>
> Ah, and thank you for review! Appreciate it.

Always welcome.) I've resent the tags for the patches 2 and 3. Patch 1
is out of my competence, sorry.

-Serge(y)

>
> --
> With Best Regards,
> Andy Shevchenko
>
>
>