[PATCH] pcmcia: remove socket_no from client_handle_t

Dominik Brodowski linux at brodo.de
Sun May 18 10:44:15 BST 2003


As "socket_no" is deprecated, replace it with struct pcmcia_socket in 
client_handle_t.

 bulkmem.c     |    2 +-
 cs.c          |   22 ++++++++++------------
 cs_internal.h |    5 ++---
 ds.c          |   22 +++++++++++-----------
 4 files changed, 24 insertions(+), 27 deletions(-)

diff -ruN linux-original/drivers/pcmcia/bulkmem.c linux/drivers/pcmcia/bulkmem.c
--- linux-original/drivers/pcmcia/bulkmem.c	2003-05-17 23:13:38.000000000 +0200
+++ linux/drivers/pcmcia/bulkmem.c	2003-05-18 09:39:26.000000000 +0200
@@ -538,7 +538,7 @@
     
     if ((handle == NULL) || CHECK_HANDLE(*handle))
 	return CS_BAD_HANDLE;
-    s = get_s_info_by_nr((*handle)->Socket);
+    s = (socket_info_t *) (*handle)->Socket->s_info;
     if (open->Attributes & MEMORY_TYPE_AM)
 	region = s->a_region;
     else
diff -ruN linux-original/drivers/pcmcia/cs.c linux/drivers/pcmcia/cs.c
--- linux-original/drivers/pcmcia/cs.c	2003-05-17 23:13:38.000000000 +0200
+++ linux/drivers/pcmcia/cs.c	2003-05-18 09:39:26.000000000 +0200
@@ -306,7 +306,7 @@
 
 #define to_class_data(dev) dev->class_data
 
-socket_info_t * get_s_info_by_nr(unsigned int s_nr)
+static socket_info_t * get_s_info_by_nr(unsigned int s_nr)
 {
 	struct pcmcia_socket *tmp;
 	down(&pcmcia_socket_list_lock);
@@ -1053,7 +1053,7 @@
     client_t *client;
     socket_info_t *s;
 
-    s = SOCKET(req);
+    s = get_s_info_by_nr(req->Socket);
     if (!s)
 	    return CS_BAD_SOCKET;
 
@@ -1062,7 +1062,7 @@
     memset(client, '\0', sizeof(client_t));
     client->client_magic = CLIENT_MAGIC;
     strncpy(client->dev_info, (char *)req->dev_info, DEV_NAME_LEN);
-    client->Socket = req->Socket;
+    client->Socket = s->sock;
     client->Function = req->Function;
     client->state = CLIENT_UNBOUND;
     client->erase_busy.next = &client->erase_busy;
@@ -1089,7 +1089,7 @@
     socket_info_t *s;
     memory_handle_t region;
     
-    s = SOCKET(req);
+    s = get_s_info_by_nr(req->Socket);
     if (!s)
 	return CS_BAD_SOCKET;
     
@@ -1119,7 +1119,7 @@
     socket_info_t *s;
     memory_handle_t region;
     u_long flags;
-    int i, sn;
+    int i;
     
     DEBUG(1, "cs: deregister_client(%p)\n", handle);
     if (CHECK_HANDLE(handle))
@@ -1140,8 +1140,6 @@
 	    if (region->mtd == handle) region->mtd = NULL;
     }
     
