From be3c1c2bf0dd83072caae5cf82df39dedf75063e Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Sat, 4 Jun 2005 14:40:52 +0000 Subject: [PATCH] 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(). --- ChangeLog | 11 ++++++++++- include/linux/ioport.h | 25 +++++++++++++++++++++++++ include/linux/pci.h | 22 +++++++++++----------- 3 files changed, 46 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 419f8b00..dc4ebfd8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,13 @@ -2005-05-28 Frank Hess,,, +2005-06-04 Frank Hess + + 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 * include/linux/delay.h: Added msleep_interruptible() * include/linux/time.h:i Added msecs_to_jiffies() and jiffies_to_msecs() diff --git a/include/linux/ioport.h b/include/linux/ioport.h index 1b59cc59..1755fe3a 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -15,5 +15,30 @@ #include_next +#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 diff --git a/include/linux/pci.h b/include/linux/pci.h index e295c534..ea1f4194 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -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) -- 2.26.2