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: Correct API device_for_each_child_reverse_from() prototype

For API device_for_each_child_reverse_from(..., const void *data,
int (*fn)(struct device *dev, const void *data))

- Type of @data is const pointer, and means caller's data @*data is not
allowed to be modified, but that usually is not proper for such non
finding device iterating API.

- Types for both @data and @fn are not consistent with all other
for_each device iterating APIs device_for_each_child(_reverse)(),
bus_for_each_dev() and (driver|class)_for_each_device().

Correct its prototype by removing const from parameter types, then adapt
for various existing usages.

An dedicated typedef device_iter_t will be introduced as @fn() type for
various for_each device interating APIs later.

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-6-3a2f1768d4d4@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Zijun Hu and committed by
Greg Kroah-Hartman
523c6b3e 037116a6

+6 -6
+2 -2
drivers/base/core.c
··· 4043 4043 * device_for_each_child_reverse_from(); 4044 4044 */ 4045 4045 int device_for_each_child_reverse_from(struct device *parent, 4046 - struct device *from, const void *data, 4047 - int (*fn)(struct device *, const void *)) 4046 + struct device *from, void *data, 4047 + int (*fn)(struct device *, void *)) 4048 4048 { 4049 4049 struct klist_iter i; 4050 4050 struct device *child;
+1 -1
drivers/cxl/core/hdm.c
··· 703 703 return 0; 704 704 } 705 705 706 - static int commit_reap(struct device *dev, const void *data) 706 + static int commit_reap(struct device *dev, void *data) 707 707 { 708 708 struct cxl_port *port = to_cxl_port(dev->parent); 709 709 struct cxl_decoder *cxld;
+1 -1
drivers/cxl/core/region.c
··· 778 778 return rc; 779 779 } 780 780 781 - static int check_commit_order(struct device *dev, const void *data) 781 + static int check_commit_order(struct device *dev, void *data) 782 782 { 783 783 struct cxl_decoder *cxld = to_cxl_decoder(dev); 784 784
+2 -2
include/linux/device.h
··· 1079 1079 int device_for_each_child_reverse(struct device *parent, void *data, 1080 1080 int (*fn)(struct device *dev, void *data)); 1081 1081 int device_for_each_child_reverse_from(struct device *parent, 1082 - struct device *from, const void *data, 1083 - int (*fn)(struct device *, const void *)); 1082 + struct device *from, void *data, 1083 + int (*fn)(struct device *, void *)); 1084 1084 struct device *device_find_child(struct device *parent, const void *data, 1085 1085 device_match_t match); 1086 1086 struct device *device_find_child_by_name(struct device *parent,