Skip to content

Commit 6904945

Browse files
bjorn-helgaasbostrovs
authored andcommitted
xen-pciback: Use dev_printk() when possible
Use dev_printk() when possible to include device and driver information in the conventional format. Add "#define dev_fmt" when needed to preserve DRV_NAME or KBUILD_MODNAME in messages. No functional change intended. Signed-off-by: Bjorn Helgaas <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Boris Ostrovsky <[email protected]> Signed-off-by: Boris Ostrovsky <[email protected]>
1 parent 2abb65a commit 6904945

File tree

6 files changed

+65
-83
lines changed

6 files changed

+65
-83
lines changed

drivers/xen/xen-pciback/conf_space.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
* Author: Ryan Wilson <[email protected]>
1111
*/
1212

13+
#define dev_fmt(fmt) DRV_NAME ": " fmt
14+
1315
#include <linux/kernel.h>
1416
#include <linux/moduleparam.h>
1517
#include <linux/pci.h>
@@ -155,8 +157,8 @@ int xen_pcibk_config_read(struct pci_dev *dev, int offset, int size,
155157
u32 value = 0, tmp_val;
156158

157159
if (unlikely(verbose_request))
158-
printk(KERN_DEBUG DRV_NAME ": %s: read %d bytes at 0x%x\n",
159-
pci_name(dev), size, offset);
160+
dev_printk(KERN_DEBUG, &dev->dev, "read %d bytes at 0x%x\n",
161+
size, offset);
160162

161163
if (!valid_request(offset, size)) {
162164
err = XEN_PCI_ERR_invalid_offset;
@@ -196,8 +198,8 @@ int xen_pcibk_config_read(struct pci_dev *dev, int offset, int size,
196198

197199
out:
198200
if (unlikely(verbose_request))
199-
printk(KERN_DEBUG DRV_NAME ": %s: read %d bytes at 0x%x = %x\n",
200-
pci_name(dev), size, offset, value);
201+
dev_printk(KERN_DEBUG, &dev->dev,
202+
"read %d bytes at 0x%x = %x\n", size, offset, value);
201203

202204
*ret_val = value;
203205
return xen_pcibios_err_to_errno(err);
@@ -213,9 +215,9 @@ int xen_pcibk_config_write(struct pci_dev *dev, int offset, int size, u32 value)
213215
int field_start, field_end;
214216

215217
if (unlikely(verbose_request))
216-
printk(KERN_DEBUG
217-
DRV_NAME ": %s: write request %d bytes at 0x%x = %x\n",
218-
pci_name(dev), size, offset, value);
218+
dev_printk(KERN_DEBUG, &dev->dev,
219+
"write request %d bytes at 0x%x = %x\n", size,
220+
offset, value);
219221

220222
if (!valid_request(offset, size))
221223
return XEN_PCI_ERR_invalid_offset;

drivers/xen/xen-pciback/conf_space_header.c

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
9+
#define dev_fmt pr_fmt
910

1011
#include <linux/kernel.h>
1112
#include <linux/pci.h>
@@ -68,52 +69,46 @@ static int command_write(struct pci_dev *dev, int offset, u16 value, void *data)
6869
dev_data = pci_get_drvdata(dev);
6970
if (!pci_is_enabled(dev) && is_enable_cmd(value)) {
7071
if (unlikely(verbose_request))
71-
printk(KERN_DEBUG DRV_NAME ": %s: enable\n",
72-
pci_name(dev));
72+
dev_printk(KERN_DEBUG, &dev->dev, "enable\n");
7373
err = pci_enable_device(dev);
7474
if (err)
7575
return err;
7676
if (dev_data)
7777
dev_data->enable_intx = 1;
7878
} else if (pci_is_enabled(dev) && !is_enable_cmd(value)) {
7979
if (unlikely(verbose_request))
80-
printk(KERN_DEBUG DRV_NAME ": %s: disable\n",
81-
pci_name(dev));
80+
dev_printk(KERN_DEBUG, &dev->dev, "disable\n");
8281
pci_disable_device(dev);
8382
if (dev_data)
8483
dev_data->enable_intx = 0;
8584
}
8685

8786
if (!dev->is_busmaster && is_master_cmd(value)) {
8887
if (unlikely(verbose_request))
89-
printk(KERN_DEBUG DRV_NAME ": %s: set bus master\n",
90-
pci_name(dev));
88+
dev_printk(KERN_DEBUG, &dev->dev, "set bus master\n");
9189
pci_set_master(dev);
9290
} else if (dev->is_busmaster && !is_master_cmd(value)) {
9391
if (unlikely(verbose_request))
94-
printk(KERN_DEBUG DRV_NAME ": %s: clear bus master\n",
95-
pci_name(dev));
92+
dev_printk(KERN_DEBUG, &dev->dev, "clear bus master\n");
9693
pci_clear_master(dev);
9794
}
9895

9996
if (!(cmd->val & PCI_COMMAND_INVALIDATE) &&
10097
(value & PCI_COMMAND_INVALIDATE)) {
10198
if (unlikely(verbose_request))
102-
printk(KERN_DEBUG
103-
DRV_NAME ": %s: enable memory-write-invalidate\n",
104-
pci_name(dev));
99+
dev_printk(KERN_DEBUG, &dev->dev,
100+
"enable memory-write-invalidate\n");
105101
err = pci_set_mwi(dev);
106102
if (err) {
107-
pr_warn("%s: cannot enable memory-write-invalidate (%d)\n",
108-
pci_name(dev), err);
103+
dev_warn(&dev->dev, "cannot enable memory-write-invalidate (%d)\n",
104+
err);
109105
value &= ~PCI_COMMAND_INVALIDATE;
110106
}
111107
} else if ((cmd->val & PCI_COMMAND_INVALIDATE) &&
112108
!(value & PCI_COMMAND_INVALIDATE)) {
113109
if (unlikely(verbose_request))
114-
printk(KERN_DEBUG
115-
DRV_NAME ": %s: disable memory-write-invalidate\n",
116-
pci_name(dev));
110+
dev_printk(KERN_DEBUG, &dev->dev,
111+
"disable memory-write-invalidate\n");
117112
pci_clear_mwi(dev);
118113
}
119114

@@ -157,8 +152,7 @@ static int rom_write(struct pci_dev *dev, int offset, u32 value, void *data)
157152
struct pci_bar_info *bar = data;
158153

159154
if (unlikely(!bar)) {
160-
pr_warn(DRV_NAME ": driver data not found for %s\n",
161-
pci_name(dev));
155+
dev_warn(&dev->dev, "driver data not found\n");
162156
return XEN_PCI_ERR_op_failed;
163157
}
164158

@@ -194,8 +188,7 @@ static int bar_write(struct pci_dev *dev, int offset, u32 value, void *data)
194188
u32 mask;
195189

196190
if (unlikely(!bar)) {
197-
pr_warn(DRV_NAME ": driver data not found for %s\n",
198-
pci_name(dev));
191+
dev_warn(&dev->dev, "driver data not found\n");
199192
return XEN_PCI_ERR_op_failed;
200193
}
201194

@@ -228,8 +221,7 @@ static int bar_read(struct pci_dev *dev, int offset, u32 * value, void *data)
228221
struct pci_bar_info *bar = data;
229222

230223
if (unlikely(!bar)) {
231-
pr_warn(DRV_NAME ": driver data not found for %s\n",
232-
pci_name(dev));
224+
dev_warn(&dev->dev, "driver data not found\n");
233225
return XEN_PCI_ERR_op_failed;
234226
}
235227

@@ -433,8 +425,8 @@ int xen_pcibk_config_header_add_fields(struct pci_dev *dev)
433425

434426
default:
435427
err = -EINVAL;
436-
pr_err("%s: Unsupported header type %d!\n",
437-
pci_name(dev), dev->hdr_type);
428+
dev_err(&dev->dev, "Unsupported header type %d!\n",
429+
dev->hdr_type);
438430
break;
439431
}
440432

drivers/xen/xen-pciback/conf_space_quirks.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* Author: Chris Bookholt <[email protected]>
77
*/
88

9+
#define dev_fmt(fmt) DRV_NAME ": " fmt
10+
911
#include <linux/kernel.h>
1012
#include <linux/pci.h>
1113
#include "pciback.h"
@@ -35,8 +37,8 @@ static struct xen_pcibk_config_quirk *xen_pcibk_find_quirk(struct pci_dev *dev)
3537
if (match_one_device(&tmp_quirk->devid, dev) != NULL)
3638
goto out;
3739
tmp_quirk = NULL;
38-
printk(KERN_DEBUG DRV_NAME
39-
": quirk didn't match any device known\n");
40+
dev_printk(KERN_DEBUG, &dev->dev,
41+
"quirk didn't match any device known\n");
4042
out:
4143
return tmp_quirk;
4244
}

drivers/xen/xen-pciback/pci_stub.c

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
9+
#define dev_fmt pr_fmt
910

1011
#include <linux/module.h>
1112
#include <linux/init.h>
@@ -626,11 +627,11 @@ static void pcistub_remove(struct pci_dev *dev)
626627
if (found_psdev->pdev) {
627628
int domid = xen_find_device_domain_owner(dev);
628629

629-
pr_warn("****** removing device %s while still in-use by domain %d! ******\n",
630+
dev_warn(&dev->dev, "****** removing device %s while still in-use by domain %d! ******\n",
630631
pci_name(found_psdev->dev), domid);
631-
pr_warn("****** driver domain may still access this device's i/o resources!\n");
632-
pr_warn("****** shutdown driver domain before binding device\n");
633-
pr_warn("****** to other drivers or domains\n");
632+
dev_warn(&dev->dev, "****** driver domain may still access this device's i/o resources!\n");
633+
dev_warn(&dev->dev, "****** shutdown driver domain before binding device\n");
634+
dev_warn(&dev->dev, "****** to other drivers or domains\n");
634635

635636
/* N.B. This ends up calling pcistub_put_pci_dev which ends up
636637
* doing the FLR. */
@@ -711,14 +712,12 @@ static pci_ers_result_t common_process(struct pcistub_device *psdev,
711712
ret = xen_pcibk_get_pcifront_dev(psdev->dev, psdev->pdev,
712713
&aer_op->domain, &aer_op->bus, &aer_op->devfn);
713714
if (!ret) {
714-
dev_err(&psdev->dev->dev,
715-
DRV_NAME ": failed to get pcifront device\n");
715+
dev_err(&psdev->dev->dev, "failed to get pcifront device\n");
716716
return PCI_ERS_RESULT_NONE;
717717
}
718718
wmb();
719719

720-
dev_dbg(&psdev->dev->dev,
721-
DRV_NAME ": aer_op %x dom %x bus %x devfn %x\n",
720+
dev_dbg(&psdev->dev->dev, "aer_op %x dom %x bus %x devfn %x\n",
722721
aer_cmd, aer_op->domain, aer_op->bus, aer_op->devfn);
723722
/*local flag to mark there's aer request, xen_pcibk callback will use
724723
* this flag to judge whether we need to check pci-front give aer
@@ -754,8 +753,7 @@ static pci_ers_result_t common_process(struct pcistub_device *psdev,
754753

755754
if (test_bit(_XEN_PCIF_active,
756755
(unsigned long *)&sh_info->flags)) {
757-
dev_dbg(&psdev->dev->dev,
758-
"schedule pci_conf service in " DRV_NAME "\n");
756+
dev_dbg(&psdev->dev->dev, "schedule pci_conf service\n");
759757
xen_pcibk_test_and_schedule_op(psdev->pdev);
760758
}
761759

@@ -786,13 +784,12 @@ static pci_ers_result_t xen_pcibk_slot_reset(struct pci_dev *dev)
786784
PCI_FUNC(dev->devfn));
787785

788786
if (!psdev || !psdev->pdev) {
789-
dev_err(&dev->dev,
790-
DRV_NAME " device is not found/assigned\n");
787+
dev_err(&dev->dev, "device is not found/assigned\n");
791788
goto end;
792789
}
793790

794791
if (!psdev->pdev->sh_info) {
795-
dev_err(&dev->dev, DRV_NAME " device is not connected or owned"
792+
dev_err(&dev->dev, "device is not connected or owned"
796793
" by HVM, kill it\n");
797794
kill_domain_by_device(psdev);
798795
goto end;
@@ -844,13 +841,12 @@ static pci_ers_result_t xen_pcibk_mmio_enabled(struct pci_dev *dev)
844841
PCI_FUNC(dev->devfn));
845842

846843
if (!psdev || !psdev->pdev) {
847-
dev_err(&dev->dev,
848-
DRV_NAME " device is not found/assigned\n");
844+
dev_err(&dev->dev, "device is not found/assigned\n");
849845
goto end;
850846
}
851847

852848
if (!psdev->pdev->sh_info) {
853-
dev_err(&dev->dev, DRV_NAME " device is not connected or owned"
849+
dev_err(&dev->dev, "device is not connected or owned"
854850
" by HVM, kill it\n");
855851
kill_domain_by_device(psdev);
856852
goto end;
@@ -902,13 +898,12 @@ static pci_ers_result_t xen_pcibk_error_detected(struct pci_dev *dev,
902898
PCI_FUNC(dev->devfn));
903899

904900
if (!psdev || !psdev->pdev) {
905-
dev_err(&dev->dev,
906-
DRV_NAME " device is not found/assigned\n");
901+
dev_err(&dev->dev, "device is not found/assigned\n");
907902
goto end;
908903
}
909904

910905
if (!psdev->pdev->sh_info) {
911-
dev_err(&dev->dev, DRV_NAME " device is not connected or owned"
906+
dev_err(&dev->dev, "device is not connected or owned"
912907
" by HVM, kill it\n");
913908
kill_domain_by_device(psdev);
914909
goto end;
@@ -956,13 +951,12 @@ static void xen_pcibk_error_resume(struct pci_dev *dev)
956951
PCI_FUNC(dev->devfn));
957952

958953
if (!psdev || !psdev->pdev) {
959-
dev_err(&dev->dev,
960-
DRV_NAME " device is not found/assigned\n");
954+
dev_err(&dev->dev, "device is not found/assigned\n");
961955
goto end;
962956
}
963957

964958
if (!psdev->pdev->sh_info) {
965-
dev_err(&dev->dev, DRV_NAME " device is not connected or owned"
959+
dev_err(&dev->dev, "device is not connected or owned"
966960
" by HVM, kill it\n");
967961
kill_domain_by_device(psdev);
968962
goto end;

0 commit comments

Comments
 (0)