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.

driver core: Move two simple APIs for finding child device to header

The following two APIs are for finding child device, and both only have
one line code in function body.
device_find_child_by_name()
device_find_any_child()

Move them to header as static inline function.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
Link: https://lore.kernel.org/r/20250105-class_fix-v6-8-3a2f1768d4d4@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Zijun Hu and committed by
Greg Kroah-Hartman
51796f5e 767b74e0

+29 -35
-32
drivers/base/core.c
··· 4100 4100 } 4101 4101 EXPORT_SYMBOL_GPL(device_find_child); 4102 4102 4103 - /** 4104 - * device_find_child_by_name - device iterator for locating a child device. 4105 - * @parent: parent struct device 4106 - * @name: name of the child device 4107 - * 4108 - * This is similar to the device_find_child() function above, but it 4109 - * returns a reference to a device that has the name @name. 4110 - * 4111 - * NOTE: you will need to drop the reference with put_device() after use. 4112 - */ 4113 - struct device *device_find_child_by_name(struct device *parent, 4114 - const char *name) 4115 - { 4116 - return device_find_child(parent, name, device_match_name); 4117 - } 4118 - EXPORT_SYMBOL_GPL(device_find_child_by_name); 4119 - 4120 - /** 4121 - * device_find_any_child - device iterator for locating a child device, if any. 4122 - * @parent: parent struct device 4123 - * 4124 - * This is similar to the device_find_child() function above, but it 4125 - * returns a reference to a child device, if any. 4126 - * 4127 - * NOTE: you will need to drop the reference with put_device() after use. 4128 - */ 4129 - struct device *device_find_any_child(struct device *parent) 4130 - { 4131 - return device_find_child(parent, NULL, device_match_any); 4132 - } 4133 - EXPORT_SYMBOL_GPL(device_find_any_child); 4134 - 4135 4103 int __init devices_init(void) 4136 4104 { 4137 4105 devices_kset = kset_create_and_add("devices", &device_uevent_ops, NULL);
+29 -3
include/linux/device.h
··· 1083 1083 device_iter_t fn); 1084 1084 struct device *device_find_child(struct device *parent, const void *data, 1085 1085 device_match_t match); 1086 - struct device *device_find_child_by_name(struct device *parent, 1087 - const char *name); 1088 - struct device *device_find_any_child(struct device *parent); 1086 + /** 1087 + * device_find_child_by_name - device iterator for locating a child device. 1088 + * @parent: parent struct device 1089 + * @name: name of the child device 1090 + * 1091 + * This is similar to the device_find_child() function above, but it 1092 + * returns a reference to a device that has the name @name. 1093 + * 1094 + * NOTE: you will need to drop the reference with put_device() after use. 1095 + */ 1096 + static inline struct device *device_find_child_by_name(struct device *parent, 1097 + const char *name) 1098 + { 1099 + return device_find_child(parent, name, device_match_name); 1100 + } 1101 + 1102 + /** 1103 + * device_find_any_child - device iterator for locating a child device, if any. 1104 + * @parent: parent struct device 1105 + * 1106 + * This is similar to the device_find_child() function above, but it 1107 + * returns a reference to a child device, if any. 1108 + * 1109 + * NOTE: you will need to drop the reference with put_device() after use. 1110 + */ 1111 + static inline struct device *device_find_any_child(struct device *parent) 1112 + { 1113 + return device_find_child(parent, NULL, device_match_any); 1114 + } 1089 1115 1090 1116 int device_rename(struct device *dev, const char *new_name); 1091 1117 int device_move(struct device *dev, struct device *new_parent,