Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9f3b795a authored by Michał Mirosław's avatar Michał Mirosław Committed by Greg Kroah-Hartman
Browse files

driver-core: constify data for class_find_device()



All in-kernel users of class_find_device() don't really need mutable
data for match callback.

In two places (kernel/power/suspend_test.c, drivers/scsi/osd/osd_uld.c)
this patch changes match callbacks to use const search data.

The const is propagated to rtc_class_open() and power_supply_get_by_name()
parameters.

Note that there's a dev reference leak in suspend_test.c that's not
touched in this patch.

Signed-off-by: default avatarMichał Mirosław <mirq-linux@rere.qmqm.pl>
Acked-by: default avatarGrant Likely <grant.likely@secretlab.ca>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 807be03c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -420,8 +420,8 @@ EXPORT_SYMBOL_GPL(class_for_each_device);
 * code.  There's no locking restriction.
 */
struct device *class_find_device(struct class *class, struct device *start,
				 void *data,
				 int (*match)(struct device *, void *))
				 const void *data,
				 int (*match)(struct device *, const void *))
{
	struct class_dev_iter iter;
	struct device *dev;
+2 −2
Original line number Diff line number Diff line
@@ -1617,9 +1617,9 @@ struct device *device_create(struct class *class, struct device *parent,
}
EXPORT_SYMBOL_GPL(device_create);

static int __match_devt(struct device *dev, void *data)
static int __match_devt(struct device *dev, const void *data)
{
	dev_t *devt = data;
	const dev_t *devt = data;

	return dev->devt == *devt;
}
+1 −1
Original line number Diff line number Diff line
@@ -806,7 +806,7 @@ int gpio_export(unsigned gpio, bool direction_may_change)
}
EXPORT_SYMBOL_GPL(gpio_export);

static int match_export(struct device *dev, void *data)
static int match_export(struct device *dev, const void *data)
{
	return dev_get_drvdata(dev) == data;
}
+2 −2
Original line number Diff line number Diff line
@@ -168,13 +168,13 @@ static struct class mISDN_class = {
};

static int
_get_mdevice(struct device *dev, void *id)
_get_mdevice(struct device *dev, const void *id)
{
	struct mISDNdevice *mdev = dev_to_mISDN(dev);

	if (!mdev)
		return 0;
	if (mdev->id != *(u_int *)id)
	if (mdev->id != *(const u_int *)id)
		return 0;
	return 1;
}
+1 −1
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ static struct class mdio_bus_class = {

#if IS_ENABLED(CONFIG_OF_MDIO)
/* Helper function for of_mdio_find_bus */
static int of_mdio_bus_match(struct device *dev, void *mdio_bus_np)
static int of_mdio_bus_match(struct device *dev, const void *mdio_bus_np)
{
	return dev->of_node == mdio_bus_np;
}
Loading