diff options
author | Rob Herring (Arm) <robh@kernel.org> | 2024-07-31 14:16:08 -0600 |
---|---|---|
committer | Jassi Brar <jassisinghbrar@gmail.com> | 2024-09-22 19:19:17 -0500 |
commit | 263dbd3cc88da7ea7413494eea66418b4f1b2e6d (patch) | |
tree | 321ba34a40c2c64c57c2faa0113daecb283d1310 /drivers/mailbox | |
parent | dc09f007caed3b2f6a3b6bd7e13777557ae22bfd (diff) | |
download | linux-stable-263dbd3cc88da7ea7413494eea66418b4f1b2e6d.tar.gz linux-stable-263dbd3cc88da7ea7413494eea66418b4f1b2e6d.tar.bz2 linux-stable-263dbd3cc88da7ea7413494eea66418b4f1b2e6d.zip |
mailbox: Use of_property_match_string() instead of open-coding
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>
Signed-off-by: Jassi Brar <jassisinghbrar@gmail.com>
Diffstat (limited to 'drivers/mailbox')
-rw-r--r-- | drivers/mailbox/mailbox.c | 22 |
1 files 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); |