[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240811-const_dfc_done-v1-1-9d85e3f943cb@quicinc.com>
Date: Sun, 11 Aug 2024 10:24:52 +0800
From: Zijun Hu <zijun_hu@...oud.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>
Cc: Zijun Hu <zijun_hu@...oud.com>, linux-kernel@...r.kernel.org,
Zijun Hu <quic_zijuhu@...cinc.com>
Subject: [PATCH 01/27] driver core: Constify driver API device_find_child()
From: Zijun Hu <quic_zijuhu@...cinc.com>
Constify the following driver API:
struct device *device_find_child(struct device *dev, void *data,
int (*match)(struct device *dev, void *data));
to
struct device *device_find_child(struct device *dev, const void *data,
device_match_t match);
typedef int (*device_match_t)(struct device *dev, const void *data);
Since it should not modify caller's match data @*data.
Signed-off-by: Zijun Hu <quic_zijuhu@...cinc.com>
---
drivers/base/core.c | 11 +++--------
include/linux/device.h | 4 ++--
2 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 3f3ebdb5aa0b..f152e0f8fb03 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -4062,8 +4062,8 @@ EXPORT_SYMBOL_GPL(device_for_each_child_reverse);
*
* NOTE: you will need to drop the reference with put_device() after use.
*/
-struct device *device_find_child(struct device *parent, void *data,
- int (*match)(struct device *dev, void *data))
+struct device *device_find_child(struct device *parent, const void *data,
+ device_match_t match)
{
struct klist_iter i;
struct device *child;
@@ -4108,11 +4108,6 @@ struct device *device_find_child_by_name(struct device *parent,
}
EXPORT_SYMBOL_GPL(device_find_child_by_name);
-static int match_any(struct device *dev, void *unused)
-{
- return 1;
-}
-
/**
* device_find_any_child - device iterator for locating a child device, if any.
* @parent: parent struct device
@@ -4124,7 +4119,7 @@ static int match_any(struct device *dev, void *unused)
*/
struct device *device_find_any_child(struct device *parent)
{
- return device_find_child(parent, NULL, match_any);
+ return device_find_child(parent, NULL, device_match_any);
}
EXPORT_SYMBOL_GPL(device_find_any_child);
diff --git a/include/linux/device.h b/include/linux/device.h
index b2423fca3d45..76f10bdbb4ea 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -1073,8 +1073,8 @@ int device_for_each_child(struct device *dev, void *data,
int (*fn)(struct device *dev, void *data));
int device_for_each_child_reverse(struct device *dev, void *data,
int (*fn)(struct device *dev, void *data));
-struct device *device_find_child(struct device *dev, void *data,
- int (*match)(struct device *dev, void *data));
+struct device *device_find_child(struct device *dev, 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);
--
2.34.1
Powered by blists - more mailing lists