Re: [PATCH v3 04/11] driver core: Constify API device_find_child() then adapt for various usages
Uwe Kleine-König <[email protected]>
| Newsgroups | gmane.linux.kernel.hwmon,gmane.linux.kernel,gmane.linux.sound,gmane.linux.ports.sparc,gmane.linux.block,gmane.linux.kernel.firewire.devel,gmane.linux.kernel.efi,gmane.linux.kernel.gpio,gmane.comp.video.dri.devel,gmane.linux.ports.arm.mediatek,gmane.linux.drivers.video-input-infrastructure,gmane.linux.pwm,gmane.linux.scsi,gmane.linux.iscsi.open-iscsi,gmane.linux.usb.general,gmane.linux.serial,gmane.linux.network |
|---|---|
| Message-ID | <7ylfj462lf6g3ej6d2cmsxadawsmajogbimi7cl4pjemb7df4h@snr73pd7vaid> |
Hello, On Thu, Dec 05, 2024 at 08:10:13AM +0800, Zijun Hu wrote: > From: Zijun Hu <[email protected]> > > 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 by simply making > various match functions take 'const void *' as type of match data @data. With the discussion that a new name would ease the conversion, maybe consider device_find_child_device() to also align the name (somewhat) to the above mentioned (bus|class|driver)_find_device()? Do you have a merge plan already? I guess this patch will go through Greg's driver core tree? Best regards Uwe
signature.asc
(application/pgp-signature, 488 B)
-----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEP4GsaTp6HlmJrf7Tj4D7WH0S/k4FAmdSpdoACgkQj4D7WH0S /k4dIQf/Zne0n0ncNUTb3GbDwFv4sf3wAVH368SbrNYMV23ZdWpNl4KZPovf5L1+ 5nMlPkc2I/CBZGE2OJcZWUhHI7cZ2ZYDHBBAf/TYhsY9f0+6wXgdi2cc+bbbQpo1 JdabxMtgPX9tQ1Rbtv6jNu1AUvx8pONwQvUe5vmIBeLFDx5+wEwm4LppEVU+x9zB dApq6D2VfLguHwMf8HDycoa0nd0GL3R4KIJF4+taiSmhz9q+yjewqiXD2ag3fYrF 1IeZ6pnyXoaq0aTwLmXXhI6se14Q+IZIVQPRXVQ5i9A8kbsWN0Fj2LfXnnNWhmHl YR8uP+UVLcfagxTg7ascr+SuV4OlCw== =cpdm -----END PGP SIGNATURE-----