mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
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>
This commit is contained in:
parent
767b74e0d1
commit
51796f5e29
2 changed files with 29 additions and 35 deletions
|
@ -4100,38 +4100,6 @@ struct device *device_find_child(struct device *parent, const void *data,
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(device_find_child);
|
||||
|
||||
/**
|
||||
* device_find_child_by_name - device iterator for locating a child device.
|
||||
* @parent: parent struct device
|
||||
* @name: name of the child device
|
||||
*
|
||||
* This is similar to the device_find_child() function above, but it
|
||||
* returns a reference to a device that has the name @name.
|
||||
*
|
||||
* NOTE: you will need to drop the reference with put_device() after use.
|
||||
*/
|
||||
struct device *device_find_child_by_name(struct device *parent,
|
||||
const char *name)
|
||||
{
|
||||
return device_find_child(parent, name, device_match_name);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(device_find_child_by_name);
|
||||
|
||||
/**
|
||||
* device_find_any_child - device iterator for locating a child device, if any.
|
||||
* @parent: parent struct device
|
||||
*
|
||||
* This is similar to the device_find_child() function above, but it
|
||||
* returns a reference to a child device, if any.
|
||||
*
|
||||
* NOTE: you will need to drop the reference with put_device() after use.
|
||||
*/
|
||||
struct device *device_find_any_child(struct device *parent)
|
||||
{
|
||||
return device_find_child(parent, NULL, device_match_any);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(device_find_any_child);
|
||||
|
||||
int __init devices_init(void)
|
||||
{
|
||||
devices_kset = kset_create_and_add("devices", &device_uevent_ops, NULL);
|
||||
|
|
|
@ -1083,9 +1083,35 @@ int device_for_each_child_reverse_from(struct device *parent,
|
|||
device_iter_t fn);
|
||||
struct device *device_find_child(struct device *parent, const void *data,
|
||||
device_match_t match);
|
||||
struct device *device_find_child_by_name(struct device *parent,
|
||||
const char *name);
|
||||
struct device *device_find_any_child(struct device *parent);
|
||||
/**
|
||||
* device_find_child_by_name - device iterator for locating a child device.
|
||||
* @parent: parent struct device
|
||||
* @name: name of the child device
|
||||
*
|
||||
* This is similar to the device_find_child() function above, but it
|
||||
* returns a reference to a device that has the name @name.
|
||||
*
|
||||
* NOTE: you will need to drop the reference with put_device() after use.
|
||||
*/
|
||||
static inline struct device *device_find_child_by_name(struct device *parent,
|
||||
const char *name)
|
||||
{
|
||||
return device_find_child(parent, name, device_match_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* device_find_any_child - device iterator for locating a child device, if any.
|
||||
* @parent: parent struct device
|
||||
*
|
||||
* This is similar to the device_find_child() function above, but it
|
||||
* returns a reference to a child device, if any.
|
||||
*
|
||||
* NOTE: you will need to drop the reference with put_device() after use.
|
||||
*/
|
||||
static inline struct device *device_find_any_child(struct device *parent)
|
||||
{
|
||||
return device_find_child(parent, NULL, device_match_any);
|
||||
}
|
||||
|
||||
int device_rename(struct device *dev, const char *new_name);
|
||||
int device_move(struct device *dev, struct device *new_parent,
|
||||
|
|
Loading…
Add table
Reference in a new issue