Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <bhelgaas@google.com>
Link: https://lore.kernel.org/r/20200527174326.254329-2-helgaas@kernel.org
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

authored by

Bjorn Helgaas and committed by
Boris Ostrovsky
69049454 2abb65a3

+65 -83
+9 -7
drivers/xen/xen-pciback/conf_space.c
··· 10 10 * Author: Ryan Wilson <hap9@epoch.ncsc.mil> 11 11 */ 12 12 13 + #define dev_fmt(fmt) DRV_NAME ": " fmt 14 + 13 15 #include <linux/kernel.h> 14 16 #include <linux/moduleparam.h> 15 17 #include <linux/pci.h> ··· 157 155 u32 value = 0, tmp_val; 158 156 159 157 if (unlikely(verbose_request)) 160 - printk(KERN_DEBUG DRV_NAME ": %s: read %d bytes at 0x%x\n", 161 - pci_name(dev), size, offset); 158 + dev_printk(KERN_DEBUG, &dev->dev, "read %d bytes at 0x%x\n", 159 + size, offset); 162 160 163 161 if (!valid_request(offset, size)) { 164 162 err = XEN_PCI_ERR_invalid_offset; ··· 198 196 199 197 out: 200 198 if (unlikely(verbose_request)) 201 - printk(KERN_DEBUG DRV_NAME ": %s: read %d bytes at 0x%x = %x\n", 202 - pci_name(dev), size, offset, value); 199 + dev_printk(KERN_DEBUG, &dev->dev, 200 + "read %d bytes at 0x%x = %x\n", size, offset, value); 203 201 204 202 *ret_val = value; 205 203 return xen_pcibios_err_to_errno(err); ··· 215 213 int field_start, field_end; 216 214 217 215 if (unlikely(verbose_request)) 218 - printk(KERN_DEBUG 219 - DRV_NAME ": %s: write request %d bytes at 0x%x = %x\n", 220 - pci_name(dev), size, offset, value); 216 + dev_printk(KERN_DEBUG, &dev->dev, 217 + "write request %d bytes at 0x%x = %x\n", size, 218 + offset, value); 221 219 222 220 if (!valid_request(offset, size)) 223 221 return XEN_PCI_ERR_invalid_offset;
+16 -24
drivers/xen/xen-pciback/conf_space_header.c
··· 6 6 */ 7 7 8 8 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 9 + #define dev_fmt pr_fmt 9 10 10 11 #include <linux/kernel.h> 11 12 #include <linux/pci.h> ··· 69 68 dev_data = pci_get_drvdata(dev); 70 69 if (!pci_is_enabled(dev) && is_enable_cmd(value)) { 71 70 if (unlikely(verbose_request)) 72 - printk(KERN_DEBUG DRV_NAME ": %s: enable\n", 73 - pci_name(dev)); 71 + dev_printk(KERN_DEBUG, &dev->dev, "enable\n"); 74 72 err = pci_enable_device(dev); 75 73 if (err) 76 74 return err; ··· 77 77 dev_data->enable_intx = 1; 78 78 } else if (pci_is_enabled(dev) && !is_enable_cmd(value)) { 79 79 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"); 82 81 pci_disable_device(dev); 83 82 if (dev_data) 84 83 dev_data->enable_intx = 0; ··· 85 86 86 87 if (!dev->is_busmaster && is_master_cmd(value)) { 87 88 if (unlikely(verbose_request)) 88 - printk(KERN_DEBUG DRV_NAME ": %s: set bus master\n", 89 - pci_name(dev)); 89 + dev_printk(KERN_DEBUG, &dev->dev, "set bus master\n"); 90 90 pci_set_master(dev); 91 91 } else if (dev->is_busmaster && !is_master_cmd(value)) { 92 92 if (unlikely(verbose_request)) 93 - printk(KERN_DEBUG DRV_NAME ": %s: clear bus master\n", 94 - pci_name(dev)); 93 + dev_printk(KERN_DEBUG, &dev->dev, "clear bus master\n"); 95 94 pci_clear_master(dev); 96 95 } 97 96 98 97 if (!(cmd->val & PCI_COMMAND_INVALIDATE) && 99 98 (value & PCI_COMMAND_INVALIDATE)) { 100 99 if (unlikely(verbose_request)) 101 - printk(KERN_DEBUG 102 - DRV_NAME ": %s: enable memory-write-invalidate\n", 103 - pci_name(dev)); 100 + dev_printk(KERN_DEBUG, &dev->dev, 101 + "enable memory-write-invalidate\n"); 104 102 err = pci_set_mwi(dev); 105 103 if (err) { 106 - pr_warn("%s: cannot enable memory-write-invalidate (%d)\n", 107 - pci_name(dev), err); 104 + dev_warn(&dev->dev, "cannot enable memory-write-invalidate (%d)\n", 105 + err); 108 106 value &= ~PCI_COMMAND_INVALIDATE; 109 107 } 110 108 } else if ((cmd->val & PCI_COMMAND_INVALIDATE) && 111 109 !(value & PCI_COMMAND_INVALIDATE)) { 112 110 if (unlikely(verbose_request)) 113 - printk(KERN_DEBUG 114 - DRV_NAME ": %s: disable memory-write-invalidate\n", 115 - pci_name(dev)); 111 + dev_printk(KERN_DEBUG, &dev->dev, 112 + "disable memory-write-invalidate\n"); 116 113 pci_clear_mwi(dev); 117 114 } 118 115 ··· 152 157 struct pci_bar_info *bar = data; 153 158 154 159 if (unlikely(!bar)) { 155 - pr_warn(DRV_NAME ": driver data not found for %s\n", 156 - pci_name(dev)); 160 + dev_warn(&dev->dev, "driver data not found\n"); 157 161 return XEN_PCI_ERR_op_failed; 158 162 } 159 163 ··· 188 194 u32 mask; 189 195 190 196 if (unlikely(!bar)) { 191 - pr_warn(DRV_NAME ": driver data not found for %s\n", 192 - pci_name(dev)); 197 + dev_warn(&dev->dev, "driver data not found\n"); 193 198 return XEN_PCI_ERR_op_failed; 194 199 } 195 200 ··· 221 228 struct pci_bar_info *bar = data; 222 229 223 230 if (unlikely(!bar)) { 224 - pr_warn(DRV_NAME ": driver data not found for %s\n", 225 - pci_name(dev)); 231 + dev_warn(&dev->dev, "driver data not found\n"); 226 232 return XEN_PCI_ERR_op_failed; 227 233 } 228 234 ··· 425 433 426 434 default: 427 435 err = -EINVAL; 428 - pr_err("%s: Unsupported header type %d!\n", 429 - pci_name(dev), dev->hdr_type); 436 + dev_err(&dev->dev, "Unsupported header type %d!\n", 437 + dev->hdr_type); 430 438 break; 431 439 } 432 440
+4 -2
drivers/xen/xen-pciback/conf_space_quirks.c
··· 6 6 * Author: Chris Bookholt <hap10@epoch.ncsc.mil> 7 7 */ 8 8 9 + #define dev_fmt(fmt) DRV_NAME ": " fmt 10 + 9 11 #include <linux/kernel.h> 10 12 #include <linux/pci.h> 11 13 #include "pciback.h" ··· 37 35 if (match_one_device(&tmp_quirk->devid, dev) != NULL) 38 36 goto out; 39 37 tmp_quirk = NULL; 40 - printk(KERN_DEBUG DRV_NAME 41 - ": quirk didn't match any device known\n"); 38 + dev_printk(KERN_DEBUG, &dev->dev, 39 + "quirk didn't match any device known\n"); 42 40 out: 43 41 return tmp_quirk; 44 42 }
+16 -22
drivers/xen/xen-pciback/pci_stub.c
··· 6 6 */ 7 7 8 8 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 9 + #define dev_fmt pr_fmt 9 10 10 11 #include <linux/module.h> 11 12 #include <linux/init.h> ··· 627 626 if (found_psdev->pdev) { 628 627 int domid = xen_find_device_domain_owner(dev); 629 628 630 - pr_warn("****** removing device %s while still in-use by domain %d! ******\n", 629 + dev_warn(&dev->dev, "****** removing device %s while still in-use by domain %d! ******\n", 631 630 pci_name(found_psdev->dev), domid); 632 - pr_warn("****** driver domain may still access this device's i/o resources!\n"); 633 - pr_warn("****** shutdown driver domain before binding device\n"); 634 - pr_warn("****** to other drivers or domains\n"); 631 + dev_warn(&dev->dev, "****** driver domain may still access this device's i/o resources!\n"); 632 + dev_warn(&dev->dev, "****** shutdown driver domain before binding device\n"); 633 + dev_warn(&dev->dev, "****** to other drivers or domains\n"); 635 634 636 635 /* N.B. This ends up calling pcistub_put_pci_dev which ends up 637 636 * doing the FLR. */ ··· 712 711 ret = xen_pcibk_get_pcifront_dev(psdev->dev, psdev->pdev, 713 712 &aer_op->domain, &aer_op->bus, &aer_op->devfn); 714 713 if (!ret) { 715 - dev_err(&psdev->dev->dev, 716 - DRV_NAME ": failed to get pcifront device\n"); 714 + dev_err(&psdev->dev->dev, "failed to get pcifront device\n"); 717 715 return PCI_ERS_RESULT_NONE; 718 716 } 719 717 wmb(); 720 718 721 - dev_dbg(&psdev->dev->dev, 722 - DRV_NAME ": aer_op %x dom %x bus %x devfn %x\n", 719 + dev_dbg(&psdev->dev->dev, "aer_op %x dom %x bus %x devfn %x\n", 723 720 aer_cmd, aer_op->domain, aer_op->bus, aer_op->devfn); 724 721 /*local flag to mark there's aer request, xen_pcibk callback will use 725 722 * this flag to judge whether we need to check pci-front give aer ··· 753 754 754 755 if (test_bit(_XEN_PCIF_active, 755 756 (unsigned long *)&sh_info->flags)) { 756 - dev_dbg(&psdev->dev->dev, 757 - "schedule pci_conf service in " DRV_NAME "\n"); 757 + dev_dbg(&psdev->dev->dev, "schedule pci_conf service\n"); 758 758 xen_pcibk_test_and_schedule_op(psdev->pdev); 759 759 } 760 760 ··· 784 786 PCI_FUNC(dev->devfn)); 785 787 786 788 if (!psdev || !psdev->pdev) { 787 - dev_err(&dev->dev, 788 - DRV_NAME " device is not found/assigned\n"); 789 + dev_err(&dev->dev, "device is not found/assigned\n"); 789 790 goto end; 790 791 } 791 792 792 793 if (!psdev->pdev->sh_info) { 793 - dev_err(&dev->dev, DRV_NAME " device is not connected or owned" 794 + dev_err(&dev->dev, "device is not connected or owned" 794 795 " by HVM, kill it\n"); 795 796 kill_domain_by_device(psdev); 796 797 goto end; ··· 841 844 PCI_FUNC(dev->devfn)); 842 845 843 846 if (!psdev || !psdev->pdev) { 844 - dev_err(&dev->dev, 845 - DRV_NAME " device is not found/assigned\n"); 847 + dev_err(&dev->dev, "device is not found/assigned\n"); 846 848 goto end; 847 849 } 848 850 849 851 if (!psdev->pdev->sh_info) { 850 - dev_err(&dev->dev, DRV_NAME " device is not connected or owned" 852 + dev_err(&dev->dev, "device is not connected or owned" 851 853 " by HVM, kill it\n"); 852 854 kill_domain_by_device(psdev); 853 855 goto end; ··· 898 902 PCI_FUNC(dev->devfn)); 899 903 900 904 if (!psdev || !psdev->pdev) { 901 - dev_err(&dev->dev, 902 - DRV_NAME " device is not found/assigned\n"); 905 + dev_err(&dev->dev, "device is not found/assigned\n"); 903 906 goto end; 904 907 } 905 908 906 909 if (!psdev->pdev->sh_info) { 907 - dev_err(&dev->dev, DRV_NAME " device is not connected or owned" 910 + dev_err(&dev->dev, "device is not connected or owned" 908 911 " by HVM, kill it\n"); 909 912 kill_domain_by_device(psdev); 910 913 goto end; ··· 951 956 PCI_FUNC(dev->devfn)); 952 957 953 958 if (!psdev || !psdev->pdev) { 954 - dev_err(&dev->dev, 955 - DRV_NAME " device is not found/assigned\n"); 959 + dev_err(&dev->dev, "device is not found/assigned\n"); 956 960 goto end; 957 961 } 958 962 959 963 if (!psdev->pdev->sh_info) { 960 - dev_err(&dev->dev, DRV_NAME " device is not connected or owned" 964 + dev_err(&dev->dev, "device is not connected or owned" 961 965 " by HVM, kill it\n"); 962 966 kill_domain_by_device(psdev); 963 967 goto end;
+15 -23
drivers/xen/xen-pciback/pciback_ops.c
··· 6 6 */ 7 7 8 8 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 9 + #define dev_fmt pr_fmt 9 10 10 11 #include <linux/moduleparam.h> 11 12 #include <linux/wait.h> ··· 149 148 int status; 150 149 151 150 if (unlikely(verbose_request)) 152 - printk(KERN_DEBUG DRV_NAME ": %s: enable MSI\n", pci_name(dev)); 151 + dev_printk(KERN_DEBUG, &dev->dev, "enable MSI\n"); 153 152 154 153 if (dev->msi_enabled) 155 154 status = -EALREADY; ··· 159 158 status = pci_enable_msi(dev); 160 159 161 160 if (status) { 162 - pr_warn_ratelimited("%s: error enabling MSI for guest %u: err %d\n", 163 - pci_name(dev), pdev->xdev->otherend_id, 164 - status); 161 + dev_warn_ratelimited(&dev->dev, "error enabling MSI for guest %u: err %d\n", 162 + pdev->xdev->otherend_id, status); 165 163 op->value = 0; 166 164 return XEN_PCI_ERR_op_failed; 167 165 } ··· 170 170 171 171 op->value = dev->irq ? xen_pirq_from_irq(dev->irq) : 0; 172 172 if (unlikely(verbose_request)) 173 - printk(KERN_DEBUG DRV_NAME ": %s: MSI: %d\n", pci_name(dev), 174 - op->value); 173 + dev_printk(KERN_DEBUG, &dev->dev, "MSI: %d\n", op->value); 175 174 176 175 dev_data = pci_get_drvdata(dev); 177 176 if (dev_data) ··· 184 185 struct pci_dev *dev, struct xen_pci_op *op) 185 186 { 186 187 if (unlikely(verbose_request)) 187 - printk(KERN_DEBUG DRV_NAME ": %s: disable MSI\n", 188 - pci_name(dev)); 188 + dev_printk(KERN_DEBUG, &dev->dev, "disable MSI\n"); 189 189 190 190 if (dev->msi_enabled) { 191 191 struct xen_pcibk_dev_data *dev_data; ··· 197 199 } 198 200 op->value = dev->irq ? xen_pirq_from_irq(dev->irq) : 0; 199 201 if (unlikely(verbose_request)) 200 - printk(KERN_DEBUG DRV_NAME ": %s: MSI: %d\n", pci_name(dev), 201 - op->value); 202 + dev_printk(KERN_DEBUG, &dev->dev, "MSI: %d\n", op->value); 202 203 return 0; 203 204 } 204 205 ··· 211 214 u16 cmd; 212 215 213 216 if (unlikely(verbose_request)) 214 - printk(KERN_DEBUG DRV_NAME ": %s: enable MSI-X\n", 215 - pci_name(dev)); 217 + dev_printk(KERN_DEBUG, &dev->dev, "enable MSI-X\n"); 216 218 217 219 if (op->value > SH_INFO_MAX_VEC) 218 220 return -EINVAL; ··· 245 249 op->msix_entries[i].vector = 246 250 xen_pirq_from_irq(entries[i].vector); 247 251 if (unlikely(verbose_request)) 248 - printk(KERN_DEBUG DRV_NAME ": %s: " \ 249 - "MSI-X[%d]: %d\n", 250 - pci_name(dev), i, 252 + dev_printk(KERN_DEBUG, &dev->dev, 253 + "MSI-X[%d]: %d\n", i, 251 254 op->msix_entries[i].vector); 252 255 } 253 256 } 254 257 } else 255 - pr_warn_ratelimited("%s: error enabling MSI-X for guest %u: err %d!\n", 256 - pci_name(dev), pdev->xdev->otherend_id, 257 - result); 258 + dev_warn_ratelimited(&dev->dev, "error enabling MSI-X for guest %u: err %d!\n", 259 + pdev->xdev->otherend_id, result); 258 260 kfree(entries); 259 261 260 262 op->value = result; ··· 268 274 struct pci_dev *dev, struct xen_pci_op *op) 269 275 { 270 276 if (unlikely(verbose_request)) 271 - printk(KERN_DEBUG DRV_NAME ": %s: disable MSI-X\n", 272 - pci_name(dev)); 277 + dev_printk(KERN_DEBUG, &dev->dev, "disable MSI-X\n"); 273 278 274 279 if (dev->msix_enabled) { 275 280 struct xen_pcibk_dev_data *dev_data; ··· 285 292 */ 286 293 op->value = dev->irq ? xen_pirq_from_irq(dev->irq) : 0; 287 294 if (unlikely(verbose_request)) 288 - printk(KERN_DEBUG DRV_NAME ": %s: MSI-X: %d\n", 289 - pci_name(dev), op->value); 295 + dev_printk(KERN_DEBUG, &dev->dev, "MSI-X: %d\n", op->value); 290 296 return 0; 291 297 } 292 298 #endif ··· 416 424 dev_data->handled++; 417 425 if ((dev_data->handled % 1000) == 0) { 418 426 if (xen_test_irq_shared(irq)) { 419 - pr_info("%s IRQ line is not shared " 427 + dev_info(&dev->dev, "%s IRQ line is not shared " 420 428 "with other domains. Turning ISR off\n", 421 429 dev_data->irq_name); 422 430 dev_data->ack_intr = 0;
+5 -5
drivers/xen/xen-pciback/vpci.c
··· 7 7 */ 8 8 9 9 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 10 + #define dev_fmt pr_fmt 10 11 11 12 #include <linux/list.h> 12 13 #include <linux/slab.h> ··· 106 105 struct pci_dev_entry, list); 107 106 108 107 if (match_slot(dev, t->dev)) { 109 - pr_info("vpci: %s: assign to virtual slot %d func %d\n", 110 - pci_name(dev), slot, 111 - PCI_FUNC(dev->devfn)); 108 + dev_info(&dev->dev, "vpci: assign to virtual slot %d func %d\n", 109 + slot, PCI_FUNC(dev->devfn)); 112 110 list_add_tail(&dev_entry->list, 113 111 &vpci_dev->dev_list[slot]); 114 112 func = PCI_FUNC(dev->devfn); ··· 119 119 /* Assign to a new slot on the virtual PCI bus */ 120 120 for (slot = 0; slot < PCI_SLOT_MAX; slot++) { 121 121 if (list_empty(&vpci_dev->dev_list[slot])) { 122 - pr_info("vpci: %s: assign to virtual slot %d\n", 123 - pci_name(dev), slot); 122 + dev_info(&dev->dev, "vpci: assign to virtual slot %d\n", 123 + slot); 124 124 list_add_tail(&dev_entry->list, 125 125 &vpci_dev->dev_list[slot]); 126 126 func = dev->is_virtfn ? 0 : PCI_FUNC(dev->devfn);