]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] Get rid of check_resource() before it becomes a problem
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 29 Oct 2002 13:14:51 +0000 (05:14 -0800)
committerAnton Blanchard <anton@samba.org>
Tue, 29 Oct 2002 13:14:51 +0000 (05:14 -0800)
The new resource interface foolishly replicated the (obsolete,
racy) spirit of the check_region call as check_resource.  You
should use request_resource/release_resource instead.

drivers/pcmcia/rsrc_mgr.c
include/linux/ioport.h
kernel/ksyms.c
kernel/resource.c

index 9519d2c6d54eead2abbe0ea57b54634f0ed4699e..950b424ce44b561070b01c6034992e70368e5d81 100644 (file)
@@ -124,16 +124,36 @@ static struct resource *resource_parent(unsigned long b, unsigned long n,
        return &ioport_resource;
 }
 
+/* FIXME: Fundamentally racy. */
 static inline int check_io_resource(unsigned long b, unsigned long n,
                                    struct pci_dev *dev)
 {
-       return check_resource(resource_parent(b, n, IORESOURCE_IO, dev), b, n);
+       struct resource *region;
+
+       region = __request_region(resource_parent(b, n, IORESOURCE_IO, dev),
+                                 b, n, "check_io_resource");
+       if (!region)
+               return -EBUSY;
+
+       release_resource(region);
+       kfree(region);
+       return 0;
 }
 
+/* FIXME: Fundamentally racy. */
 static inline int check_mem_resource(unsigned long b, unsigned long n,
                                     struct pci_dev *dev)
 {
-       return check_resource(resource_parent(b, n, IORESOURCE_MEM, dev), b, n);
+       struct resource *region;
+
+       region = __request_region(resource_parent(b, n, IORESOURCE_MEM, dev),
+                                 b, n, "check_mem_resource");
+       if (!region)
+               return -EBUSY;
+
+       release_resource(region);
+       kfree(region);
+       return 0;
 }
 
 static struct resource *make_resource(unsigned long b, unsigned long n,
index 7f50af85568737da88e0e5a18be94c2133e6768f..020bd1596ab9541c41aa324149eda22fafb965e1 100644 (file)
@@ -85,7 +85,6 @@ extern struct resource iomem_resource;
 
 extern int get_resource_list(struct resource *, char *buf, int size);
 
-extern int check_resource(struct resource *root, unsigned long, unsigned long);
 extern int request_resource(struct resource *root, struct resource *new);
 extern int release_resource(struct resource *new);
 extern int allocate_resource(struct resource *root, struct resource *new,
index 190fb0c1f0cb571e4ed330fc0a764faa7d5e443a..7ecffcd552d11a1e4f224af351655f0c91134427 100644 (file)
@@ -445,7 +445,6 @@ EXPORT_SYMBOL(enable_hlt);
 EXPORT_SYMBOL(request_resource);
 EXPORT_SYMBOL(release_resource);
 EXPORT_SYMBOL(allocate_resource);
-EXPORT_SYMBOL(check_resource);
 EXPORT_SYMBOL(__request_region);
 EXPORT_SYMBOL(__check_region);
 EXPORT_SYMBOL(__release_region);
index 57541cc03d09071be6f331516397889f9db1550e..9664ad073db7ed74972637d80c57d6199668f4c4 100644 (file)
@@ -131,20 +131,6 @@ int release_resource(struct resource *old)
        return retval;
 }
 
-int check_resource(struct resource *root, unsigned long start, unsigned long len)
-{
-       struct resource *conflict, tmp;
-
-       tmp.start = start;
-       tmp.end = start + len - 1;
-       write_lock(&resource_lock);
-       conflict = __request_resource(root, &tmp);
-       if (!conflict)
-               __release_resource(&tmp);
-       write_unlock(&resource_lock);
-       return conflict ? -EBUSY : 0;
-}
-
 /*
  * Find empty slot in the resource tree given range and alignment.
  */