[ar71xx] increase size of the kernel partition on the TEW-632BR board
[openwrt.git] / target / linux / generic-2.6 / patches-2.6.28 / 060-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 @@ -273,17 +275,17 @@ static struct block2mtd_dev *add_device(
25
26 mutex_init(&dev->write_mutex);
27
28 - /* Setup the MTD structure */
29 - /* make the name contain the block device in */
30 - name = kmalloc(sizeof("block2mtd: ") + strlen(devname) + 1,
31 - GFP_KERNEL);
32 + if (!mtdname)
33 + mtdname = devname;
34 +
35 + name = kmalloc(strlen(mtdname) + 1, GFP_KERNEL);
36 if (!name)
37 goto devinit_err;
38
39 - sprintf(name, "block2mtd: %s", devname);
40 + strcpy(name, mtdname);
41 dev->mtd.name = name;
42
43 - dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK;
44 + dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK & ~(erase_size - 1);
45 dev->mtd.erasesize = erase_size;
46 dev->mtd.writesize = 1;
47 dev->mtd.type = MTD_RAM;
48 @@ -296,14 +298,17 @@ static struct block2mtd_dev *add_device(
49 dev->mtd.priv = dev;
50 dev->mtd.owner = THIS_MODULE;
51
52 - if (add_mtd_device(&dev->mtd)) {
53 + part = kzalloc(sizeof(struct mtd_partition), GFP_KERNEL);
54 + part->name = dev->mtd.name;
55 + part->offset = 0;
56 + part->size = dev->mtd.size;
57 + if (add_mtd_partitions(&dev->mtd, part, 1)) {
58 /* Device didnt get added, so free the entry */
59 goto devinit_err;
60 }
61 list_add(&dev->list, &blkmtd_device_list);
62 INFO("mtd%d: [%s] erase_size = %dKiB [%d]", dev->mtd.index,
63 - dev->mtd.name + strlen("block2mtd: "),
64 - dev->mtd.erasesize >> 10, dev->mtd.erasesize);
65 + mtdname, dev->mtd.erasesize >> 10, dev->mtd.erasesize);
66 return dev;
67
68 devinit_err:
69 @@ -376,9 +381,9 @@ static char block2mtd_paramline[80 + 12]
70
71 static int block2mtd_setup2(const char *val)
72 {
73 - char buf[80 + 12]; /* 80 for device, 12 for erase size */
74 + char buf[80 + 12 + 80]; /* 80 for device, 12 for erase size, 80 for name */
75 char *str = buf;
76 - char *token[2];
77 + char *token[3];
78 char *name;
79 size_t erase_size = PAGE_SIZE;
80 int i, ret;
81 @@ -389,7 +394,7 @@ static int block2mtd_setup2(const char *
82 strcpy(str, val);
83 kill_final_newline(str);
84
85 - for (i = 0; i < 2; i++)
86 + for (i = 0; i < 3; i++)
87 token[i] = strsep(&str, ",");
88
89 if (str)
90 @@ -408,8 +413,10 @@ static int block2mtd_setup2(const char *
91 parse_err("illegal erase size");
92 }
93 }
94 + if (token[2] && (strlen(token[2]) + 1 > 80))
95 + parse_err("mtd device name too long");
96
97 - add_device(name, erase_size);
98 + add_device(name, erase_size, token[2]);
99
100 return 0;
101 }
102 @@ -443,7 +450,7 @@ static int block2mtd_setup(const char *v
103
104
105 module_param_call(block2mtd, block2mtd_setup, NULL, NULL, 0200);
106 -MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>]\"");
107 +MODULE_PARM_DESC(block2mtd, "Device to use. \"block2mtd=<dev>[,<erasesize>[,<name>]]\"");
108
109 static int __init block2mtd_init(void)
110 {
This page took 0.044723 seconds and 5 git commands to generate.