mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [patch 0/2] dev_printk() conversions, v3
@ 2008-07-07 22:43 Bjorn Helgaas
  2008-07-07 22:43 ` [patch 1/2] x86 PCI: use dev_printk when possible Bjorn Helgaas
  2008-07-07 22:43 ` [patch 2/2] x86 PCI: replace DBG() with pr_debug() Bjorn Helgaas
  0 siblings, 2 replies; 3+ messages in thread
From: Bjorn Helgaas @ 2008-07-07 22:43 UTC (permalink / raw)
  To: Jesse Barnes, Thomas Gleixner, Ingo Molnar, H. Peter Anvin
  Cc: linux-pci, linux-kernel, Andrew Morton

These convert some printks to dev_printks.

v3 changes:

    - refresh for newer tree (these were generated against 2.6.26-rc8-mm1)
    - doesn't include the ACPI and PCI changes already in linux-next
    - new patch replaces non-device-specific DBG() with pr_debug() and
      removes DBG()

v2 changes:

    - print "PCI INT A" instead of "PCI INTA#"
    - in pci_request_region(), print "bar", not "bar + 1"

Bjorn
-- 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [patch 1/2] x86 PCI: use dev_printk when possible
  2008-07-07 22:43 [patch 0/2] dev_printk() conversions, v3 Bjorn Helgaas
@ 2008-07-07 22:43 ` Bjorn Helgaas
  2008-07-07 22:43 ` [patch 2/2] x86 PCI: replace DBG() with pr_debug() Bjorn Helgaas
  1 sibling, 0 replies; 3+ messages in thread
From: Bjorn Helgaas @ 2008-07-07 22:43 UTC (permalink / raw)
  To: Jesse Barnes, Thomas Gleixner, Ingo Molnar, H. Peter Anvin
  Cc: linux-pci, linux-kernel, Andrew Morton

