From 9ac7849e35f705830f7b016ff272b0ff1f7ff759 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Sat, 20 Jan 2007 16:00:26 +0900 Subject: devres: device resource management Implement device resource management, in short, devres. A device driver can allocate arbirary size of devres data which is associated with a release function. On driver detach, release function is invoked on the devres data, then, devres data is freed. devreses are typed by associated release functions. Some devreses are better represented by single instance of the type while others need multiple instances sharing the same release function. Both usages are supported. devreses can be grouped using devres group such that a device driver can easily release acquired resources halfway through initialization or selectively release resources (e.g. resources for port 1 out of 4 ports). This patch adds devres core including documentation and the following managed interfaces. * alloc/free : devm_kzalloc(), devm_kzfree() * IO region : devm_request_region(), devm_release_region() * IRQ : devm_request_irq(), devm_free_irq() * DMA : dmam_alloc_coherent(), dmam_free_coherent(), dmam_declare_coherent_memory(), dmam_pool_create(), dmam_pool_destroy() * PCI : pcim_enable_device(), pcim_pin_device(), pci_is_managed() * iomap : devm_ioport_map(), devm_ioport_unmap(), devm_ioremap(), devm_ioremap_nocache(), devm_iounmap(), pcim_iomap_table(), pcim_iomap(), pcim_iounmap() Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- include/linux/io.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'include/linux/io.h') diff --git a/include/linux/io.h b/include/linux/io.h index 81877ea3930..f5edf9c5de0 100644 --- a/include/linux/io.h +++ b/include/linux/io.h @@ -28,6 +28,23 @@ void __iowrite64_copy(void __iomem *to, const void *from, size_t count); int ioremap_page_range(unsigned long addr, unsigned long end, unsigned long phys_addr, pgprot_t prot); +/* + * Managed iomap interface + */ +void __iomem * devm_ioport_map(struct device *dev, unsigned long port, + unsigned int nr); +void devm_ioport_unmap(struct device *dev, void __iomem *addr); + +void __iomem * devm_ioremap(struct device *dev, unsigned long offset, + unsigned long size); +void __iomem * devm_ioremap_nocache(struct device *dev, unsigned long offset, + unsigned long size); +void devm_iounmap(struct device *dev, void __iomem *addr); + +void __iomem * pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen); +void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr); +void __iomem * const * pcim_iomap_table(struct pci_dev *pdev); + /** * check_signature - find BIOS signatures * @io_addr: mmio address to check -- cgit v1.2.3 From d24bbbf251e70bf984cbaa9b1fcadc5f56fc3ae9 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Sat, 20 Jan 2007 16:00:28 +0900 Subject: devres: implement pcim_iomap_regions() Implement pcim_iomap_regions(). This function takes mask of BARs to request and iomap. No BAR should have length of zero. BARs are iomapped using pcim_iomap_table(). Signed-off-by: Tejun Heo Signed-off-by: Jeff Garzik --- include/linux/io.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/linux/io.h') diff --git a/include/linux/io.h b/include/linux/io.h index f5edf9c5de0..45a9c944cb0 100644 --- a/include/linux/io.h +++ b/include/linux/io.h @@ -45,6 +45,8 @@ void __iomem * pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen); void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr); void __iomem * const * pcim_iomap_table(struct pci_dev *pdev); +int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name); + /** * check_signature - find BIOS signatures * @io_addr: mmio address to check -- cgit v1.2.3 From 7f25377043925554cb9f3f9d8ada3390f71a5d10 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Fri, 2 Feb 2007 18:07:15 -0800 Subject: git-libata-all: forward declare struct device In file included from drivers/infiniband/hw/ipath/ipath_diag.c:44: include/linux/io.h:35: warning: 'struct device' declared inside parameter list include/linux/io.h:35: warning: its scope is only this definition or declaration Cc: Jeff Garzik Signed-off-by: Andrew Morton Signed-off-by: Jeff Garzik --- include/linux/io.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/linux/io.h') diff --git a/include/linux/io.h b/include/linux/io.h index 45a9c944cb0..9e419ebfc98 100644 --- a/include/linux/io.h +++ b/include/linux/io.h @@ -22,6 +22,8 @@ #include #include +struct device; + void __iowrite32_copy(void __iomem *to, const void *from, size_t count); void __iowrite64_copy(void __iomem *to, const void *from, size_t count); -- cgit v1.2.3