Commit 523c6b3e authored by Zijun Hu's avatar Zijun Hu Committed by Greg Kroah-Hartman
Browse files

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: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: default avatarZijun Hu <quic_zijuhu@quicinc.com>
Link: https://lore.kernel.org/r/20250105-class_fix-v6-6-3a2f1768d4d4@quicinc.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 037116a6
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -4043,8 +4043,8 @@ EXPORT_SYMBOL_GPL(device_for_each_child_reverse);
 * device_for_each_child_reverse_from();
 */
int device_for_each_child_reverse_from(struct device *parent,
				       struct device *from, const void *data,
				       int (*fn)(struct device *, const void *))
				       struct device *from, void *data,
				       int (*fn)(struct device *, void *))
{
	struct klist_iter i;
	struct device *child;
+1 −1
Original line number Diff line number Diff line
@@ -703,7 +703,7 @@ static int cxl_decoder_commit(struct cxl_decoder *cxld)
	return 0;
}

static int commit_reap(struct device *dev, const void *data)
static int commit_reap(struct device *dev, void *data)
{
	struct cxl_port *port = to_cxl_port(dev->parent);
	struct cxl_decoder *cxld;
+1 −1
Original line number Diff line number Diff line
@@ -778,7 +778,7 @@ static size_t show_targetN(struct cxl_region *cxlr, char *buf, int pos)
	return rc;
}

static int check_commit_order(struct device *dev, const void *data)
static int check_commit_order(struct device *dev, void *data)
{
	struct cxl_decoder *cxld = to_cxl_decoder(dev);

+2 −2
Original line number Diff line number Diff line
@@ -1079,8 +1079,8 @@ int device_for_each_child(struct device *parent, void *data,
int device_for_each_child_reverse(struct device *parent, void *data,
				  int (*fn)(struct device *dev, void *data));
int device_for_each_child_reverse_from(struct device *parent,
				       struct device *from, const void *data,
				       int (*fn)(struct device *, const void *));
				       struct device *from, void *data,
				       int (*fn)(struct device *, void *));
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,