Skip to content

Commit 51796f5

Browse files
zijun-hugregkh
authored andcommitted
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 <[email protected]> Signed-off-by: Zijun Hu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 767b74e commit 51796f5

File tree

2 files changed

+29
-35
lines changed

2 files changed

+29
-35
lines changed

drivers/base/core.c

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4100,38 +4100,6 @@ struct device *device_find_child(struct device *parent, const void *data,
41004100
}
41014101
EXPORT_SYMBOL_GPL(device_find_child);
41024102

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-
41354103
int __init devices_init(void)
41364104
{
41374105
devices_kset = kset_create_and_add("devices", &device_uevent_ops, NULL);

include/linux/device.h

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,9 +1083,35 @@ int device_for_each_child_reverse_from(struct device *parent,
10831083
device_iter_t fn);
10841084
struct device *device_find_child(struct device *parent, const void *data,
10851085
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+
}
10891115

10901116
int device_rename(struct device *dev, const char *new_name);
10911117
int device_move(struct device *dev, struct device *new_parent,

0 commit comments

Comments
 (0)