linux/3.{2,3}: even more NAND symbols
[openwrt.git] / target / linux / generic / patches-2.6.37 / 440-block2mtd_init.patch
1 --- a/drivers/mtd/devices/block2mtd.c
2 +++ b/drivers/mtd/devices/block2mtd.c
3 @@ -14,6 +14,7 @@
4 #include <linux/list.h>
5 #include <linux/init.h>
6 #include <linux/mtd/mtd.h>
7 +#include <linux/mtd/partitions.h>
8 #include <linux/buffer_head.h>
9 #include <linux/mutex.h>
10 #include <linux/mount.h>
11 @@ -232,10 +233,11 @@ static void block2mtd_free_device(struct
12
13
14 /* FIXME: ensure that mtd->size % erase_size == 0 */
15 -static struct block2mtd_dev *add_device(char *devname, int erase_size)
16 +static struct block2mtd_dev *add_device(char *devname, int erase_size, const char *mtdname)
17 {
18 struct block_device *bdev;
19 struct block2mtd_dev *dev;
20 + struct mtd_partition *part;
21 char *name;
22
23 if (!devname)
24 @@ -275,13 +277,16 @@ static struct block2mtd_dev *add_device(
25
26 /* Setup the MTD structure */
27 /* make the name contain the block device in */
28 - name = kasprintf(GFP_KERNEL, "block2mtd: %s", devname);
29 + if (!mtdname)
30 + mtdname = devname;
31 + name = kmalloc(strlen(mtdname) + 1, GFP_KERNEL);
32 if (!name)
33 goto devinit_err;
34
35 + strcpy(name, mtdname);
36 dev->mtd.name = name;
37
38 - dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK;
39 + dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK & ~(erase_size - 1);
40 dev->mtd.erasesize = erase_size;
41 dev->mtd.writesize = 1;
42 dev->mtd.type = MTD_RAM;
43 @@ -294,14 +299,17 @@ static struct block2mtd_dev *add_device(
44 dev->mtd.priv = dev;
45 dev->mtd.owner = THIS_MODULE;
46
47 - if (add_mtd_device(&dev->mtd)) {
48 + part = kzalloc(sizeof(struct mtd_partition), GFP_KERNEL);
49 + part->name = dev->mtd.name;
50 + part->offset = 0;
51 + part->size = dev->mtd.size;
52 + if (add_mtd_partitions(&dev->mtd, part, 1)) {
53 /* Device didnt get added, so free the entry */
54 goto devinit_err;
55 }
56 list_add(&dev->list, &blkmtd_device_list);
57 INFO("mtd%d: [%s] erase_size = %dKiB [%d]", dev->mtd.index,
58 - dev->mtd.name + strlen("block2mtd: "),
59 - dev->mtd.erasesize >> 10, dev->mtd.erasesize);
60 + mtdname, dev->mtd.erasesize >> 10, dev->mtd.erasesize);
61 return dev;
62
63 devinit_err:
64 @@ -374,9 +382,9 @@ static char block2mtd_paramline[80 + 12]
65
66 static int block2mtd_setup2(const char *val)
67 {
68 - char buf[80 + 12]; /* 80 for device, 12 for erase size */
69 + char buf[80 + 12 + 80]; /* 80 for device, 12 for erase size, 80 for name */
70 char *str = buf;
71 - char *token[2];
72 + char *token[3];
73 char *name;
74 size_t erase_size = PAGE_SIZE;
75 int i, ret;
76 @@ -387,7 +395,7 @@ static int block2mtd_setup2(const char *
77 strcpy(str, val);
78 kill_final_newline(str);
79
80 - for (i = 0; i < 2; i++)
81 + for (i = 0; i < 3; i++)
82 token[i] = strsep(&str, ",");
83
84 if (str)
85 @@ -406,8 +414,10 @@ static int block2mtd_setup2(const char *
86 parse_err("illegal erase size");
87 }
88 }
89 + if (token[2] && (strlen(token[2]) + 1 > 80))
90 + parse_err("mtd device name too long");
91
92 - add_device(name, erase_size);
93 + add_device(name, erase_size, token[2]);
94
95 return 0;
96 }
97 @@ -441,7 +451,7 @@ static int block2mtd_setup(const char *v
98
99
100 module_param_call(block2mtd, block2mtd_setup, NULL, NULL, 0200);
101 -MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>]\"");
102 +MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>[,<name>]]\"");
103
104 static int __init block2mtd_init(void)
105 {
106 --- a/fs/partitions/check.c
107 +++ b/fs/partitions/check.c
108 @@ -715,6 +715,7 @@ rescan:
109 kfree(state);
110 return 0;
111 }
112 +EXPORT_SYMBOL(rescan_partitions);
113
114 unsigned char *read_dev_sector(struct block_device *bdev, sector_t n, Sector *p)
115 {
This page took 0.048899 seconds and 5 git commands to generate.