summaryrefslogtreecommitdiff
path: root/include/linux/device.h
diff options
context:
space:
mode:
authorZijun Hu <quic_zijuhu@quicinc.com>2025-01-05 16:34:08 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-01-10 15:26:12 +0100
commit767b74e0d1fc7890a94d1770acf05a442474bd87 (patch)
treea19826f7cc5fa404ffd37e6a0f5a695416a11a06 /include/linux/device.h
parent523c6b3ed7702a638e0f8fd02708a7ed4f938269 (diff)
driver core: Introduce device_iter_t for device iterating APIs
There are several for_each APIs which has parameter with type below: int (*fn)(struct device *dev, void *data) They iterate over various device lists and call @fn() for each device with caller provided data @*data, and they usually need to modify @*data. Give the type an dedicated typedef with advantages shown below: typedef int (*device_iter_t)(struct device *dev, void *data) - Shorter API declarations and definitions - Prevent further for_each APIs from using bad parameter type So introduce device_iter_t and apply it to various existing APIs below: bus_for_each_dev() (class|driver)_for_each_device() device_for_each_child(_reverse|_reverse_from)(). 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-7-3a2f1768d4d4@quicinc.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/device.h')
-rw-r--r--include/linux/device.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index 025bac08fca7..36d1a1607712 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -1075,12 +1075,12 @@ void device_del(struct device *dev);
DEFINE_FREE(device_del, struct device *, if (_T) device_del(_T))
int device_for_each_child(struct device *parent, void *data,
- int (*fn)(struct device *dev, void *data));
+ device_iter_t fn);
int device_for_each_child_reverse(struct device *parent, void *data,
- int (*fn)(struct device *dev, void *data));
+ device_iter_t fn);
int device_for_each_child_reverse_from(struct device *parent,
struct device *from, void *data,
- int (*fn)(struct device *, void *));
+ 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,