[-- Attachment #1: x86-pci-irq-dev_printk --]
[-- Type: text/plain, Size: 6298 bytes --]

Convert printks to use dev_printk().

I converted DBG() to dev_dbg().  This DBG() is from arch/x86/pci/pci.h
and requires source-code modification to enable, so dev_dbg() seems
roughly equivalent.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

Index: linux-mm/arch/x86/pci/irq.c
===================================================================
--- linux-mm.orig/arch/x86/pci/irq.c	2008-07-07 14:09:00.000000000 -0600
+++ linux-mm/arch/x86/pci/irq.c	2008-07-07 16:40:35.000000000 -0600
@@ -918,20 +918,20 @@ static int pcibios_lookup_irq(struct pci
 	if (!pirq_table)
 		return 0;
 
-	DBG(KERN_DEBUG "IRQ for %s[%c]", pci_name(dev), 'A' + pin);
 	info = pirq_get_info(dev);
 	if (!info) {
-		DBG(" -> not found in routing table\n" KERN_DEBUG);
+		dev_dbg(&dev->dev, "PCI INT %c not found in routing table\n",
+			'A' + pin);
 		return 0;
 	}
 	pirq = info->irq[pin].link;
 	mask = info->irq[pin].bitmap;
 	if (!pirq) {
-		DBG(" -> not routed\n" KERN_DEBUG);
+		dev_dbg(&dev->dev, "PCI INT %c not routed\n", 'A' + pin);
 		return 0;
 	}
-	DBG(" -> PIRQ %02x, mask %04x, excl %04x", pirq, mask,
-		pirq_table->exclusive_irqs);
+	dev_dbg(&dev->dev, "PCI INT %c -> PIRQ %02x, mask %04x, excl %04x",
+		'A' + pin, pirq, mask, pirq_table->exclusive_irqs);
 	mask &= pcibios_irq_mask;
 
 	/* Work around broken HP Pavilion Notebooks which assign USB to
@@ -961,10 +961,8 @@ static int pcibios_lookup_irq(struct pci
 		if (pci_probe & PCI_USE_PIRQ_MASK)
 			newirq = 0;
 		else
-			printk("\n" KERN_WARNING
-				"PCI: IRQ %i for device %s doesn't match PIRQ mask - try pci=usepirqmask\n"
-				KERN_DEBUG, newirq,
-				pci_name(dev));
+			dev_warn(&dev->dev, "IRQ %d doesn't match PIRQ mask "
+				 "%#x; try pci=usepirqmask\n", newirq, mask);
 	}
 	if (!newirq && assign) {
 		for (i = 0; i < 16; i++) {
@@ -975,39 +973,35 @@ static int pcibios_lookup_irq(struct pci
 				newirq = i;
 		}
 	}
-	DBG(" -> newirq=%d", newirq);
+	dev_dbg(&dev->dev, "PCI INT %c -> newirq %d", 'A' + pin, newirq);
 
 	/* Check if it is hardcoded */
 	if ((pirq & 0xf0) == 0xf0) {
 		irq = pirq & 0xf;
-		DBG(" -> hardcoded IRQ %d\n", irq);
-		msg = "Hardcoded";
+		msg = "hardcoded";
 	} else if (r->get && (irq = r->get(pirq_router_dev, dev, pirq)) && \
 	((!(pci_probe & PCI_USE_PIRQ_MASK)) || ((1 << irq) & mask))) {
-		DBG(" -> got IRQ %d\n", irq);
-		msg = "Found";
+		msg = "found";
 		eisa_set_level_irq(irq);
 	} else if (newirq && r->set &&
 		(dev->class >> 8) != PCI_CLASS_DISPLAY_VGA) {
-		DBG(" -> assigning IRQ %d", newirq);
 		if (r->set(pirq_router_dev, dev, pirq, newirq)) {
 			eisa_set_level_irq(newirq);
-			DBG(" ... OK\n");
-			msg = "Assigned";
+			msg = "assigned";
 			irq = newirq;
 		}
 	}
 
 	if (!irq) {
-		DBG(" ... failed\n");
 		if (newirq && mask == (1 << newirq)) {
-			msg = "Guessed";
+			msg = "guessed";
 			irq = newirq;
-		} else
+		} else {
+			dev_dbg(&dev->dev, "can't route interrupt\n");
 			return 0;
+		}
 	}
-	printk(KERN_INFO "PCI: %s IRQ %d for device %s\n", msg, irq,
-		pci_name(dev));
+	dev_info(&dev->dev, "%s PCI INT %c -> IRQ %d\n", msg, 'A' + pin, irq);
 
 	/* Update IRQ for all devices with the same pirq value */
 	while ((dev2 = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev2)) != NULL) {
@@ -1027,18 +1021,17 @@ static int pcibios_lookup_irq(struct pci
 			(!(pci_probe & PCI_USE_PIRQ_MASK) || \
 			((1 << dev2->irq) & mask))) {
 #ifndef CONFIG_PCI_MSI
-				printk(KERN_INFO
-					"IRQ routing conflict for %s, have irq %d, want irq %d\n",
-					pci_name(dev2), dev2->irq, irq);
+				dev_info(&dev2->dev, "IRQ routing conflict: "
+					 "have IRQ %d, want IRQ %d\n",
+					 dev2->irq, irq);
 #endif
 				continue;
 			}
 			dev2->irq = irq;
 			pirq_penalty[irq]++;
 			if (dev != dev2)
-				printk(KERN_INFO
-					"PCI: Sharing IRQ %d with %s\n",
-					irq, pci_name(dev2));
+				dev_info(&dev->dev, "sharing IRQ %d with %s\n",
+					 irq, pci_name(dev2));
 		}
 	}
 	return 1;
