]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
driver core: Simplify API device_find_child_by_name() implementation
authorZijun Hu <quic_zijuhu@quicinc.com>
Tue, 24 Dec 2024 13:05:04 +0000 (21:05 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 3 Jan 2025 10:19:35 +0000 (11:19 +0100)
Simplify device_find_child_by_name() implementation by both existing
API device_find_child() and device_match_name().

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
Link: https://lore.kernel.org/r/20241224-const_dfc_done-v5-5-6623037414d4@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/core.c

index b242993f816dfab25fa8f555ca07df883252b415..ee778d3807771b14841927b1b916a08383e4c3e1 100644 (file)
@@ -4110,18 +4110,7 @@ EXPORT_SYMBOL_GPL(device_find_child);
 struct device *device_find_child_by_name(struct device *parent,
                                         const char *name)
 {
-       struct klist_iter i;
-       struct device *child;
-
-       if (!parent)
-               return NULL;
-
-       klist_iter_init(&parent->p->klist_children, &i);
-       while ((child = next_device(&i)))
-               if (sysfs_streq(dev_name(child), name) && get_device(child))
-                       break;
-       klist_iter_exit(&i);
-       return child;
+       return device_find_child(parent, name, device_match_name);
 }
 EXPORT_SYMBOL_GPL(device_find_child_by_name);