[PATCH] pcmcia: don't hide calls to socket drivers

Dominik Brodowski linux at brodo.de
Sat Jul 5 11:44:24 BST 2003


Don't hide calls to the socket driver by "shorthand functions"

 drivers/pcmcia/cs.c |   89 ++++++++++++++++------------------------------------
 1 files changed, 28 insertions(+), 61 deletions(-)

diff -ruN linux-original/drivers/pcmcia/cs.c linux/drivers/pcmcia/cs.c
--- linux-original/drivers/pcmcia/cs.c	2003-07-05 10:35:43.000000000 +0200
+++ linux/drivers/pcmcia/cs.c	2003-07-05 10:42:51.000000000 +0200
@@ -225,43 +225,6 @@
 };
 #define SERVICE_COUNT (sizeof(service_table)/sizeof(lookup_t))
 
-/*======================================================================
-
- These functions are just shorthand for the actual low-level drivers
-
-======================================================================*/
-
-static int get_socket_status(struct pcmcia_socket *s, int *val)
-{
-	return s->ss_entry->get_status(s, val);
-}
-
-static int set_socket(struct pcmcia_socket *s, socket_state_t *state)
-{
-	return s->ss_entry->set_socket(s, state);
-}
-
-static int set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io)
-{
-	return s->ss_entry->set_io_map(s, io);
-}
-
-static int set_mem_map(struct pcmcia_socket *s, struct pccard_mem_map *mem)
-{
-	return s->ss_entry->set_mem_map(s, mem);
-}
-
-static int suspend_socket(struct pcmcia_socket *s)
-{
-	s->socket = dead_socket;
-	return s->ss_entry->suspend(s);
-}
-
-static int init_socket(struct pcmcia_socket *s)
-{
-	s->socket = dead_socket;
-	return s->ss_entry->init(s);
-}
 
 /*====================================================================
 
@@ -339,7 +302,8 @@
 	INIT_LIST_HEAD(&socket->cis_cache);
 	spin_lock_init(&socket->lock);
 
-	init_socket(socket);
+	socket->socket = dead_socket;
+	socket->ss_entry->init(socket);
 
 	init_completion(&socket->thread_done);
 	init_waitqueue_head(&socket->thread_wait);
@@ -516,7 +480,8 @@
 
     /* Blank out the socket state */
     s->state &= SOCKET_PRESENT|SOCKET_SETUP_PENDING;
-    init_socket(s);
+    s->socket = dead_socket;
+    s->ss_entry->init(s);
     s->irq.AssignedIRQ = s->irq.Config = 0;
     s->lock_count = 0;
     destroy_cis_cache(s);
@@ -531,7 +496,7 @@
     s->socket.Vpp = 0;
     s->socket.Vcc = 0;
     s->socket.io_irq = 0;
-    set_socket(s, &s->socket);
+    s->ss_entry->set_socket(s, &s->socket);
     /* */
 #ifdef CONFIG_CARDBUS
     cb_free(s);
@@ -625,16 +590,16 @@
 	int status, i;
 
 	skt->socket.flags |= SS_OUTPUT_ENA | SS_RESET;
-	set_socket(skt, &skt->socket);
+	skt->ss_entry->set_socket(skt, &skt->socket);
 	udelay((long)reset_time);
 
 	skt->socket.flags &= ~SS_RESET;
-	set_socket(skt, &skt->socket);
+	skt->ss_entry->set_socket(skt, &skt->socket);
 
 	set_current_state(TASK_UNINTERRUPTIBLE);
 	schedule_timeout(cs_to_timeout(unreset_delay));
 	for (i = 0; i < unreset_limit; i++) {
-		get_socket_status(skt, &status);
+		skt->ss_entry->get_status(skt, &status);
 
 		if (!(status & SS_DETECT))
 			return CS_NO_CARD;
@@ -654,7 +619,7 @@
 {
 	int status, i;
 
-	get_socket_status(skt, &status);
+	skt->ss_entry->get_status(skt, &status);
 	if (!(status & SS_DETECT))
 		return CS_NO_CARD;
 
@@ -662,7 +627,7 @@
 	schedule_timeout(cs_to_timeout(initial_delay));
 
 	for (i = 0; i < 100; i++) {
-		get_socket_status(skt, &status);
+		skt->ss_entry->get_status(skt, &status);
 		if (!(status & SS_DETECT))
 			return CS_NO_CARD;
 
@@ -699,7 +664,7 @@
 	}
 	skt->state |= SOCKET_PRESENT;
 	skt->socket.flags = SS_DEBOUNCED;
-	set_socket(skt, &skt->socket);
+	skt->ss_entry->set_socket(skt, &skt->socket);
 
 	/*
 	 * Wait "vcc_settle" for the supply to stabilise.
@@ -745,7 +710,8 @@
 		return CS_IN_USE;
 
 	send_event(skt, CS_EVENT_PM_SUSPEND, CS_EVENT_PRI_LOW);
-	suspend_socket(skt);
+	skt->socket = dead_socket;
+	skt->ss_entry->suspend(skt);
 	skt->state |= SOCKET_SUSPEND;
 
 	return CS_SUCCESS;
@@ -763,7 +729,8 @@
 	if (!(skt->state & SOCKET_SUSPEND))
 		return CS_IN_USE;
 
-	init_socket(skt);
+	skt->socket = dead_socket;
+	skt->ss_entry->init(skt);
 
 	ret = socket_setup(skt, resume_delay);
 	if (ret == CS_SUCCESS) {
@@ -817,7 +784,7 @@
 			schedule_timeout(cs_to_timeout(2));
 		}
 
-		get_socket_status(skt, &status);
+		skt->ss_entry->get_status(skt, &status);
 		if ((skt->state & SOCKET_PRESENT) &&
 		     !(status & SS_DETECT))
 			socket_remove(skt);
@@ -1371,7 +1338,7 @@
     if (CHECK_HANDLE(handle))
 	return CS_BAD_HANDLE;
     s = SOCKET(handle);
-    get_socket_status(s, &val);
+    s->ss_entry->get_status(s, &val);
     status->CardState = status->SocketState = 0;
     status->CardState |= (val & SS_DETECT) ? CS_EVENT_CARD_DETECT : 0;
     status->CardState |= (val & SS_CARDBUS) ? CS_EVENT_CB_DETECT : 0;
@@ -1450,7 +1417,7 @@
 	return CS_BAD_PAGE;
     s = win->sock;
     win->ctl.card_start = req->CardOffset;
-    if (set_mem_map(s, &win->ctl) != 0)
+    if (s->ss_entry->set_mem_map(s, &win->ctl) != 0)
 	return CS_BAD_OFFSET;
     return CS_SUCCESS;
 } /* map_mem_page */
@@ -1483,7 +1450,7 @@
 	    c->Attributes &= ~CONF_ENABLE_IRQ;
 	    s->socket.io_irq = 0;
 	}
-	set_socket(s, &s->socket);
+	s->ss_entry->set_socket(s, &s->socket);
     }
 
     if (mod->Attributes & CONF_VCC_CHANGE_VALID)
@@ -1495,7 +1462,7 @@
 	if (mod->Vpp1 != mod->Vpp2)
 	    return CS_BAD_VPP;
 	c->Vpp1 = c->Vpp2 = s->socket.Vpp = mod->Vpp1;
-	if (set_socket(s, &s->socket))
+	if (s->ss_entry->set_socket(s, &s->socket))
 	    return CS_BAD_VPP;
     } else if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) ||
 	       (mod->Attributes & CONF_VPP2_CHANGE_VALID))
@@ -1525,7 +1492,7 @@
     if (req->Attributes & WIN_USE_WAIT)
 	win->ctl.flags |= MAP_USE_WAIT;
     win->ctl.speed = req->AccessSpeed;
-    set_mem_map(win->sock, &win->ctl);
+    win->sock->ss_entry->set_mem_map(win->sock, &win->ctl);
     
     return CS_SUCCESS;
 } /* modify_window */
@@ -1625,7 +1592,7 @@
 	    s->socket.flags = SS_OUTPUT_ENA;   /* Is this correct? */
 	    s->socket.Vpp = 0;
 	    s->socket.io_irq = 0;
-	    set_socket(s, &s->socket);
+	    s->ss_entry->set_socket(s, &s->socket);
 	}
 	if (c->state & CONFIG_IO_REQ)
 	    for (i = 0; i < MAX_IO_WIN; i++) {
@@ -1635,7 +1602,7 @@
 		if (s->io[i].Config != 0)
 		    continue;
 		io.map = i;
-		set_io_map(s, &io);
+		s->ss_entry->set_io_map(s, &io);
 	    }
 	c->state &= ~CONFIG_LOCKED;
     }
@@ -1736,7 +1703,7 @@
 
     /* Shut down memory window */
     win->ctl.flags &= ~MAP_ACTIVE;
-    set_mem_map(s, &win->ctl);
+    s->ss_entry->set_mem_map(s, &win->ctl);
     s->state &= ~SOCKET_WIN_REQ(win->index);
 
     /* Release system memory */
@@ -1783,7 +1750,7 @@
     if (req->Vpp1 != req->Vpp2)
 	return CS_BAD_VPP;
     s->socket.Vpp = req->Vpp1;
-    if (set_socket(s, &s->socket))
+    if (s->ss_entry->set_socket(s, &s->socket))
 	return CS_BAD_VPP;
     
     c->Vcc = req->Vcc; c->Vpp1 = c->Vpp2 = req->Vpp1;
@@ -1801,7 +1768,7 @@
 	s->socket.io_irq = s->irq.AssignedIRQ;
     else
 	s->socket.io_irq = 0;
-    set_socket(s, &s->socket);
+    s->ss_entry->set_socket(s, &s->socket);
     s->lock_count++;
     
     /* Set up CIS configuration registers */
@@ -1866,7 +1833,7 @@
 		}
 		iomap.start = s->io[i].BasePort;
 		iomap.stop = iomap.start + s->io[i].NumPorts - 1;
-		set_io_map(s, &iomap);
+		s->ss_entry->set_io_map(s, &iomap);
 		s->io[i].Config++;
 	    }
     }
@@ -2087,7 +2054,7 @@
     win->ctl.sys_start = win->base;
     win->ctl.sys_stop = win->base + win->size-1;
     win->ctl.card_start = 0;
-    if (set_mem_map(s, &win->ctl) != 0)
+    if (s->ss_entry->set_mem_map(s, &win->ctl) != 0)
 	return CS_BAD_ARGS;
     s->state |= SOCKET_WIN_REQ(w);
 



More information about the linux-pcmcia mailing list