2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-15 00:34:10 +08:00

bus_find_device: Unify the match callback with class_find_device

There is an arbitrary difference between the prototypes of
bus_find_device() and class_find_device() preventing their callers
from passing the same pair of data and match() arguments to both of
them, which is the const qualifier used in the prototype of
class_find_device().  If that qualifier is also used in the
bus_find_device() prototype, it will be possible to pass the same
match() callback function to both bus_find_device() and
class_find_device(), which will allow some optimizations to be made in
order to avoid code duplication going forward.  Also with that, constify
the "data" parameter as it is passed as a const to the match function.

For this reason, change the prototype of bus_find_device() to match
the prototype of class_find_device() and adjust its callers to use the
const qualifier in accordance with the new prototype of it.

Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Andreas Noever <andreas.noever@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Corey Minyard <minyard@acm.org>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: David Kershner <david.kershner@unisys.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: David Airlie <airlied@linux.ie>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: Frank Rowand <frowand.list@gmail.com>
Cc: Grygorii Strashko <grygorii.strashko@ti.com>
Cc: Harald Freudenberger <freude@linux.ibm.com>
Cc: Hartmut Knaack <knaack.h@gmx.de>
Cc: Heiko Stuebner <heiko@sntech.de>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: Len Brown <lenb@kernel.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Michael Jamet <michael.jamet@intel.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Peter Oberparleiter <oberpar@linux.ibm.com>
Cc: Sebastian Ott <sebott@linux.ibm.com>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Yehezkel Bernat <YehezkelShB@gmail.com>
Cc: rafael@kernel.org
Acked-by: Corey Minyard <minyard@acm.org>
Acked-by: David Kershner <david.kershner@unisys.com>
Acked-by: Mark Brown <broonie@kernel.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Acked-by: Wolfram Sang <wsa@the-dreams.de> # for the I2C parts
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Suzuki K Poulose 2019-06-14 18:53:59 +01:00 committed by Greg Kroah-Hartman
parent e6374f6b2e
commit 418e3ea157
39 changed files with 67 additions and 68 deletions

View File

@ -147,13 +147,13 @@ static const struct dma_map_ops ibmebus_dma_ops = {
.unmap_page = ibmebus_unmap_page,
};
static int ibmebus_match_path(struct device *dev, void *data)
static int ibmebus_match_path(struct device *dev, const void *data)
{
struct device_node *dn = to_platform_device(dev)->dev.of_node;
return (of_find_node_by_path(data) == dn);
}
static int ibmebus_match_node(struct device *dev, void *data)
static int ibmebus_match_node(struct device *dev, const void *data)
{
return to_platform_device(dev)->dev.of_node == data;
}

View File

