2.6.x kernels & PCI-to-PCMCIA bridges [again]

komujun at nifty.com komujun at nifty.com
Sat Jun 19 06:17:13 EDT 2004


>Essentially, I've:
>- corrected the formatting
>- removed extraneous white space
>- removed useless "card_state" variable (it was only ever set to 1 and
>  3, and only ever tested to be 0. IOW, the test could never be true.)

I've made some changes.

(1)fix compile error
>drivers/pcmcia/pd6729.c:321: error: structure has no member named `dev'

-	if (socket->dev != NULL)
-		state->io_irq = socket->socket.pci_irq;
+	state->io_irq = socket->socket.pci_irq;

(2)card_present is unnecessary.

(3)kmalloc size is sizeof(*socket)*MAX_SOCKETS.

(4)pci_disable_device when unloading.

Please see the followng patch.
Best Regards
Komuro


--- pd6729.c.orig	2004-06-19 11:46:48.000000000 +0900
+++ pd6729.c	2004-06-19 12:22:38.292064992 +0900
@@ -200,22 +200,6 @@
 	return IRQ_RETVAL(handled);
 }
 
-/* socket functions */
-
-static int card_present(struct pd6729_socket *socket)
-{
-	unsigned int val;
-
-	val = indirect_read(socket, 1); /* Interface status register */
-	if ((val&12) == 12) {
-		dprintk("card_present 1");
-		return 1;
-	}
-
-	dprintk("card_present 0");
-	return 0;
-}
-
 static void set_bridge_state(struct pd6729_socket *socket)
 {
 	indirect_write(socket, I365_GBLCTL, 0x00);
@@ -318,8 +302,7 @@
 		state->flags |= SS_IOCARD; /* This is an IO card */
 
 	/* Set the IRQ number */
-	if (socket->dev != NULL)
-		state->io_irq = socket->socket.pci_irq;
+	state->io_irq = socket->socket.pci_irq;
 
 	/* Card status change */
 	/* CSCICR, Card Status Change Interrupt Configuration */
@@ -613,7 +596,7 @@
 	char configbyte;
 	struct pd6729_socket **socket;
 
-	socket = kmalloc(sizeof(socket)*MAX_SOCKETS, GFP_KERNEL);
+	socket = kmalloc(sizeof(*socket)*MAX_SOCKETS, GFP_KERNEL);
 	if (!socket)
 		return -ENOMEM;
 
@@ -666,12 +649,6 @@
 		socket[i]->socket.driver_data = socket[i];
 
 		pci_set_drvdata(dev, socket);
-
-		if (card_present(socket[i])) {
-			dprintk(KERN_DEBUG "pd6729: slot %i is occupied\n", i);
-		} else {
-			dprintk(KERN_DEBUG "pd6729: slot %i is vacant\n", i);
-		}
 	}
 
 	/* Register the interrupt handler */
@@ -716,6 +693,7 @@
 
 	free_irq(dev->irq, socket);
 	pci_release_regions(dev);
+	pci_disable_device(dev);
 
 	kfree(socket[0]);
 	kfree(socket);





More information about the linux-pcmcia mailing list