Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

usb: common: Use helper function for_each_node_with_property()

for_each_node_with_property() can iterate through the device_node
with a given property name, and we don't need to find the device_node
in the while loop. Since of_device_is_available() will return false if
the "controller" is NULL and break the while loop, there is no functional
change with such conversion.

Signed-off-by: Zhang Zekun <zhangzekun11@huawei.com>
Link: https://lore.kernel.org/r/20240809082711.99085-1-zhangzekun11@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Zhang Zekun and committed by
Greg Kroah-Hartman
88177cd4 5cffefa1

+3 -4
+3 -4
drivers/usb/common/common.c
··· 276 276 */ 277 277 enum usb_dr_mode of_usb_get_dr_mode_by_phy(struct device_node *np, int arg0) 278 278 { 279 - struct device_node *controller = NULL; 279 + struct device_node *controller; 280 280 struct of_phandle_args args; 281 281 const char *dr_mode; 282 282 int index; 283 283 int err; 284 284 285 - do { 286 - controller = of_find_node_with_property(controller, "phys"); 285 + for_each_node_with_property(controller, "phys") { 287 286 if (!of_device_is_available(controller)) 288 287 continue; 289 288 index = 0; ··· 305 306 goto finish; 306 307 index++; 307 308 } while (args.np); 308 - } while (controller); 309 + } 309 310 310 311 finish: 311 312 err = of_property_read_string(controller, "dr_mode", &dr_mode);