Re: PCMCIA driver resource allocation

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Bjorn Helgaas <bjorn.helgaas@...>
Cc: <linux-pcmcia@...>, <linux-kernel@...>, Dominik Brodowski <linux@...>
Date: Friday, October 19, 2007 - 6:40 pm

On Fri, Oct 19, 2007 at 10:51:51AM -0600, Bjorn Helgaas wrote:

The list is still around, but Dominik seems to have vanished.


That's from around the time that I handed PCMCIA over to Dominik, and was
a to-do item.  I had some drivers converted over - mainly the few that I
was using, those being serial and pcnet_cs (serial is converted over but
the patch I had for pcnet_cs is below.)

However, in spite of me pointing Dominik at my remaining patch sets several
times, as far as I could tell they got ignored.  So essentially I all lost
interest in helping out with PCMCIA.


Wrong function.  release_resource() doesn't pair with request_region().
request_region() allocates memory for the struct resource.
release_resource() merely removes the struct resource from the tree.
release_region() on the other hand removes the struct resource and
frees it.

---

Convert pcnet_cs and serial_cs to request their IO regions, thereby
marking them busy.  These are only two of many drivers which need this
update.

diff -u -x BitKeeper -x ChangeSet -x SCCS -x _xlk -x '*.orig' -x '*.rej' ref/drivers/net/pcmcia/pcnet_cs.c linux/drivers/net/pcmcia/pcnet_cs.c
--- ref/drivers/net/pcmcia/pcnet_cs.c	Sun Nov 16 19:12:33 2003
+++ linux/drivers/net/pcmcia/pcnet_cs.c	Tue Dec 23 09:43:22 2003
@@ -687,8 +687,15 @@
     dev->poll_controller = ei_poll;
 #endif
 
+    if (!request_region(dev->base_addr, link->io.NumPorts1, "pcnet_cs")) {
+	printk(KERN_NOTICE "pcnet_cs: request_region() failed\n");
+	link->dev = NULL;
+	goto failed;
+    }
+
     if (register_netdev(dev) != 0) {
 	printk(KERN_NOTICE "pcnet_cs: register_netdev() failed\n");
+	release_region(dev->base_addr, link->io.NumPorts1);
 	link->dev = NULL;
 	goto failed;
     }
@@ -736,6 +743,9 @@
 
     DEBUG(0, "pcnet_release(0x%p)\n", link);
 
+    if (link->dev)
+	release_region(link->io.BasePort1, link->io.NumPorts1);
+
     if (info->flags & USE_SHMEM) {
 	iounmap(info->base);
 	pcmcia_release_window(link->win);


-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
PCMCIA driver resource allocation, Bjorn Helgaas, (Fri Oct 19, 12:51 pm)
Re: PCMCIA driver resource allocation, Russell King, (Fri Oct 19, 6:40 pm)
Re: PCMCIA driver resource allocation, Bjorn Helgaas, (Mon Oct 22, 11:27 am)
Re: PCMCIA driver resource allocation, Kristoffer Ericson, (Sun Oct 21, 1:46 pm)
Re: PCMCIA driver resource allocation, Russell King, (Sun Oct 21, 4:41 am)