Skip to content

Commit cc973ef

Browse files
l1kbjorn-helgaas
authored andcommitted
PCI: hotplug: Inline pci_hp_{create,remove}_module_link()
For no apparent reason, the pci_hp_{create,remove}_module_link() helpers live in slot.c, even though they're only called from two functions in pci_hotplug_core.c. Inline the helpers to reduce code size and number of exported symbols. Link: https://lore.kernel.org/r/c207f03cfe32ae9002d9b453001a1dd63d9ab3fb.1740501868.git.lukas@wunner.de Signed-off-by: Lukas Wunner <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent 34bd614 commit cc973ef

File tree

3 files changed

+11
-50
lines changed

3 files changed

+11
-50
lines changed

drivers/pci/hotplug/pci_hotplug_core.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,18 @@ static bool has_test_file(struct hotplug_slot *slot)
245245

246246
static int fs_add_slot(struct hotplug_slot *slot, struct pci_slot *pci_slot)
247247
{
248+
struct kobject *kobj;
248249
int retval = 0;
249250

250251
/* Create symbolic link to the hotplug driver module */
251-
pci_hp_create_module_link(pci_slot);
252+
kobj = kset_find_obj(module_kset, slot->mod_name);
253+
if (kobj) {
254+
retval = sysfs_create_link(&pci_slot->kobj, kobj, "module");
255+
if (retval)
256+
dev_err(&pci_slot->bus->dev,
257+
"Error creating sysfs link (%d)\n", retval);
258+
kobject_put(kobj);
259+
}
252260

253261
if (has_power_file(slot)) {
254262
retval = sysfs_create_file(&pci_slot->kobj,
@@ -302,7 +310,7 @@ static int fs_add_slot(struct hotplug_slot *slot, struct pci_slot *pci_slot)
302310
if (has_power_file(slot))
303311
sysfs_remove_file(&pci_slot->kobj, &hotplug_slot_attr_power.attr);
304312
exit_power:
305-
pci_hp_remove_module_link(pci_slot);
313+
sysfs_remove_link(&pci_slot->kobj, "module");
306314
exit:
307315
return retval;
308316
}
@@ -326,7 +334,7 @@ static void fs_remove_slot(struct hotplug_slot *slot, struct pci_slot *pci_slot)
326334
if (has_test_file(slot))
327335
sysfs_remove_file(&pci_slot->kobj, &hotplug_slot_attr_test.attr);
328336

329-
pci_hp_remove_module_link(pci_slot);
337+
sysfs_remove_link(&pci_slot->kobj, "module");
330338
}
331339

332340
/**

drivers/pci/slot.c

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
#include <linux/kobject.h>
99
#include <linux/slab.h>
10-
#include <linux/module.h>
1110
#include <linux/pci.h>
1211
#include <linux/err.h>
1312
#include "pci.h"
@@ -325,47 +324,6 @@ void pci_destroy_slot(struct pci_slot *slot)
325324
}
326325
EXPORT_SYMBOL_GPL(pci_destroy_slot);
327326

328-
#if defined(CONFIG_HOTPLUG_PCI) || defined(CONFIG_HOTPLUG_PCI_MODULE)
329-
#include <linux/pci_hotplug.h>
330-
/**
331-
* pci_hp_create_module_link - create symbolic link to hotplug driver module
332-
* @pci_slot: struct pci_slot
333-
*
334-
* Helper function for pci_hotplug_core.c to create symbolic link to
335-
* the hotplug driver module.
336-
*/
337-
void pci_hp_create_module_link(struct pci_slot *pci_slot)
338-
{
339-
struct hotplug_slot *slot = pci_slot->hotplug;
340-
struct kobject *kobj = NULL;
341-
int ret;
342-
343-
kobj = kset_find_obj(module_kset, slot->mod_name);
344-
if (!kobj)
345-
return;
346-
ret = sysfs_create_link(&pci_slot->kobj, kobj, "module");
347-
if (ret)
348-
dev_err(&pci_slot->bus->dev, "Error creating sysfs link (%d)\n",
349-
ret);
350-
kobject_put(kobj);
351-
}
352-
EXPORT_SYMBOL_GPL(pci_hp_create_module_link);
353-
354-
/**
355-
* pci_hp_remove_module_link - remove symbolic link to the hotplug driver
356-
* module.
357-
* @pci_slot: struct pci_slot
358-
*
359-
* Helper function for pci_hotplug_core.c to remove symbolic link to
360-
* the hotplug driver module.
361-
*/
362-
void pci_hp_remove_module_link(struct pci_slot *pci_slot)
363-
{
364-
sysfs_remove_link(&pci_slot->kobj, "module");
365-
}
366-
EXPORT_SYMBOL_GPL(pci_hp_remove_module_link);
367-
#endif
368-
369327
static int pci_slot_init(void)
370328
{
371329
struct kset *pci_bus_kset;

include/linux/pci.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,11 +2447,6 @@ static inline resource_size_t pci_iov_resource_size(struct pci_dev *dev, int res
24472447
static inline void pci_vf_drivers_autoprobe(struct pci_dev *dev, bool probe) { }
24482448
#endif
24492449

2450-
#if defined(CONFIG_HOTPLUG_PCI) || defined(CONFIG_HOTPLUG_PCI_MODULE)
2451-
void pci_hp_create_module_link(struct pci_slot *pci_slot);
2452-
void pci_hp_remove_module_link(struct pci_slot *pci_slot);
2453-
#endif
2454-
24552450
/**
24562451
* pci_pcie_cap - get the saved PCIe capability offset
24572452
* @dev: PCI device

0 commit comments

Comments
 (0)