@@ -1057,8 +1050,7 @@ static void __init pcibios_fixup_irqs(vo
 		 * already in use.
 		 */
 		if (dev->irq >= 16) {
-			DBG(KERN_DEBUG "%s: ignoring bogus IRQ %d\n",
-				pci_name(dev), dev->irq);
+			dev_dbg(&dev->dev, "ignoring bogus IRQ %d\n", dev->irq);
 			dev->irq = 0;
 		}
 		/*
@@ -1104,15 +1096,16 @@ static void __init pcibios_fixup_irqs(vo
 							PCI_SLOT(bridge->devfn),
 							pin);
 					if (irq >= 0)
-						printk(KERN_WARNING
-							"PCI: using PPB %s[%c] to get irq %d\n",
-							pci_name(bridge),
-							'A' + pin, irq);
+						dev_warn(&dev->dev, "using "
+							 "bridge %s INT %c to "
+							 "get IRQ %d\n",
+							 pci_name(bridge),
+							 'A' + pin, irq);
 				}
 				if (irq >= 0) {
-					printk(KERN_INFO
-						"PCI->APIC IRQ transform: %s[%c] -> IRQ %d\n",
-						pci_name(dev), 'A' + pin, irq);
+					dev_info(&dev->dev, "PCI->APIC IRQ "
+						 "transform: INT %c -> "
+						 "IRQ %d\n", 'A' + pin, irq);
 					dev->irq = irq;
 				}
 			}
@@ -1275,25 +1268,24 @@ static int pirq_enable_irq(struct pci_de
 				irq = IO_APIC_get_PCI_irq_vector(bridge->bus->number,
 						PCI_SLOT(bridge->devfn), pin);
 				if (irq >= 0)
-					printk(KERN_WARNING
-						"PCI: using PPB %s[%c] to get irq %d\n",
-						pci_name(bridge),
-						'A' + pin, irq);
+					dev_warn(&dev->dev, "using bridge %s "
+						 "INT %c to get IRQ %d\n",
+						 pci_name(bridge), 'A' + pin,
+						 irq);
 				dev = bridge;
 			}
 			dev = temp_dev;
 			if (irq >= 0) {
-				printk(KERN_INFO
-					"PCI->APIC IRQ transform: %s[%c] -> IRQ %d\n",
-					pci_name(dev), 'A' + pin, irq);
+				dev_info(&dev->dev, "PCI->APIC IRQ transform: "
+					 "INT %c -> IRQ %d\n", 'A' + pin, irq);
 				dev->irq = irq;
 				return 0;
 			} else
-				msg = " Probably buggy MP table.";
+				msg = "; probably buggy MP table";
 		} else if (pci_probe & PCI_BIOS_IRQ_SCAN)
 			msg = "";
 		else
-			msg = " Please try using pci=biosirq.";
+			msg = "; please try using pci=biosirq";
 
 		/*
 		 * With IDE legacy devices the IRQ lookup failure is not
@@ -1303,9 +1295,8 @@ static int pirq_enable_irq(struct pci_de
 				!(dev->class & 0x5))
 			return 0;
 
-		printk(KERN_WARNING
-			"PCI: No IRQ known for interrupt pin %c of device %s.%s\n",
-			'A' + pin, pci_name(dev), msg);
+		dev_warn(&dev->dev, "can't find IRQ for PCI INT %c%s\n",
+			 'A' + pin, msg);
 	}
 	return 0;
 }

-- 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [patch 2/2] x86 PCI: replace DBG() with pr_debug()
  2008-07-07 22:43 [patch 0/2] dev_printk() conversions, v3 Bjorn Helgaas
  2008-07-07 22:43 ` [patch 1/2] x86 PCI: use dev_printk when possible Bjorn Helgaas
@ 2008-07-07 22:43 ` Bjorn Helgaas
  1 sibling, 0 replies; 3+ messages in thread
From: Bjorn Helgaas @ 2008-07-07 22:43 UTC (permalink / raw)
  To: Jesse Barnes, Thomas Gleixner, Ingo Molnar, H. Peter Anvin
  Cc: linux-pci, linux-kernel, Andrew Morton

[-- Attachment #1: x86-pci-dbg --]
[-- Type: text/plain, Size: 7783 bytes --]

The remaining uses of DBG() are not specific to a device, so
I converted them to pr_debug() and removed DBG() from arch/x86/pci/pci.h.

DBG() requires source-code modification to enable, so pr_debug(), which
requires compilation with "DEBUG" defined, seems roughly equivalent.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

Index: linux-mm/arch/x86/pci/irq.c
===================================================================
--- linux-mm.orig/arch/x86/pci/irq.c	2008-07-07 16:40:35.000000000 -0600
+++ linux-mm/arch/x86/pci/irq.c	2008-07-07 16:42:34.000000000 -0600
@@ -78,8 +78,7 @@ static inline struct irq_routing_table *
 	for (i = 0; i < rt->size; i++)
 		sum += addr[i];
 	if (!sum) {
-		DBG(KERN_DEBUG "PCI: Interrupt Routing Table found at 0x%p\n",
-			rt);
+		pr_debug("PCI: Interrupt Routing Table found at 0x%p\n", rt);
 		return rt;
 	}
 	return NULL;
@@ -128,17 +127,13 @@ static void __init pirq_peer_trick(void)
 	for (i = 0; i < (rt->size - sizeof(struct irq_routing_table)) /
 		sizeof(struct irq_info); i++) {
 		e = &rt->slots[i];
-#ifdef DEBUG
-		{
-			int j;
-			DBG(KERN_DEBUG "%02x:%02x slot=%02x", e->bus,
-				e->devfn/8, e->slot);
-			for (j = 0; j < 4; j++)
-				DBG(" %d:%02x/%04x", j, e->irq[j].link,
-					e->irq[j].bitmap);
-			DBG("\n");
-		}
-#endif
+		pr_debug("%02x:%02x slot=%02x "
+			 "0:%02x/%04x 1:%02x/%04x 2:%02x/%04x 3:%02x/%04x\n",
+			 e->bus, e->devfn/8, e->slot,
+			 e->irq[0].link, e->irq[0].bitmap,
+			 e->irq[1].link, e->irq[1].bitmap,
+			 e->irq[2].link, e->irq[2].bitmap,
+			 e->irq[3].link, e->irq[3].bitmap);
 		busmap[e->bus] = 1;
 	}
 	for (i = 1; i < 256; i++) {
@@ -171,7 +166,7 @@ void eisa_set_level_irq(unsigned int irq
 	printk(KERN_DEBUG "PCI: setting IRQ %u as level-triggered\n", irq);
 	val = inb(port);
 	if (!(val & mask)) {
-		DBG(KERN_DEBUG " -> edge");
+		pr_debug(" -> edge");
 		outb(val | mask, port);
 	}
 }
@@ -853,13 +848,13 @@ static void __init pirq_find_router(stru
 	r->get = NULL;
 	r->set = NULL;
 
-	DBG(KERN_DEBUG "PCI: Attempting to find IRQ router for %04x:%04x\n",
-	    rt->rtr_vendor, rt->rtr_device);
+	pr_debug("PCI: Attempting to find IRQ router for [%04x/%04x]\n",
+		 rt->rtr_vendor, rt->rtr_device);
 
 	pirq_router_dev = pci_get_bus_and_slot(rt->rtr_bus, rt->rtr_devfn);
 	if (!pirq_router_dev) {
-		DBG(KERN_DEBUG "PCI: Interrupt router not found at "
-			"%02x:%02x\n", rt->rtr_bus, rt->rtr_devfn);
+		pr_debug("PCI: IRQ router not found at %02x:%02x\n",
+			 rt->rtr_bus, rt->rtr_devfn);
 		return;
 	}
 
@@ -1042,7 +1037,7 @@ static void __init pcibios_fixup_irqs(vo
 	struct pci_dev *dev = NULL;
 	u8 pin;
 
-	DBG(KERN_DEBUG "PCI: IRQ fixup\n");
+	pr_debug("PCI: IRQ fixup\n");
 	while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
 		/*
 		 * If the BIOS has set an out of range IRQ number, just
@@ -1172,7 +1167,7 @@ static struct dmi_system_id __initdata p
 
 static int __init pcibios_irq_init(void)
 {
-	DBG(KERN_DEBUG "PCI: IRQ init\n");
+	pr_debug("PCI: IRQ init\n");
 
 	if (pcibios_enable_irq || raw_pci_ops == NULL)
 		return 0;
Index: linux-mm/arch/x86/pci/direct.c
===================================================================
--- linux-mm.orig/arch/x86/pci/direct.c	2008-07-07 16:40:35.000000000 -0600
+++ linux-mm/arch/x86/pci/direct.c	2008-07-07 16:42:34.000000000 -0600
@@ -213,7 +213,7 @@ static int __init pci_sanity_check(struc
 			return 1;
 	}
 
-	DBG(KERN_WARNING "PCI: Sanity check failed\n");
+	pr_warning("PCI: Sanity check failed\n");
 	return 0;
 }
 
Index: linux-mm/arch/x86/pci/i386.c
===================================================================
--- linux-mm.orig/arch/x86/pci/i386.c	2008-07-07 16:40:35.000000000 -0600
+++ linux-mm/arch/x86/pci/i386.c	2008-07-07 16:42:34.000000000 -0600
@@ -226,7 +226,7 @@ static int __init pcibios_assign_resourc
 
 void __init pcibios_resource_survey(void)
 {
-	DBG("PCI: Allocating resources\n");
+	pr_debug("PCI: Allocating resources\n");
 	pcibios_allocate_bus_resources(&pci_root_buses);
 	pcibios_allocate_resources(0);
 	pcibios_allocate_resources(1);
Index: linux-mm/arch/x86/pci/legacy.c
===================================================================
--- linux-mm.orig/arch/x86/pci/legacy.c	2008-07-07 16:40:35.000000000 -0600
+++ linux-mm/arch/x86/pci/legacy.c	2008-07-07 16:42:34.000000000 -0600
@@ -16,7 +16,7 @@ static void __devinit pcibios_fixup_peer
 
 	if (pcibios_last_bus <= 0 || pcibios_last_bus >= 0xff)
 		return;
-	DBG("PCI: Peer bridge fixup\n");
+	pr_debug("PCI: Peer bridge fixup\n");
 
 	for (n=0; n <= pcibios_last_bus; n++) {
 		u32 l;
@@ -26,7 +26,8 @@ static void __devinit pcibios_fixup_peer
 		for (devfn = 0; devfn < 256; devfn += 8) {
 			if (!raw_pci_read(0, n, devfn, PCI_VENDOR_ID, 2, &l) &&
 			    l != 0x0000 && l != 0xffff) {
-				DBG("Found device at %02x:%02x [%04x]\n", n, devfn, l);
+				pr_debug("%02x:%02x found device "
+					 "[vendor %04x]\n", n, devfn, l);
 				printk(KERN_INFO "PCI: Discovered peer bus %02x\n", n);
 				pci_scan_bus_on_node(n, &pci_root_ops, node);
 				break;
Index: linux-mm/arch/x86/pci/pcbios.c
===================================================================
--- linux-mm.orig/arch/x86/pci/pcbios.c	2008-07-07 16:40:35.000000000 -0600
+++ linux-mm/arch/x86/pci/pcbios.c	2008-07-07 16:42:34.000000000 -0600
@@ -132,8 +132,9 @@ static int __devinit check_pcibios(void)
 		minor_ver = ebx & 0xff;
 		if (pcibios_last_bus < 0)
 			pcibios_last_bus = ecx & 0xff;
-		DBG("PCI: BIOS probe returned s=%02x hw=%02x ver=%02x.%02x l=%02x\n",
-			status, hw_mech, major_ver, minor_ver, pcibios_last_bus);
+		pr_debug("PCI: BIOS probe returned s=%02x hw=%02x "
+			 "ver=%02x.%02x l=%02x\n", status, hw_mech, major_ver,
+			 minor_ver, pcibios_last_bus);
 		if (status || signature != PCI_SIGNATURE) {
 			printk (KERN_ERR "PCI: BIOS BUG #%x[%08x] found\n",
 				status, signature);
@@ -322,15 +323,16 @@ static struct pci_raw_ops * __devinit pc
 				check->fields.revision, check);
 			continue;
 		}
-		DBG("PCI: BIOS32 Service Directory structure at 0x%p\n", check);
+		pr_debug("PCI: BIOS32 Service Directory structure at 0x%p\n",
+			 check);
 		if (check->fields.entry >= 0x100000) {
 			printk("PCI: BIOS32 entry (0x%p) in high memory, "
 					"cannot use.\n", check);
 			return NULL;
 		} else {
 			unsigned long bios32_entry = check->fields.entry;
-			DBG("PCI: BIOS32 Service Directory entry at 0x%lx\n",
-					bios32_entry);
+			pr_debug("PCI: BIOS32 Service Directory entry at "
+				 "0x%lx\n", bios32_entry);
 			bios32_indirect.address = bios32_entry + PAGE_OFFSET;
 			if (check_pcibios())
 				return &pci_bios_access;
@@ -367,7 +369,7 @@ struct irq_routing_table * pcibios_get_i
 	opt.size = PAGE_SIZE;
 	opt.segment = __KERNEL_DS;
 
-	DBG("PCI: Fetching IRQ routing table... ");
+	pr_debug("PCI: Fetching IRQ routing table...\n");
 	__asm__("push %%es\n\t"
 		"push %%ds\n\t"
 		"pop  %%es\n\t"
@@ -385,7 +387,7 @@ struct irq_routing_table * pcibios_get_i
 		  "S" (&pci_indirect),
 		  "m" (opt)
 		: "memory");
-	DBG("OK  ret=%d, size=%d, map=%x\n", ret, opt.size, map);
+	pr_debug("OK  ret=%d, size=%d, map=%x\n", ret, opt.size, map);
 	if (ret & 0xff00)
 		printk(KERN_ERR "PCI: Error %02x when fetching IRQ routing table.\n", (ret >> 8) & 0xff);
 	else if (opt.size) {
Index: linux-mm/arch/x86/pci/pci.h
===================================================================
--- linux-mm.orig/arch/x86/pci/pci.h	2008-07-07 16:40:35.000000000 -0600
+++ linux-mm/arch/x86/pci/pci.h	2008-07-07 16:42:34.000000000 -0600
@@ -4,14 +4,6 @@
  *	(c) 1999 Martin Mares <mj@ucw.cz>
  */
 
-#undef DEBUG
-
-#ifdef DEBUG
-#define DBG(x...) printk(x)
-#else
-#define DBG(x...)
-#endif
-
 #define PCI_PROBE_BIOS		0x0001
 #define PCI_PROBE_CONF1		0x0002
 #define PCI_PROBE_CONF2		0x0004

-- 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-07-07 22:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-07 22:43 [patch 0/2] dev_printk() conversions, v3 Bjorn Helgaas
2008-07-07 22:43 ` [patch 1/2] x86 PCI: use dev_printk when possible Bjorn Helgaas
2008-07-07 22:43 ` [patch 2/2] x86 PCI: replace DBG() with pr_debug() Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®