Skip to content

Commit 92ce7e8

Browse files
Suzuki K Poulosegregkh
authored andcommitted
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>
1 parent 418e3ea commit 92ce7e8

12 files changed

Lines changed: 21 additions & 21 deletions

File tree

‎drivers/amba/tegra-ahb.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ static inline void gizmo_writel(struct tegra_ahb *ahb, u32 value, u32 offset)
143143
}
144144

145145
#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)
147147
{
148148
struct tegra_ahb *ahb = dev_get_drvdata(dev);
149-
struct device_node *dn = data;
149+
const struct device_node *dn = data;
150150

151151
return (ahb->dev->of_node == dn) ? 1 : 0;
152152
}

‎drivers/base/driver.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ EXPORT_SYMBOL_GPL(driver_for_each_device);
7373
* return to the caller and not iterate over any more devices.
7474
*/
7575
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))
7878
{
7979
struct klist_iter i;
8080
struct device *dev;

‎drivers/char/ipmi/ipmi_msghandler.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2819,9 +2819,9 @@ static const struct device_type bmc_device_type = {
28192819
.groups = bmc_dev_attr_groups,
28202820
};
28212821

2822-
static int __find_bmc_guid(struct device *dev, void *data)
2822+
static int __find_bmc_guid(struct device *dev, const void *data)
28232823
{
2824-
guid_t *guid = data;
2824+
const guid_t *guid = data;
28252825
struct bmc_device *bmc;
28262826
int rv;
28272827

@@ -2857,9 +2857,9 @@ struct prod_dev_id {
28572857
unsigned char device_id;
28582858
};
28592859

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)
28612861
{
2862-
struct prod_dev_id *cid = data;
2862+
const struct prod_dev_id *cid = data;
28632863
struct bmc_device *bmc;
28642864
int rv;
28652865

‎drivers/gpu/drm/tegra/dc.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2375,10 +2375,10 @@ static int tegra_dc_parse_dt(struct tegra_dc *dc)
23752375
return 0;
23762376
}
23772377

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)
23792379
{
23802380
struct tegra_dc *dc = dev_get_drvdata(dev);
2381-
unsigned int pipe = (unsigned long)data;
2381+
unsigned int pipe = (unsigned long)(void *)data;
23822382

23832383
return dc->pipe == pipe;
23842384
}

‎drivers/i2c/busses/i2c-amd-mp2-pci.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ static struct pci_driver amd_mp2_pci_driver = {
457457
};
458458
module_pci_driver(amd_mp2_pci_driver);
459459

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)
461461
{
462462
return 1;
463463
}

‎drivers/iommu/arm-smmu-v3.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2023,7 +2023,7 @@ arm_smmu_iova_to_phys(struct iommu_domain *domain, dma_addr_t iova)
20232023

20242024
static struct platform_driver arm_smmu_driver;
20252025

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)
20272027
{
20282028
return dev->fwnode == data;
20292029
}

‎drivers/iommu/arm-smmu.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1431,7 +1431,7 @@ static bool arm_smmu_capable(enum iommu_cap cap)
14311431
}
14321432
}
14331433

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)
14351435
{
14361436
return dev->fwnode == data;
14371437
}

‎drivers/mfd/altera-sysmgr.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ static struct regmap_config altr_sysmgr_regmap_cfg = {
9292
* Matching function used by driver_find_device().
9393
* Return: True if match is found, otherwise false.
9494
*/
95-
static int sysmgr_match_phandle(struct device *dev, void *data)
95+
static int sysmgr_match_phandle(struct device *dev, const void *data)
9696
{
97-
return dev->of_node == (struct device_node *)data;
97+
return dev->of_node == (const struct device_node *)data;
9898
}
9999

100100
/**

‎drivers/s390/cio/ccwgroup.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ int ccwgroup_driver_register(struct ccwgroup_driver *cdriver)
581581
}
582582
EXPORT_SYMBOL(ccwgroup_driver_register);
583583

584-
static int __ccwgroup_match_all(struct device *dev, void *data)
584+
static int __ccwgroup_match_all(struct device *dev, const void *data)
585585
{
586586
return 1;
587587
}
@@ -608,7 +608,7 @@ void ccwgroup_driver_unregister(struct ccwgroup_driver *cdriver)
608608
}
609609
EXPORT_SYMBOL(ccwgroup_driver_unregister);
610610

611-
static int __ccwgroupdev_check_busid(struct device *dev, void *id)
611+
static int __ccwgroupdev_check_busid(struct device *dev, const void *id)
612612
{
613613
char *bus_id = id;
614614

‎drivers/s390/cio/chsc_sch.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ static void chsc_cleanup_sch_driver(void)
203203

204204
static DEFINE_SPINLOCK(chsc_lock);
205205

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)
207207
{
208208
struct subchannel *sch = to_subchannel(dev);
209209

0 commit comments

Comments
 (0)