diff options
author | Timothy S. Nelson <wayland@wayland.id.au> | 2009-01-29 14:12:47 -0500 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2009-02-04 19:58:41 -0500 |
commit | 97c44836cdec1ea713a15d84098a1a908157e68f (patch) | |
tree | bc544c64ed8eeb3feb2f0b210ae7db04a40e1bae /drivers/pci | |
parent | 3419c75e15f82c3ab09bd944fddbde72c9e4b3ea (diff) |
PCI: return error on failure to read PCI ROMs
This patch makes the ROM reading code return an error to user space if
the size of the ROM read is equal to 0.
The patch also emits a warnings if the contents of the ROM are invalid,
and documents the effects of the "enable" file on ROM reading.
Signed-off-by: Timothy S. Nelson <wayland@wayland.id.au>
Acked-by: Alex Villacis-Lasso <a_villacis@palosanto.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci')
-rw-r--r-- | drivers/pci/pci-sysfs.c | 4 | ||||
-rw-r--r-- | drivers/pci/rom.c | 8 |
2 files changed, 7 insertions, 5 deletions
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index db7ec14fa719..dfc4e0ddf241 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -768,8 +768,8 @@ pci_read_rom(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
768 | return -EINVAL; | 768 | return -EINVAL; |
769 | 769 | ||
770 | rom = pci_map_rom(pdev, &size); /* size starts out as PCI window size */ | 770 | rom = pci_map_rom(pdev, &size); /* size starts out as PCI window size */ |
771 | if (!rom) | 771 | if (!rom || !size) |
772 | return 0; | 772 | return -EIO; |
773 | 773 | ||
774 | if (off >= size) | 774 | if (off >= size) |
775 | count = 0; | 775 | count = 0; |
diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c index 132a78159b60..29cbe47f219f 100644 --- a/drivers/pci/rom.c +++ b/drivers/pci/rom.c | |||
@@ -63,7 +63,7 @@ void pci_disable_rom(struct pci_dev *pdev) | |||
63 | * The PCI window size could be much larger than the | 63 | * The PCI window size could be much larger than the |
64 | * actual image size. | 64 | * actual image size. |
65 | */ | 65 | */ |
66 | size_t pci_get_rom_size(void __iomem *rom, size_t size) | 66 | size_t pci_get_rom_size(struct pci_dev *pdev, void __iomem *rom, size_t size) |
67 | { | 67 | { |
68 | void __iomem *image; | 68 | void __iomem *image; |
69 | int last_image; | 69 | int last_image; |
@@ -72,8 +72,10 @@ size_t pci_get_rom_size(void __iomem *rom, size_t size) | |||
72 | do { | 72 | do { |
73 | void __iomem *pds; | 73 | void __iomem *pds; |
74 | /* Standard PCI ROMs start out with these bytes 55 AA */ | 74 | /* Standard PCI ROMs start out with these bytes 55 AA */ |
75 | if (readb(image) != 0x55) | 75 | if (readb(image) != 0x55) { |
76 | dev_err(&pdev->dev, "Invalid ROM contents\n"); | ||
76 | break; | 77 | break; |
78 | } | ||
77 | if (readb(image + 1) != 0xAA) | 79 | if (readb(image + 1) != 0xAA) |
78 | break; | 80 | break; |
79 | /* get the PCI data structure and check its signature */ | 81 | /* get the PCI data structure and check its signature */ |
@@ -159,7 +161,7 @@ void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size) | |||
159 | * size is much larger than the actual size of the ROM. | 161 | * size is much larger than the actual size of the ROM. |
160 | * True size is important if the ROM is going to be copied. | 162 | * True size is important if the ROM is going to be copied. |
161 | */ | 163 | */ |
162 | *size = pci_get_rom_size(rom, *size); | 164 | *size = pci_get_rom_size(pdev, rom, *size); |
163 | return rom; | 165 | return rom; |
164 | } | 166 | } |
165 | 167 | ||