
From: Dominik Brodowski <linux@dominikbrodowski.de>

This patch updates pcmcia wireless drivers so that their class devices are
linked to the correct physical device.  Based on an patch by Adam Belay, but
adapted to a different pcmcia driver model implementation.

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

 25-akpm/drivers/net/wireless/airo.c       |   20 ++++++++++----------
 25-akpm/drivers/net/wireless/airo_cs.c    |    4 ++--
 25-akpm/drivers/net/wireless/atmel_cs.c   |   14 +-------------
 25-akpm/drivers/net/wireless/netwave_cs.c |    2 ++
 25-akpm/drivers/net/wireless/orinoco_cs.c |    1 +
 25-akpm/drivers/net/wireless/ray_cs.c     |    1 +
 25-akpm/drivers/net/wireless/wavelan_cs.c |    1 +
 25-akpm/drivers/net/wireless/wl3501_cs.c  |    1 +
 8 files changed, 19 insertions(+), 25 deletions(-)

diff -puN drivers/net/wireless/airo.c~pcmcia-set_netdev-for-wireless-network-devices drivers/net/wireless/airo.c
--- 25/drivers/net/wireless/airo.c~pcmcia-set_netdev-for-wireless-network-devices	2004-12-03 18:44:48.114468688 -0800
+++ 25-akpm/drivers/net/wireless/airo.c	2004-12-03 18:44:48.135465496 -0800
@@ -2694,7 +2694,8 @@ int reset_card( struct net_device *dev ,
 }
 
 struct net_device *_init_airo_card( unsigned short irq, int port,
-				    int is_pcmcia, struct pci_dev *pci )
+				    int is_pcmcia, struct pci_dev *pci,
+				    struct device *dmdev )
 {
 	struct net_device *dev;
 	struct airo_info *ai;
@@ -2756,10 +2757,8 @@ struct net_device *_init_airo_card( unsi
 	dev->irq = irq;
 	dev->base_addr = port;
 
-	/* what is with PCMCIA ??? */
-	if (pci) {
-		SET_NETDEV_DEV(dev, &pci->dev);
-	}
+	SET_NETDEV_DEV(dev, dmdev);
+
 
 	if (test_bit(FLAG_MPI,&ai->flags))
 		reset_card (dev, 1);
@@ -2841,9 +2840,10 @@ err_out_free:
 	return NULL;
 }
 
-struct net_device *init_airo_card( unsigned short irq, int port, int is_pcmcia )
+struct net_device *init_airo_card( unsigned short irq, int port, int is_pcmcia,
+				  struct device *dmdev)
 {
-	return _init_airo_card ( irq, port, is_pcmcia, NULL);
+	return _init_airo_card ( irq, port, is_pcmcia, NULL, dmdev);
 }
 
 EXPORT_SYMBOL(init_airo_card);
@@ -5452,9 +5452,9 @@ static int __devinit airo_pci_probe(stru
 	pci_set_master(pdev);
 
 	if (pdev->device == 0x5000 || pdev->device == 0xa504)
-			dev = _init_airo_card(pdev->irq, pdev->resource[0].start, 0, pdev);
+			dev = _init_airo_card(pdev->irq, pdev->resource[0].start, 0, pdev, &pdev->dev);
 	else
-			dev = _init_airo_card(pdev->irq, pdev->resource[2].start, 0, pdev);
+			dev = _init_airo_card(pdev->irq, pdev->resource[2].start, 0, pdev, &pdev->dev);
 	if (!dev)
 		return -ENODEV;
 
@@ -5556,7 +5556,7 @@ static int __init airo_init_module( void
 		printk( KERN_INFO
 			"airo:  Trying to configure ISA adapter at irq=%d io=0x%x\n",
 			irq[i], io[i] );
-		if (init_airo_card( irq[i], io[i], 0 ))
+		if (init_airo_card( irq[i], io[i], 0, NULL ))
 			have_isa_dev = 1;
 	}
 
diff -puN drivers/net/wireless/airo_cs.c~pcmcia-set_netdev-for-wireless-network-devices drivers/net/wireless/airo_cs.c
--- 25/drivers/net/wireless/airo_cs.c~pcmcia-set_netdev-for-wireless-network-devices	2004-12-03 18:44:48.116468384 -0800
+++ 25-akpm/drivers/net/wireless/airo_cs.c	2004-12-03 18:44:48.136465344 -0800
@@ -89,7 +89,7 @@ MODULE_PARM(irq_list, "1-4i");
    event handler. 
 */
 
-struct net_device *init_airo_card( int, int, int );
+struct net_device *init_airo_card( int, int, int, struct device * );
 void stop_airo_card( struct net_device *, int );
 int reset_airo_card( struct net_device * );
 
@@ -450,7 +450,7 @@ static void airo_config(dev_link_t *link
 	CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf));
 	((local_info_t*)link->priv)->eth_dev = 
 		init_airo_card( link->irq.AssignedIRQ,
-				link->io.BasePort1, 1 );
+				link->io.BasePort1, 1, &handle_to_dev(handle) );
 	if (!((local_info_t*)link->priv)->eth_dev) goto cs_failed;
 	
 	/*
diff -puN drivers/net/wireless/atmel_cs.c~pcmcia-set_netdev-for-wireless-network-devices drivers/net/wireless/atmel_cs.c
--- 25/drivers/net/wireless/atmel_cs.c~pcmcia-set_netdev-for-wireless-network-devices	2004-12-03 18:44:48.117468232 -0800
+++ 25-akpm/drivers/net/wireless/atmel_cs.c	2004-12-03 18:44:48.363430840 -0800
@@ -347,18 +347,6 @@ static struct { 
 	{ 0, 0, "11WAVE/11WP611AL-E", "atmel_at76c502e%s.bin", "11WAVE WaveBuddy" } 
 };
 
-/* This is strictly temporary, until PCMCIA devices get integrated into the device model. */
-static struct device *atmel_device(void)
-{
-	static struct device dev = {
-		.bus_id    = "pcmcia",
-	};
-	kobject_set_name(&dev.kobj, "atmel_cs");
-	kobject_init(&dev.kobj);
-	
-	return &dev;
-}
-
 static void atmel_config(dev_link_t *link)
 {
 	client_handle_t handle;
@@ -549,7 +537,7 @@ static void atmel_config(dev_link_t *lin
 		init_atmel_card(link->irq.AssignedIRQ,
 				link->io.BasePort1,
 				card_index == -1 ? NULL :  card_table[card_index].firmware,
-				atmel_device(),
+				&handle_to_dev(handle),
 				card_present, 
 				link);
 	if (!((local_info_t*)link->priv)->eth_dev) 
diff -puN drivers/net/wireless/netwave_cs.c~pcmcia-set_netdev-for-wireless-network-devices drivers/net/wireless/netwave_cs.c
--- 25/drivers/net/wireless/netwave_cs.c~pcmcia-set_netdev-for-wireless-network-devices	2004-12-03 18:44:48.119467928 -0800
+++ 25-akpm/drivers/net/wireless/netwave_cs.c	2004-12-03 18:44:48.364430688 -0800
@@ -1073,6 +1073,8 @@ static void netwave_pcmcia_config(dev_li
 
     dev->irq = link->irq.AssignedIRQ;
     dev->base_addr = link->io.BasePort1;
+    SET_NETDEV_DEV(dev, &handle_to_dev(handle));
+
     if (register_netdev(dev) != 0) {
 	printk(KERN_DEBUG "netwave_cs: register_netdev() failed\n");
 	goto failed;
diff -puN drivers/net/wireless/orinoco_cs.c~pcmcia-set_netdev-for-wireless-network-devices drivers/net/wireless/orinoco_cs.c
--- 25/drivers/net/wireless/orinoco_cs.c~pcmcia-set_netdev-for-wireless-network-devices	2004-12-03 18:44:48.121467624 -0800
+++ 25-akpm/drivers/net/wireless/orinoco_cs.c	2004-12-03 18:44:48.365430536 -0800
@@ -458,6 +458,7 @@ orinoco_cs_config(dev_link_t *link)
 
 	/* register_netdev will give us an ethX name */
 	dev->name[0] = '\0';
+	SET_NETDEV_DEV(dev, &handle_to_dev(handle));
 	/* Tell the stack we exist */
 	if (register_netdev(dev) != 0) {
 		printk(KERN_ERR PFX "register_netdev() failed\n");
diff -puN drivers/net/wireless/ray_cs.c~pcmcia-set_netdev-for-wireless-network-devices drivers/net/wireless/ray_cs.c
--- 25/drivers/net/wireless/ray_cs.c~pcmcia-set_netdev-for-wireless-network-devices	2004-12-03 18:44:48.123467320 -0800
+++ 25-akpm/drivers/net/wireless/ray_cs.c	2004-12-03 18:44:48.368430080 -0800
@@ -564,6 +564,7 @@ static void ray_config(dev_link_t *link)
         return;
     }
 
+    SET_NETDEV_DEV(dev, &handle_to_dev(handle));
     i = register_netdev(dev);
     if (i != 0) {
         printk("ray_config register_netdev() failed\n");
diff -puN drivers/net/wireless/wavelan_cs.c~pcmcia-set_netdev-for-wireless-network-devices drivers/net/wireless/wavelan_cs.c
--- 25/drivers/net/wireless/wavelan_cs.c~pcmcia-set_netdev-for-wireless-network-devices	2004-12-03 18:44:48.125467016 -0800
+++ 25-akpm/drivers/net/wireless/wavelan_cs.c	2004-12-03 18:44:48.373429320 -0800
@@ -4068,6 +4068,7 @@ wv_pcmcia_config(dev_link_t *	link)
 	     lp->mem, dev->irq, (u_int) dev->base_addr);
 #endif
 
+      SET_NETDEV_DEV(dev, &handle_to_dev(handle));
       i = register_netdev(dev);
       if(i != 0)
 	{
diff -puN drivers/net/wireless/wl3501_cs.c~pcmcia-set_netdev-for-wireless-network-devices drivers/net/wireless/wl3501_cs.c
--- 25/drivers/net/wireless/wl3501_cs.c~pcmcia-set_netdev-for-wireless-network-devices	2004-12-03 18:44:48.126466864 -0800
+++ 25-akpm/drivers/net/wireless/wl3501_cs.c	2004-12-03 18:44:48.375429016 -0800
@@ -2105,6 +2105,7 @@ static void wl3501_config(dev_link_t *li
 
 	dev->irq = link->irq.AssignedIRQ;
 	dev->base_addr = link->io.BasePort1;
+	SET_NETDEV_DEV(dev, &handle_to_dev(handle));
 	if (register_netdev(dev)) {
 		printk(KERN_NOTICE "wl3501_cs: register_netdev() failed\n");
 		goto failed;
_
