aboutsummaryrefslogtreecommitdiffstats
path: root/test/testpools.c
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-12-28 09:57:11 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-12-28 09:57:11 +0000
commitfb1b2273837207d71bdb2e676a10a934eb8fb7a7 (patch)
tree2259be0d0a81df7c7209909ad40fda6b68559131 /test/testpools.c
parenta77c78a51ccf7a64dd5414300fe61b39c81732d2 (diff)
downloadChibiOS-fb1b2273837207d71bdb2e676a10a934eb8fb7a7.tar.gz
ChibiOS-fb1b2273837207d71bdb2e676a10a934eb8fb7a7.tar.bz2
ChibiOS-fb1b2273837207d71bdb2e676a10a934eb8fb7a7.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4980 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'test/testpools.c')
0 files changed, 0 insertions, 0 deletions
'>79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
Index: linux-2.6.21.7/drivers/mtd/devices/block2mtd.c
===================================================================
--- linux-2.6.21.7.orig/drivers/mtd/devices/block2mtd.c
+++ linux-2.6.21.7/drivers/mtd/devices/block2mtd.c
@@ -16,6 +16,7 @@
 #include <linux/list.h>
 #include <linux/init.h>
 #include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
 #include <linux/buffer_head.h>
 #include <linux/mutex.h>
 #include <linux/mount.h>
@@ -288,10 +289,11 @@ static void block2mtd_free_device(struct
 
 
 /* FIXME: ensure that mtd->size % erase_size == 0 */
-static struct block2mtd_dev *add_device(char *devname, int erase_size)
+static struct block2mtd_dev *add_device(char *devname, int erase_size, char *mtdname)
 {
 	struct block_device *bdev;
 	struct block2mtd_dev *dev;
+	struct mtd_partition *part;
 
 	if (!devname)
 		return NULL;
@@ -330,14 +332,18 @@ static struct block2mtd_dev *add_device(
 
 	/* Setup the MTD structure */
 	/* make the name contain the block device in */
-	dev->mtd.name = kmalloc(sizeof("block2mtd: ") + strlen(devname),
-			GFP_KERNEL);
+
+	if (!mtdname)
+		mtdname = devname;
+
+	dev->mtd.name = kmalloc(strlen(mtdname) + 1, GFP_KERNEL);
+
 	if (!dev->mtd.name)
 		goto devinit_err;
+	
+	strcpy(dev->mtd.name, mtdname);
 
-	sprintf(dev->mtd.name, "block2mtd: %s", devname);
-
-	dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK;
+	dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK & ~(erase_size - 1);
 	dev->mtd.erasesize = erase_size;
 	dev->mtd.writesize = 1;
 	dev->mtd.type = MTD_RAM;
@@ -349,15 +355,18 @@ static struct block2mtd_dev *add_device(
 	dev->mtd.read = block2mtd_read;
 	dev->mtd.priv = dev;
 	dev->mtd.owner = THIS_MODULE;
-
-	if (add_mtd_device(&dev->mtd)) {
+	
+	part = kzalloc(sizeof(struct mtd_partition), GFP_KERNEL);
+	part->name = dev->mtd.name;
+	part->offset = 0;
+	part->size = dev->mtd.size;
+	if (add_mtd_partitions(&dev->mtd, part, 1)) {
 		/* Device didnt get added, so free the entry */