diff mbox series

[RFC,04/11] drivers: base: Make device_{add|remove}_class_symlinks() public

Message ID 20191024172157.878735-5-s.miroshnichenko@yadro.com
State New
Delegated to: Bjorn Helgaas
Headers show
Series PCI: hotplug: Movable bus numbers | expand

Commit Message

Sergei Miroshnichenko Oct. 24, 2019, 5:21 p.m. UTC
When updating the /sys/devices/pci* entries affected by changes in the PCI
topology, their symlinks in /sys/bus/pci/devices/* must also be rebuilt.

Moving device_add_class_symlinks() and device_remove_class_symlinks() to a
public API allows the PCI subsystem to update the sysfs without destroying
the working affected devices.

Signed-off-by: Sergey Miroshnichenko <s.miroshnichenko@yadro.com>
 drivers/base/core.c    | 6 ++++--
 include/linux/device.h | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)
diff mbox series


diff --git a/drivers/base/core.c b/drivers/base/core.c
index 7bd9cd366d41..23e689fc8478 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1922,7 +1922,7 @@  static void cleanup_glue_dir(struct device *dev, struct kobject *glue_dir)
-static int device_add_class_symlinks(struct device *dev)
+int device_add_class_symlinks(struct device *dev)
 	struct device_node *of_node = dev_of_node(dev);
 	int error;
@@ -1973,8 +1973,9 @@  static int device_add_class_symlinks(struct device *dev)
 	sysfs_remove_link(&dev->kobj, "of_node");
 	return error;
-static void device_remove_class_symlinks(struct device *dev)
+void device_remove_class_symlinks(struct device *dev)
 	if (dev_of_node(dev))
 		sysfs_remove_link(&dev->kobj, "of_node");
@@ -1991,6 +1992,7 @@  static void device_remove_class_symlinks(struct device *dev)
 	sysfs_delete_link(&dev->class->p->subsys.kobj, &dev->kobj, dev_name(dev));
  * dev_set_name - set a device name
diff --git a/include/linux/device.h b/include/linux/device.h
index 4d8bbc8ae73d..420228ab9c4b 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -268,6 +268,8 @@  void bus_sort_breadthfirst(struct bus_type *bus,
 			   int (*compare)(const struct device *a,
 					  const struct device *b));
 extern int bus_add_device(struct device *dev);
+extern int device_add_class_symlinks(struct device *dev);
+extern void device_remove_class_symlinks(struct device *dev);
  * Bus notifiers: Get notified of addition/removal of devices