PATCH: startup.c -- excluding io and mem via config.opts

Arne Ahrend aahrend at web.de
Mon Aug 8 15:35:10 EDT 2005


On Sat, 30 Jul 2005 17:36:52 +0200
Arne Ahrend <aahrend at web.de> wrote:

> On Sat, 30 Jul 2005 00:12:31 +0200
> Dominik Brodowski <linux at dominikbrodowski.net> wrote:
> 
> > Please remove this line from /etc/pcmcia/config.opts
> > > exclude port 0x220-0x22f, port 0x300-0x307, port 0x388-0x38f, port 0x800-0x807
> > 
> > and try to run
> > /sbin/pcmcia-socket-startup 0
> > manually.

The following patch adds the ability to exclude io and memory regions
via corresponding entries in config.opts. It also will only call disallow_irq(),
if the irq is excluded in config.opts. However, nothing is done for
included irqs. (I believe this is a bit less counter-intuitive than actively dissallowing
included irqs).

Cheers,
Arne

--- startup.c-orig	2005-07-23 22:48:39.000000000 +0200
+++ startup.c	2005-08-08 20:42:05.000000000 +0200
@@ -50,6 +50,7 @@
 
 
 static int add_available_resource(unsigned int socket_no, unsigned int type,
+				  unsigned int action,
 				  unsigned long start, unsigned long end)
 {
 	char file[SYSFS_PATH_MAX];
@@ -64,12 +65,25 @@
 	if (end <= start)
 		return -EINVAL;
 
-	dprintf("%d %d %lx %lx\n", socket_no, type, start, end);
+	dprintf("%d %d %d 0x%lx 0x%lx\n", socket_no, type, action, start, end);
 
 	snprintf(file, SYSFS_PATH_MAX, PATH_TO_SOCKET "pcmcia_socket%u/%s",
 		socket_no, resource_files[type]);
 
-	len = snprintf(content, SYSFS_PATH_MAX, "0x%08lx - 0x%08lx", start, end);
+	switch(action) {
+	case ADD_MANAGED_RESOURCE:
+		len = snprintf(content, SYSFS_PATH_MAX,
+			       "0x%08lx - 0x%08lx", start, end);
+		break;
+		
+	case REMOVE_MANAGED_RESOURCE:
+		len = snprintf(content, SYSFS_PATH_MAX,
+			       "- 0x%08lx - 0x%08lx", start, end);
+		break;
+		
+	default:
+		return -EINVAL;
+	}
 
 	dprintf("content is %s\n", content);
 
@@ -125,9 +139,10 @@
 	if (irq >= 32)
 		return -EINVAL;
 
-	snprintf(file, SYSFS_PATH_MAX, PATH_TO_SOCKET
+	len = snprintf(file, SYSFS_PATH_MAX, PATH_TO_SOCKET
 		 "pcmcia_socket%u/card_irq_mask",
 		 socket_no);
+	dprintf("file is %s\n", file);
 
 	attr = sysfs_open_attribute(file);
 	if (!attr)
@@ -184,18 +199,21 @@
 	    switch (al->adj.Resource) {
 	    case RES_MEMORY_RANGE:
 		    add_available_resource(socket_no, RESOURCE_MEM,
+					   al->adj.Action,
 					   al->adj.resource.memory.Base,
 					   al->adj.resource.memory.Base +
 					   al->adj.resource.memory.Size - 1);
 		    break;
 	    case RES_IO_RANGE:
 		    add_available_resource(socket_no, RESOURCE_IO,
+					   al->adj.Action,
 					   al->adj.resource.io.BasePort,
 					   al->adj.resource.io.BasePort +
 					   al->adj.resource.io.NumPorts - 1);
 		    break;
 	    case RES_IRQ:
-		    disallow_irq(socket_no, al->adj.resource.irq.IRQ);
+		    if(al->adj.Action == REMOVE_MANAGED_RESOURCE)
+			    disallow_irq(socket_no, al->adj.resource.irq.IRQ);
 		    break;
 	    }
     }



More information about the linux-pcmcia mailing list