From: "dmitry.torokhov@gmail.com" <dmitry.torokhov@gmail.com>
To: Jun Li <jun.li@nxp.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
"heikki.krogerus@linux.intel.com"
<heikki.krogerus@linux.intel.com>,
"robh+dt@kernel.org" <robh+dt@kernel.org>,
"rafael@kernel.org" <rafael@kernel.org>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"hdegoede@redhat.com" <hdegoede@redhat.com>,
"lee.jones@linaro.org" <lee.jones@linaro.org>,
"mika.westerberg@linux.intel.com"
<mika.westerberg@linux.intel.com>,
"prabhakar.mahadev-lad.rj@bp.renesas.com"
<prabhakar.mahadev-lad.rj@bp.renesas.com>,
"laurent.pinchart+renesas@ideasonboard.com"
<laurent.pinchart+renesas@ideasonboard.com>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
dl-linux-imx <linux-imx@nxp.com>, Peter Chen <peter.chen@nxp.com>
Subject: Re: [PATCH v4 2/4] device property: Add fwnode_is_compatible() and device_is_compatible() helpers
Date: Wed, 21 Oct 2020 11:55:47 -0700 [thread overview]
Message-ID: <20201021185547.GC444962@dtor-ws> (raw)
In-Reply-To: <VE1PR04MB652805416A0A85E45FFD106E891F0@VE1PR04MB6528.eurprd04.prod.outlook.com>
On Tue, Oct 20, 2020 at 11:13:47AM +0000, Jun Li wrote:
>
>
> > -----Original Message-----
> > From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > Sent: Monday, October 19, 2020 8:25 PM
> > To: Jun Li <jun.li@nxp.com>
> > Cc: heikki.krogerus@linux.intel.com; robh+dt@kernel.org;
> > rafael@kernel.org; gregkh@linuxfoundation.org; hdegoede@redhat.com;
> > lee.jones@linaro.org; mika.westerberg@linux.intel.com;
> > dmitry.torokhov@gmail.com; prabhakar.mahadev-lad.rj@bp.renesas.com;
> > laurent.pinchart+renesas@ideasonboard.com; linux-usb@vger.kernel.org;
> > devicetree@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>; Peter Chen
> > <peter.chen@nxp.com>
> > Subject: Re: [PATCH v4 2/4] device property: Add fwnode_is_compatible() and
> > device_is_compatible() helpers
> >
> > On Mon, Oct 19, 2020 at 05:03:13PM +0800, Li Jun wrote:
> > > From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > >
> > > Since there are also some ACPI platforms where the "compatible"
> > > property is used, introducing a generic helper function
> > > fwnode_is_compatible() that can be used with DT, ACPI and swnodes, and
> > > a wrapper function
> > > device_is_compatible() with it.
> > >
> > > The function calls of_device_is_comaptible() with OF nodes, and with
> > > ACPI and swnodes it matches the given string against the "compatible"
> > > string property array.
> >
> > ...
> >
> > > + * Match the compatible strings of @fwnode against @compat. Returns
> > > + positive
> > > + * value on match, and 0 when no matching compatible string is found.
> >
> > Please move Returns... to a separate paragraph.
>
> OK, will change.
>
> >
> > Btw, this is not true...
> >
> > > +int fwnode_is_compatible(struct fwnode_handle *fwnode, const char
> > > +*compat) {
> > > + int ret;
> > > +
> > > + if (is_of_node(fwnode))
> > > + return of_device_is_compatible(to_of_node(fwnode), compat);
> > > +
> > > + ret = fwnode_property_match_string(fwnode, "compatible", compat);
> > > +
> >
> > > + return ret < 0 ? 0 : 1;
> >
> > ...and this is at least strange after all.
>
> of_device_is_compatible() will return positive value on match, and 0
> when no matching,
> fwnode_property_match_string() will return 0 if the property was found
> (success); and negative error code on failure. so the return conversion
> of fwnode_property_match_string () should work here.
Yes, but please make the function return bool instead of int.
of_device_is_compatible() returns "score", so it is int, but here we
only want yes/no.
So
return fwnode_property_match_string(...) == 0;
Thanks.
--
Dmitry
next prev parent reply other threads:[~2020-10-21 18:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-19 9:03 [PATCH v4 1/4] dt-bindings: usb: add documentation for typec switch simple driver Li Jun
2020-10-19 9:03 ` [PATCH v4 2/4] device property: Add fwnode_is_compatible() and device_is_compatible() helpers Li Jun
2020-10-19 12:25 ` Andy Shevchenko
2020-10-20 11:13 ` Jun Li
2020-10-20 12:06 ` Andy Shevchenko
2020-10-21 18:55 ` dmitry.torokhov [this message]
2020-10-22 11:03 ` Jun Li
2020-10-19 9:03 ` [PATCH v4 3/4] usb: typec: mux: add "compatible" property for switch match Li Jun
2020-10-20 6:05 ` Peter Chen
2020-10-20 13:02 ` Jun Li
2020-10-21 0:16 ` Peter Chen
2020-10-21 2:43 ` Jun Li
2020-10-19 9:03 ` [PATCH v4 4/4] usb: typec: mux: add typec switch simple driver Li Jun
2020-10-19 12:31 ` Andy Shevchenko
2020-10-20 12:48 ` Jun Li
2020-10-21 19:55 ` dmitry.torokhov
2020-10-22 11:52 ` Jun Li
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=20201021185547.GC444962@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=hdegoede@redhat.com \
--cc=heikki.krogerus@linux.intel.com \
--cc=jun.li@nxp.com \
--cc=laurent.pinchart+renesas@ideasonboard.com \
--cc=lee.jones@linaro.org \
--cc=linux-imx@nxp.com \
--cc=linux-usb@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=peter.chen@nxp.com \
--cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
--cc=rafael@kernel.org \
--cc=robh+dt@kernel.org \
/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).