Skip to content

Commit 7506dc7

Browse files
fredlawlbjorn-helgaas
authored andcommitted
PCI: Add wrappers for dev_printk()
Add PCI-specific dev_printk() wrappers and use them to simplify the code slightly. No functional change intended. Signed-off-by: Frederick Lawler <[email protected]> [bhelgaas: squash into one patch] Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent c7abb23 commit 7506dc7

29 files changed

+345
-362
lines changed

drivers/pci/access.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,7 @@ static size_t pci_vpd_size(struct pci_dev *dev, size_t old_size)
333333
(tag == PCI_VPD_LTIN_RW_DATA)) {
334334
if (pci_read_vpd(dev, off+1, 2,
335335
&header[1]) != 2) {
336-
dev_warn(&dev->dev,
337-
"invalid large VPD tag %02x size at offset %zu",
336+
pci_warn(dev, "invalid large VPD tag %02x size at offset %zu",
338337
tag, off + 1);
339338
return 0;
340339
}
@@ -354,8 +353,7 @@ static size_t pci_vpd_size(struct pci_dev *dev, size_t old_size)
354353
if ((tag != PCI_VPD_LTIN_ID_STRING) &&
355354
(tag != PCI_VPD_LTIN_RO_DATA) &&
356355
(tag != PCI_VPD_LTIN_RW_DATA)) {
357-
dev_warn(&dev->dev,
358-
"invalid %s VPD tag %02x at offset %zu",
356+
pci_warn(dev, "invalid %s VPD tag %02x at offset %zu",
359357
(header[0] & PCI_VPD_LRDT) ? "large" : "short",
360358
tag, off);
361359
return 0;
@@ -402,7 +400,7 @@ static int pci_vpd_wait(struct pci_dev *dev)
402400
max_sleep *= 2;
403401
}
404402

405-
dev_warn(&dev->dev, "VPD access failed. This is likely a firmware bug on this device. Contact the card vendor for a firmware update\n");
403+
pci_warn(dev, "VPD access failed. This is likely a firmware bug on this device. Contact the card vendor for a firmware update\n");
406404
return -ETIMEDOUT;
407405
}
408406

drivers/pci/bus.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ bool pci_bus_clip_resource(struct pci_dev *dev, int idx)
289289
res->end = end;
290290
res->flags &= ~IORESOURCE_UNSET;
291291
orig_res.flags &= ~IORESOURCE_UNSET;
292-
dev_printk(KERN_DEBUG, &dev->dev, "%pR clipped to %pR\n",
292+
pci_printk(KERN_DEBUG, dev, "%pR clipped to %pR\n",
293293
&orig_res, res);
294294

295295
return true;
@@ -325,7 +325,7 @@ void pci_bus_add_device(struct pci_dev *dev)
325325
dev->match_driver = true;
326326
retval = device_attach(&dev->dev);
327327
if (retval < 0 && retval != -EPROBE_DEFER) {
328-
dev_warn(&dev->dev, "device attach failed (%d)\n", retval);
328+
pci_warn(dev, "device attach failed (%d)\n", retval);
329329
pci_proc_detach_device(dev);
330330
pci_remove_sysfs_dev_files(dev);
331331
return;

drivers/pci/hotplug/cpqphp_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
835835

836836
bus = pdev->subordinate;
837837
if (!bus) {
838-
dev_notice(&pdev->dev, "the device is not a bridge, skipping\n");
838+
pci_notice(pdev, "the device is not a bridge, skipping\n");
839839
rc = -ENODEV;
840840
goto err_disable_device;
841841
}

drivers/pci/hotplug/pnv_php.c

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,7 @@ static int pnv_php_add_devtree(struct pnv_php_slot *php_slot)
271271

272272
ret = pnv_pci_get_device_tree(php_slot->dn->phandle, fdt1, 0x10000);
273273
if (ret) {
274-
dev_warn(&php_slot->pdev->dev, "Error %d getting FDT blob\n",
275-
ret);
274+
pci_warn(php_slot->pdev, "Error %d getting FDT blob\n", ret);
276275
goto free_fdt1;
277276
}
278277

@@ -287,7 +286,7 @@ static int pnv_php_add_devtree(struct pnv_php_slot *php_slot)
287286
dt = of_fdt_unflatten_tree(fdt, php_slot->dn, NULL);
288287
if (!dt) {
289288
ret = -EINVAL;
290-
dev_warn(&php_slot->pdev->dev, "Cannot unflatten FDT\n");
289+
pci_warn(php_slot->pdev, "Cannot unflatten FDT\n");
291290
goto free_fdt;
292291
}
293292

@@ -297,16 +296,15 @@ static int pnv_php_add_devtree(struct pnv_php_slot *php_slot)
297296
ret = pnv_php_populate_changeset(&php_slot->ocs, php_slot->dn);
298297
if (ret) {
299298
pnv_php_reverse_nodes(php_slot->dn);
300-
dev_warn(&php_slot->pdev->dev, "Error %d populating changeset\n",
299+
pci_warn(php_slot->pdev, "Error %d populating changeset\n",
301300
ret);
302301
goto free_dt;
303302
}
304303

305304
php_slot->dn->child = NULL;
306305
ret = of_changeset_apply(&php_slot->ocs);
307306
if (ret) {
308-
dev_warn(&php_slot->pdev->dev, "Error %d applying changeset\n",
309-
ret);
307+
pci_warn(php_slot->pdev, "Error %d applying changeset\n", ret);
310308
goto destroy_changeset;
311309
}
312310

@@ -342,14 +340,14 @@ int pnv_php_set_slot_power_state(struct hotplug_slot *slot,
342340
if (be64_to_cpu(msg.params[1]) != php_slot->dn->phandle ||
343341
be64_to_cpu(msg.params[2]) != state ||
344342
be64_to_cpu(msg.params[3]) != OPAL_SUCCESS) {
345-
dev_warn(&php_slot->pdev->dev, "Wrong msg (%lld, %lld, %lld)\n",
343+
pci_warn(php_slot->pdev, "Wrong msg (%lld, %lld, %lld)\n",
346344
be64_to_cpu(msg.params[1]),
347345
be64_to_cpu(msg.params[2]),
348346
be64_to_cpu(msg.params[3]));
349347
return -ENOMSG;
350348
}
351349
} else if (ret < 0) {
352-
dev_warn(&php_slot->pdev->dev, "Error %d powering %s\n",
350+
pci_warn(php_slot->pdev, "Error %d powering %s\n",
353351
ret, (state == OPAL_PCI_SLOT_POWER_ON) ? "on" : "off");
354352
return ret;
355353
}
@@ -376,7 +374,7 @@ static int pnv_php_get_power_state(struct hotplug_slot *slot, u8 *state)
376374
*/
377375
ret = pnv_pci_get_power_state(php_slot->id, &power_state);
378376
if (ret) {
379-
dev_warn(&php_slot->pdev->dev, "Error %d getting power status\n",
377+
pci_warn(php_slot->pdev, "Error %d getting power status\n",
380378
ret);
381379
} else {
382380
*state = power_state;
@@ -402,8 +400,7 @@ static int pnv_php_get_adapter_state(struct hotplug_slot *slot, u8 *state)
402400
slot->info->adapter_status = presence;
403401
ret = 0;
404402
} else {
405-
dev_warn(&php_slot->pdev->dev, "Error %d getting presence\n",
406-
ret);
403+
pci_warn(php_slot->pdev, "Error %d getting presence\n", ret);
407404
}
408405

409406
return ret;
@@ -626,8 +623,7 @@ static int pnv_php_register_slot(struct pnv_php_slot *php_slot)
626623
ret = pci_hp_register(&php_slot->slot, php_slot->bus,
627624
php_slot->slot_no, php_slot->name);
628625
if (ret) {
629-
dev_warn(&php_slot->pdev->dev, "Error %d registering slot\n",
630-
ret);
626+
pci_warn(php_slot->pdev, "Error %d registering slot\n", ret);
631627
return ret;
632628
}
633629

@@ -680,7 +676,7 @@ static int pnv_php_enable_msix(struct pnv_php_slot *php_slot)
680676
/* Enable MSIx */
681677
ret = pci_enable_msix_exact(pdev, &entry, 1);
682678
if (ret) {
683-
dev_warn(&pdev->dev, "Error %d enabling MSIx\n", ret);
679+
pci_warn(pdev, "Error %d enabling MSIx\n", ret);
684680
return ret;
685681
}
686682

@@ -724,7 +720,7 @@ static irqreturn_t pnv_php_interrupt(int irq, void *data)
724720
(sts & PCI_EXP_SLTSTA_PDC)) {
725721
ret = pnv_pci_get_presence_state(php_slot->id, &presence);
726722
if (ret) {
727-
dev_warn(&pdev->dev, "PCI slot [%s] error %d getting presence (0x%04x), to retry the operation.\n",
723+
pci_warn(pdev, "PCI slot [%s] error %d getting presence (0x%04x), to retry the operation.\n",
728724
php_slot->name, ret, sts);
729725
return IRQ_HANDLED;
730726
}
@@ -754,12 +750,12 @@ static irqreturn_t pnv_php_interrupt(int irq, void *data)
754750
*/
755751
event = kzalloc(sizeof(*event), GFP_ATOMIC);
756752
if (!event) {
757-
dev_warn(&pdev->dev, "PCI slot [%s] missed hotplug event 0x%04x\n",
753+
pci_warn(pdev, "PCI slot [%s] missed hotplug event 0x%04x\n",
758754
php_slot->name, sts);
759755
return IRQ_HANDLED;
760756
}
761757

762-
dev_info(&pdev->dev, "PCI slot [%s] %s (IRQ: %d)\n",
758+
pci_info(pdev, "PCI slot [%s] %s (IRQ: %d)\n",
763759
php_slot->name, added ? "added" : "removed", irq);
764760
INIT_WORK(&event->work, pnv_php_event_handler);
765761
event->added = added;
@@ -779,7 +775,7 @@ static void pnv_php_init_irq(struct pnv_php_slot *php_slot, int irq)
779775
/* Allocate workqueue */
780776
php_slot->wq = alloc_workqueue("pciehp-%s", 0, 0, php_slot->name);
781777
if (!php_slot->wq) {
782-
dev_warn(&pdev->dev, "Cannot alloc workqueue\n");
778+
pci_warn(pdev, "Cannot alloc workqueue\n");
783779
pnv_php_disable_irq(php_slot, true);
784780
return;
785781
}
@@ -803,7 +799,7 @@ static void pnv_php_init_irq(struct pnv_php_slot *php_slot, int irq)
803799
php_slot->name, php_slot);
804800
if (ret) {
805801
pnv_php_disable_irq(php_slot, true);
806-
dev_warn(&pdev->dev, "Error %d enabling IRQ %d\n", ret, irq);
802+
pci_warn(pdev, "Error %d enabling IRQ %d\n", ret, irq);
807803
return;
808804
}
809805

@@ -839,7 +835,7 @@ static void pnv_php_enable_irq(struct pnv_php_slot *php_slot)
839835

840836
ret = pci_enable_device(pdev);
841837
if (ret) {
842-
dev_warn(&pdev->dev, "Error %d enabling device\n", ret);
838+
pci_warn(pdev, "Error %d enabling device\n", ret);
843839
return;
844840
}
845841

drivers/pci/hotplug/sgi_hotplug.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -245,18 +245,18 @@ static int sn_slot_enable(struct hotplug_slot *bss_hotplug_slot,
245245

246246

247247
if (rc == PCI_SLOT_ALREADY_UP) {
248-
dev_dbg(&slot->pci_bus->self->dev, "is already active\n");
248+
pci_dbg(slot->pci_bus->self, "is already active\n");
249249
return 1; /* return 1 to user */
250250
}
251251

252252
if (rc == PCI_L1_ERR) {
253-
dev_dbg(&slot->pci_bus->self->dev, "L1 failure %d with message: %s",
253+
pci_dbg(slot->pci_bus->self, "L1 failure %d with message: %s",
254254
resp.resp_sub_errno, resp.resp_l1_msg);
255255
return -EPERM;
256256
}
257257

258258
if (rc) {
259-
dev_dbg(&slot->pci_bus->self->dev, "insert failed with error %d sub-error %d\n",
259+
pci_dbg(slot->pci_bus->self, "insert failed with error %d sub-error %d\n",
260260
rc, resp.resp_sub_errno);
261261
return -EIO;
262262
}
@@ -281,23 +281,23 @@ static int sn_slot_disable(struct hotplug_slot *bss_hotplug_slot,
281281

282282
if ((action == PCI_REQ_SLOT_ELIGIBLE) &&
283283
(rc == PCI_SLOT_ALREADY_DOWN)) {
284-
dev_dbg(&slot->pci_bus->self->dev, "Slot %s already inactive\n", slot->physical_path);
284+
pci_dbg(slot->pci_bus->self, "Slot %s already inactive\n", slot->physical_path);
285285
return 1; /* return 1 to user */
286286
}
287287

288288
if ((action == PCI_REQ_SLOT_ELIGIBLE) && (rc == PCI_EMPTY_33MHZ)) {
289-
dev_dbg(&slot->pci_bus->self->dev, "Cannot remove last 33MHz card\n");
289+
pci_dbg(slot->pci_bus->self, "Cannot remove last 33MHz card\n");
290290
return -EPERM;
291291
}
292292

293293
if ((action == PCI_REQ_SLOT_ELIGIBLE) && (rc == PCI_L1_ERR)) {
294-
dev_dbg(&slot->pci_bus->self->dev, "L1 failure %d with message \n%s\n",
294+
pci_dbg(slot->pci_bus->self, "L1 failure %d with message \n%s\n",
295295
resp.resp_sub_errno, resp.resp_l1_msg);
296296
return -EPERM;
297297
}
298298

299299
if ((action == PCI_REQ_SLOT_ELIGIBLE) && rc) {
300-
dev_dbg(&slot->pci_bus->self->dev, "remove failed with error %d sub-error %d\n",
300+
pci_dbg(slot->pci_bus->self, "remove failed with error %d sub-error %d\n",
301301
rc, resp.resp_sub_errno);
302302
return -EIO;
303303
}
@@ -308,12 +308,12 @@ static int sn_slot_disable(struct hotplug_slot *bss_hotplug_slot,
308308
if ((action == PCI_REQ_SLOT_DISABLE) && !rc) {
309309
pcibus_info = SN_PCIBUS_BUSSOFT_INFO(slot->pci_bus);
310310
pcibus_info->pbi_enabled_devices &= ~(1 << device_num);
311-
dev_dbg(&slot->pci_bus->self->dev, "remove successful\n");
311+
pci_dbg(slot->pci_bus->self, "remove successful\n");
312312
return 0;
313313
}
314314

315315
if ((action == PCI_REQ_SLOT_DISABLE) && rc) {
316-
dev_dbg(&slot->pci_bus->self->dev, "remove failed rc = %d\n", rc);
316+
pci_dbg(slot->pci_bus->self, "remove failed rc = %d\n", rc);
317317
}
318318

319319
return rc;
@@ -366,7 +366,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
366366
num_funcs = pci_scan_slot(slot->pci_bus,
367367
PCI_DEVFN(slot->device_num + 1, 0));
368368
if (!num_funcs) {
369-
dev_dbg(&slot->pci_bus->self->dev, "no device in slot\n");
369+
pci_dbg(slot->pci_bus->self, "no device in slot\n");
370370
mutex_unlock(&sn_hotplug_mutex);
371371
return -ENODEV;
372372
}
@@ -412,7 +412,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
412412
phandle = acpi_device_handle(PCI_CONTROLLER(slot->pci_bus)->companion);
413413

414414
if (acpi_bus_get_device(phandle, &pdevice)) {
415-
dev_dbg(&slot->pci_bus->self->dev, "no parent device, assuming NULL\n");
415+
pci_dbg(slot->pci_bus->self, "no parent device, assuming NULL\n");
416416
pdevice = NULL;
417417
}
418418

@@ -463,9 +463,9 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
463463
mutex_unlock(&sn_hotplug_mutex);
464464

465465
if (rc == 0)
466-
dev_dbg(&slot->pci_bus->self->dev, "insert operation successful\n");
466+
pci_dbg(slot->pci_bus->self, "insert operation successful\n");
467467
else
468-
dev_dbg(&slot->pci_bus->self->dev, "insert operation failed rc = %d\n", rc);
468+
pci_dbg(slot->pci_bus->self, "insert operation failed rc = %d\n", rc);
469469

470470
return rc;
471471
}
@@ -643,16 +643,16 @@ static int sn_hotplug_slot_register(struct pci_bus *pci_bus)
643643
if (rc)
644644
goto register_err;
645645
}
646-
dev_dbg(&pci_bus->self->dev, "Registered bus with hotplug\n");
646+
pci_dbg(pci_bus->self, "Registered bus with hotplug\n");
647647
return rc;
648648

649649
register_err:
650-
dev_dbg(&pci_bus->self->dev, "bus failed to register with err = %d\n",
650+
pci_dbg(pci_bus->self, "bus failed to register with err = %d\n",
651651
rc);
652652

653653
alloc_err:
654654
if (rc == -ENOMEM)
655-
dev_dbg(&pci_bus->self->dev, "Memory allocation error\n");
655+
pci_dbg(pci_bus->self, "Memory allocation error\n");
656656

657657
/* destroy THIS element */
658658
if (bss_hotplug_slot)
@@ -685,10 +685,10 @@ static int __init sn_pci_hotplug_init(void)
685685

686686
rc = sn_pci_bus_valid(pci_bus);
687687
if (rc != 1) {
688-
dev_dbg(&pci_bus->self->dev, "not a valid hotplug bus\n");
688+
pci_dbg(pci_bus->self, "not a valid hotplug bus\n");
689689
continue;
690690
}
691-
dev_dbg(&pci_bus->self->dev, "valid hotplug bus\n");
691+
pci_dbg(pci_bus->self, "valid hotplug bus\n");
692692

693693
rc = sn_hotplug_slot_register(pci_bus);
694694
if (!rc) {

drivers/pci/hotplug/shpchp.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ do { \
6262
#define ctrl_dbg(ctrl, format, arg...) \
6363
do { \
6464
if (shpchp_debug) \
65-
dev_printk(KERN_DEBUG, &ctrl->pci_dev->dev, \
65+
pci_printk(KERN_DEBUG, ctrl->pci_dev, \
6666
format, ## arg); \
6767
} while (0)
6868
#define ctrl_err(ctrl, format, arg...) \
69-
dev_err(&ctrl->pci_dev->dev, format, ## arg)
69+
pci_err(ctrl->pci_dev, format, ## arg)
7070
#define ctrl_info(ctrl, format, arg...) \
71-
dev_info(&ctrl->pci_dev->dev, format, ## arg)
71+
pci_info(ctrl->pci_dev, format, ## arg)
7272
#define ctrl_warn(ctrl, format, arg...) \
73-
dev_warn(&ctrl->pci_dev->dev, format, ## arg)
73+
pci_warn(ctrl->pci_dev, format, ## arg)
7474

7575

7676
#define SLOT_NAME_SIZE 10

drivers/pci/iov.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,19 +259,19 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
259259
nres++;
260260
}
261261
if (nres != iov->nres) {
262-
dev_err(&dev->dev, "not enough MMIO resources for SR-IOV\n");
262+
pci_err(dev, "not enough MMIO resources for SR-IOV\n");
263263
return -ENOMEM;
264264
}
265265

266266
bus = pci_iov_virtfn_bus(dev, nr_virtfn - 1);
267267
if (bus > dev->bus->busn_res.end) {
268-
dev_err(&dev->dev, "can't enable %d VFs (bus %02x out of range of %pR)\n",
268+
pci_err(dev, "can't enable %d VFs (bus %02x out of range of %pR)\n",
269269
nr_virtfn, bus, &dev->bus->busn_res);
270270
return -ENOMEM;
271271
}
272272

273273
if (pci_enable_resources(dev, bars)) {
274-
dev_err(&dev->dev, "SR-IOV: IOV BARS not allocated\n");
274+
pci_err(dev, "SR-IOV: IOV BARS not allocated\n");
275275
return -ENOMEM;
276276
}
277277

@@ -298,7 +298,7 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)
298298

299299
rc = pcibios_sriov_enable(dev, initial);
300300
if (rc) {
301-
dev_err(&dev->dev, "failure %d from pcibios_sriov_enable()\n", rc);
301+
pci_err(dev, "failure %d from pcibios_sriov_enable()\n", rc);
302302
goto err_pcibios;
303303
}
304304

@@ -432,7 +432,7 @@ static int sriov_init(struct pci_dev *dev, int pos)
432432
}
433433
iov->barsz[i] = resource_size(res);
434434
res->end = res->start + resource_size(res) * total - 1;
435-
dev_info(&dev->dev, "VF(n) BAR%d space: %pR (contains BAR%d for %d VFs)\n",
435+
pci_info(dev, "VF(n) BAR%d space: %pR (contains BAR%d for %d VFs)\n",
436436
i, res, i, total);
437437
i += bar64;
438438
nres++;

0 commit comments

Comments
 (0)