[PATCH RFC] pcmcia: load include_io, include_mem from /etc/modprobe.d/pcmcia.conf

Komuro komurojun-mbn at nifty.com
Sat Nov 7 21:19:24 EST 2009


load include_io, include_mem from /etc/modprobe.d/pcmcia.conf
instead of running pcmcia-socket-startup.
(integration of pcmcia-socket-startup to the kernel)

if /etc/modprobe.d/pcmcia.conf does not exist,
rsrc_nonstatic allocates minimum io/mem resource.

exclude_io, exclude_mem, include_irq, exclude_irq
are not yet implemented.

Here is example of pcmcia.conf

options rsrc_nonstatic include_io_list=0x100,0x3af,0x3e0,0x4ff,0x800,0x820,0xc00,0xcf7,0xa00,0xaff
options rsrc_nonstatic include_mem_list=0xc0000,0xfffff,0xa0000000,0xa0ffffff,0x60000000,0x60ffffff



--- linux-2.6.32-rc5-git3/drivers/pcmcia/rsrc_nonstatic.c.orig	2009-11-01 20:51:39.000000000 +0900
+++ linux-2.6.32-rc5-git3/drivers/pcmcia/rsrc_nonstatic.c	2009-11-08 11:00:14.000000000 +0900
@@ -47,6 +47,13 @@ INT_MODULE_PARM(probe_io,	1);		/* IO por
 INT_MODULE_PARM(mem_limit,	0x10000);
 #endif
 
+static int include_io_list[16];
+static unsigned int include_io_count = 0;
+module_param_array(include_io_list, int, &include_io_count, 0444);
+static int include_mem_list[16];
+static unsigned int include_mem_count = 0;
+module_param_array(include_mem_list, int, &include_mem_count, 0444);
+
 /* for io_db and mem_db */
 struct resource_map {
 	u_long			base, num;
@@ -779,8 +786,49 @@ static int nonstatic_autoadd_resources(s
 	struct resource *res;
 	int i, done = 0;
 
-	if (!s->cb_dev || !s->cb_dev->bus)
-		return -ENODEV;
+	if (include_io_count) {
+		for (i = 0; i < include_io_count; i=i+2) {
+			if (!adjust_io(s, ADD_MANAGED_RESOURCE, 
+				include_io_list[i], include_io_list[i+1])) {
+				done |= IORESOURCE_IO;
+			}
+		}
+	}
+#if defined(CONFIG_X86)
+	  else {
+		/* allocate minimum io resource */
+		if (!adjust_io(s, ADD_MANAGED_RESOURCE, 0x100, 0x03af)) {
+			done |= IORESOURCE_IO;
+		}
+	} 
+#endif
+
+	if (include_mem_count) {
+		for (i = 0; i < include_mem_count; i=i+2) {
+			if (!adjust_memory(s, ADD_MANAGED_RESOURCE, 
+				include_mem_list[i], include_mem_list[i+1])) {
+				done |= IORESOURCE_MEM;
+			}
+		}
+	}
+
+#if defined(CONFIG_X86)
+	  else  {
+		/* allocate minimum memory resource */
+		if (!adjust_memory(s, ADD_MANAGED_RESOURCE, 
+				0xa0000000, 0xa0ffffff)) {
+			done |= IORESOURCE_MEM;
+		}
+	} 
+#endif
+
+	if (!s->cb_dev || !s->cb_dev->bus) {
+		if (done == (IORESOURCE_MEM | IORESOURCE_IO)) {
+			s->resource_setup_done = 1;
+			return 0;
+		} else 
+			return -ENODEV;
+	}
 
 #if defined(CONFIG_X86)
 	/* If this is the root bus, the risk of hitting
@@ -789,8 +837,13 @@ static int nonstatic_autoadd_resources(s
 	 * resources is too big. Therefore, don't do auto-adding
 	 * of resources at the moment.
 	 */
-	if (s->cb_dev->bus->number == 0)
-		return -EINVAL;
+	if (s->cb_dev->bus->number == 0) {
+		if (done == (IORESOURCE_MEM | IORESOURCE_IO)) {
+			s->resource_setup_done = 1;
+			return 0;
+		} else 
+			return -EINVAL;
+	}
 #endif
 
 	for (i=0; i < PCI_BUS_NUM_RESOURCES; i++) {



More information about the linux-pcmcia mailing list