Commit 2243acd5 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

driver core: class: remove struct class_interface * from callbacks



The add_dev and remove_dev callbacks in struct class_interface currently
pass in a pointer back to the class_interface structure that is calling
them, but none of the callback implementations actually use this pointer
as it is pointless (the structure is known, the driver passed it in in
the first place if it is really needed again.)

So clean this up and just remove the pointer from the callbacks and fix
up all callback functions.

Cc: Jean Delvare <jdelvare@suse.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Kurt Schwemmer <kurt.schwemmer@microsemi.com>
Cc: Jon Mason <jdmason@kudzu.us>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Allen Hubbe <allenbh@gmail.com>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Matt Porter <mporter@kernel.crashing.org>
Cc: Alexandre Bounine <alex.bou9@gmail.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Doug Gilbert <dgilbert@interlog.com>
Cc: John Stultz <jstultz@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Stephen Boyd <sboyd@kernel.org>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Wang Weiyang <wangweiyang2@huawei.com>
Cc: Yang Yingliang <yangyingliang@huawei.com>
Cc: Jakob Koschel <jakobkoschel@gmail.com>
Cc: Cai Xinchen <caixinchen1@huawei.com>
Acked-by: default avatarRafael J. Wysocki <rafael@kernel.org>
Acked-by: default avatarLogan Gunthorpe <logang@deltatee.com>
Link: https://lore.kernel.org/r/2023040250-pushover-platter-509c@gregkh


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6b0d49be
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -486,7 +486,7 @@ int class_interface_register(struct class_interface *class_intf)
	if (class_intf->add_dev) {
		class_dev_iter_init(&iter, parent, NULL, NULL);
		while ((dev = class_dev_iter_next(&iter)))
			class_intf->add_dev(dev, class_intf);
			class_intf->add_dev(dev);
		class_dev_iter_exit(&iter);
	}
	mutex_unlock(&sp->mutex);
@@ -514,7 +514,7 @@ void class_interface_unregister(struct class_interface *class_intf)
	if (class_intf->remove_dev) {
		class_dev_iter_init(&iter, parent, NULL, NULL);
		while ((dev = class_dev_iter_next(&iter)))
			class_intf->remove_dev(dev, class_intf);
			class_intf->remove_dev(dev);
		class_dev_iter_exit(&iter);
	}
	mutex_unlock(&sp->mutex);
+4 −6
Original line number Diff line number Diff line
@@ -541,8 +541,7 @@ static struct class devlink_class = {
	.dev_release = devlink_dev_release,
};

static int devlink_add_symlinks(struct device *dev,
				struct class_interface *class_intf)
static int devlink_add_symlinks(struct device *dev)
{
	int ret;
	size_t len;
@@ -591,8 +590,7 @@ static int devlink_add_symlinks(struct device *dev,
	return ret;
}

static void devlink_remove_symlinks(struct device *dev,
				   struct class_interface *class_intf)
static void devlink_remove_symlinks(struct device *dev)
{
	struct device_link *link = to_devlink(dev);
	size_t len;
@@ -3647,7 +3645,7 @@ int device_add(struct device *dev)
		/* notify any interfaces that the device is here */
		list_for_each_entry(class_intf, &sp->interfaces, node)
			if (class_intf->add_dev)
				class_intf->add_dev(dev, class_intf);
				class_intf->add_dev(dev);
		mutex_unlock(&sp->mutex);
		subsys_put(sp);
	}
@@ -3805,7 +3803,7 @@ void device_del(struct device *dev)
		/* notify any interfaces that the device is now gone */
		list_for_each_entry(class_intf, &sp->interfaces, node)
			if (class_intf->remove_dev)
				class_intf->remove_dev(dev, class_intf);
				class_intf->remove_dev(dev);
		/* remove the device from the class list */
		klist_del(&dev->p->knode_class);
		mutex_unlock(&sp->mutex);
+2 −2
Original line number Diff line number Diff line
@@ -550,7 +550,7 @@ static const struct hwmon_chip_info drivetemp_chip_info = {
 * The device argument points to sdev->sdev_dev. Its parent is
 * sdev->sdev_gendev, which we can use to get the scsi_device pointer.
 */
static int drivetemp_add(struct device *dev, struct class_interface *intf)
static int drivetemp_add(struct device *dev)
{
	struct scsi_device *sdev = to_scsi_device(dev->parent);
	struct drivetemp_data *st;
@@ -585,7 +585,7 @@ static int drivetemp_add(struct device *dev, struct class_interface *intf)
	return err;
}

static void drivetemp_remove(struct device *dev, struct class_interface *intf)
static void drivetemp_remove(struct device *dev)
{
	struct drivetemp_data *st, *tmp;

+1 −2
Original line number Diff line number Diff line
@@ -662,8 +662,7 @@ static int rionet_shutdown(struct notifier_block *nb, unsigned long code,
	return NOTIFY_DONE;
}

static void rionet_remove_mport(struct device *dev,
				struct class_interface *class_intf)
static void rionet_remove_mport(struct device *dev)
{
	struct rio_mport *mport = to_rio_mport(dev);
	struct net_device *ndev;
+2 −4
Original line number Diff line number Diff line
@@ -1470,8 +1470,7 @@ static int switchtec_ntb_reinit_peer(struct switchtec_ntb *sndev)
	return rc;
}

static int switchtec_ntb_add(struct device *dev,
			     struct class_interface *class_intf)
static int switchtec_ntb_add(struct device *dev)
{
	struct switchtec_dev *stdev = to_stdev(dev);
	struct switchtec_ntb *sndev;
@@ -1541,8 +1540,7 @@ static int switchtec_ntb_add(struct device *dev,
	return rc;
}

static void switchtec_ntb_remove(struct device *dev,
				 struct class_interface *class_intf)
static void switchtec_ntb_remove(struct device *dev)
{
	struct switchtec_dev *stdev = to_stdev(dev);
	struct switchtec_ntb *sndev = stdev->sndev;
Loading