]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
driver core: Constify API device_find_child() and adapt for various usages
authorZijun Hu <quic_zijuhu@quicinc.com>
Tue, 24 Dec 2024 13:05:03 +0000 (21:05 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 3 Jan 2025 10:19:35 +0000 (11:19 +0100)
commitf1e8bf56320a7fb32095b6c51b707459361b403b
treeeb3d636aab796bf613249cb7e7a71d06dce61a31
parente9451ab968bb34f2b37fdd91c376d5f36c4745ee
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>
28 files changed:
arch/sparc/kernel/vio.c
drivers/base/core.c
drivers/block/sunvdc.c
drivers/bus/fsl-mc/dprc-driver.c
drivers/cxl/core/pci.c
drivers/cxl/core/pmem.c
drivers/cxl/core/region.c
drivers/firewire/core-device.c
drivers/firmware/arm_scmi/bus.c
drivers/firmware/efi/dev-path-parser.c
drivers/gpio/gpio-sim.c
drivers/gpu/drm/mediatek/mtk_drm_drv.c
drivers/hwmon/hwmon.c
drivers/media/pci/mgb4/mgb4_core.c
drivers/nvdimm/bus.c
drivers/pwm/core.c
drivers/rpmsg/rpmsg_core.c
drivers/scsi/qla4xxx/ql4_os.c
drivers/scsi/scsi_transport_iscsi.c
drivers/slimbus/core.c
drivers/thunderbolt/retimer.c
drivers/thunderbolt/xdomain.c
drivers/tty/serial/serial_core.c
drivers/usb/typec/class.c
include/linux/device.h
include/scsi/scsi_transport_iscsi.h
net/dsa/dsa.c
tools/testing/cxl/test/cxl.c