[patch 9/19] pcmcia: make PCMCIA status a bitfield

Dominik Brodowski linux at dominikbrodowski.net
Sun Mar 20 05:43:42 EST 2005


make pcmcia_bus_socket->state a bitfield, and rename it pcmcia_state to
prepare for struct pcmcia_bus_socket integration into struct pcmcia_socket.

Signed-off-by: Dominik Brodowski <linux at dominikbrodowski.net>

Index: 2.6.11+/drivers/pcmcia/ds.c
===================================================================
--- 2.6.11+.orig/drivers/pcmcia/ds.c	2005-03-09 00:03:03.000000000 +0100
+++ 2.6.11+/drivers/pcmcia/ds.c	2005-03-09 00:03:04.000000000 +0100
@@ -622,14 +622,14 @@
 {
 	struct pcmcia_bus_socket *s = data;
 	pcmcia_device_add(s, 0);
-	s->device_add_pending = 0;
+	s->pcmcia_state.device_add_pending = 0;
 }
 
 static inline void pcmcia_add_pseudo_device(struct pcmcia_bus_socket *s)
 {
-	if (!s->device_add_pending) {
+	if (!s->pcmcia_state.device_add_pending) {
 		schedule_work(&s->device_add);
-		s->device_add_pending = 1;
+		s->pcmcia_state.device_add_pending = 1;
 	}
 	return;
 }
@@ -980,14 +980,14 @@
 	switch (event) {
 
 	case CS_EVENT_CARD_REMOVAL:
-		s->state &= ~DS_SOCKET_PRESENT;
+		s->pcmcia_state.present = 0;
 	    	send_event(skt, event, priority);
 		unbind_request(s);
 		handle_event(s, event);
 		break;
 	
 	case CS_EVENT_CARD_INSERTION:
-		s->state |= DS_SOCKET_PRESENT;
+		s->pcmcia_state.present = 1;
 		pcmcia_card_add(skt);
 		handle_event(s, event);
 		break;
@@ -1229,7 +1229,7 @@
 
 	pccard_register_pcmcia(socket, NULL);
 
-	socket->pcmcia->state |= DS_SOCKET_DEAD;
+	socket->pcmcia->pcmcia_state.dead = 1;
 	pcmcia_put_bus_socket(socket->pcmcia);
 	socket->pcmcia = NULL;
 
Index: 2.6.11+/drivers/pcmcia/ds_internal.h
===================================================================
--- 2.6.11+.orig/drivers/pcmcia/ds_internal.h	2005-03-09 00:03:03.000000000 +0100
+++ 2.6.11+/drivers/pcmcia/ds_internal.h	2005-03-09 00:03:04.000000000 +0100
@@ -5,7 +5,6 @@
 /* Socket state information */
 struct pcmcia_bus_socket {
 	struct kref		refcount;
-	int			state;
 	struct pcmcia_socket	*parent;
 
 	/* the PCMCIA devices connected to this socket (normally one, more
@@ -15,7 +14,14 @@
 					       * only internally and subject
 					       * to incorrectness and change */
 
-	u8			device_add_pending;
+	struct {
+		u8		present:1,
+				busy:1,
+				dead:1,
+				device_add_pending:1,
+				reserved:4;
+	} 			pcmcia_state;
+
 	struct work_struct	device_add;
 
 
@@ -29,10 +35,6 @@
 extern struct bus_type pcmcia_bus_type;
 
 
-#define DS_SOCKET_PRESENT		0x01
-#define DS_SOCKET_BUSY			0x02
-#define DS_SOCKET_DEAD			0x80
-
 extern struct pcmcia_device * pcmcia_get_dev(struct pcmcia_device *p_dev);
 extern void pcmcia_put_dev(struct pcmcia_device *p_dev);
 
Index: 2.6.11+/drivers/pcmcia/pcmcia_ioctl.c
===================================================================
--- 2.6.11+.orig/drivers/pcmcia/pcmcia_ioctl.c	2005-03-09 00:03:01.000000000 +0100
+++ 2.6.11+/drivers/pcmcia/pcmcia_ioctl.c	2005-03-09 00:03:04.000000000 +0100
@@ -404,12 +404,12 @@
 	    return -ENODEV;
 
     if ((file->f_flags & O_ACCMODE) != O_RDONLY) {
-	    if (s->state & DS_SOCKET_BUSY) {
+	    if (s->pcmcia_state.busy) {
 		    pcmcia_put_bus_socket(s);
 		    return -EBUSY;
 	    }
 	else
-	    s->state |= DS_SOCKET_BUSY;
+	    s->pcmcia_state.busy = 1;
     }
     
     user = kmalloc(sizeof(user_info_t), GFP_KERNEL);
@@ -424,7 +424,7 @@
     s->user = user;
     file->private_data = user;
     
-    if (s->state & DS_SOCKET_PRESENT)
+    if (s->pcmcia_state.present)
 	queue_event(user, CS_EVENT_CARD_INSERTION);
     return 0;
 } /* ds_open */
@@ -446,7 +446,7 @@
 
     /* Unlink user data structure */
     if ((file->f_flags & O_ACCMODE) != O_RDONLY) {
-	s->state &= ~DS_SOCKET_BUSY;
+	s->pcmcia_state.busy = 0;
     }
     file->private_data = NULL;
     for (link = &s->user; *link; link = &(*link)->next)
@@ -480,7 +480,7 @@
 	return -EIO;
     
     s = user->socket;
-    if (s->state & DS_SOCKET_DEAD)
+    if (s->pcmcia_state.dead)
         return -EIO;
 
     ret = wait_event_interruptible(s->queue, !queue_empty(user));
@@ -550,7 +550,7 @@
 	return -EIO;
 
     s = user->socket;
-    if (s->state & DS_SOCKET_DEAD)
+    if (s->pcmcia_state.dead)
         return -EIO;
     
     size = (cmd & IOCSIZE_MASK) >> IOCSIZE_SHIFT;



More information about the linux-pcmcia mailing list