linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: Fix device class print out
@ 2012-02-19 22:50 Yinghai Lu
  2012-02-23 20:10 ` Jesse Barnes
  0 siblings, 1 reply; 2+ messages in thread
From: Yinghai Lu @ 2012-02-19 22:50 UTC (permalink / raw)
  To: Jesse Barnes; +Cc: linux-pci, linux-kernel, Yinghai Lu

Found debug print out about class is shifted.

| pci 0000:f8:15.2: [8086:2b56] type 0 class 0x000600

code is trying to print class with 6 digits, but use shifted class with 4 digits
valid value as variable.

Change to original dev->class directly.

also remove not needed calculating of local variable class, because it will be
updated after pci_fixup_device(pci_fixup_early...)

Also unify type print out when class and header is not matched.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
 drivers/pci/probe.c |   12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Index: linux-2.6/drivers/pci/probe.c
===================================================================
--- linux-2.6.orig/drivers/pci/probe.c
+++ linux-2.6/drivers/pci/probe.c
@@ -1125,12 +1125,10 @@ int pci_setup_device(struct pci_dev *dev
 
 	pci_read_config_dword(dev, PCI_CLASS_REVISION, &class);
 	dev->revision = class & 0xff;
-	class >>= 8;				    /* upper 3 bytes */
-	dev->class = class;
-	class >>= 8;
+	dev->class = class >> 8;		    /* upper 3 bytes */
 
-	dev_printk(KERN_DEBUG, &dev->dev, "[%04x:%04x] type %d class %#08x\n",
-		   dev->vendor, dev->device, dev->hdr_type, class);
+	dev_printk(KERN_DEBUG, &dev->dev, "[%04x:%04x] type %02x class %#08x\n",
+		   dev->vendor, dev->device, dev->hdr_type, dev->class);
 
 	/* need to have dev->class ready */
 	dev->cfg_size = pci_cfg_space_size(dev);
@@ -1212,8 +1210,8 @@ int pci_setup_device(struct pci_dev *dev
 		return -EIO;
 
 	bad:
-		dev_err(&dev->dev, "ignoring class %02x (doesn't match header "
-			"type %02x)\n", class, dev->hdr_type);
+		dev_err(&dev->dev, "ignoring class %#08x (doesn't match header "
+			"type %02x)\n", dev->class, dev->hdr_type);
 		dev->class = PCI_CLASS_NOT_DEFINED;
 	}
 

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

* Re: [PATCH] PCI: Fix device class print out
  2012-02-19 22:50 [PATCH] PCI: Fix device class print out Yinghai Lu
@ 2012-02-23 20:10 ` Jesse Barnes
  0 siblings, 0 replies; 2+ messages in thread
From: Jesse Barnes @ 2012-02-23 20:10 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: linux-pci, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 708 bytes --]

On Sun, 19 Feb 2012 14:50:12 -0800
Yinghai Lu <yinghai@kernel.org> wrote:

> Found debug print out about class is shifted.
> 
> | pci 0000:f8:15.2: [8086:2b56] type 0 class 0x000600
> 
> code is trying to print class with 6 digits, but use shifted class with 4 digits
> valid value as variable.
> 
> Change to original dev->class directly.
> 
> also remove not needed calculating of local variable class, because it will be
> updated after pci_fixup_device(pci_fixup_early...)
> 
> Also unify type print out when class and header is not matched.
> 
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>

Applied to linux-next, thanks.

-- 
Jesse Barnes, Intel Open Source Technology Center

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2012-02-23 20:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-19 22:50 [PATCH] PCI: Fix device class print out Yinghai Lu
2012-02-23 20:10 ` Jesse Barnes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).