[PATCH] pmc551: fix signedness bug in init_pmc551()
Xi Wang
xi.wang at gmail.com
Tue Dec 27 15:54:16 EST 2011
Since "length" is a u32, the error handling below didn't work when
fixup_pmc551() returns -ENODEV.
if ((length = fixup_pmc551(PCI_Device)) <= 0)
This patch changes fixup_pmc551() by separating the error handling
and the size.
Signed-off-by: Xi Wang <xi.wang at gmail.com>
---
drivers/mtd/devices/pmc551.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/devices/pmc551.c b/drivers/mtd/devices/pmc551.c
index ecff765..17b3536 100644
--- a/drivers/mtd/devices/pmc551.c
+++ b/drivers/mtd/devices/pmc551.c
@@ -359,7 +359,7 @@ static int pmc551_write(struct mtd_info *mtd, loff_t to, size_t len,
* mechanism
* returns the size of the memory region found.
*/
-static u32 fixup_pmc551(struct pci_dev *dev)
+static int fixup_pmc551(struct pci_dev *dev, u32 *lenp)
{
#ifdef CONFIG_MTD_PMC551_BUGFIX
u32 dram_data;
@@ -638,7 +638,8 @@ static u32 fixup_pmc551(struct pci_dev *dev)
(bcmd & 0x1) ? "software" : "hardware",
(bcmd & 0x20) ? "" : "un", (bcmd & 0x40) ? "" : "un");
#endif
- return size;
+ *lenp = size;
+ return 0;
}
/*
@@ -713,7 +714,7 @@ static int __init init_pmc551(void)
* with the oldproc.c driver in
* some kernels (2.2.*)
*/
- if ((length = fixup_pmc551(PCI_Device)) <= 0) {
+ if (fixup_pmc551(PCI_Device, &length) < 0 || !length) {
printk(KERN_NOTICE "pmc551: Cannot init SDRAM\n");
break;
}
--
1.7.5.4
More information about the linux-mtd
mailing list