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: Introduce device_find_any_child() helper

There are several places in the kernel where this kind of functionality is
being used. Provide a generic helper for such cases.

Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220610120219.18988-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Andy Shevchenko and committed by
Greg Kroah-Hartman
82b070be 9cbffc7a

+22
+20
drivers/base/core.c
··· 3920 3920 } 3921 3921 EXPORT_SYMBOL_GPL(device_find_child_by_name); 3922 3922 3923 + static int match_any(struct device *dev, void *unused) 3924 + { 3925 + return 1; 3926 + } 3927 + 3928 + /** 3929 + * device_find_any_child - device iterator for locating a child device, if any. 3930 + * @parent: parent struct device 3931 + * 3932 + * This is similar to the device_find_child() function above, but it 3933 + * returns a reference to a child device, if any. 3934 + * 3935 + * NOTE: you will need to drop the reference with put_device() after use. 3936 + */ 3937 + struct device *device_find_any_child(struct device *parent) 3938 + { 3939 + return device_find_child(parent, NULL, match_any); 3940 + } 3941 + EXPORT_SYMBOL_GPL(device_find_any_child); 3942 + 3923 3943 int __init devices_init(void) 3924 3944 { 3925 3945 devices_kset = kset_create_and_add("devices", &device_uevent_ops, NULL);
+2
include/linux/device.h
··· 905 905 int (*match)(struct device *dev, void *data)); 906 906 struct device *device_find_child_by_name(struct device *parent, 907 907 const char *name); 908 + struct device *device_find_any_child(struct device *parent); 909 + 908 910 int device_rename(struct device *dev, const char *new_name); 909 911 int device_move(struct device *dev, struct device *new_parent, 910 912 enum dpm_order dpm_order);