diff options
| author | Zijun Hu <quic_zijuhu@quicinc.com> | 2024-12-24 21:05:03 +0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-01-03 11:19:35 +0100 |
| commit | f1e8bf56320a7fb32095b6c51b707459361b403b (patch) | |
| tree | eb3d636aab796bf613249cb7e7a71d06dce61a31 /drivers/slimbus | |
| parent | e9451ab968bb34f2b37fdd91c376d5f36c4745ee (diff) | |
| download | linux-f1e8bf56320a7fb32095b6c51b707459361b403b.tar.gz linux-f1e8bf56320a7fb32095b6c51b707459361b403b.tar.bz2 linux-f1e8bf56320a7fb32095b6c51b707459361b403b.zip | |
driver core: Constify API device_find_child() and adapt for various usages
Constify the following 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);
with the following reasons:
- Protect caller's match data @*data which is for comparison and lookup
and the API does not actually need to modify @*data.
- Make the API's parameters (@match)() and @data have the same type as
all of other device finding APIs (bus|class|driver)_find_device().
- All kinds of existing device match functions can be directly taken
as the API's argument, they were exported by driver core.
Constify the API and adapt for various existing usages.
BTW, various subsystem changes are squashed into this commit to meet
'git bisect' requirement, and this commit has the minimal and simplest
changes to complement squashing shortcoming, and that may bring extra
code improvement.
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Uwe Kleine-König <ukleinek@kernel.org> # for drivers/pwm
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Link: https://lore.kernel.org/r/20241224-const_dfc_done-v5-4-6623037414d4@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/slimbus')
| -rw-r--r-- | drivers/slimbus/core.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/slimbus/core.c b/drivers/slimbus/core.c index b5d5bbb9fdb6..ab927fd077cb 100644 --- a/drivers/slimbus/core.c +++ b/drivers/slimbus/core.c @@ -337,9 +337,9 @@ static bool slim_eaddr_equal(const struct slim_eaddr *a, a->instance == b->instance); } -static int slim_match_dev(struct device *dev, void *data) +static int slim_match_dev(struct device *dev, const void *data) { - struct slim_eaddr *e_addr = data; + const struct slim_eaddr *e_addr = data; struct slim_device *sbdev = to_slim_device(dev); return slim_eaddr_equal(&sbdev->e_addr, e_addr); @@ -385,9 +385,9 @@ struct slim_device *slim_get_device(struct slim_controller *ctrl, } EXPORT_SYMBOL_GPL(slim_get_device); -static int of_slim_match_dev(struct device *dev, void *data) +static int of_slim_match_dev(struct device *dev, const void *data) { - struct device_node *np = data; + const struct device_node *np = data; struct slim_device *sbdev = to_slim_device(dev); return (sbdev->dev.of_node == np); |
