diff options
-rw-r--r-- | drivers/mtd/chips/gen_probe.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/mtd/chips/gen_probe.c b/drivers/mtd/chips/gen_probe.c index 9b252d2e4a70..b2d30525c04c 100644 --- a/drivers/mtd/chips/gen_probe.c +++ b/drivers/mtd/chips/gen_probe.c | |||
@@ -37,8 +37,15 @@ struct mtd_info *mtd_do_chip_probe(struct map_info *map, struct chip_probe *cp) | |||
37 | if (!mtd) | 37 | if (!mtd) |
38 | mtd = check_cmd_set(map, 0); /* Then the secondary */ | 38 | mtd = check_cmd_set(map, 0); /* Then the secondary */ |
39 | 39 | ||
40 | if (mtd) | 40 | if (mtd) { |
41 | if (mtd->size > map->size) { | ||
42 | printk(KERN_WARNING "Reducing visibility of %lKiB chip to %lKiB\n", | ||
43 | (unsigned long)mtd->size >> 10, | ||
44 | (unsigned long)map->size >> 10); | ||
45 | mtd->size = map->size; | ||
46 | } | ||
41 | return mtd; | 47 | return mtd; |
48 | } | ||
42 | 49 | ||
43 | printk(KERN_WARNING"gen_probe: No supported Vendor Command Set found\n"); | 50 | printk(KERN_WARNING"gen_probe: No supported Vendor Command Set found\n"); |
44 | 51 | ||
@@ -100,7 +107,12 @@ static struct cfi_private *genprobe_ident_chips(struct map_info *map, struct chi | |||
100 | * Align bitmap storage size to full byte. | 107 | * Align bitmap storage size to full byte. |
101 | */ | 108 | */ |
102 | max_chips = map->size >> cfi.chipshift; | 109 | max_chips = map->size >> cfi.chipshift; |
103 | mapsize = (max_chips / 8) + ((max_chips % 8) ? 1 : 0); | 110 | if (!max_chips) { |
111 | printk(KERN_WARNING "NOR chip too large to fit in mapping. Attempting to cope...\n"); | ||
112 | max_chips = 1; | ||
113 | } | ||
114 | |||
115 | mapsize = (max_chips + BITS_PER_LONG-1) / BITS_PER_LONG; | ||
104 | chip_map = kmalloc(mapsize, GFP_KERNEL); | 116 | chip_map = kmalloc(mapsize, GFP_KERNEL); |
105 | if (!chip_map) { | 117 | if (!chip_map) { |
106 | printk(KERN_WARNING "%s: kmalloc failed for CFI chip map\n", map->name); | 118 | printk(KERN_WARNING "%s: kmalloc failed for CFI chip map\n", map->name); |