* [PATCH] mailbox: Use of_property_match_string() instead of open-coding
@ 2024-07-31 20:16 Rob Herring (Arm)
2024-09-03 19:17 ` Rob Herring
0 siblings, 1 reply; 5+ messages in thread
From: Rob Herring (Arm) @ 2024-07-31 20:16 UTC (permalink / raw)
To: Jassi Brar; +Cc: linux-kernel
Use of_property_match_string() instead of open-coding the search. With
this, of_get_property() can be removed as there is no need to check for
"mbox-names" presence first.
This is part of a larger effort to remove callers of of_get_property()
and similar functions. of_get_property() leaks the DT property data
pointer which is a problem for dynamically allocated nodes which may
be freed.
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
---
drivers/mailbox/mailbox.c | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index ebff3baf3045..d3d26a2c9895 100644
--- a/drivers/mailbox/mailbox.c
+++ b/drivers/mailbox/mailbox.c
@@ -450,30 +450,20 @@ struct mbox_chan *mbox_request_channel_byname(struct mbox_client *cl,
const char *name)
{
struct device_node *np = cl->dev->of_node;
- struct property *prop;
- const char *mbox_name;
- int index = 0;
+ int index;
if (!np) {
dev_err(cl->dev, "%s() currently only supports DT\n", __func__);
return ERR_PTR(-EINVAL);
}
- if (!of_get_property(np, "mbox-names", NULL)) {
- dev_err(cl->dev,
- "%s() requires an \"mbox-names\" property\n", __func__);
+ index = of_property_match_string(np, "mbox-names", name);
+ if (index < 0) {
+ dev_err(cl->dev, "%s() could not locate channel named \"%s\"\n",
+ __func__, name);
return ERR_PTR(-EINVAL);
}
-
- of_property_for_each_string(np, "mbox-names", prop, mbox_name) {
- if (!strncmp(name, mbox_name, strlen(name)))
- return mbox_request_channel(cl, index);
- index++;
- }
-
- dev_err(cl->dev, "%s() could not locate channel named \"%s\"\n",
- __func__, name);
- return ERR_PTR(-EINVAL);
+ return mbox_request_channel(cl, index);
}
EXPORT_SYMBOL_GPL(mbox_request_channel_byname);
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] mailbox: Use of_property_match_string() instead of open-coding
2024-07-31 20:16 [PATCH] mailbox: Use of_property_match_string() instead of open-coding Rob Herring (Arm)
@ 2024-09-03 19:17 ` Rob Herring
2024-09-03 21:05 ` Jassi Brar
0 siblings, 1 reply; 5+ messages in thread
From: Rob Herring @ 2024-09-03 19:17 UTC (permalink / raw)
To: Jassi Brar; +Cc: linux-kernel
On Wed, Jul 31, 2024 at 3:16 PM Rob Herring (Arm) <robh@kernel.org> wrote:
>
> Use of_property_match_string() instead of open-coding the search. With
> this, of_get_property() can be removed as there is no need to check for
> "mbox-names" presence first.
>
> This is part of a larger effort to remove callers of of_get_property()
> and similar functions. of_get_property() leaks the DT property data
> pointer which is a problem for dynamically allocated nodes which may
> be freed.
>
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> ---
> drivers/mailbox/mailbox.c | 22 ++++++----------------
> 1 file changed, 6 insertions(+), 16 deletions(-)
Ping!
>
> diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
> index ebff3baf3045..d3d26a2c9895 100644
> --- a/drivers/mailbox/mailbox.c
> +++ b/drivers/mailbox/mailbox.c
> @@ -450,30 +450,20 @@ struct mbox_chan *mbox_request_channel_byname(struct mbox_client *cl,
> const char *name)
> {
> struct device_node *np = cl->dev->of_node;
> - struct property *prop;
> - const char *mbox_name;
> - int index = 0;
> + int index;
>
> if (!np) {
> dev_err(cl->dev, "%s() currently only supports DT\n", __func__);
> return ERR_PTR(-EINVAL);
> }
>
> - if (!of_get_property(np, "mbox-names", NULL)) {
> - dev_err(cl->dev,
> - "%s() requires an \"mbox-names\" property\n", __func__);
> + index = of_property_match_string(np, "mbox-names", name);
> + if (index < 0) {
> + dev_err(cl->dev, "%s() could not locate channel named \"%s\"\n",
> + __func__, name);
> return ERR_PTR(-EINVAL);
> }
> -
> - of_property_for_each_string(np, "mbox-names", prop, mbox_name) {
> - if (!strncmp(name, mbox_name, strlen(name)))
> - return mbox_request_channel(cl, index);
> - index++;
> - }
> -
> - dev_err(cl->dev, "%s() could not locate channel named \"%s\"\n",
> - __func__, name);
> - return ERR_PTR(-EINVAL);
> + return mbox_request_channel(cl, index);
> }
> EXPORT_SYMBOL_GPL(mbox_request_channel_byname);
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] mailbox: Use of_property_match_string() instead of open-coding
2024-09-03 19:17 ` Rob Herring
@ 2024-09-03 21:05 ` Jassi Brar
2024-09-04 13:20 ` Rob Herring
0 siblings, 1 reply; 5+ messages in thread
From: Jassi Brar @ 2024-09-03 21:05 UTC (permalink / raw)
To: Rob Herring; +Cc: linux-kernel
On Tue, Sep 3, 2024 at 2:18 PM Rob Herring <robh@kernel.org> wrote:
>
> On Wed, Jul 31, 2024 at 3:16 PM Rob Herring (Arm) <robh@kernel.org> wrote:
> >
> > Use of_property_match_string() instead of open-coding the search. With
> > this, of_get_property() can be removed as there is no need to check for
> > "mbox-names" presence first.
> >
> > This is part of a larger effort to remove callers of of_get_property()
> > and similar functions. of_get_property() leaks the DT property data
> > pointer which is a problem for dynamically allocated nodes which may
> > be freed.
> >
> > Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> > ---
> > drivers/mailbox/mailbox.c | 22 ++++++----------------
> > 1 file changed, 6 insertions(+), 16 deletions(-)
>
> Ping!
>
Acked-by: Jassi Brar <jassisinghbrar@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mailbox: Use of_property_match_string() instead of open-coding
2024-09-03 21:05 ` Jassi Brar
@ 2024-09-04 13:20 ` Rob Herring
2024-09-04 14:44 ` Jassi Brar
0 siblings, 1 reply; 5+ messages in thread
From: Rob Herring @ 2024-09-04 13:20 UTC (permalink / raw)
To: Jassi Brar; +Cc: linux-kernel
On Tue, Sep 3, 2024 at 4:05 PM Jassi Brar <jassisinghbrar@gmail.com> wrote:
>
> On Tue, Sep 3, 2024 at 2:18 PM Rob Herring <robh@kernel.org> wrote:
> >
> > On Wed, Jul 31, 2024 at 3:16 PM Rob Herring (Arm) <robh@kernel.org> wrote:
> > >
> > > Use of_property_match_string() instead of open-coding the search. With
> > > this, of_get_property() can be removed as there is no need to check for
> > > "mbox-names" presence first.
> > >
> > > This is part of a larger effort to remove callers of of_get_property()
> > > and similar functions. of_get_property() leaks the DT property data
> > > pointer which is a problem for dynamically allocated nodes which may
> > > be freed.
> > >
> > > Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> > > ---
> > > drivers/mailbox/mailbox.c | 22 ++++++----------------
> > > 1 file changed, 6 insertions(+), 16 deletions(-)
> >
> > Ping!
> >
> Acked-by: Jassi Brar <jassisinghbrar@gmail.com>
Don't need an ack, are you going to apply?
Rob
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mailbox: Use of_property_match_string() instead of open-coding
2024-09-04 13:20 ` Rob Herring
@ 2024-09-04 14:44 ` Jassi Brar
0 siblings, 0 replies; 5+ messages in thread
From: Jassi Brar @ 2024-09-04 14:44 UTC (permalink / raw)
To: Rob Herring; +Cc: linux-kernel
On Wed, Sep 4, 2024 at 8:20 AM Rob Herring <robh@kernel.org> wrote:
>
> On Tue, Sep 3, 2024 at 4:05 PM Jassi Brar <jassisinghbrar@gmail.com> wrote:
> >
> > On Tue, Sep 3, 2024 at 2:18 PM Rob Herring <robh@kernel.org> wrote:
> > >
> > > On Wed, Jul 31, 2024 at 3:16 PM Rob Herring (Arm) <robh@kernel.org> wrote:
> > > >
> > > > Use of_property_match_string() instead of open-coding the search. With
> > > > this, of_get_property() can be removed as there is no need to check for
> > > > "mbox-names" presence first.
> > > >
> > > > This is part of a larger effort to remove callers of of_get_property()
> > > > and similar functions. of_get_property() leaks the DT property data
> > > > pointer which is a problem for dynamically allocated nodes which may
> > > > be freed.
> > > >
> > > > Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> > > > ---
> > > > drivers/mailbox/mailbox.c | 22 ++++++----------------
> > > > 1 file changed, 6 insertions(+), 16 deletions(-)
> > >
> > > Ping!
> > >
> > Acked-by: Jassi Brar <jassisinghbrar@gmail.com>
>
> Don't need an ack, are you going to apply?
>
Yes I was and will be if you won't.
-Jassi
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-09-04 14:44 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-31 20:16 [PATCH] mailbox: Use of_property_match_string() instead of open-coding Rob Herring (Arm)
2024-09-03 19:17 ` Rob Herring
2024-09-03 21:05 ` Jassi Brar
2024-09-04 13:20 ` Rob Herring
2024-09-04 14:44 ` Jassi Brar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox