[RFC][5/5] pcmcia_{eject,insert,suspend,resume}_card abstraction

Dominik Brodowski linux at brodo.de
Sat Nov 22 11:36:01 GMT 2003


The pcmcia_{suspend,resume,eject,insert}_card calls are only issued
by the userspace cardctl tool via ds.c. There's no need to verify the
caller (ds) has a valid "handle", as long as it knows the proper
struct pcmcia_socket.

 drivers/pcmcia/cs.c |   32 ++++----------------------------
 drivers/pcmcia/ds.c |   20 ++++++++------------
 include/pcmcia/cs.h |    8 ++++----
 3 files changed, 16 insertions(+), 44 deletions(-)

diff -ruN linux-original/drivers/pcmcia/cs.c linux/drivers/pcmcia/cs.c
--- linux-original/drivers/pcmcia/cs.c	2003-11-22 10:23:01.813152400 +0100
+++ linux/drivers/pcmcia/cs.c	2003-11-22 10:26:59.164069576 +0100
@@ -1955,16 +1955,10 @@
     
 ======================================================================*/
 
-int pcmcia_suspend_card(client_handle_t handle, client_req_t *req)
+int pcmcia_suspend_card(struct pcmcia_socket *skt)
 {
-	struct pcmcia_socket *skt;
 	int ret;
     
-	if (CHECK_HANDLE(handle))
-		return CS_BAD_HANDLE;
-	DEBUG(1, "cs: suspending socket %p\n", handle->Socket);
-	skt = SOCKET(handle);
-
 	down(&skt->skt_sem);
 	do {
 		if (!(skt->state & SOCKET_PRESENT)) {
@@ -1982,16 +1976,10 @@
 	return ret;
 } /* suspend_card */
 
-int pcmcia_resume_card(client_handle_t handle, client_req_t *req)
+int pcmcia_resume_card(struct pcmcia_socket *skt)
 {
-	struct pcmcia_socket *skt;
 	int ret;
     
-	if (CHECK_HANDLE(handle))
-		return CS_BAD_HANDLE;
-	DEBUG(1, "cs: waking up socket %p\n", handle->Socket);
-	skt = SOCKET(handle);
-
 	down(&skt->skt_sem);
 	do {
 		if (!(skt->state & SOCKET_PRESENT)) {
@@ -2015,16 +2003,10 @@
     
 ======================================================================*/
 
-int pcmcia_eject_card(client_handle_t handle, client_req_t *req)
+int pcmcia_eject_card(struct pcmcia_socket *skt)
 {
-	struct pcmcia_socket *skt;
 	int ret;
     
-	if (CHECK_HANDLE(handle))
-		return CS_BAD_HANDLE;
-	DEBUG(1, "cs: user eject request on socket %p\n", handle->Socket);
-	skt = SOCKET(handle);
-
 	down(&skt->skt_sem);
 	do {
 		if (!(skt->state & SOCKET_PRESENT)) {
@@ -2044,16 +2026,10 @@
 	return ret;
 } /* eject_card */
 
-int pcmcia_insert_card(client_handle_t handle, client_req_t *req)
+int pcmcia_insert_card(struct pcmcia_socket *skt)
 {
-	struct pcmcia_socket *skt;
 	int ret;
 
-	if (CHECK_HANDLE(handle))
-		return CS_BAD_HANDLE;
-	DEBUG(1, "cs: user insert request on socket %p\n", handle->Socket);
-	skt = SOCKET(handle);
-
 	down(&skt->skt_sem);
 	do {
 		if (skt->state & SOCKET_PRESENT) {
diff -ruN linux-original/drivers/pcmcia/ds.c linux/drivers/pcmcia/ds.c
--- linux-original/drivers/pcmcia/ds.c	2003-11-22 10:23:01.815152096 +0100
+++ linux/drivers/pcmcia/ds.c	2003-11-22 10:26:59.164069576 +0100
@@ -455,14 +455,6 @@
 		return pcmcia_write_memory(a1, a2, a3); break;
 	case ReportError:
 		return pcmcia_report_error(a1, a2); break;
-	case SuspendCard:
-		return pcmcia_suspend_card(a1, a2); break;
-	case ResumeCard:
-		return pcmcia_resume_card(a1, a2); break;
-	case EjectCard:
-		return pcmcia_eject_card(a1, a2); break;
-	case InsertCard:
-		return pcmcia_insert_card(a1, a2); break;
 	case ReplaceCIS:
 		return pcmcia_replace_cis(a1, a2); break;
 	case GetFirstWindow:
@@ -473,6 +465,10 @@
 		return pcmcia_get_mem_page(a1, a2); break;
 	case BindDevice:
 	case BindMTD:
+	case SuspendCard:
+	case ResumeCard:
+	case EjectCard:
+	case InsertCard:
 		return -ENOSYS; break;
 	default:
 		return CS_UNSUPPORTED_FUNCTION; break;
@@ -1078,16 +1074,16 @@
 	ret = pcmcia_validate_cis(s->handle, &buf.cisinfo);
 	break;
     case DS_SUSPEND_CARD:
-	ret = pcmcia_suspend_card(s->handle, NULL);
+	ret = pcmcia_suspend_card(s->parent);
 	break;
     case DS_RESUME_CARD:
-	ret = pcmcia_resume_card(s->handle, NULL);
+	ret = pcmcia_resume_card(s->parent);
 	break;
     case DS_EJECT_CARD:
-	ret = pcmcia_eject_card(s->handle, NULL);
+	ret = pcmcia_eject_card(s->parent);
 	break;
     case DS_INSERT_CARD:
-	ret = pcmcia_insert_card(s->handle, NULL);
+	ret = pcmcia_insert_card(s->parent);
 	break;
     case DS_ACCESS_CONFIGURATION_REGISTER:
 	if ((buf.conf_reg.Action == CS_WRITE) && !capable(CAP_SYS_ADMIN))
diff -ruN linux-original/include/pcmcia/cs.h linux/include/pcmcia/cs.h
--- linux-original/include/pcmcia/cs.h	2003-11-22 10:23:01.815152096 +0100
+++ linux/include/pcmcia/cs.h	2003-11-22 10:26:59.166069272 +0100
@@ -451,10 +451,10 @@
 int pcmcia_request_irq(client_handle_t handle, irq_req_t *req);
 int pcmcia_request_window(client_handle_t *handle, win_req_t *req, window_handle_t *wh);
 int pcmcia_reset_card(client_handle_t handle, client_req_t *req);
-int pcmcia_suspend_card(client_handle_t handle, client_req_t *req);
-int pcmcia_resume_card(client_handle_t handle, client_req_t *req);
-int pcmcia_eject_card(client_handle_t handle, client_req_t *req);
-int pcmcia_insert_card(client_handle_t handle, client_req_t *req);
+int pcmcia_suspend_card(struct pcmcia_socket *skt);
+int pcmcia_resume_card(struct pcmcia_socket *skt);
+int pcmcia_eject_card(struct pcmcia_socket *skt);
+int pcmcia_insert_card(struct pcmcia_socket *skt);
 int pcmcia_set_event_mask(client_handle_t handle, eventmask_t *mask);
 struct pci_bus *pcmcia_lookup_bus(client_handle_t handle);
 



More information about the linux-pcmcia mailing list