[PCMCIA][2/3] driver model integration for PCMCIA wireless drivers

Dominik Brodowski linux at dominikbrodowski.de
Fri Oct 22 15:53:00 EDT 2004


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 at dominikbrodowski.de>

diff -ruN linux-original/drivers/net/wireless/airo.c linux/drivers/net/wireless/airo.c
--- linux-original/drivers/net/wireless/airo.c	2004-10-22 11:58:10.000000000 +0200
+++ linux/drivers/net/wireless/airo.c	2004-10-22 21:18:48.921427360 +0200
@@ -2697,7 +2697,8 @@
 }
 
 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;
@@ -2759,10 +2760,8 @@
 	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);
@@ -2844,9 +2843,10 @@
 	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);
@@ -5455,9 +5455,9 @@
 	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;
 
@@ -5559,7 +5559,7 @@
 		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 -ruN linux-original/drivers/net/wireless/airo_cs.c linux/drivers/net/wireless/airo_cs.c
--- linux-original/drivers/net/wireless/airo_cs.c	2004-10-22 16:35:42.000000000 +0200
+++ linux/drivers/net/wireless/airo_cs.c	2004-10-22 21:18:48.945423712 +0200
@@ -89,7 +89,7 @@
    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 @@
 	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 -ruN linux-original/drivers/net/wireless/atmel_cs.c linux/drivers/net/wireless/atmel_cs.c
--- linux-original/drivers/net/wireless/atmel_cs.c	2004-10-22 16:35:42.000000000 +0200
+++ linux/drivers/net/wireless/atmel_cs.c	2004-10-22 21:18:48.947423408 +0200
@@ -347,21 +347,6 @@
 	{ 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 char *kobj_name = "atmel_cs";
-
-	static struct device dev = {
-		.bus_id    = "pcmcia",
-	};
-	dev.kobj.k_name = kmalloc(strlen(kobj_name)+1, GFP_KERNEL);
-	strcpy(dev.kobj.k_name, kobj_name);
-	kobject_init(&dev.kobj);
-	
-	return &dev;
-}
-
 static void atmel_config(dev_link_t *link)
 {
 	client_handle_t handle;
@@ -552,7 +537,7 @@
 		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 -ruN linux-original/drivers/net/wireless/netwave_cs.c linux/drivers/net/wireless/netwave_cs.c
--- linux-original/drivers/net/wireless/netwave_cs.c	2004-10-22 16:35:42.000000000 +0200
+++ linux/drivers/net/wireless/netwave_cs.c	2004-10-22 21:18:48.949423104 +0200
@@ -1075,6 +1075,8 @@
 
     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 -ruN linux-original/drivers/net/wireless/orinoco_cs.c linux/drivers/net/wireless/orinoco_cs.c
--- linux-original/drivers/net/wireless/orinoco_cs.c	2004-10-22 16:35:42.000000000 +0200
+++ linux/drivers/net/wireless/orinoco_cs.c	2004-10-22 21:18:48.975419152 +0200
@@ -454,6 +454,7 @@
 
 	/* 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 -ruN linux-original/drivers/net/wireless/ray_cs.c linux/drivers/net/wireless/ray_cs.c
--- linux-original/drivers/net/wireless/ray_cs.c	2004-10-22 16:35:42.000000000 +0200
+++ linux/drivers/net/wireless/ray_cs.c	2004-10-22 21:18:49.015413072 +0200
@@ -568,6 +568,7 @@
         return;
     }
 
+    SET_NETDEV_DEV(dev, &handle_to_dev(handle));
     i = register_netdev(dev);
     if (i != 0) {
         printk("ray_config register_netdev() failed\n");
diff -ruN linux-original/drivers/net/wireless/wavelan_cs.c linux/drivers/net/wireless/wavelan_cs.c
--- linux-original/drivers/net/wireless/wavelan_cs.c	2004-10-22 11:58:10.000000000 +0200
+++ linux/drivers/net/wireless/wavelan_cs.c	2004-10-22 21:18:49.042408968 +0200
@@ -4066,6 +4066,7 @@
 	     (u_int) dev->mem_start, dev->irq, (u_int) dev->base_addr);
 #endif
 
+      SET_NETDEV_DEV(dev, &handle_to_dev(handle));
       i = register_netdev(dev);
       if(i != 0)
 	{
diff -ruN linux-original/drivers/net/wireless/wl3501_cs.c linux/drivers/net/wireless/wl3501_cs.c
--- linux-original/drivers/net/wireless/wl3501_cs.c	2004-10-22 16:35:42.000000000 +0200
+++ linux/drivers/net/wireless/wl3501_cs.c	2004-10-22 21:18:49.066405320 +0200
@@ -2105,6 +2105,7 @@
 
 	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;



More information about the linux-pcmcia mailing list