Skip to content

Commit

Permalink
Merge branch 'pci/misc'
Browse files Browse the repository at this point in the history
- Reorganize kerneldoc parameter names to match order in function signature
  (Julia Lawall)

- Remove kerneldoc return value descriptions from hotplug registration
  interfaces that don't return anything (Ilpo Järvinen)

- Fix sysfs reset_method_store() memory leak (Todd Kjos)

- Simplify pci_create_slot() (Ilpo Järvinen)

- Fix incorrect printf format specifiers in pcitest (Luo Yifan)

* pci/misc:
  tools: PCI: Fix incorrect printf format specifiers
  PCI: Simplify pci_create_slot() logic
  PCI: Fix reset_method_store() memory leak
  PCI: hotplug: Remove "Returns" kerneldoc from void functions
  PCI: hotplug: Reorganize kerneldoc parameter names
  • Loading branch information
Bjorn Helgaas committed Nov 25, 2024
2 parents e6b95ef + d9db393 commit 2d56427
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 23 deletions.
8 changes: 1 addition & 7 deletions drivers/pci/hotplug/pci_hotplug_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,8 @@ static struct hotplug_slot *get_slot_from_name(const char *name)

/**
* __pci_hp_register - register a hotplug_slot with the PCI hotplug subsystem
* @bus: bus this slot is on
* @slot: pointer to the &struct hotplug_slot to register
* @bus: bus this slot is on
* @devnr: device number
* @name: name registered with kobject core
* @owner: caller module owner
Expand Down Expand Up @@ -498,8 +498,6 @@ EXPORT_SYMBOL_GPL(pci_hp_add);
*
* The @slot must have been registered with the pci hotplug subsystem
* previously with a call to pci_hp_register().
*
* Returns 0 if successful, anything else for an error.
*/
void pci_hp_deregister(struct hotplug_slot *slot)
{
Expand All @@ -513,8 +511,6 @@ EXPORT_SYMBOL_GPL(pci_hp_deregister);
* @slot: pointer to the &struct hotplug_slot to unpublish
*
* Remove a hotplug slot's sysfs interface.
*
* Returns 0 on success or a negative int on error.
*/
void pci_hp_del(struct hotplug_slot *slot)
{
Expand Down Expand Up @@ -545,8 +541,6 @@ EXPORT_SYMBOL_GPL(pci_hp_del);
* the driver may no longer invoke hotplug_slot_name() to get the slot's
* unique name. The driver no longer needs to handle a ->reset_slot callback
* from this point on.
*
* Returns 0 on success or a negative int on error.
*/
void pci_hp_destroy(struct hotplug_slot *slot)
{
Expand Down
5 changes: 3 additions & 2 deletions drivers/pci/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -5250,7 +5250,7 @@ static ssize_t reset_method_store(struct device *dev,
const char *buf, size_t count)
{
struct pci_dev *pdev = to_pci_dev(dev);
char *options, *name;
char *options, *tmp_options, *name;
int m, n;
u8 reset_methods[PCI_NUM_RESET_METHODS] = { 0 };

Expand All @@ -5270,7 +5270,8 @@ static ssize_t reset_method_store(struct device *dev,
return -ENOMEM;

n = 0;
while ((name = strsep(&options, " ")) != NULL) {
tmp_options = options;
while ((name = strsep(&tmp_options, " ")) != NULL) {
if (sysfs_streq(name, ""))
continue;

Expand Down
20 changes: 11 additions & 9 deletions drivers/pci/slot.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,13 @@ struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr,
slot = get_slot(parent, slot_nr);
if (slot) {
if (hotplug) {
if ((err = slot->hotplug ? -EBUSY : 0)
|| (err = rename_slot(slot, name))) {
kobject_put(&slot->kobj);
slot = NULL;
goto err;
if (slot->hotplug) {
err = -EBUSY;
goto put_slot;
}
err = rename_slot(slot, name);
if (err)
goto put_slot;
}
goto out;
}
Expand Down Expand Up @@ -280,10 +281,8 @@ struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr,

err = kobject_init_and_add(&slot->kobj, &pci_slot_ktype, NULL,
"%s", slot_name);
if (err) {
kobject_put(&slot->kobj);
goto err;
}
if (err)
goto put_slot;

down_read(&pci_bus_sem);
list_for_each_entry(dev, &parent->devices, bus_list)
Expand All @@ -298,6 +297,9 @@ struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr,
kfree(slot_name);
mutex_unlock(&pci_slot_mutex);
return slot;

put_slot:
kobject_put(&slot->kobj);
err:
slot = ERR_PTR(err);
goto out;
Expand Down
10 changes: 5 additions & 5 deletions tools/pci/pcitest.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static int run_test(struct pci_test *test)

if (test->msinum > 0 && test->msinum <= 32) {
ret = ioctl(fd, PCITEST_MSI, test->msinum);
fprintf(stdout, "MSI%d:\t\t", test->msinum);
fprintf(stdout, "MSI%u:\t\t", test->msinum);
if (ret < 0)
fprintf(stdout, "TEST FAILED\n");
else
Expand All @@ -104,7 +104,7 @@ static int run_test(struct pci_test *test)

if (test->msixnum > 0 && test->msixnum <= 2048) {
ret = ioctl(fd, PCITEST_MSIX, test->msixnum);
fprintf(stdout, "MSI-X%d:\t\t", test->msixnum);
fprintf(stdout, "MSI-X%u:\t\t", test->msixnum);
if (ret < 0)
fprintf(stdout, "TEST FAILED\n");
else
Expand All @@ -116,7 +116,7 @@ static int run_test(struct pci_test *test)
if (test->use_dma)
param.flags = PCITEST_FLAGS_USE_DMA;
ret = ioctl(fd, PCITEST_WRITE, &param);
fprintf(stdout, "WRITE (%7ld bytes):\t\t", test->size);
fprintf(stdout, "WRITE (%7lu bytes):\t\t", test->size);
if (ret < 0)
fprintf(stdout, "TEST FAILED\n");
else
Expand All @@ -128,7 +128,7 @@ static int run_test(struct pci_test *test)
if (test->use_dma)
param.flags = PCITEST_FLAGS_USE_DMA;
ret = ioctl(fd, PCITEST_READ, &param);
fprintf(stdout, "READ (%7ld bytes):\t\t", test->size);
fprintf(stdout, "READ (%7lu bytes):\t\t", test->size);
if (ret < 0)
fprintf(stdout, "TEST FAILED\n");
else
Expand All @@ -140,7 +140,7 @@ static int run_test(struct pci_test *test)
if (test->use_dma)
param.flags = PCITEST_FLAGS_USE_DMA;
ret = ioctl(fd, PCITEST_COPY, &param);
fprintf(stdout, "COPY (%7ld bytes):\t\t", test->size);
fprintf(stdout, "COPY (%7lu bytes):\t\t", test->size);
if (ret < 0)
fprintf(stdout, "TEST FAILED\n");
else
Expand Down

0 comments on commit 2d56427

Please sign in to comment.