public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* PATCH: ability to build blkmtd into the kernel and still use it
@ 2002-04-11 16:43 Mike Mattice
  2002-04-11 19:39 ` spse
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Mattice @ 2002-04-11 16:43 UTC (permalink / raw)
  To: linux-mtd; +Cc: Simon Evans

Basically all this does is point the *device to a bootdevice
var that's initialized by passing the kernel 'blkmtd=<non devfs device>'.
I have no idea why giving it arguments like /dev/discs/disc0/disc doesn't
work with devfs compiled in, but apparantly support is just not set
up by that time.  

I'd ultimately like to be able to set blkmtd devices up at build time,
but my current project has enough room on the ide-emulated flash to 
fit a stripped down lilo on it so it doesn't matter much now.


diff -rNubBw linux-2.4.18.orig/drivers/mtd/devices/blkmtd.c linux-2.4.18.mtddevel/drivers/mtd/devices/blkmtd.c
--- linux-2.4.18.orig/drivers/mtd/devices/blkmtd.c	Tue Apr  9 11:08:22 2002
+++ linux-2.4.18.mtddevel/drivers/mtd/devices/blkmtd.c	Thu Apr 11 11:26:31 2002
@@ -4,6 +4,7 @@
  * blkmtd.c - use a block device as a fake MTD
  *
  * Author: Simon Evans <spse@secret.org.uk>
+ * Modified: Michael Mattice <mike@mattice.org>
  *
  * Copyright (C) 2001 Simon Evans
  * 
@@ -53,6 +54,7 @@
 #include <linux/pagemap.h>
 #include <linux/mtd/compatmac.h>
 #include <linux/mtd/mtd.h>
+#include <linux/ctype.h>
 
 #ifdef CONFIG_MTD_DEBUG
 #ifdef CONFIG_PROC_FS
@@ -130,6 +132,8 @@
 int bs;          /* optionally force the block size (avoid using) */
 int count;       /* optionally force the block count (avoid using) */
 int wqs;         /* optionally set the write queue size */
+char bootdevice[64];	/* boot device option */
+int bootdevset = 0;	/* flag for above */
 
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
@@ -1073,9 +1077,13 @@
 
   /* Check args */
   if(device == 0) {
+    if (bootdevset) {
+      device = &bootdevice;
+    } else {
     printk("blkmtd: error, missing `device' name\n");
     return -EINVAL;
   }
+  }
 
   if(ro)
     readonly = 1;
@@ -1312,6 +1320,26 @@
     __free_pages(erase_page, 0);
   return err;
 }
+
+static int __init blkmtd_setup(char *line)
+{
+        int i;
+        char ch;
+
+	bootdevset = 1;
+        memset (bootdevice, 0, sizeof bootdevice);
+        for (i = 0; i < sizeof bootdevice - 1; ++i)
+        {
+            ch = line[i];
+            if ( isspace (ch) || (ch == ',') || (ch == '\0') ) break;  
+	    // don't have to worry about setting the last char to \0, 
+	    // because the memset has taken care of that for us.
+            bootdevice[i] = ch;
+        }
+        return 1;
+}
+
+__setup("blkmtd=", blkmtd_setup);
 
 module_init(init_blkmtd);
 module_exit(cleanup_blkmtd);

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-04-12  9:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-11 16:43 PATCH: ability to build blkmtd into the kernel and still use it Mike Mattice
2002-04-11 19:39 ` spse
2002-04-12  9:35   ` Stephan Linke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox