[PATCH] pcmcia: don't sleep when you aren't tired

Dominik Brodowski linux at brodo.de
Sat Jun 21 00:43:56 BST 2003


There seems to be no reason why ds.c should wait for 100ms before it
unregisters the drivers etc. Also, check whether it's safe to sleep
here...

 ds.c |   18 ++++--------------
 1 files changed, 4 insertions(+), 14 deletions(-)

diff -ruN linux-original/drivers/pcmcia/ds.c linux/drivers/pcmcia/ds.c
--- linux-original/drivers/pcmcia/ds.c	2003-06-20 08:48:25.000000000 +0200
+++ linux/drivers/pcmcia/ds.c	2003-06-20 20:59:04.000000000 +0200
@@ -31,6 +31,7 @@
     
 ======================================================================*/
 
+#include <linux/kernel.h>
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/init.h>
@@ -104,7 +105,6 @@
 	user_info_t		*user;
 	int			req_pending, req_result;
 	wait_queue_head_t	queue, request;
-	struct work_struct	removal;
 	socket_bind_t		*bind;
 	struct device		*socket_dev;
 	struct pcmcia_socket	*parent;
@@ -112,7 +112,6 @@
 
 #define SOCKET_PRESENT		0x01
 #define SOCKET_BUSY		0x02
-#define SOCKET_REMOVAL_PENDING	0x10
 
 /*====================================================================*/
 
@@ -240,13 +239,6 @@
     return CS_SUCCESS;
 }
 
-static void handle_removal(void *data)
-{
-    struct pcmcia_bus_socket *s = data;
-    handle_event(s, CS_EVENT_CARD_REMOVAL);
-    s->state &= ~SOCKET_REMOVAL_PENDING;
-}
-
 /*======================================================================
 
     The card status event handler.
@@ -261,15 +253,14 @@
     DEBUG(1, "ds: ds_event(0x%06x, %d, 0x%p)\n",
 	  event, priority, args->client_handle);
     s = args->client_data;
+
+    might_sleep();
     
     switch (event) {
 	
     case CS_EVENT_CARD_REMOVAL:
 	s->state &= ~SOCKET_PRESENT;
-	if (!(s->state & SOCKET_REMOVAL_PENDING)) {
-		s->state |= SOCKET_REMOVAL_PENDING;
-		schedule_delayed_work(&s->removal,  HZ/10);
-	}
+	handle_event(s, event);
 	break;
 	
     case CS_EVENT_CARD_INSERTION:
@@ -846,7 +837,6 @@
 
 	/* initialize data */
 	s->socket_dev = socket->dev.dev;
-	INIT_WORK(&s->removal, handle_removal, s);
 	s->parent = socket;
 
 	/* Set up hotline to Card Services */



More information about the linux-pcmcia mailing list