-    sn = handle->Socket; s = get_s_info_by_nr(sn);
-
     if ((handle->state & CLIENT_STALE) ||
 	(handle->Attributes & INFO_MASTER_CLIENT)) {
 	spin_lock_irqsave(&s->lock, flags);
@@ -1292,7 +1290,7 @@
     if ((*handle)->next == NULL) {
 	if (req->Attributes & CLIENT_THIS_SOCKET)
 	    return CS_NO_MORE_ITEMS;
-	s = get_s_info_by_nr((*handle)->Socket);
+	s = ((socket_info_t *) (*handle)->Socket->s_info);
 	if (s->clients == NULL)
 	    return CS_NO_MORE_ITEMS;
 	*handle = s->clients;
@@ -1310,7 +1308,7 @@
     int w;
 
     if (idx == 0)
-	s = get_s_info_by_nr(((client_handle_t)*handle)->Socket);
+	s = (socket_info_t *) (((client_handle_t)* handle)->Socket->s_info);
     else
 	s = (*handle)->sock;
     if (!(s->state & SOCKET_PRESENT))
@@ -1588,7 +1586,7 @@
 
     *handle = client;
     client->state &= ~CLIENT_UNBOUND;
-    client->Socket = socket->socket_no;
+    client->Socket = socket;
     client->Attributes = req->Attributes;
     client->EventMask = req->EventMask;
     client->event_handler = req->event_handler;
@@ -1789,7 +1787,7 @@
     
     if (CHECK_HANDLE(handle))
 	return CS_BAD_HANDLE;
-    i = handle->Socket; s = get_s_info_by_nr(i);
+    s = SOCKET(handle);
     if (!(s->state & SOCKET_PRESENT))
 	return CS_NO_CARD;
     
@@ -2058,7 +2056,7 @@
     
     if (CHECK_HANDLE(*handle))
 	return CS_BAD_HANDLE;
-    s = get_s_info_by_nr((*handle)->Socket);
+    s = (socket_info_t *) ((*handle)->Socket->s_info);
     if (!(s->state & SOCKET_PRESENT))
 	return CS_NO_CARD;
     if (req->Attributes & (WIN_PAGED | WIN_SHARED))
diff -ruN linux-original/drivers/pcmcia/cs_internal.h linux/drivers/pcmcia/cs_internal.h
--- linux-original/drivers/pcmcia/cs_internal.h	2003-05-17 23:13:38.000000000 +0200
+++ linux/drivers/pcmcia/cs_internal.h	2003-05-18 09:39:26.000000000 +0200
@@ -39,7 +39,7 @@
 #define CLIENT_MAGIC 	0x51E6
 typedef struct client_t {
     u_short		client_magic;
-    socket_t		Socket;
+	struct pcmcia_socket 	*Socket;
     u_char		Function;
     dev_info_t		dev_info;
     u_int		Attributes;
@@ -183,8 +183,7 @@
 #define CHECK_HANDLE(h) \
     (((h) == NULL) || ((h)->client_magic != CLIENT_MAGIC))
 
-socket_info_t * get_s_info_by_nr(unsigned int socket);
-#define SOCKET(h) (get_s_info_by_nr(h->Socket))
+#define SOCKET(h) ((socket_info_t *) h->Socket->s_info)
 #define CONFIG(h) (&SOCKET(h)->config[(h)->Function])
 
 #define CHECK_REGION(r) \
diff -ruN linux-original/drivers/pcmcia/ds.c linux/drivers/pcmcia/ds.c
--- linux-original/drivers/pcmcia/ds.c	2003-05-17 22:03:15.000000000 +0200
+++ linux/drivers/pcmcia/ds.c	2003-05-18 09:39:38.000000000 +0200
@@ -108,7 +108,7 @@
 	socket_bind_t		*bind;
 	struct device		*socket_dev;
 	struct list_head	socket_list;
-	unsigned int		socket_no; /* deprecated */
+	struct pcmcia_socket	*socket;
 };
 
 #define SOCKET_PRESENT		0x01
@@ -363,14 +363,14 @@
 
     bind_req.dev_info = &mtd_info->dev_info;
     bind_req.Attributes = mtd_info->Attributes;
-    bind_req.Socket = bus_sock->socket_no;
+    bind_req.Socket = bus_sock->socket->socket_no;
     bind_req.CardOffset = mtd_info->CardOffset;
     ret = pcmcia_bind_mtd(&bind_req);
     if (ret != CS_SUCCESS) {
 	cs_error(NULL, BindMTD, ret);
-	printk(KERN_NOTICE "ds: unable to bind MTD '%s' to socket %d"
+	printk(KERN_NOTICE "ds: unable to bind MTD '%s' to socket %p"
 	       " offset 0x%x\n",
-	       (char *)bind_req.dev_info, bus_sock->socket_no, bind_req.CardOffset);
+	       (char *)bind_req.dev_info, bus_sock, bind_req.CardOffset);
 	return -ENODEV;
     }
     return 0;
@@ -410,14 +410,14 @@
 	return -EBUSY;
     }
 
-    bind_req.Socket = s->socket_no;
+    bind_req.Socket = s->socket->socket_no;
     bind_req.Function = bind_info->function;
     bind_req.dev_info = (dev_info_t *) driver->drv.name;
     ret = pcmcia_bind_device(&bind_req);
     if (ret != CS_SUCCESS) {
 	cs_error(NULL, BindDevice, ret);
-	printk(KERN_NOTICE "ds: unable to bind '%s' to socket %d\n",
-	       (char *)dev_info, s->socket_no);
+	printk(KERN_NOTICE "ds: unable to bind '%s' to socket %p\n",
+	       (char *)dev_info, s);
 	return -ENODEV;
     }
 
@@ -912,7 +912,7 @@
 	init_waitqueue_head(&s->queue);
 	init_waitqueue_head(&s->request);
 
-	s->socket_no = socket->socket_no;
+	s->socket = socket;
 
 	/* initialize data */
 	s->socket_dev = dev;
@@ -921,7 +921,7 @@
 	/* Set up hotline to Card Services */
 	client_reg.dev_info = bind.dev_info = &dev_info;
 
-	bind.Socket = s->socket_no;
+	bind.Socket = socket->socket_no;
 	bind.Function = BIND_FN_ALL;
 	ret = pcmcia_bind_device(&bind);
 	if (ret != CS_SUCCESS) {
@@ -965,7 +965,7 @@
 	down_write(&bus_socket_list_rwsem);
 	list_for_each_safe(list_loop, tmp_storage, &bus_socket_list) {
 		struct pcmcia_bus_socket *bus_sock = container_of(list_loop, struct pcmcia_bus_socket, socket_list);
-		if (bus_sock->socket_no == socket->socket_no) {
+		if (bus_sock->socket == socket) {
 			pcmcia_deregister_client(bus_sock->handle);
 			list_del(&bus_sock->socket_list);
 			kfree(bus_sock);
@@ -1041,7 +1041,7 @@
 	struct pcmcia_bus_socket * s;
 	down_read(&bus_socket_list_rwsem);
 	list_for_each_entry(s, &bus_socket_list, socket_list)
-		if (s->socket_no == nr) {
+		if (s->socket->socket_no == nr) {
 			up_read(&bus_socket_list_rwsem);
 			return s;
 		}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.infradead.org/pipermail/linux-pcmcia/attachments/20030518/b340684f/attachment.bin


More information about the linux-pcmcia mailing list