6d820c9ce4700e37e235d62283fbe0b8897f1f16
[openwrt/staging/yousong.git] / target / linux / adm8668 / patches-3.3 / a03-adm8668-flash-map-fix.patch
1 --- a/drivers/mtd/maps/adm8668.c
2 +++ b/drivers/mtd/maps/adm8668.c
3 @@ -47,9 +47,7 @@
4 #include <linux/mtd/mtd.h>
5 #include <linux/mtd/map.h>
6 #include <linux/slab.h>
7 -#ifdef CONFIG_MTD_PARTITIONS
8 #include <linux/mtd/partitions.h>
9 -#endif
10 #include <linux/crc32.h>
11 #include <linux/magic.h>
12 #include <asm/io.h>
13 @@ -94,8 +92,6 @@ struct map_info adm8668_map = {
14 bankwidth: BANKWIDTH,
15 };
16
17 -#ifdef CONFIG_MTD_PARTITIONS
18 -
19 /*
20 * Copied from mtdblock.c
21 *
22 @@ -238,7 +234,12 @@ init_mtd_partitions(struct mtd_info *mtd
23 return NR_PARTS;
24
25 if (be32_to_cpu(uhdr.ih_size) != (linux_len - sizeof(uhdr))) {
26 - unsigned char *block, *data = (unsigned char *)(WINDOW_ADDR | (adm8668_parts[PART_LINUX].offset + sizeof(struct uboot_header)) | 0xA0000000);
27 + unsigned char *block, *data;
28 + unsigned int offset;
29 +
30 + offset = adm8668_parts[PART_LINUX].offset +
31 + sizeof(struct uboot_header);
32 + data = (unsigned char *)(WINDOW_ADDR | 0xA0000000 | offset);
33
34 printk(KERN_NOTICE "Updating U-boot image:\n");
35 printk(KERN_NOTICE " old: [size: %8d crc32: 0x%08x]\n",
36 @@ -279,16 +280,11 @@ init_mtd_partitions(struct mtd_info *mtd
37 return NR_PARTS;
38 }
39
40 -#endif
41 -
42 -
43 int __init init_adm8668_map(void)
44 {
45 -#ifdef CONFIG_MTD_PARTITIONS
46 int nr_parts, ret;
47 -#endif
48
49 - adm8668_map.virt = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE);
50 + adm8668_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
51
52 if (!adm8668_map.virt) {
53 printk(KERN_ERR "Failed to ioremap\n");
54 @@ -304,14 +300,12 @@ int __init init_adm8668_map(void)
55
56 adm8668_mtd->owner = THIS_MODULE;
57
58 -#ifdef CONFIG_MTD_PARTITIONS
59 nr_parts = init_mtd_partitions(adm8668_mtd, adm8668_mtd->size);
60 - ret = add_mtd_partitions(adm8668_mtd, adm8668_parts, nr_parts);
61 + ret = mtd_device_register(adm8668_mtd, adm8668_parts, nr_parts);
62 if (ret) {
63 - printk(KERN_ERR "Flash: add_mtd_partitions failed\n");
64 + printk(KERN_ERR "Flash: mtd_device_register failed\n");
65 goto fail;
66 }
67 -#endif
68
69 return 0;
70
71 @@ -326,9 +320,7 @@ int __init init_adm8668_map(void)
72
73 void __exit cleanup_adm8668_map(void)
74 {
75 -#ifdef CONFIG_MTD_PARTITIONS
76 - del_mtd_partitions(adm8668_mtd);
77 -#endif
78 + mtd_device_unregister(adm8668_mtd);
79 map_destroy(adm8668_mtd);
80 iounmap((void *) adm8668_map.virt);
81 adm8668_map.virt = 0;