mailbox: Use of_property_match_string() instead of open-coding
PATCH 1/1 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.
--- drivers/mailbox/mailbox.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-)
drivers/mailbox/mailbox.c +6 -16
@@ -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);
Signature · 1 line
2.43.0
Quoted 10 lines · Rob Herring (Arm)
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.
Quoted 4 lines
Signed-off-by Rob Herring (Arm) <[email protected]>--- drivers/mailbox/mailbox.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-)
Ping!
Quoted 45 lines
drivers/mailbox/mailbox.c +6
-17@@ -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
Quoted 12 lines · Rob Herring
Quoted 10 lines · Rob Herring (Arm)
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.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Rob Herring (Arm) <[email protected]>--- drivers/mailbox/mailbox.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-)Ping!
Quoted 14 lines · Jassi Brar
Quoted 12 lines · Rob Herring
Quoted 10 lines · Rob Herring (Arm)
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.
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Signed-off-by Rob Herring (Arm) <[email protected]>--- drivers/mailbox/mailbox.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-)Ping!
Acked-by Jassi Brar <[email protected]>
Don't need an ack, are you going to apply?
Rob
Jassi Brar
maintainerQuoted 21 lines · Rob Herring
Quoted 19 lines · Jassi Brar
Quoted 17 lines · Rob Herring
Quoted 14 lines · Rob Herring (Arm)
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) <[email protected]>--- drivers/mailbox/mailbox.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-)
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
Ping!
Acked-by Jassi Brar <[email protected]>Don't need an ack, are you going to apply?
Yes I was and will be if you won't.
-Jassi