
From: Dominik Brodowski <linux@dominikbrodowski.de>

Obtain a reference to struct pcmcia_bus_socket for each pcmcia_device. This
means that pcmcia_device always holds an indirect reference to struct 
pcmcia_socket as well.

Signed-off-by: Dominik Brodowski <linux@brodo.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/drivers/pcmcia/ds.c |    9 +++++++++
 1 files changed, 9 insertions(+)

diff -puN drivers/pcmcia/ds.c~pcmcia-get-a-reference-to-ds-socket-for-each-pcmcia_device drivers/pcmcia/ds.c
--- 25/drivers/pcmcia/ds.c~pcmcia-get-a-reference-to-ds-socket-for-each-pcmcia_device	2004-12-03 18:44:36.108293904 -0800
+++ 25-akpm/drivers/pcmcia/ds.c	2004-12-03 18:44:36.112293296 -0800
@@ -475,6 +475,7 @@ static void pcmcia_put_dev(struct pcmcia
 static void pcmcia_release_dev(struct device *dev)
 {
 	struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
+	pcmcia_put_bus_socket(p_dev->socket->pcmcia);
 	kfree(p_dev);
 }
 
@@ -689,6 +690,13 @@ static int bind_request(struct pcmcia_bu
 	}
 	memset(p_dev, 0, sizeof(struct pcmcia_device));
 
+	s = pcmcia_get_bus_socket(s);
+ 	if (!s) {
+		ret = -ENODEV;
+		kfree(p_dev);
+		goto err_free_client;
+	}
+
 	p_dev->socket = s->parent;
 	p_dev->func   = bind_info->function;
 
@@ -701,6 +709,7 @@ static int bind_request(struct pcmcia_bu
 	ret = device_register(&p_dev->dev);
 	if (ret) {
 		kfree(p_dev);
+		pcmcia_put_bus_socket(s);
 		goto err_free_client;
 	}
 
_
