[PATCH 1/5] check for proper registration with device core

Dominik Brodowski linux at dominikbrodowski.de
Tue May 11 22:28:29 BST 2004


Fail if registration of socket with driver core failed. This is necessary
so that socket-related sysfs entries will appear always if a socket thread
is up and running.

 drivers/pcmcia/cs.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff -ruN linux-original/drivers/pcmcia/cs.c linux/drivers/pcmcia/cs.c
--- linux-original/drivers/pcmcia/cs.c	2004-05-11 19:12:38.859397496 +0200
+++ linux/drivers/pcmcia/cs.c	2004-05-11 19:17:18.659861360 +0200
@@ -264,7 +264,10 @@
 		goto err;
 
 	wait_for_completion(&socket->thread_done);
-	BUG_ON(!socket->thread);
+	if(!socket->thread) {
+		printk(KERN_WARNING "PCMCIA: warning: socket thread for socket %p did not start\n", socket);
+		return -EIO;
+	}
 	pcmcia_parse_events(socket, SS_DETECT);
 
 	return 0;
@@ -678,9 +681,8 @@
 	int ret;
 
 	daemonize("pccardd");
-	skt->thread = current;
-	complete(&skt->thread_done);
 
+	skt->thread = current;
 	skt->socket = dead_socket;
 	skt->ops->init(skt);
 	skt->ops->set_socket(skt, &skt->socket);
@@ -690,7 +692,10 @@
 	if (ret) {
 		printk(KERN_WARNING "PCMCIA: unable to register socket 0x%p\n",
 			skt);
+		skt->thread = NULL;
+		complete_and_exit(&skt->thread_done, 0);
 	}
+	complete(&skt->thread_done);
 
 	add_wait_queue(&skt->thread_wait, &wait);
 	for (;;) {



More information about the linux-pcmcia mailing list