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>

authored by Rob Herring (Arm) and committed by Jassi Brar 263dbd3c dc09f007

+6 -16
+6 -16
drivers/mailbox/mailbox.c
··· 450 450 const char *name) 451 451 { 452 452 struct device_node *np = cl->dev->of_node; 453 - struct property *prop; 454 - const char *mbox_name; 455 - int index = 0; 453 + int index; 456 454 457 455 if (!np) { 458 456 dev_err(cl->dev, "%s() currently only supports DT\n", __func__); 459 457 return ERR_PTR(-EINVAL); 460 458 } 461 459 462 - if (!of_get_property(np, "mbox-names", NULL)) { 463 - dev_err(cl->dev, 464 - "%s() requires an \"mbox-names\" property\n", __func__); 460 + index = of_property_match_string(np, "mbox-names", name); 461 + if (index < 0) { 462 + dev_err(cl->dev, "%s() could not locate channel named \"%s\"\n", 463 + __func__, name); 465 464 return ERR_PTR(-EINVAL); 466 465 } 467 - 468 - of_property_for_each_string(np, "mbox-names", prop, mbox_name) { 469 - if (!strncmp(name, mbox_name, strlen(name))) 470 - return mbox_request_channel(cl, index); 471 - index++; 472 - } 473 - 474 - dev_err(cl->dev, "%s() could not locate channel named \"%s\"\n", 475 - __func__, name); 476 - return ERR_PTR(-EINVAL); 466 + return mbox_request_channel(cl, index); 477 467 } 478 468 EXPORT_SYMBOL_GPL(mbox_request_channel_byname); 479 469