linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linuxppc-dev@lists.ozlabs.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org,
	Qiang Zhao <qiang.zhao@nxp.com>, Li Yang <leoyang.li@nxp.com>,
	Daniel Scally <djrscally@gmail.com>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>
Subject: Re: [PATCH v2 1/2] device property: Introduce fwnode_device_is_compatible() helper
Date: Wed, 5 Oct 2022 21:05:54 +0000	[thread overview]
Message-ID: <Yz3xsmy/3wlntStv@paasikivi.fi.intel.com> (raw)
In-Reply-To: <20221005152947.71696-2-andriy.shevchenko@linux.intel.com>

Hi Andy,

On Wed, Oct 05, 2022 at 06:29:46PM +0300, Andy Shevchenko wrote:
> The fwnode_device_is_compatible() helper searches for the
> given string in the "compatible" string array property and,
> if found, returns true.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  include/linux/property.h | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/property.h b/include/linux/property.h
> index 1c26d263d5e4..701570423943 100644
> --- a/include/linux/property.h
> +++ b/include/linux/property.h
> @@ -55,7 +55,6 @@ int device_property_read_string(struct device *dev, const char *propname,
>  int device_property_match_string(struct device *dev,
>  				 const char *propname, const char *string);
>  
> -bool fwnode_device_is_available(const struct fwnode_handle *fwnode);
>  bool fwnode_property_present(const struct fwnode_handle *fwnode,
>  			     const char *propname);
>  int fwnode_property_read_u8_array(const struct fwnode_handle *fwnode,
> @@ -77,6 +76,15 @@ int fwnode_property_read_string(const struct fwnode_handle *fwnode,
>  				const char *propname, const char **val);
>  int fwnode_property_match_string(const struct fwnode_handle *fwnode,
>  				 const char *propname, const char *string);
> +
> +bool fwnode_device_is_available(const struct fwnode_handle *fwnode);
> +
> +static inline
> +bool fwnode_device_is_compatible(const struct fwnode_handle *fwnode, const char *compat)
> +{
> +	return fwnode_property_match_string(fwnode, "compatible", compat) >= 0;

fwnode_property_match_string() returns zero on success, therefore >= 0 is
not needed. I'd just use !fwnode_property_match_string(...).

For both patches:

Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>

> +}
> +
>  int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
>  				       const char *prop, const char *nargs_prop,
>  				       unsigned int nargs, unsigned int index,

-- 
Regards,

Sakari Ailus

  reply	other threads:[~2022-10-05 21:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-05 15:29 [PATCH v2 0/2] gpiolib: more cleanups to get rid of of_node Andy Shevchenko
2022-10-05 15:29 ` [PATCH v2 1/2] device property: Introduce fwnode_device_is_compatible() helper Andy Shevchenko
2022-10-05 21:05   ` Sakari Ailus [this message]
2022-10-06 12:34     ` Andy Shevchenko
2022-10-05 15:29 ` [PATCH v2 2/2] soc: fsl: qe: Switch to use fwnode instead of of_node Andy Shevchenko
2022-10-21 19:01 ` [PATCH v2 0/2] gpiolib: more cleanups to get rid " Andy Shevchenko
2022-11-02 11:01   ` Andy Shevchenko

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=Yz3xsmy/3wlntStv@paasikivi.fi.intel.com \
    --to=sakari.ailus@linux.intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=djrscally@gmail.com \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=leoyang.li@nxp.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=qiang.zhao@nxp.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;
as well as URLs for NNTP newsgroup(s).