Patch from abbotti@mev.co.uk (Ian Abbott) to
authorFrank Mori Hess <fmhess@speakeasy.net>
Sat, 4 Jun 2005 14:40:52 +0000 (14:40 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Sat, 4 Jun 2005 14:40:52 +0000 (14:40 +0000)
make it possible to remove deprecated check_region()
calls from drivers.
* include/linux/ioport.h: Added compat__request_region()
* include/linux/pci.h: Replace use of check_region() with
modern version of request_region().

ChangeLog
include/linux/ioport.h
include/linux/pci.h

index 419f8b0042e137a521a3d6a4e4f14ecacda555b4..dc4ebfd8633dde532e616d480140619dd91427f0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,13 @@
-2005-05-28  Frank Hess,,,  <fmhess@users.sourceforge.net>
+2005-06-04  Frank Hess  <fmhess@users.sourceforge.net>
+
+       Patch from abbotti@mev.co.uk (Ian Abbott) to
+       make it possible to remove deprecated check_region()
+       calls from drivers. 
+       * include/linux/ioport.h: Added compat__request_region()
+       * include/linux/pci.h: Replace use of check_region() with
+               modern version of request_region().
+
+2005-05-28  Frank Hess  <fmhess@users.sourceforge.net>
 
        * include/linux/delay.h: Added msleep_interruptible() 
        * include/linux/time.h:i Added msecs_to_jiffies() and jiffies_to_msecs()
index 1b59cc59dbe33345b73323062a43758413726844..1755fe3ad87fc86162294dec7f3a13a98356edf3 100644 (file)
 
 #include_next <linux/ioport.h>
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,3,11)
+
+/* 'struct resource' not defined.  Define a dummy version. */
+struct resource {
+       int dummy;
+};
+
+/* Define a compatible version of request_region that returns a pointer
+ * to a non-NULL value on success.  */
+static inline struct resource *compat__request_region(unsigned long from,
+               unsigned long extent, const char *name)
+{
+       if (check_region(from, extent) < 0) {
+               return (struct resource *)0;
+       }
+       request_region(from, extent, name);
+       return ((struct resource *)0 + 1);      /* Should be non-NULL */
+}
+
+/* Replace existing request_region macro/function. */
+#undef request_region
+#define request_region(f,e,n)  compat__request_region(f,e,n)
+
+#endif
+
 #endif // _COMPAT_IOPORT_H
 
index e295c534fbd166d24fb1e816473637cf5d2b56fc..ea1f41944539b4bdf3c7866445f870164638f87d 100644 (file)
@@ -103,26 +103,26 @@ static inline int pci_request_regions(struct pci_dev *dev, char *name)
                if(dev->base_address[i])
                {
                        if(dev->base_address[i] & PCI_BASE_ADDRESS_SPACE_IO)
-                               retval = check_region(pci_resource_start(dev, i),
-                                       fake_length);
-                       if( retval )
-                               break;
+                               if(!request_region(pci_resource_start(dev, i),
+                                       fake_length, name))
+                               {
+                                       retval = -EBUSY;
+                                       break;
+                               }
                }
        }
 
-       if(retval) return retval;
-
-       for(i = 0; i < max_num_base_addr; i++)
+       if(retval)
        {
-               if(dev->base_address[i])
+               while(--i >= 0)
                {
                        if(dev->base_address[i] & PCI_BASE_ADDRESS_SPACE_IO)
-                               request_region(pci_resource_start(dev, i),
-                                       fake_length, name);
+                               release_region(pci_resource_start(dev, i),
+                                       fake_length);
                }
        }
 
-       return 0;
+       return retval;
 }
 
 static inline void pci_release_regions(struct pci_dev *dev)