linux/atheros: add 2.6.38 preliminary support
[openwrt.git] / target / linux / atheros / patches-2.6.38 / 140-redboot_partition_scan.patch
1 --- a/drivers/mtd/redboot.c
2 +++ b/drivers/mtd/redboot.c
3 @@ -78,31 +78,32 @@ static int parse_redboot_partitions(stru
4         static char nullstring[] = "unallocated";
5  #endif
6  
7 +       buf = vmalloc(master->erasesize);
8 +       if (!buf)
9 +               return -ENOMEM;
10 +
11 + restart:
12         if ( directory < 0 ) {
13                 offset = master->size + directory * master->erasesize;
14 -               while (master->block_isbad && 
15 +               while (master->block_isbad &&
16                        master->block_isbad(master, offset)) {
17                         if (!offset) {
18                         nogood:
19                                 printk(KERN_NOTICE "Failed to find a non-bad block to check for RedBoot partition table\n");
20 +                               vfree(buf);
21                                 return -EIO;
22                         }
23                         offset -= master->erasesize;
24                 }
25         } else {
26                 offset = directory * master->erasesize;
27 -               while (master->block_isbad && 
28 +               while (master->block_isbad &&
29                        master->block_isbad(master, offset)) {
30                         offset += master->erasesize;
31                         if (offset == master->size)
32                                 goto nogood;
33                 }
34         }
35 -       buf = vmalloc(master->erasesize);
36 -
37 -       if (!buf)
38 -               return -ENOMEM;
39 -
40         printk(KERN_NOTICE "Searching for RedBoot partition table in %s at offset 0x%lx\n",
41                master->name, offset);
42  
43 @@ -174,6 +175,11 @@ static int parse_redboot_partitions(stru
44         }
45         if (i == numslots) {
46                 /* Didn't find it */
47 +               if (offset + master->erasesize < master->size) {
48 +                       /* not at the end of the flash yet, maybe next block :) */
49 +                       directory++;
50 +                       goto restart;
51 +               }
52                 printk(KERN_NOTICE "No RedBoot partition table detected in %s\n",
53                        master->name);
54                 ret = 0;