Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

driver_find_device: Unify the match function with class_find_device()

The driver_find_device() accepts a match function pointer to
filter the devices for lookup, similar to bus/class_find_device().
However, there is a minor difference in the prototype for the
match parameter for driver_find_device() with the now unified
version accepted by {bus/class}_find_device(), where it doesn't
accept a "const" qualifier for the data argument. This prevents
us from reusing the generic match functions for driver_find_device().

For this reason, change the prototype of the driver_find_device() to
make the "match" parameter in line with {bus/class}_find_device()
and adjust its callers to use the const qualifier. Also, we could
now promote the "data" parameter to const as we pass it down
as a const parameter to the match functions.

Cc: Corey Minyard <minyard@acm.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
Cc: Sebastian Ott <sebott@linux.ibm.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Nehal Shah <nehal-bakulchandra.shah@amd.com>
Cc: Shyam Sundar S K <shyam-sundar.s-k@amd.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Suzuki K Poulose and committed by
Greg Kroah-Hartman
92ce7e83 418e3ea1

+21 -21
+2 -2
drivers/amba/tegra-ahb.c
··· 143 143 } 144 144 145 145 #ifdef CONFIG_TEGRA_IOMMU_SMMU 146 - static int tegra_ahb_match_by_smmu(struct device *dev, void *data) 146 + static int tegra_ahb_match_by_smmu(struct device *dev, const void *data) 147 147 { 148 148 struct tegra_ahb *ahb = dev_get_drvdata(dev); 149 - struct device_node *dn = data; 149 + const struct device_node *dn = data; 150 150 151 151 return (ahb->dev->of_node == dn) ? 1 : 0; 152 152 }
+2 -2
drivers/base/driver.c
··· 73 73 * return to the caller and not iterate over any more devices. 74 74 */ 75 75 struct device *driver_find_device(struct device_driver *drv, 76 - struct device *start, void *data, 77 - int (*match)(struct device *dev, void *data)) 76 + struct device *start, const void *data, 77 + int (*match)(struct device *dev, const void *data)) 78 78 { 79 79 struct klist_iter i; 80 80 struct device *dev;
+4 -4
drivers/char/ipmi/ipmi_msghandler.c
··· 2819 2819 .groups = bmc_dev_attr_groups, 2820 2820 }; 2821 2821 2822 - static int __find_bmc_guid(struct device *dev, void *data) 2822 + static int __find_bmc_guid(struct device *dev, const void *data) 2823 2823 { 2824 - guid_t *guid = data; 2824 + const guid_t *guid = data; 2825 2825 struct bmc_device *bmc; 2826 2826 int rv; 2827 2827 ··· 2857 2857 unsigned char device_id; 2858 2858 }; 2859 2859 2860 - static int __find_bmc_prod_dev_id(struct device *dev, void *data) 2860 + static int __find_bmc_prod_dev_id(struct device *dev, const void *data) 2861 2861 { 2862 - struct prod_dev_id *cid = data; 2862 + const struct prod_dev_id *cid = data; 2863 2863 struct bmc_device *bmc; 2864 2864 int rv; 2865 2865
+2 -2
drivers/gpu/drm/tegra/dc.c
··· 2375 2375 return 0; 2376 2376 } 2377 2377 2378 - static int tegra_dc_match_by_pipe(struct device *dev, void *data) 2378 + static int tegra_dc_match_by_pipe(struct device *dev, const void *data) 2379 2379 { 2380 2380 struct tegra_dc *dc = dev_get_drvdata(dev); 2381 - unsigned int pipe = (unsigned long)data; 2381 + unsigned int pipe = (unsigned long)(void *)data; 2382 2382 2383 2383 return dc->pipe == pipe; 2384 2384 }
+1 -1
drivers/i2c/busses/i2c-amd-mp2-pci.c
··· 457 457 }; 458 458 module_pci_driver(amd_mp2_pci_driver); 459 459 460 - static int amd_mp2_device_match(struct device *dev, void *data) 460 + static int amd_mp2_device_match(struct device *dev, const void *data) 461 461 { 462 462 return 1; 463 463 }
+1 -1
drivers/iommu/arm-smmu-v3.c
··· 2023 2023 2024 2024 static struct platform_driver arm_smmu_driver; 2025 2025 2026 - static int arm_smmu_match_node(struct device *dev, void *data) 2026 + static int arm_smmu_match_node(struct device *dev, const void *data) 2027 2027 { 2028 2028 return dev->fwnode == data; 2029 2029 }
+1 -1
drivers/iommu/arm-smmu.c
··· 1431 1431 } 1432 1432 } 1433 1433 1434 - static int arm_smmu_match_node(struct device *dev, void *data) 1434 + static int arm_smmu_match_node(struct device *dev, const void *data) 1435 1435 { 1436 1436 return dev->fwnode == data; 1437 1437 }
+2 -2
drivers/mfd/altera-sysmgr.c
··· 92 92 * Matching function used by driver_find_device(). 93 93 * Return: True if match is found, otherwise false. 94 94 */ 95 - static int sysmgr_match_phandle(struct device *dev, void *data) 95 + static int sysmgr_match_phandle(struct device *dev, const void *data) 96 96 { 97 - return dev->of_node == (struct device_node *)data; 97 + return dev->of_node == (const struct device_node *)data; 98 98 } 99 99 100 100 /**
+2 -2
drivers/s390/cio/ccwgroup.c
··· 581 581 } 582 582 EXPORT_SYMBOL(ccwgroup_driver_register); 583 583 584 - static int __ccwgroup_match_all(struct device *dev, void *data) 584 + static int __ccwgroup_match_all(struct device *dev, const void *data) 585 585 { 586 586 return 1; 587 587 } ··· 608 608 } 609 609 EXPORT_SYMBOL(ccwgroup_driver_unregister); 610 610 611 - static int __ccwgroupdev_check_busid(struct device *dev, void *id) 611 + static int __ccwgroupdev_check_busid(struct device *dev, const void *id) 612 612 { 613 613 char *bus_id = id; 614 614
+1 -1
drivers/s390/cio/chsc_sch.c
··· 203 203 204 204 static DEFINE_SPINLOCK(chsc_lock); 205 205 206 - static int chsc_subchannel_match_next_free(struct device *dev, void *data) 206 + static int chsc_subchannel_match_next_free(struct device *dev, const void *data) 207 207 { 208 208 struct subchannel *sch = to_subchannel(dev); 209 209
+1 -1
drivers/s390/cio/device.c
··· 1653 1653 * get ccw_device matching the busid, but only if owned by cdrv 1654 1654 */ 1655 1655 static int 1656 - __ccwdev_check_busid(struct device *dev, void *id) 1656 + __ccwdev_check_busid(struct device *dev, const void *id) 1657 1657 { 1658 1658 char *bus_id; 1659 1659
+2 -2
include/linux/device.h
··· 336 336 int (*fn)(struct device *dev, 337 337 void *)); 338 338 struct device *driver_find_device(struct device_driver *drv, 339 - struct device *start, void *data, 340 - int (*match)(struct device *dev, void *data)); 339 + struct device *start, const void *data, 340 + int (*match)(struct device *dev, const void *data)); 341 341 342 342 void driver_deferred_probe_add(struct device *dev); 343 343 int driver_deferred_probe_check_state(struct device *dev);