@ -511,10 +511,10 @@ struct hid_uid {
const char *uid;
};
static int match_hid_uid(struct device *dev, void *data)
static int match_hid_uid(struct device *dev, const void *data)
{
struct acpi_device *adev = ACPI_COMPANION(dev);
struct hid_uid *id = data;
const struct hid_uid *id = data;
if (!adev)
return 0;

View File

@ -454,7 +454,7 @@ static int acpi_pm_prepare(void)
return error;
}
static int find_powerf_dev(struct device *dev, void *data)
static int find_powerf_dev(struct device *dev, const void *data)
{
struct acpi_device *device = to_acpi_device(dev);
const char *hid = acpi_device_hid(device);

View File

@ -730,10 +730,10 @@ struct acpi_dev_match_info {
s64 hrv;
};
static int acpi_dev_match_cb(struct device *dev, void *data)
static int acpi_dev_match_cb(struct device *dev, const void *data)
{
struct acpi_device *adev = to_acpi_device(dev);
struct acpi_dev_match_info *match = data;
const struct acpi_dev_match_info *match = data;
unsigned long long hrv;
acpi_status status;

View File

@ -323,8 +323,8 @@ EXPORT_SYMBOL_GPL(bus_for_each_dev);
* return to the caller and not iterate over any more devices.
*/
struct device *bus_find_device(struct bus_type *bus,
struct device *start, void *data,
int (*match)(struct device *dev, void *data))
struct device *start, const void *data,
int (*match)(struct device *dev, const void *data))
{
struct klist_iter i;
struct device *dev;
@ -342,7 +342,7 @@ struct device *bus_find_device(struct bus_type *bus,
}
EXPORT_SYMBOL_GPL(bus_find_device);
static int match_name(struct device *dev, void *data)
static int match_name(struct device *dev, const void *data)
{
const char *name = data;

View File

@ -107,7 +107,7 @@ static struct bus_type *generic_match_buses[] = {
NULL,
};
static int device_fwnode_match(struct device *dev, void *fwnode)
static int device_fwnode_match(struct device *dev, const void *fwnode)
{
return dev_fwnode(dev) == fwnode;
}

View File

@ -426,7 +426,7 @@ static int ipmi_remove(struct platform_device *pdev)
return ipmi_si_remove_by_dev(&pdev->dev);
}
static int pdev_match_name(struct device *dev, void *data)
static int pdev_match_name(struct device *dev, const void *data)
{
struct platform_device *pdev = to_platform_device(dev);
const char *name = data;

View File

@ -17,9 +17,9 @@ struct acpi_hid_uid {
char uid[11]; /* UINT_MAX + null byte */
};
static int __init match_acpi_dev(struct device *dev, void *data)
static int __init match_acpi_dev(struct device *dev, const void *data)
{
struct acpi_hid_uid hid_uid = *(struct acpi_hid_uid *)data;
struct acpi_hid_uid hid_uid = *(const struct acpi_hid_uid *)data;
struct acpi_device *adev = to_acpi_device(dev);
if (acpi_match_device_ids(adev, hid_uid.hid))

View File

@ -93,7 +93,7 @@ static struct bus_type mipi_dsi_bus_type = {
.pm = &mipi_dsi_device_pm_ops,
};
static int of_device_match(struct device *dev, void *data)
static int of_device_match(struct device *dev, const void *data)
{
return dev->of_node == data;
}

View File

@ -498,9 +498,9 @@ struct coresight_device *coresight_get_sink(struct list_head *path)
return csdev;
}
static int coresight_enabled_sink(struct device *dev, void *data)
static int coresight_enabled_sink(struct device *dev, const void *data)
{
bool *reset = data;
const bool *reset = data;
struct coresight_device *csdev = to_coresight_device(dev);
if ((csdev->type == CORESIGHT_DEV_TYPE_SINK ||
@ -544,7 +544,7 @@ struct coresight_device *coresight_get_enabled_sink(bool deactivate)
return dev ? to_coresight_device(dev) : NULL;
}
static int coresight_sink_by_id(struct device *dev, void *data)
static int coresight_sink_by_id(struct device *dev, const void *data)
{
struct coresight_device *csdev = to_coresight_device(dev);
unsigned long hash;

View File

@ -18,7 +18,7 @@
#include <asm/smp_plat.h>
static int of_dev_node_match(struct device *dev, void *data)
static int of_dev_node_match(struct device *dev, const void *data)
{
return dev->of_node == data;
}

View File

@ -789,10 +789,9 @@ static int intel_th_populate(struct intel_th *th)
return 0;
}
static int match_devt(struct device *dev, void *data)
static int match_devt(struct device *dev, const void *data)
{
dev_t devt = (dev_t)(unsigned long)data;
dev_t devt = (dev_t)(unsigned long)(void *)data;
return dev->devt == devt;
}

View File

@ -318,7 +318,7 @@ u32 i2c_acpi_find_bus_speed(struct device *dev)
}
EXPORT_SYMBOL_GPL(i2c_acpi_find_bus_speed);
static int i2c_acpi_find_match_adapter(struct device *dev, void *data)
static int i2c_acpi_find_match_adapter(struct device *dev, const void *data)
{
struct i2c_adapter *adapter = i2c_verify_adapter(dev);
@ -328,7 +328,7 @@ static int i2c_acpi_find_match_adapter(struct device *dev, void *data)
return ACPI_HANDLE(dev) == (acpi_handle)data;
}
static int i2c_acpi_find_match_device(struct device *dev, void *data)
static int i2c_acpi_find_match_device(struct device *dev, const void *data)
{
return ACPI_COMPANION(dev) == data;
}

View File

@ -112,12 +112,12 @@ void of_i2c_register_devices(struct i2c_adapter *adap)
of_node_put(bus);
}
static int of_dev_node_match(struct device *dev, void *data)
static int of_dev_node_match(struct device *dev, const void *data)
{
return dev->of_node == data;
}
static int of_dev_or_parent_node_match(struct device *dev, void *data)
static int of_dev_or_parent_node_match(struct device *dev, const void *data)
{
if (dev->of_node == data)
return 1;

View File

@ -93,7 +93,7 @@ static const struct iio_chan_spec
#ifdef CONFIG_OF
static int iio_dev_node_match(struct device *dev, void *data)
static int iio_dev_node_match(struct device *dev, const void *data)
{
return dev->of_node == data && dev->type == &iio_device_type;
}

View File

@ -4497,7 +4497,7 @@ static const struct acpi_device_id hns_roce_acpi_match[] = {
};
MODULE_DEVICE_TABLE(acpi, hns_roce_acpi_match);
static int hns_roce_node_match(struct device *dev, void *fwnode)
static int hns_roce_node_match(struct device *dev, const void *fwnode)
{
return dev->fwnode == fwnode;
}

View File

@ -754,7 +754,7 @@ struct dsaf_misc_op *hns_misc_op_get(struct dsaf_device *dsaf_dev)
return (void *)misc_op;
}
static int hns_dsaf_dev_match(struct device *dev, void *fwnode)
static int hns_dsaf_dev_match(struct device *dev, const void *fwnode)
{
return dev->fwnode == fwnode;
}

View File

@ -151,9 +151,9 @@ static void cpsw_gmii_sel_dra7xx(struct cpsw_phy_sel_priv *priv,
}
static struct platform_driver cpsw_phy_sel_driver;
static int match(struct device *dev, void *data)
static int match(struct device *dev, const void *data)
{
struct device_node *node = (struct device_node *)data;
const struct device_node *node = (const struct device_node *)data;
return dev->of_node == node &&
dev->driver == &cpsw_phy_sel_driver.driver;
}

View File

@ -1371,7 +1371,7 @@ static int emac_devioctl(struct net_device *ndev, struct ifreq *ifrq, int cmd)
return -EOPNOTSUPP;
}
static int match_first_device(struct device *dev, void *data)
static int match_first_device(struct device *dev, const void *data)
{
if (dev->parent && dev->parent->of_node)
return of_device_is_compatible(dev->parent->of_node,

View File

@ -694,10 +694,10 @@ err_out:
* should provide a "tc35815-mac" device with a MAC address in its
* platform_data.
*/
static int tc35815_mac_match(struct device *dev, void *data)
static int tc35815_mac_match(struct device *dev, const void *data)
{
struct platform_device *plat_dev = to_platform_device(dev);
struct pci_dev *pci_dev = data;
const struct pci_dev *pci_dev = data;
unsigned int id = pci_dev->irq;
return !strcmp(plat_dev->name, "tc35815-mac") && plat_dev->id == id;
}

View File

@ -76,7 +76,7 @@ static struct bus_type nvmem_bus_type = {
.name = "nvmem",
};
static int of_nvmem_match(struct device *dev, void *nvmem_np)
static int of_nvmem_match(struct device *dev, const void *nvmem_np)
{
return dev->of_node == nvmem_np;
}

View File

@ -282,7 +282,7 @@ unregister:
EXPORT_SYMBOL(of_mdiobus_register);
/* Helper function for of_phy_find_device */
static int of_phy_match(struct device *dev, void *phy_np)
static int of_phy_match(struct device *dev, const void *phy_np)
{
return dev->of_node == phy_np;
}

View File

@ -37,7 +37,7 @@ static const struct of_device_id of_skipped_node_table[] = {
{} /* Empty terminated list */
};
static int of_dev_node_match(struct device *dev, void *data)
static int of_dev_node_match(struct device *dev, const void *data)
{
return dev->of_node == data;
}

View File

@ -64,7 +64,7 @@ static struct resource *get_pci_domain_busn_res(int domain_nr)
return &r->res;
}
static int find_anything(struct device *dev, void *data)
static int find_anything(struct device *dev, const void *data)
{
return 1;
}

View File

@ -236,10 +236,10 @@ struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus,
}
EXPORT_SYMBOL(pci_get_domain_bus_and_slot);
static int match_pci_dev_by_id(struct device *dev, void *data)
static int match_pci_dev_by_id(struct device *dev, const void *data)
{
struct pci_dev *pdev = to_pci_dev(dev);
struct pci_device_id *id = data;
const struct pci_device_id *id = data;
if (pci_match_one_device(id, pdev))
return 1;

View File

@ -434,10 +434,10 @@ static int css_probe_device(struct subchannel_id schid, struct schib *schib)
}
static int
check_subchannel(struct device * dev, void * data)
check_subchannel(struct device *dev, const void *data)
{
struct subchannel *sch;
struct subchannel_id *schid = data;
struct subchannel_id *schid = (void *)data;
sch = to_subchannel(dev);
return schid_equal(&sch->schid, schid);

View File

@ -642,10 +642,10 @@ static int ccw_device_add(struct ccw_device *cdev)
return device_add(dev);
}
static int match_dev_id(struct device *dev, void *data)
static int match_dev_id(struct device *dev, const void *data)
{
struct ccw_device *cdev = to_ccwdev(dev);
struct ccw_dev_id *dev_id = data;
struct ccw_dev_id *dev_id = (void *)data;
return ccw_dev_id_is_equal(&cdev->private->dev_id, dev_id);
}

View File

@ -174,10 +174,10 @@ out:
kobject_uevent(&scmdev->dev.kobj, KOBJ_CHANGE);
}
static int check_address(struct device *dev, void *data)
static int check_address(struct device *dev, const void *data)
{
struct scm_device *scmdev = to_scm_dev(dev);
struct sale *sale = data;
const struct sale *sale = data;
return scmdev->address == sale->sa;
}

View File

@ -1356,16 +1356,16 @@ static int ap_get_compatible_type(ap_qid_t qid, int rawtype, unsigned int func)
* Helper function to be used with bus_find_dev
* matches for the card device with the given id
*/
static int __match_card_device_with_id(struct device *dev, void *data)
static int __match_card_device_with_id(struct device *dev, const void *data)
{
return is_card_dev(dev) && to_ap_card(dev)->id == (int)(long) data;
return is_card_dev(dev) && to_ap_card(dev)->id == (int)(long)(void *) data;
}
/*
* Helper function to be used with bus_find_dev
* matches for the queue device with a given qid
*/
static int __match_queue_device_with_qid(struct device *dev, void *data)
static int __match_queue_device_with_qid(struct device *dev, const void *data)
{
return is_queue_dev(dev) && to_ap_queue(dev)->qid == (int)(long) data;
}
@ -1374,7 +1374,7 @@ static int __match_queue_device_with_qid(struct device *dev, void *data)
* Helper function to be used with bus_find_dev
* matches any queue device with given queue id
*/
static int __match_queue_device_with_queue_id(struct device *dev, void *data)
static int __match_queue_device_with_queue_id(struct device *dev, const void *data)
{
return is_queue_dev(dev)
&& AP_QID_QUEUE(to_ap_queue(dev)->qid) == (int)(long) data;

View File

@ -372,7 +372,7 @@ static ssize_t proc_scsi_write(struct file *file, const char __user *buf,
return err;
}
static int always_match(struct device *dev, void *data)
static int always_match(struct device *dev, const void *data)
{
return 1;
}

View File

@ -3538,7 +3538,7 @@ EXPORT_SYMBOL_GPL(spi_write_then_read);
/*-------------------------------------------------------------------------*/
#if IS_ENABLED(CONFIG_OF)
static int __spi_of_device_match(struct device *dev, void *data)
static int __spi_of_device_match(struct device *dev, const void *data)
{
return dev->of_node == data;
}
@ -3639,7 +3639,7 @@ static int spi_acpi_controller_match(struct device *dev, const void *data)
return ACPI_COMPANION(dev->parent) == data;
}
static int spi_acpi_device_match(struct device *dev, void *data)
static int spi_acpi_device_match(struct device *dev, const void *data)
{
return ACPI_COMPANION(dev) == data;
}

View File

@ -1946,10 +1946,10 @@ struct tb_sw_lookup {
u64 route;
};
static int tb_switch_match(struct device *dev, void *data)
static int tb_switch_match(struct device *dev, const void *data)
{
struct tb_switch *sw = tb_to_switch(dev);
struct tb_sw_lookup *lookup = data;
const struct tb_sw_lookup *lookup = data;
if (!sw)
return 0;

View File

@ -947,9 +947,9 @@ error:
return ret;
}
static int match_devt(struct device *dev, void *data)
static int match_devt(struct device *dev, const void *data)
{
return dev->devt == (dev_t) (unsigned long) data;
return dev->devt == (dev_t)(unsigned long)(void *)data;
}
static struct usb_device *usbdev_lookup_by_devt(dev_t devt)

View File

@ -325,9 +325,9 @@ struct find_interface_arg {
struct device_driver *drv;
};
static int __find_interface(struct device *dev, void *data)
static int __find_interface(struct device *dev, const void *data)
{
struct find_interface_arg *arg = data;
const struct find_interface_arg *arg = data;
struct usb_interface *intf;
if (!is_usb_interface(dev))

View File

@ -118,9 +118,9 @@ static const struct of_device_id omap_control_usb_id_table[] = {
MODULE_DEVICE_TABLE(of, omap_control_usb_id_table);
static struct platform_driver am335x_control_driver;
static int match(struct device *dev, void *data)
static int match(struct device *dev, const void *data)
{
struct device_node *node = (struct device_node *)data;
const struct device_node *node = (const struct device_node *)data;
return dev->of_node == node &&
dev->driver == &am335x_control_driver.driver;
}

View File

@ -142,9 +142,9 @@ static struct i2c_driver isp1301_driver = {
module_i2c_driver(isp1301_driver);
static int match(struct device *dev, void *data)
static int match(struct device *dev, const void *data)
{
struct device_node *node = (struct device_node *)data;
const struct device_node *node = (const struct device_node *)data;
return (dev->of_node == node) &&
(dev->driver == &isp1301_driver.driver);
}

View File

@ -171,10 +171,10 @@ struct visor_busdev {
u32 dev_no;
};
static int match_visorbus_dev_by_id(struct device *dev, void *data)
static int match_visorbus_dev_by_id(struct device *dev, const void *data)
{
struct visor_device *vdev = to_visor_device(dev);
struct visor_busdev *id = data;
const struct visor_busdev *id = data;
if (vdev->chipset_bus_no == id->bus_no &&
vdev->chipset_dev_no == id->dev_no)

View File

@ -166,8 +166,8 @@ void subsys_dev_iter_exit(struct subsys_dev_iter *iter);
int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
int (*fn)(struct device *dev, void *data));
struct device *bus_find_device(struct bus_type *bus, struct device *start,
void *data,
int (*match)(struct device *dev, void *data));
const void *data,
int (*match)(struct device *dev, const void *data));
struct device *bus_find_device_by_name(struct bus_type *bus,
struct device *start,
const char *name);

View File

@ -405,7 +405,7 @@ static const struct dailink_match_data dailink_match[] = {
},
};
static int of_dev_node_match(struct device *dev, void *data)
static int of_dev_node_match(struct device *dev, const void *data)
{
return dev->of_node == data;
}