Many drivers can simplified by using devm_ioremap_resource()
instead of open coding its functionality. However, as pointed
by Wei Yongjun, that function cannot be used when memory region
is already taken. See previous discussion here:
https://www.spinics.net/lists/linux-pci/msg68495.html
To ease job of driver developers, new function for that
purpose is implemented and its usage shown.
Also, there are few cleanup patches, which may bring some
controversy, but seemed usefull to do along the way.
Feel free to object or suggest something else. Thank you.
Ladislav Michl (5):
devres: Move managed io function declarations into device.h
PCI: Move managed resource alloc to devres
devres: Make devm_ioremap_release() static
devres: Add devm_ioremap_shared_resource()
mtd: nand: davinci: Use devm_ioremap_shared_resource()
drivers/mtd/nand/davinci_nand.c | 24 +++------
drivers/pci/pci.c | 82 -------------------------------
include/linux/device.h | 65 +++++++++++++++++++++++-
include/linux/io.h | 39 ---------------
include/linux/ioport.h | 23 ---------
lib/devres.c | 106 ++++++++++++++++++++++++++++++++++++----
6 files changed, 168 insertions(+), 171 deletions(-)
--
2.15.1
devm_pci_remap_cfgspace() is using devm_ioremap_release()
devres release function. Move it to devres along with
similar PCI functions to allow hiding devm_ioremap_release()
from public.
Signed-off-by: Ladislav Michl <[email protected]>
---
drivers/pci/pci.c | 82 -------------------------------------------------------
lib/devres.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 82 insertions(+), 82 deletions(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 764ca7b8840d..fcf5cc2c91de 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -3533,88 +3533,6 @@ void pci_unmap_iospace(struct resource *res)
}
EXPORT_SYMBOL(pci_unmap_iospace);
-/**
- * devm_pci_remap_cfgspace - Managed pci_remap_cfgspace()
- * @dev: Generic device to remap IO address for
- * @offset: Resource address to map
- * @size: Size of map
- *
- * Managed pci_remap_cfgspace(). Map is automatically unmapped on driver
- * detach.
- */
-void __iomem *devm_pci_remap_cfgspace(struct device *dev,
- resource_size_t offset,
- resource_size_t size)
-{
- void __iomem **ptr, *addr;
-
- ptr = devres_alloc(devm_ioremap_release, sizeof(*ptr), GFP_KERNEL);
- if (!ptr)
- return NULL;
-
- addr = pci_remap_cfgspace(offset, size);
- if (addr) {
- *ptr = addr;
- devres_add(dev, ptr);
- } else
- devres_free(ptr);
-
- return addr;
-}
-EXPORT_SYMBOL(devm_pci_remap_cfgspace);
-
-/**
- * devm_pci_remap_cfg_resource - check, request region and ioremap cfg resource
- * @dev: generic device to handle the resource for
- * @res: configuration space resource to be handled
- *
- * Checks that a resource is a valid memory region, requests the memory
- * region and ioremaps with pci_remap_cfgspace() API that ensures the
- * proper PCI configuration space memory attributes are guaranteed.
- *
- * All operations are managed and will be undone on driver detach.
- *
- * Returns a pointer to the remapped memory or an ERR_PTR() encoded error code
- * on failure. Usage example::
- *
- * res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- * base = devm_pci_remap_cfg_resource(&pdev->dev, res);
- * if (IS_ERR(base))
- * return PTR_ERR(base);
- */
-void __iomem *devm_pci_remap_cfg_resource(struct device *dev,
- struct resource *res)
-{
- resource_size_t size;
- const char *name;
- void __iomem *dest_ptr;
-
- BUG_ON(!dev);
-
- if (!res || resource_type(res) != IORESOURCE_MEM) {
- dev_err(dev, "invalid resource\n");
- return IOMEM_ERR_PTR(-EINVAL);
- }
-
- size = resource_size(res);
- name = res->name ?: dev_name(dev);
-
- if (!devm_request_mem_region(dev, res->start, size, name)) {
- dev_err(dev, "can't request region for resource %pR\n", res);
- return IOMEM_ERR_PTR(-EBUSY);
- }
-
- dest_ptr = devm_pci_remap_cfgspace(dev, res->start, size);
- if (!dest_ptr) {
- dev_err(dev, "ioremap failed for resource %pR\n", res);
- devm_release_mem_region(dev, res->start, size);
- dest_ptr = IOMEM_ERR_PTR(-ENOMEM);
- }
-
- return dest_ptr;
-}
-EXPORT_SYMBOL(devm_pci_remap_cfg_resource);
-
static void __pci_set_master(struct pci_dev *dev, bool enable)
{
u16 old_cmd, cmd;
diff --git a/lib/devres.c b/lib/devres.c
index 5f2aedd58bc5..f2f80c233aa4 100644
--- a/lib/devres.c
+++ b/lib/devres.c
@@ -428,4 +428,86 @@ void pcim_iounmap_regions(struct pci_dev *pdev, int mask)
}
}
EXPORT_SYMBOL(pcim_iounmap_regions);
+
+/**
+ * devm_pci_remap_cfgspace - Managed pci_remap_cfgspace()
+ * @dev: Generic device to remap IO address for
+ * @offset: Resource address to map
+ * @size: Size of map
+ *
+ * Managed pci_remap_cfgspace(). Map is automatically unmapped on driver
+ * detach.
+ */
+void __iomem *devm_pci_remap_cfgspace(struct device *dev,
+ resource_size_t offset,
+ resource_size_t size)
+{
+ void __iomem **ptr, *addr;
+
+ ptr = devres_alloc(devm_ioremap_release, sizeof(*ptr), GFP_KERNEL);
+ if (!ptr)
+ return NULL;
+
+ addr = pci_remap_cfgspace(offset, size);
+ if (addr) {
+ *ptr = addr;
+ devres_add(dev, ptr);
+ } else
+ devres_free(ptr);
+
+ return addr;
+}
+EXPORT_SYMBOL(devm_pci_remap_cfgspace);
+
+/**
+ * devm_pci_remap_cfg_resource - check, request region and ioremap cfg resource
+ * @dev: generic device to handle the resource for
+ * @res: configuration space resource to be handled
+ *
+ * Checks that a resource is a valid memory region, requests the memory
+ * region and ioremaps with pci_remap_cfgspace() API that ensures the
+ * proper PCI configuration space memory attributes are guaranteed.
+ *
+ * All operations are managed and will be undone on driver detach.
+ *
+ * Returns a pointer to the remapped memory or an ERR_PTR() encoded error code
+ * on failure. Usage example::
+ *
+ * res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ * base = devm_pci_remap_cfg_resource(&pdev->dev, res);
+ * if (IS_ERR(base))
+ * return PTR_ERR(base);
+ */
+void __iomem *devm_pci_remap_cfg_resource(struct device *dev,
+ struct resource *res)
+{
+ resource_size_t size;
+ const char *name;
+ void __iomem *dest_ptr;
+
+ BUG_ON(!dev);
+
+ if (!res || resource_type(res) != IORESOURCE_MEM) {
+ dev_err(dev, "invalid resource\n");
+ return IOMEM_ERR_PTR(-EINVAL);
+ }
+
+ size = resource_size(res);
+ name = res->name ?: dev_name(dev);
+
+ if (!devm_request_mem_region(dev, res->start, size, name)) {
+ dev_err(dev, "can't request region for resource %pR\n", res);
+ return IOMEM_ERR_PTR(-EBUSY);
+ }
+
+ dest_ptr = devm_pci_remap_cfgspace(dev, res->start, size);
+ if (!dest_ptr) {
+ dev_err(dev, "ioremap failed for resource %pR\n", res);
+ devm_release_mem_region(dev, res->start, size);
+ dest_ptr = IOMEM_ERR_PTR(-ENOMEM);
+ }
+
+ return dest_ptr;
+}
+EXPORT_SYMBOL(devm_pci_remap_cfg_resource);
#endif /* CONFIG_PCI */
--
2.15.1
Moving managed io function declarations into device.h allows
removing forward struct device and resource definitions from
io(port).h
Signed-off-by: Ladislav Michl <[email protected]>
---
include/linux/device.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++
include/linux/io.h | 39 ----------------------------------
include/linux/ioport.h | 23 --------------------
3 files changed, 57 insertions(+), 62 deletions(-)
diff --git a/include/linux/device.h b/include/linux/device.h
index 4d88b6b9cda9..91f508edb266 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -683,8 +683,65 @@ extern unsigned long devm_get_free_pages(struct device *dev,
gfp_t gfp_mask, unsigned int order);
extern void devm_free_pages(struct device *dev, unsigned long addr);
+/* managed resource interface */
+extern int devm_request_resource(struct device *dev, struct resource *root,
+ struct resource *new);
+extern void devm_release_resource(struct device *dev, struct resource *new);
+
+#define devm_request_region(dev,start,n,name) \
+ __devm_request_region(dev, &ioport_resource, (start), (n), (name))
+#define devm_request_mem_region(dev,start,n,name) \
+ __devm_request_region(dev, &iomem_resource, (start), (n), (name))
+
+extern struct resource * __devm_request_region(struct device *dev,
+ struct resource *parent, resource_size_t start,
+ resource_size_t n, const char *name);
+
+#define devm_release_region(dev, start, n) \
+ __devm_release_region(dev, &ioport_resource, (start), (n))
+#define devm_release_mem_region(dev, start, n) \
+ __devm_release_region(dev, &iomem_resource, (start), (n))
+
+extern void __devm_release_region(struct device *dev, struct resource *parent,
+ resource_size_t start, resource_size_t n);
+
+/* managed iomap interface */
+#ifdef CONFIG_HAS_IOPORT_MAP
+void __iomem * devm_ioport_map(struct device *dev, unsigned long port,
+ unsigned int nr);
+void devm_ioport_unmap(struct device *dev, void __iomem *addr);
+#else
+static inline void __iomem *devm_ioport_map(struct device *dev,
+ unsigned long port,
+ unsigned int nr)
+{
+ return NULL;
+}
+
+static inline void devm_ioport_unmap(struct device *dev, void __iomem *addr)
+{
+}
+#endif
+
+#define IOMEM_ERR_PTR(err) (__force void __iomem *)ERR_PTR(err)
+
+void __iomem *devm_ioremap(struct device *dev, resource_size_t offset,
+ resource_size_t size);
+void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t offset,
+ resource_size_t size);
+void __iomem *devm_ioremap_wc(struct device *dev, resource_size_t offset,
+ resource_size_t size);
void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res);
+void devm_iounmap(struct device *dev, void __iomem *addr);
+void devm_ioremap_release(struct device *dev, void *res);
+
+void *devm_memremap(struct device *dev, resource_size_t offset,
+ size_t size, unsigned long flags);
+void devm_memunmap(struct device *dev, void *addr);
+
+void *__devm_memremap_pages(struct device *dev, struct resource *res);
+
/* allows to add/remove a custom action to devres stack */
int devm_add_action(struct device *dev, void (*action)(void *), void *data);
void devm_remove_action(struct device *dev, void (*action)(void *), void *data);
diff --git a/include/linux/io.h b/include/linux/io.h
index 32e30e8fb9db..58554147ccdb 100644
--- a/include/linux/io.h
+++ b/include/linux/io.h
@@ -25,9 +25,6 @@
#include <asm/io.h>
#include <asm/page.h>
-struct device;
-struct resource;
-
__visible void __iowrite32_copy(void __iomem *to, const void *from, size_t count);
void __ioread32_copy(void *to, const void __iomem *from, size_t count);
void __iowrite64_copy(void __iomem *to, const void *from, size_t count);
@@ -51,44 +48,8 @@ int arch_ioremap_pmd_supported(void);
static inline void ioremap_huge_init(void) { }
#endif
-/*
- * Managed iomap interface
- */
-#ifdef CONFIG_HAS_IOPORT_MAP
-void __iomem * devm_ioport_map(struct device *dev, unsigned long port,
- unsigned int nr);
-void devm_ioport_unmap(struct device *dev, void __iomem *addr);
-#else
-static inline void __iomem *devm_ioport_map(struct device *dev,
- unsigned long port,
- unsigned int nr)
-{
- return NULL;
-}
-
-static inline void devm_ioport_unmap(struct device *dev, void __iomem *addr)
-{
-}
-#endif
-
-#define IOMEM_ERR_PTR(err) (__force void __iomem *)ERR_PTR(err)
-
-void __iomem *devm_ioremap(struct device *dev, resource_size_t offset,
- resource_size_t size);
-void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t offset,
- resource_size_t size);
-void __iomem *devm_ioremap_wc(struct device *dev, resource_size_t offset,
- resource_size_t size);
-void devm_iounmap(struct device *dev, void __iomem *addr);
int check_signature(const volatile void __iomem *io_addr,
const unsigned char *signature, int length);
-void devm_ioremap_release(struct device *dev, void *res);
-
-void *devm_memremap(struct device *dev, resource_size_t offset,
- size_t size, unsigned long flags);
-void devm_memunmap(struct device *dev, void *addr);
-
-void *__devm_memremap_pages(struct device *dev, struct resource *res);
#ifdef CONFIG_PCI
/*
diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index da0ebaec25f0..dc43f2f52416 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -241,29 +241,6 @@ extern int release_mem_region_adjustable(struct resource *, resource_size_t,
resource_size_t);
#endif
-/* Wrappers for managed devices */
-struct device;
-
-extern int devm_request_resource(struct device *dev, struct resource *root,
- struct resource *new);
-extern void devm_release_resource(struct device *dev, struct resource *new);
-
-#define devm_request_region(dev,start,n,name) \
- __devm_request_region(dev, &ioport_resource, (start), (n), (name))
-#define devm_request_mem_region(dev,start,n,name) \
- __devm_request_region(dev, &iomem_resource, (start), (n), (name))
-
-extern struct resource * __devm_request_region(struct device *dev,
- struct resource *parent, resource_size_t start,
- resource_size_t n, const char *name);
-
-#define devm_release_region(dev, start, n) \
- __devm_release_region(dev, &ioport_resource, (start), (n))
-#define devm_release_mem_region(dev, start, n) \
- __devm_release_region(dev, &iomem_resource, (start), (n))
-
-extern void __devm_release_region(struct device *dev, struct resource *parent,
- resource_size_t start, resource_size_t n);
extern int iomem_map_sanity_check(resource_size_t addr, unsigned long size);
extern bool iomem_is_exclusive(u64 addr);
--
2.15.1
devm_ioremap_release() is an implementation detail and shouldn't
be public.
Signed-off-by: Ladislav Michl <[email protected]>
---
include/linux/device.h | 1 -
lib/devres.c | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/include/linux/device.h b/include/linux/device.h
index 91f508edb266..e99d41a6190b 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -734,7 +734,6 @@ void __iomem *devm_ioremap_wc(struct device *dev, resource_size_t offset,
void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res);
void devm_iounmap(struct device *dev, void __iomem *addr);
-void devm_ioremap_release(struct device *dev, void *res);
void *devm_memremap(struct device *dev, resource_size_t offset,
size_t size, unsigned long flags);
diff --git a/lib/devres.c b/lib/devres.c
index f2f80c233aa4..e9aad136f667 100644
--- a/lib/devres.c
+++ b/lib/devres.c
@@ -5,7 +5,7 @@
#include <linux/gfp.h>
#include <linux/export.h>
-void devm_ioremap_release(struct device *dev, void *res)
+static void devm_ioremap_release(struct device *dev, void *res)
{
iounmap(*(void __iomem **)res);
}
--
2.15.1
Implement managed ioremap function for shared resources.
Signed-off-by: Ladislav Michl <[email protected]>
---
include/linux/device.h | 9 ++++++++-
lib/devres.c | 22 ++++++++++++++--------
2 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/include/linux/device.h b/include/linux/device.h
index e99d41a6190b..a35247a5f578 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -731,7 +731,14 @@ void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t offset,
resource_size_t size);
void __iomem *devm_ioremap_wc(struct device *dev, resource_size_t offset,
resource_size_t size);
-void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res);
+
+#define devm_ioremap_resource(dev, res) \
+ __devm_ioremap_resource(dev, res, false)
+#define devm_ioremap_shared_resource(dev, res) \
+ __devm_ioremap_resource(dev, res, true)
+
+void __iomem *__devm_ioremap_resource(struct device *dev, struct resource *res,
+ bool shared);
void devm_iounmap(struct device *dev, void __iomem *addr);
diff --git a/lib/devres.c b/lib/devres.c
index e9aad136f667..9fa15816cb83 100644
--- a/lib/devres.c
+++ b/lib/devres.c
@@ -22,6 +22,9 @@ static int devm_ioremap_match(struct device *dev, void *res, void *match_data)
* @size: Size of map
*
* Managed ioremap(). Map is automatically unmapped on driver detach.
+ *
+ * When possible, use devm_ioremap_resource() or
+ * devm_ioremap_shared_resource() instead.
*/
void __iomem *devm_ioremap(struct device *dev, resource_size_t offset,
resource_size_t size)
@@ -116,13 +119,14 @@ void devm_iounmap(struct device *dev, void __iomem *addr)
EXPORT_SYMBOL(devm_iounmap);
/**
- * devm_ioremap_resource() - check, request region, and ioremap resource
+ * __devm_ioremap_resource() - check, request region, and ioremap resource
* @dev: generic device to handle the resource for
* @res: resource to be handled
+ * @shared: region is not requested when true
*
- * Checks that a resource is a valid memory region, requests the memory
- * region and ioremaps it. All operations are managed and will be undone
- * on driver detach.
+ * Checks that a resource is a valid memory region, eventually requests the
+ * memory region and ioremaps it. All operations are managed and will be
+ * undone on driver detach.
*
* Returns a pointer to the remapped memory or an ERR_PTR() encoded error code
* on failure. Usage example:
@@ -132,7 +136,8 @@ EXPORT_SYMBOL(devm_iounmap);
* if (IS_ERR(base))
* return PTR_ERR(base);
*/
-void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res)
+void __iomem *__devm_ioremap_resource(struct device *dev, struct resource *res,
+ bool shared)
{
resource_size_t size;
const char *name;
@@ -148,7 +153,7 @@ void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res)
size = resource_size(res);
name = res->name ?: dev_name(dev);
- if (!devm_request_mem_region(dev, res->start, size, name)) {
+ if (!shared && !devm_request_mem_region(dev, res->start, size, name)) {
dev_err(dev, "can't request region for resource %pR\n", res);
return IOMEM_ERR_PTR(-EBUSY);
}
@@ -156,13 +161,14 @@ void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res)
dest_ptr = devm_ioremap(dev, res->start, size);
if (!dest_ptr) {
dev_err(dev, "ioremap failed for resource %pR\n", res);
- devm_release_mem_region(dev, res->start, size);
+ if (!shared)
+ devm_release_mem_region(dev, res->start, size);
dest_ptr = IOMEM_ERR_PTR(-ENOMEM);
}
return dest_ptr;
}
-EXPORT_SYMBOL(devm_ioremap_resource);
+EXPORT_SYMBOL(__devm_ioremap_resource);
#ifdef CONFIG_HAS_IOPORT_MAP
/*
--
2.15.1
Simplify error handling by using devm_ioremap_shared_resource().
Signed-off-by: Ladislav Michl <[email protected]>
---
drivers/mtd/nand/davinci_nand.c | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/drivers/mtd/nand/davinci_nand.c b/drivers/mtd/nand/davinci_nand.c
index ccc8c43abcff..9b6f06b177b9 100644
--- a/drivers/mtd/nand/davinci_nand.c
+++ b/drivers/mtd/nand/davinci_nand.c
@@ -612,10 +612,8 @@ static int nand_davinci_probe(struct platform_device *pdev)
{
struct davinci_nand_pdata *pdata;
struct davinci_nand_info *info;
- struct resource *res1;
- struct resource *res2;
+ struct resource *res;
void __iomem *vaddr;
- void __iomem *base;
int ret;
uint32_t val;
struct mtd_info *mtd;
@@ -638,14 +636,8 @@ static int nand_davinci_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, info);
- res1 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- res2 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
- if (!res1 || !res2) {
- dev_err(&pdev->dev, "resource missing\n");
- return -EINVAL;
- }
-
- vaddr = devm_ioremap_resource(&pdev->dev, res1);
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ vaddr = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(vaddr))
return PTR_ERR(vaddr);
@@ -655,14 +647,12 @@ static int nand_davinci_probe(struct platform_device *pdev)
* by AEMIF, so we cannot request it twice, just ioremap.
* The AEMIF and NAND drivers not use the same registers in this range.
*/
- base = devm_ioremap(&pdev->dev, res2->start, resource_size(res2));
- if (!base) {
- dev_err(&pdev->dev, "ioremap failed for resource %pR\n", res2);
- return -EADDRNOTAVAIL;
- }
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+ info->base = devm_ioremap_shared_resource(&pdev->dev, res);
+ if (IS_ERR(info->base))
+ return PTR_ERR(info->base);
info->dev = &pdev->dev;
- info->base = base;
info->vaddr = vaddr;
mtd = nand_to_mtd(&info->chip);
--
2.15.1
Hi Ladislav,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on next-20180119]
[also build test ERROR on v4.15-rc9]
[cannot apply to linus/master pci/next l2-mtd-boris/nand/next v4.15-rc8 v4.15-rc7 v4.15-rc6]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Ladislav-Michl/Add-managed-ioremap-function-for-shared-resources/20180122-164512
config: i386-tinyconfig (attached as .config)
compiler: gcc-7 (Debian 7.2.0-12) 7.2.1 20171025
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All errors (new ones prefixed by >>):
In file included from include/linux/device.h:23:0,
from drivers/base/dd.c:19:
include/linux/pinctrl/devinfo.h:48:44: warning: 'struct device' declared inside parameter list will not be visible outside of this definition or declaration
static inline int pinctrl_bind_pins(struct device *dev)
^~~~~~
include/linux/pinctrl/devinfo.h:53:44: warning: 'struct device' declared inside parameter list will not be visible outside of this definition or declaration
static inline int pinctrl_init_done(struct device *dev)
^~~~~~
drivers/base/dd.c: In function 'really_probe':
>> drivers/base/dd.c:394:26: error: passing argument 1 of 'pinctrl_bind_pins' from incompatible pointer type [-Werror=incompatible-pointer-types]
ret = pinctrl_bind_pins(dev);
^~~
In file included from include/linux/device.h:23:0,
from drivers/base/dd.c:19:
include/linux/pinctrl/devinfo.h:48:19: note: expected 'struct device *' but argument is of type 'struct device *'
static inline int pinctrl_bind_pins(struct device *dev)
^~~~~~~~~~~~~~~~~
>> drivers/base/dd.c:451:20: error: passing argument 1 of 'pinctrl_init_done' from incompatible pointer type [-Werror=incompatible-pointer-types]
pinctrl_init_done(dev);
^~~
In file included from include/linux/device.h:23:0,
from drivers/base/dd.c:19:
include/linux/pinctrl/devinfo.h:53:19: note: expected 'struct device *' but argument is of type 'struct device *'
static inline int pinctrl_init_done(struct device *dev)
^~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +/pinctrl_bind_pins +394 drivers/base/dd.c
0ff26c662 Adrian Hunter 2017-11-02 360
21c7f30b1 Cornelia Huck 2007-02-05 361 static int really_probe(struct device *dev, struct device_driver *drv)
07e4a3e27 Patrick Mochel 2005-03-21 362 {
013c074f8 Strashko, Grygorii 2015-11-10 363 int ret = -EPROBE_DEFER;
58b116bce Grant Likely 2014-04-29 364 int local_trigger_count = atomic_read(&deferred_trigger_count);
c5f062748 Rob Herring 2016-10-11 365 bool test_remove = IS_ENABLED(CONFIG_DEBUG_TEST_DRIVER_REMOVE) &&
c5f062748 Rob Herring 2016-10-11 366 !drv->suppress_bind_attrs;
07e4a3e27 Patrick Mochel 2005-03-21 367
013c074f8 Strashko, Grygorii 2015-11-10 368 if (defer_all_probes) {
013c074f8 Strashko, Grygorii 2015-11-10 369 /*
013c074f8 Strashko, Grygorii 2015-11-10 370 * Value of defer_all_probes can be set only by
013c074f8 Strashko, Grygorii 2015-11-10 371 * device_defer_all_probes_enable() which, in turn, will call
013c074f8 Strashko, Grygorii 2015-11-10 372 * wait_for_device_probe() right after that to avoid any races.
013c074f8 Strashko, Grygorii 2015-11-10 373 */
013c074f8 Strashko, Grygorii 2015-11-10 374 dev_dbg(dev, "Driver %s force probe deferral\n", drv->name);
013c074f8 Strashko, Grygorii 2015-11-10 375 driver_deferred_probe_add(dev);
013c074f8 Strashko, Grygorii 2015-11-10 376 return ret;
013c074f8 Strashko, Grygorii 2015-11-10 377 }
013c074f8 Strashko, Grygorii 2015-11-10 378
9ed989537 Rafael J. Wysocki 2016-10-30 379 ret = device_links_check_suppliers(dev);
0ff26c662 Adrian Hunter 2017-11-02 380 if (ret == -EPROBE_DEFER)
0ff26c662 Adrian Hunter 2017-11-02 381 driver_deferred_probe_add_trigger(dev, local_trigger_count);
9ed989537 Rafael J. Wysocki 2016-10-30 382 if (ret)
9ed989537 Rafael J. Wysocki 2016-10-30 383 return ret;
9ed989537 Rafael J. Wysocki 2016-10-30 384
d779249ed Greg Kroah-Hartman 2006-07-18 385 atomic_inc(&probe_count);
7dc72b284 Greg Kroah-Hartman 2007-11-28 386 pr_debug("bus: '%s': %s: probing driver %s with device %s\n",
1e0b2cf93 Kay Sievers 2008-10-30 387 drv->bus->name, __func__, drv->name, dev_name(dev));
9ac7849e3 Tejun Heo 2007-01-20 388 WARN_ON(!list_empty(&dev->devres_head));
07e4a3e27 Patrick Mochel 2005-03-21 389
bea5b158f Rob Herring 2016-08-11 390 re_probe:
07e4a3e27 Patrick Mochel 2005-03-21 391 dev->driver = drv;
ab78029ec Linus Walleij 2013-01-22 392
ab78029ec Linus Walleij 2013-01-22 393 /* If using pinctrl, bind pins now before probing */
ab78029ec Linus Walleij 2013-01-22 @394 ret = pinctrl_bind_pins(dev);
ab78029ec Linus Walleij 2013-01-22 395 if (ret)
14b6257a5 Andy Shevchenko 2015-12-04 396 goto pinctrl_bind_failed;
ab78029ec Linus Walleij 2013-01-22 397
09515ef5d Sricharan R 2017-04-10 398 ret = dma_configure(dev);
09515ef5d Sricharan R 2017-04-10 399 if (ret)
09515ef5d Sricharan R 2017-04-10 400 goto dma_failed;
09515ef5d Sricharan R 2017-04-10 401
1901fb260 Kay Sievers 2006-10-07 402 if (driver_sysfs_add(dev)) {
1901fb260 Kay Sievers 2006-10-07 403 printk(KERN_ERR "%s: driver_sysfs_add(%s) failed\n",
1e0b2cf93 Kay Sievers 2008-10-30 404 __func__, dev_name(dev));
1901fb260 Kay Sievers 2006-10-07 405 goto probe_failed;
1901fb260 Kay Sievers 2006-10-07 406 }
1901fb260 Kay Sievers 2006-10-07 407
e90d55327 Rafael J. Wysocki 2015-03-20 408 if (dev->pm_domain && dev->pm_domain->activate) {
e90d55327 Rafael J. Wysocki 2015-03-20 409 ret = dev->pm_domain->activate(dev);
e90d55327 Rafael J. Wysocki 2015-03-20 410 if (ret)
e90d55327 Rafael J. Wysocki 2015-03-20 411 goto probe_failed;
e90d55327 Rafael J. Wysocki 2015-03-20 412 }
e90d55327 Rafael J. Wysocki 2015-03-20 413
52cdbdd49 Grygorii Strashko 2015-07-27 414 /*
52cdbdd49 Grygorii Strashko 2015-07-27 415 * Ensure devices are listed in devices_kset in correct order
52cdbdd49 Grygorii Strashko 2015-07-27 416 * It's important to move Dev to the end of devices_kset before
52cdbdd49 Grygorii Strashko 2015-07-27 417 * calling .probe, because it could be recursive and parent Dev
52cdbdd49 Grygorii Strashko 2015-07-27 418 * should always go first
52cdbdd49 Grygorii Strashko 2015-07-27 419 */
52cdbdd49 Grygorii Strashko 2015-07-27 420 devices_kset_move_last(dev);
52cdbdd49 Grygorii Strashko 2015-07-27 421
594c8281f Russell King 2006-01-05 422 if (dev->bus->probe) {
594c8281f Russell King 2006-01-05 423 ret = dev->bus->probe(dev);
1901fb260 Kay Sievers 2006-10-07 424 if (ret)
d779249ed Greg Kroah-Hartman 2006-07-18 425 goto probe_failed;
594c8281f Russell King 2006-01-05 426 } else if (drv->probe) {
0d3e5a2e3 Patrick Mochel 2005-04-05 427 ret = drv->probe(dev);
1901fb260 Kay Sievers 2006-10-07 428 if (ret)
d779249ed Greg Kroah-Hartman 2006-07-18 429 goto probe_failed;
07e4a3e27 Patrick Mochel 2005-03-21 430 }
1901fb260 Kay Sievers 2006-10-07 431
bea5b158f Rob Herring 2016-08-11 432 if (test_remove) {
bea5b158f Rob Herring 2016-08-11 433 test_remove = false;
bea5b158f Rob Herring 2016-08-11 434
bdacd1b42 Rob Herring 2016-10-11 435 if (dev->bus->remove)
bea5b158f Rob Herring 2016-08-11 436 dev->bus->remove(dev);
bea5b158f Rob Herring 2016-08-11 437 else if (drv->remove)
bea5b158f Rob Herring 2016-08-11 438 drv->remove(dev);
bea5b158f Rob Herring 2016-08-11 439
bea5b158f Rob Herring 2016-08-11 440 devres_release_all(dev);
bea5b158f Rob Herring 2016-08-11 441 driver_sysfs_remove(dev);
bea5b158f Rob Herring 2016-08-11 442 dev->driver = NULL;
bea5b158f Rob Herring 2016-08-11 443 dev_set_drvdata(dev, NULL);
bea5b158f Rob Herring 2016-08-11 444 if (dev->pm_domain && dev->pm_domain->dismiss)
bea5b158f Rob Herring 2016-08-11 445 dev->pm_domain->dismiss(dev);
bea5b158f Rob Herring 2016-08-11 446 pm_runtime_reinit(dev);
bea5b158f Rob Herring 2016-08-11 447
bea5b158f Rob Herring 2016-08-11 448 goto re_probe;
bea5b158f Rob Herring 2016-08-11 449 }
bea5b158f Rob Herring 2016-08-11 450
ef0eebc05 Douglas Anderson 2015-10-20 @451 pinctrl_init_done(dev);
ef0eebc05 Douglas Anderson 2015-10-20 452
e90d55327 Rafael J. Wysocki 2015-03-20 453 if (dev->pm_domain && dev->pm_domain->sync)
e90d55327 Rafael J. Wysocki 2015-03-20 454 dev->pm_domain->sync(dev);
e90d55327 Rafael J. Wysocki 2015-03-20 455
1901fb260 Kay Sievers 2006-10-07 456 driver_bound(dev);
0d3e5a2e3 Patrick Mochel 2005-04-05 457 ret = 1;
7dc72b284 Greg Kroah-Hartman 2007-11-28 458 pr_debug("bus: '%s': %s: bound device %s to driver %s\n",
1e0b2cf93 Kay Sievers 2008-10-30 459 drv->bus->name, __func__, dev_name(dev), drv->name);
d779249ed Greg Kroah-Hartman 2006-07-18 460 goto done;
2287c322b Patrick Mochel 2005-03-24 461
d779249ed Greg Kroah-Hartman 2006-07-18 462 probe_failed:
09515ef5d Sricharan R 2017-04-10 463 dma_deconfigure(dev);
09515ef5d Sricharan R 2017-04-10 464 dma_failed:
14b6257a5 Andy Shevchenko 2015-12-04 465 if (dev->bus)
14b6257a5 Andy Shevchenko 2015-12-04 466 blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
14b6257a5 Andy Shevchenko 2015-12-04 467 BUS_NOTIFY_DRIVER_NOT_BOUND, dev);
14b6257a5 Andy Shevchenko 2015-12-04 468 pinctrl_bind_failed:
9ed989537 Rafael J. Wysocki 2016-10-30 469 device_links_no_driver(dev);
9ac7849e3 Tejun Heo 2007-01-20 470 devres_release_all(dev);
1901fb260 Kay Sievers 2006-10-07 471 driver_sysfs_remove(dev);
1901fb260 Kay Sievers 2006-10-07 472 dev->driver = NULL;
0998d0631 Hans de Goede 2012-05-23 473 dev_set_drvdata(dev, NULL);
e90d55327 Rafael J. Wysocki 2015-03-20 474 if (dev->pm_domain && dev->pm_domain->dismiss)
e90d55327 Rafael J. Wysocki 2015-03-20 475 dev->pm_domain->dismiss(dev);
5de85b9d5 Ulf Hansson 2015-11-18 476 pm_runtime_reinit(dev);
08810a411 Rafael J. Wysocki 2017-10-25 477 dev_pm_set_driver_flags(dev, 0);
1901fb260 Kay Sievers 2006-10-07 478
bb2b40754 Sergei Shtylyov 2015-01-17 479 switch (ret) {
bb2b40754 Sergei Shtylyov 2015-01-17 480 case -EPROBE_DEFER:
d1c3414c2 Grant Likely 2012-03-05 481 /* Driver requested deferred probing */
13fcffbbd Mark Brown 2015-03-10 482 dev_dbg(dev, "Driver %s requests probe deferral\n", drv->name);
0ff26c662 Adrian Hunter 2017-11-02 483 driver_deferred_probe_add_trigger(dev, local_trigger_count);
bb2b40754 Sergei Shtylyov 2015-01-17 484 break;
bb2b40754 Sergei Shtylyov 2015-01-17 485 case -ENODEV:
bb2b40754 Sergei Shtylyov 2015-01-17 486 case -ENXIO:
bb2b40754 Sergei Shtylyov 2015-01-17 487 pr_debug("%s: probe of %s rejects match %d\n",
bb2b40754 Sergei Shtylyov 2015-01-17 488 drv->name, dev_name(dev), ret);
bb2b40754 Sergei Shtylyov 2015-01-17 489 break;
bb2b40754 Sergei Shtylyov 2015-01-17 490 default:
2287c322b Patrick Mochel 2005-03-24 491 /* driver matched but the probe failed */
2287c322b Patrick Mochel 2005-03-24 492 printk(KERN_WARNING
2287c322b Patrick Mochel 2005-03-24 493 "%s: probe of %s failed with error %d\n",
1e0b2cf93 Kay Sievers 2008-10-30 494 drv->name, dev_name(dev), ret);
2287c322b Patrick Mochel 2005-03-24 495 }
c578abbc2 Cornelia Huck 2006-11-27 496 /*
c578abbc2 Cornelia Huck 2006-11-27 497 * Ignore errors returned by ->probe so that the next driver can try
c578abbc2 Cornelia Huck 2006-11-27 498 * its luck.
c578abbc2 Cornelia Huck 2006-11-27 499 */
c578abbc2 Cornelia Huck 2006-11-27 500 ret = 0;
d779249ed Greg Kroah-Hartman 2006-07-18 501 done:
d779249ed Greg Kroah-Hartman 2006-07-18 502 atomic_dec(&probe_count);
735a7ffb7 Andrew Morton 2006-10-27 503 wake_up(&probe_waitqueue);
d779249ed Greg Kroah-Hartman 2006-07-18 504 return ret;
d779249ed Greg Kroah-Hartman 2006-07-18 505 }
d779249ed Greg Kroah-Hartman 2006-07-18 506
:::::: The code at line 394 was first introduced by commit
:::::: ab78029ecc347debbd737f06688d788bd9d60c1d drivers/pinctrl: grab default handles from device core
:::::: TO: Linus Walleij <[email protected]>
:::::: CC: Linus Walleij <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Hi Ladislav,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on next-20180119]
[also build test ERROR on v4.15-rc9]
[cannot apply to linus/master pci/next l2-mtd-boris/nand/next v4.15-rc8 v4.15-rc7 v4.15-rc6]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Ladislav-Michl/Add-managed-ioremap-function-for-shared-resources/20180122-164512
config: i386-randconfig-a0-201803 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All error/warnings (new ones prefixed by >>):
In file included from drivers/mfd/syscon.c:21:0:
include/linux/of_address.h: In function 'of_io_request_and_map':
>> include/linux/of_address.h:65:2: error: implicit declaration of function 'IOMEM_ERR_PTR' [-Werror=implicit-function-declaration]
return IOMEM_ERR_PTR(-EINVAL);
^
>> include/linux/of_address.h:65:2: warning: return makes pointer from integer without a cast
cc1: some warnings being treated as errors
--
In file included from drivers//fpga/altera-pr-ip-core.c:22:0:
>> include/linux/fpga/altera-pr-ip-core.h:26:28: warning: 'struct device' declared inside parameter list
int alt_pr_register(struct device *dev, void __iomem *reg_base);
^
>> include/linux/fpga/altera-pr-ip-core.h:26:28: warning: its scope is only this definition or declaration, which is probably not what you want
include/linux/fpga/altera-pr-ip-core.h:27:30: warning: 'struct device' declared inside parameter list
int alt_pr_unregister(struct device *dev);
^
>> drivers//fpga/altera-pr-ip-core.c:187:5: error: conflicting types for 'alt_pr_register'
int alt_pr_register(struct device *dev, void __iomem *reg_base)
^
In file included from drivers//fpga/altera-pr-ip-core.c:22:0:
include/linux/fpga/altera-pr-ip-core.h:26:5: note: previous declaration of 'alt_pr_register' was here
int alt_pr_register(struct device *dev, void __iomem *reg_base);
^
In file included from include/linux/linkage.h:7:0,
from include/linux/kernel.h:7,
from include/linux/delay.h:22,
from drivers//fpga/altera-pr-ip-core.c:21:
drivers//fpga/altera-pr-ip-core.c:206:19: error: conflicting types for 'alt_pr_register'
EXPORT_SYMBOL_GPL(alt_pr_register);
^
include/linux/export.h:65:21: note: in definition of macro '___EXPORT_SYMBOL'
extern typeof(sym) sym; \
^
drivers//fpga/altera-pr-ip-core.c:206:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
EXPORT_SYMBOL_GPL(alt_pr_register);
^
In file included from drivers//fpga/altera-pr-ip-core.c:22:0:
include/linux/fpga/altera-pr-ip-core.h:26:5: note: previous declaration of 'alt_pr_register' was here
int alt_pr_register(struct device *dev, void __iomem *reg_base);
^
>> drivers//fpga/altera-pr-ip-core.c:208:5: error: conflicting types for 'alt_pr_unregister'
int alt_pr_unregister(struct device *dev)
^
In file included from drivers//fpga/altera-pr-ip-core.c:22:0:
include/linux/fpga/altera-pr-ip-core.h:27:5: note: previous declaration of 'alt_pr_unregister' was here
int alt_pr_unregister(struct device *dev);
^
In file included from include/linux/linkage.h:7:0,
from include/linux/kernel.h:7,
from include/linux/delay.h:22,
from drivers//fpga/altera-pr-ip-core.c:21:
drivers//fpga/altera-pr-ip-core.c:216:19: error: conflicting types for 'alt_pr_unregister'
EXPORT_SYMBOL_GPL(alt_pr_unregister);
^
include/linux/export.h:65:21: note: in definition of macro '___EXPORT_SYMBOL'
extern typeof(sym) sym; \
^
drivers//fpga/altera-pr-ip-core.c:216:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
EXPORT_SYMBOL_GPL(alt_pr_unregister);
^
In file included from drivers//fpga/altera-pr-ip-core.c:22:0:
include/linux/fpga/altera-pr-ip-core.h:27:5: note: previous declaration of 'alt_pr_unregister' was here
int alt_pr_unregister(struct device *dev);
^
--
In file included from drivers/fpga/altera-pr-ip-core.c:22:0:
>> include/linux/fpga/altera-pr-ip-core.h:26:28: warning: 'struct device' declared inside parameter list
int alt_pr_register(struct device *dev, void __iomem *reg_base);
^
>> include/linux/fpga/altera-pr-ip-core.h:26:28: warning: its scope is only this definition or declaration, which is probably not what you want
include/linux/fpga/altera-pr-ip-core.h:27:30: warning: 'struct device' declared inside parameter list
int alt_pr_unregister(struct device *dev);
^
drivers/fpga/altera-pr-ip-core.c:187:5: error: conflicting types for 'alt_pr_register'
int alt_pr_register(struct device *dev, void __iomem *reg_base)
^
In file included from drivers/fpga/altera-pr-ip-core.c:22:0:
include/linux/fpga/altera-pr-ip-core.h:26:5: note: previous declaration of 'alt_pr_register' was here
int alt_pr_register(struct device *dev, void __iomem *reg_base);
^
In file included from include/linux/linkage.h:7:0,
from include/linux/kernel.h:7,
from include/linux/delay.h:22,
from drivers/fpga/altera-pr-ip-core.c:21:
drivers/fpga/altera-pr-ip-core.c:206:19: error: conflicting types for 'alt_pr_register'
EXPORT_SYMBOL_GPL(alt_pr_register);
^
include/linux/export.h:65:21: note: in definition of macro '___EXPORT_SYMBOL'
extern typeof(sym) sym; \
^
drivers/fpga/altera-pr-ip-core.c:206:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
EXPORT_SYMBOL_GPL(alt_pr_register);
^
In file included from drivers/fpga/altera-pr-ip-core.c:22:0:
include/linux/fpga/altera-pr-ip-core.h:26:5: note: previous declaration of 'alt_pr_register' was here
int alt_pr_register(struct device *dev, void __iomem *reg_base);
^
drivers/fpga/altera-pr-ip-core.c:208:5: error: conflicting types for 'alt_pr_unregister'
int alt_pr_unregister(struct device *dev)
^
In file included from drivers/fpga/altera-pr-ip-core.c:22:0:
include/linux/fpga/altera-pr-ip-core.h:27:5: note: previous declaration of 'alt_pr_unregister' was here
int alt_pr_unregister(struct device *dev);
^
In file included from include/linux/linkage.h:7:0,
from include/linux/kernel.h:7,
from include/linux/delay.h:22,
from drivers/fpga/altera-pr-ip-core.c:21:
drivers/fpga/altera-pr-ip-core.c:216:19: error: conflicting types for 'alt_pr_unregister'
EXPORT_SYMBOL_GPL(alt_pr_unregister);
^
include/linux/export.h:65:21: note: in definition of macro '___EXPORT_SYMBOL'
extern typeof(sym) sym; \
^
drivers/fpga/altera-pr-ip-core.c:216:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
EXPORT_SYMBOL_GPL(alt_pr_unregister);
^
In file included from drivers/fpga/altera-pr-ip-core.c:22:0:
include/linux/fpga/altera-pr-ip-core.h:27:5: note: previous declaration of 'alt_pr_unregister' was here
int alt_pr_unregister(struct device *dev);
^
vim +/IOMEM_ERR_PTR +65 include/linux/of_address.h
29b635c0 Andrew Murray 2013-05-16 24
29b635c0 Andrew Murray 2013-05-16 25 #define for_each_of_pci_range(parser, range) \
29b635c0 Andrew Murray 2013-05-16 26 for (; of_pci_range_parser_one(parser, range);)
29b635c0 Andrew Murray 2013-05-16 27
d0dfa16a Rob Herring 2013-09-16 28 /* Translate a DMA address from device space to CPU space */
d0dfa16a Rob Herring 2013-09-16 29 extern u64 of_translate_dma_address(struct device_node *dev,
d0dfa16a Rob Herring 2013-09-16 30 const __be32 *in_addr);
d0dfa16a Rob Herring 2013-09-16 31
a850a755 Grant Likely 2012-02-14 32 #ifdef CONFIG_OF_ADDRESS
0131d897 Sebastian Andrzej Siewior 2010-12-01 33 extern u64 of_translate_address(struct device_node *np, const __be32 *addr);
1f5bef30 Grant Likely 2010-06-08 34 extern int of_address_to_resource(struct device_node *dev, int index,
1f5bef30 Grant Likely 2010-06-08 35 struct resource *r);
90e33f62 Grant Likely 2011-07-05 36 extern struct device_node *of_find_matching_node_by_address(
90e33f62 Grant Likely 2011-07-05 37 struct device_node *from,
90e33f62 Grant Likely 2011-07-05 38 const struct of_device_id *matches,
90e33f62 Grant Likely 2011-07-05 39 u64 base_address);
6b884a8d Grant Likely 2010-06-08 40 extern void __iomem *of_iomap(struct device_node *device, int index);
fcd71d9c Sudip Mukherjee 2015-12-08 41 void __iomem *of_io_request_and_map(struct device_node *device,
fcd71d9c Sudip Mukherjee 2015-12-08 42 int index, const char *name);
6b884a8d Grant Likely 2010-06-08 43
22ae782f Grant Likely 2010-07-29 44 /* Extract an address from a device, returns the region size and
22ae782f Grant Likely 2010-07-29 45 * the address space flags too. The PCI version uses a BAR number
22ae782f Grant Likely 2010-07-29 46 * instead of an absolute index
22ae782f Grant Likely 2010-07-29 47 */
47b1e689 Kim Phillips 2012-10-08 48 extern const __be32 *of_get_address(struct device_node *dev, int index,
22ae782f Grant Likely 2010-07-29 49 u64 *size, unsigned int *flags);
22ae782f Grant Likely 2010-07-29 50
29b635c0 Andrew Murray 2013-05-16 51 extern int of_pci_range_parser_init(struct of_pci_range_parser *parser,
29b635c0 Andrew Murray 2013-05-16 52 struct device_node *node);
a060c210 Marc Gonzalez 2017-09-26 53 extern int of_pci_dma_range_parser_init(struct of_pci_range_parser *parser,
a060c210 Marc Gonzalez 2017-09-26 54 struct device_node *node);
29b635c0 Andrew Murray 2013-05-16 55 extern struct of_pci_range *of_pci_range_parser_one(
29b635c0 Andrew Murray 2013-05-16 56 struct of_pci_range_parser *parser,
29b635c0 Andrew Murray 2013-05-16 57 struct of_pci_range *range);
18308c94 Grygorii Strashko 2014-04-24 58 extern int of_dma_get_range(struct device_node *np, u64 *dma_addr,
18308c94 Grygorii Strashko 2014-04-24 59 u64 *paddr, u64 *size);
92ea637e Santosh Shilimkar 2014-04-24 60 extern bool of_dma_is_coherent(struct device_node *np);
a850a755 Grant Likely 2012-02-14 61 #else /* CONFIG_OF_ADDRESS */
fcd71d9c Sudip Mukherjee 2015-12-08 62 static inline void __iomem *of_io_request_and_map(struct device_node *device,
fcd71d9c Sudip Mukherjee 2015-12-08 63 int index, const char *name)
fcd71d9c Sudip Mukherjee 2015-12-08 64 {
fcd71d9c Sudip Mukherjee 2015-12-08 @65 return IOMEM_ERR_PTR(-EINVAL);
fcd71d9c Sudip Mukherjee 2015-12-08 66 }
b1d06b60 Guenter Roeck 2015-11-06 67
:::::: The code at line 65 was first introduced by commit
:::::: fcd71d9cc6e301bdbd71829b79e80168473ca609 of: fix declaration of of_io_request_and_map
:::::: TO: Sudip Mukherjee <[email protected]>
:::::: CC: Rob Herring <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
On Mon, Jan 22, 2018 at 05:30:05PM +0800, kbuild test robot wrote:
> Hi Ladislav,
>
> Thank you for the patch! Yet something to improve:
Thank you kbuild test robot for your valueable testing, Linus Walleij
will find proposed fix bellow.
> [auto build test ERROR on next-20180119]
> [also build test ERROR on v4.15-rc9]
> [cannot apply to linus/master pci/next l2-mtd-boris/nand/next v4.15-rc8 v4.15-rc7 v4.15-rc6]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>
> url: https://github.com/0day-ci/linux/commits/Ladislav-Michl/Add-managed-ioremap-function-for-shared-resources/20180122-164512
> config: i386-tinyconfig (attached as .config)
> compiler: gcc-7 (Debian 7.2.0-12) 7.2.1 20171025
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=i386
>
> All errors (new ones prefixed by >>):
>
> In file included from include/linux/device.h:23:0,
> from drivers/base/dd.c:19:
> include/linux/pinctrl/devinfo.h:48:44: warning: 'struct device' declared inside parameter list will not be visible outside of this definition or declaration
> static inline int pinctrl_bind_pins(struct device *dev)
> ^~~~~~
> include/linux/pinctrl/devinfo.h:53:44: warning: 'struct device' declared inside parameter list will not be visible outside of this definition or declaration
> static inline int pinctrl_init_done(struct device *dev)
> ^~~~~~
> drivers/base/dd.c: In function 'really_probe':
> >> drivers/base/dd.c:394:26: error: passing argument 1 of 'pinctrl_bind_pins' from incompatible pointer type [-Werror=incompatible-pointer-types]
> ret = pinctrl_bind_pins(dev);
> ^~~
> In file included from include/linux/device.h:23:0,
> from drivers/base/dd.c:19:
> include/linux/pinctrl/devinfo.h:48:19: note: expected 'struct device *' but argument is of type 'struct device *'
> static inline int pinctrl_bind_pins(struct device *dev)
> ^~~~~~~~~~~~~~~~~
> >> drivers/base/dd.c:451:20: error: passing argument 1 of 'pinctrl_init_done' from incompatible pointer type [-Werror=incompatible-pointer-types]
> pinctrl_init_done(dev);
> ^~~
> In file included from include/linux/device.h:23:0,
> from drivers/base/dd.c:19:
> include/linux/pinctrl/devinfo.h:53:19: note: expected 'struct device *' but argument is of type 'struct device *'
> static inline int pinctrl_init_done(struct device *dev)
> ^~~~~~~~~~~~~~~~~
> cc1: some warnings being treated as errors
Linus,
after moving managed io function declarations into device.h, above error
was triggered. Please consider folowing patch:
>8--------------
From: Ladislav Michl <[email protected]>
Subject: [PATCH] include/pinctrl: Forward declare struct device
pinctrl/devinfo.h is using forward declaration from pinctrl/consumer.h
for configurations with CONFIG_PINCTRL defined, however nothing declares
it in the opposite case. Fix this by adding a forward declaration.
Signed-off-by: Ladislav Michl <[email protected]>
---
include/linux/pinctrl/devinfo.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/linux/pinctrl/devinfo.h b/include/linux/pinctrl/devinfo.h
index 05082e407c4a..d01a8638bb45 100644
--- a/include/linux/pinctrl/devinfo.h
+++ b/include/linux/pinctrl/devinfo.h
@@ -43,6 +43,8 @@ extern int pinctrl_init_done(struct device *dev);
#else
+struct device;
+
/* Stubs if we're not using pinctrl */
static inline int pinctrl_bind_pins(struct device *dev)
--
2.15.1
On Mon, Jan 22, 2018 at 12:50 PM, Ladislav Michl <[email protected]> wrote:
> Linus,
>
> after moving managed io function declarations into device.h, above error
> was triggered. Please consider folowing patch:
>
>>8--------------
>
> From: Ladislav Michl <[email protected]>
> Subject: [PATCH] include/pinctrl: Forward declare struct device
>
> pinctrl/devinfo.h is using forward declaration from pinctrl/consumer.h
> for configurations with CONFIG_PINCTRL defined, however nothing declares
> it in the opposite case. Fix this by adding a forward declaration.
>
> Signed-off-by: Ladislav Michl <[email protected]>
Ah good catch.
Patch applied.
Yours,
Linus Walleij
On Mon, Jan 22, 2018 at 06:08:57PM +0800, kbuild test robot wrote:
> Hi Ladislav,
>
> Thank you for the patch! Yet something to improve:
Thank you kbuild test robot for your valueable testing, Matthew Gerlach
will find proposed fix bellow.
> [auto build test ERROR on next-20180119]
> [also build test ERROR on v4.15-rc9]
> [cannot apply to linus/master pci/next l2-mtd-boris/nand/next v4.15-rc8 v4.15-rc7 v4.15-rc6]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>
> url: https://github.com/0day-ci/linux/commits/Ladislav-Michl/Add-managed-ioremap-function-for-shared-resources/20180122-164512
> config: i386-randconfig-a0-201803 (attached as .config)
> compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=i386
>
> All error/warnings (new ones prefixed by >>):
>
> In file included from drivers/mfd/syscon.c:21:0:
> include/linux/of_address.h: In function 'of_io_request_and_map':
> >> include/linux/of_address.h:65:2: error: implicit declaration of function 'IOMEM_ERR_PTR' [-Werror=implicit-function-declaration]
> return IOMEM_ERR_PTR(-EINVAL);
> ^
> >> include/linux/of_address.h:65:2: warning: return makes pointer from integer without a cast
> cc1: some warnings being treated as errors
This one is caused by accidental move of IOMEM_ERR_PTR, which will be fixed
in v2.
> In file included from drivers//fpga/altera-pr-ip-core.c:22:0:
> >> include/linux/fpga/altera-pr-ip-core.h:26:28: warning: 'struct device' declared inside parameter list
> int alt_pr_register(struct device *dev, void __iomem *reg_base);
> ^
> >> include/linux/fpga/altera-pr-ip-core.h:26:28: warning: its scope is only this definition or declaration, which is probably not what you want
> include/linux/fpga/altera-pr-ip-core.h:27:30: warning: 'struct device' declared inside parameter list
> int alt_pr_unregister(struct device *dev);
> ^
> >> drivers//fpga/altera-pr-ip-core.c:187:5: error: conflicting types for 'alt_pr_register'
> int alt_pr_register(struct device *dev, void __iomem *reg_base)
> ^
> In file included from drivers//fpga/altera-pr-ip-core.c:22:0:
> include/linux/fpga/altera-pr-ip-core.h:26:5: note: previous declaration of 'alt_pr_register' was here
> int alt_pr_register(struct device *dev, void __iomem *reg_base);
> ^
> In file included from include/linux/linkage.h:7:0,
> from include/linux/kernel.h:7,
> from include/linux/delay.h:22,
> from drivers//fpga/altera-pr-ip-core.c:21:
> drivers//fpga/altera-pr-ip-core.c:206:19: error: conflicting types for 'alt_pr_register'
> EXPORT_SYMBOL_GPL(alt_pr_register);
> ^
> include/linux/export.h:65:21: note: in definition of macro '___EXPORT_SYMBOL'
> extern typeof(sym) sym; \
> ^
> drivers//fpga/altera-pr-ip-core.c:206:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
> EXPORT_SYMBOL_GPL(alt_pr_register);
> ^
> In file included from drivers//fpga/altera-pr-ip-core.c:22:0:
> include/linux/fpga/altera-pr-ip-core.h:26:5: note: previous declaration of 'alt_pr_register' was here
> int alt_pr_register(struct device *dev, void __iomem *reg_base);
> ^
> >> drivers//fpga/altera-pr-ip-core.c:208:5: error: conflicting types for 'alt_pr_unregister'
> int alt_pr_unregister(struct device *dev)
> ^
> In file included from drivers//fpga/altera-pr-ip-core.c:22:0:
> include/linux/fpga/altera-pr-ip-core.h:27:5: note: previous declaration of 'alt_pr_unregister' was here
> int alt_pr_unregister(struct device *dev);
> ^
> In file included from include/linux/linkage.h:7:0,
> from include/linux/kernel.h:7,
> from include/linux/delay.h:22,
> from drivers//fpga/altera-pr-ip-core.c:21:
> drivers//fpga/altera-pr-ip-core.c:216:19: error: conflicting types for 'alt_pr_unregister'
> EXPORT_SYMBOL_GPL(alt_pr_unregister);
> ^
> include/linux/export.h:65:21: note: in definition of macro '___EXPORT_SYMBOL'
> extern typeof(sym) sym; \
> ^
> drivers//fpga/altera-pr-ip-core.c:216:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
> EXPORT_SYMBOL_GPL(alt_pr_unregister);
> ^
> In file included from drivers//fpga/altera-pr-ip-core.c:22:0:
> include/linux/fpga/altera-pr-ip-core.h:27:5: note: previous declaration of 'alt_pr_unregister' was here
> int alt_pr_unregister(struct device *dev);
> ^
> --
> In file included from drivers/fpga/altera-pr-ip-core.c:22:0:
> >> include/linux/fpga/altera-pr-ip-core.h:26:28: warning: 'struct device' declared inside parameter list
> int alt_pr_register(struct device *dev, void __iomem *reg_base);
> ^
> >> include/linux/fpga/altera-pr-ip-core.h:26:28: warning: its scope is only this definition or declaration, which is probably not what you want
> include/linux/fpga/altera-pr-ip-core.h:27:30: warning: 'struct device' declared inside parameter list
> int alt_pr_unregister(struct device *dev);
> ^
> drivers/fpga/altera-pr-ip-core.c:187:5: error: conflicting types for 'alt_pr_register'
> int alt_pr_register(struct device *dev, void __iomem *reg_base)
> ^
> In file included from drivers/fpga/altera-pr-ip-core.c:22:0:
> include/linux/fpga/altera-pr-ip-core.h:26:5: note: previous declaration of 'alt_pr_register' was here
> int alt_pr_register(struct device *dev, void __iomem *reg_base);
> ^
> In file included from include/linux/linkage.h:7:0,
> from include/linux/kernel.h:7,
> from include/linux/delay.h:22,
> from drivers/fpga/altera-pr-ip-core.c:21:
> drivers/fpga/altera-pr-ip-core.c:206:19: error: conflicting types for 'alt_pr_register'
> EXPORT_SYMBOL_GPL(alt_pr_register);
> ^
> include/linux/export.h:65:21: note: in definition of macro '___EXPORT_SYMBOL'
> extern typeof(sym) sym; \
> ^
> drivers/fpga/altera-pr-ip-core.c:206:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
> EXPORT_SYMBOL_GPL(alt_pr_register);
> ^
> In file included from drivers/fpga/altera-pr-ip-core.c:22:0:
> include/linux/fpga/altera-pr-ip-core.h:26:5: note: previous declaration of 'alt_pr_register' was here
> int alt_pr_register(struct device *dev, void __iomem *reg_base);
> ^
> drivers/fpga/altera-pr-ip-core.c:208:5: error: conflicting types for 'alt_pr_unregister'
> int alt_pr_unregister(struct device *dev)
> ^
> In file included from drivers/fpga/altera-pr-ip-core.c:22:0:
> include/linux/fpga/altera-pr-ip-core.h:27:5: note: previous declaration of 'alt_pr_unregister' was here
> int alt_pr_unregister(struct device *dev);
> ^
> In file included from include/linux/linkage.h:7:0,
> from include/linux/kernel.h:7,
> from include/linux/delay.h:22,
> from drivers/fpga/altera-pr-ip-core.c:21:
> drivers/fpga/altera-pr-ip-core.c:216:19: error: conflicting types for 'alt_pr_unregister'
> EXPORT_SYMBOL_GPL(alt_pr_unregister);
> ^
> include/linux/export.h:65:21: note: in definition of macro '___EXPORT_SYMBOL'
> extern typeof(sym) sym; \
> ^
> drivers/fpga/altera-pr-ip-core.c:216:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
> EXPORT_SYMBOL_GPL(alt_pr_unregister);
> ^
> In file included from drivers/fpga/altera-pr-ip-core.c:22:0:
> include/linux/fpga/altera-pr-ip-core.h:27:5: note: previous declaration of 'alt_pr_unregister' was here
> int alt_pr_unregister(struct device *dev);
> ^
Dear Matthew,
after moving managed io function declarations into device.h, above error
was triggered. As this stuff seems to be used with device model anyway,
please consider folowing patch:
>8-------------------
From: Ladislav Michl <[email protected]>
Subject: [PATCH] fpga pr ip: Include device.h to get 'struct device'
Include device.h instead of io.h to get 'struct device'
and allow moving managed io function declarations out of
io.h
Signed-off-by: Ladislav Michl <[email protected]>
---
include/linux/fpga/altera-pr-ip-core.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/fpga/altera-pr-ip-core.h b/include/linux/fpga/altera-pr-ip-core.h
index 3810a9033f49..36147005d6df 100644
--- a/include/linux/fpga/altera-pr-ip-core.h
+++ b/include/linux/fpga/altera-pr-ip-core.h
@@ -21,7 +21,7 @@
#ifndef _ALT_PR_IP_CORE_H
#define _ALT_PR_IP_CORE_H
-#include <linux/io.h>
+#include <linux/device.h>
int alt_pr_register(struct device *dev, void __iomem *reg_base);
int alt_pr_unregister(struct device *dev);
--
2.15.1
On Sun, Jan 21, 2018 at 10:15:08PM +0100, Ladislav Michl wrote:
> Moving managed io function declarations into device.h allows
> removing forward struct device and resource definitions from
> io(port).h
In the face of it, what is the issue with forward declarations of device
and resource structures? device.h is supposed to be about Linux device
model, not hardware. You would not want all devm_* functions to go into
device.h (clock, regulator, input, rtc, hwmon, etc, etc devm API),
right? Why would we want ioport there?
Thanks.
--
Dmitry
On Mon, Jan 22, 2018 at 09:49:03AM -0800, Dmitry Torokhov wrote:
> On Sun, Jan 21, 2018 at 10:15:08PM +0100, Ladislav Michl wrote:
> > Moving managed io function declarations into device.h allows
> > removing forward struct device and resource definitions from
> > io(port).h
>
> In the face of it, what is the issue with forward declarations of device
> and resource structures? device.h is supposed to be about Linux device
> model, not hardware. You would not want all devm_* functions to go into
> device.h (clock, regulator, input, rtc, hwmon, etc, etc devm API),
> right? Why would we want ioport there?
Allright, point taken. Then I would assume devm_ioremap_resource should
be moved from device.h into io.h, to get some consistency, right?
Any other comment (mainly to devm_ioremap_shared_resource) before v2?
Thank you,
ladis
On Mon, Jan 22, 2018 at 10:50:57PM +0100, Ladislav Michl wrote:
> On Mon, Jan 22, 2018 at 09:49:03AM -0800, Dmitry Torokhov wrote:
> > On Sun, Jan 21, 2018 at 10:15:08PM +0100, Ladislav Michl wrote:
> > > Moving managed io function declarations into device.h allows
> > > removing forward struct device and resource definitions from
> > > io(port).h
> >
> > In the face of it, what is the issue with forward declarations of device
> > and resource structures? device.h is supposed to be about Linux device
> > model, not hardware. You would not want all devm_* functions to go into
> > device.h (clock, regulator, input, rtc, hwmon, etc, etc devm API),
> > right? Why would we want ioport there?
>
> Allright, point taken. Then I would assume devm_ioremap_resource should
> be moved from device.h into io.h, to get some consistency, right?
Yes, I think that would be good.
> Any other comment (mainly to devm_ioremap_shared_resource) before v2?
>
> Thank you,
> ladis
Thanks.
--
Dmitry
On Sun, Jan 21, 2018 at 10:15:39PM +0100, Ladislav Michl wrote:
> devm_pci_remap_cfgspace() is using devm_ioremap_release()
> devres release function. Move it to devres along with
> similar PCI functions to allow hiding devm_ioremap_release()
> from public.
So we are sharing this function:
void devm_ioremap_release(struct device *dev, void *res)
{
iounmap(*(void __iomem **)res);
}
and we want to hide it, and for that we are moving a lot of PCI-specific
stuff into lib/devres.c. If anything, I'd say we should move more PCI
stuff _out_ of lib/devres.c, and if we wait to make local copy and call
it devm_pci_cfgspace_release() that woudl be fine with me.
Anyway, up to the maintainers.
Thanks.
--
Dmitry
On Mon, Jan 22, 2018 at 03:33:52PM -0800, Dmitry Torokhov wrote:
> On Sun, Jan 21, 2018 at 10:15:39PM +0100, Ladislav Michl wrote:
> > devm_pci_remap_cfgspace() is using devm_ioremap_release()
> > devres release function. Move it to devres along with
> > similar PCI functions to allow hiding devm_ioremap_release()
> > from public.
>
> So we are sharing this function:
>
> void devm_ioremap_release(struct device *dev, void *res)
> {
> iounmap(*(void __iomem **)res);
> }
>
> and we want to hide it, and for that we are moving a lot of PCI-specific
> stuff into lib/devres.c. If anything, I'd say we should move more PCI
> stuff _out_ of lib/devres.c, and if we wait to make local copy and call
> it devm_pci_cfgspace_release() that woudl be fine with me.
Well, that's fine with me too. Will send v2 without all these changes.
> Anyway, up to the maintainers.
>
> Thanks.
Thank you,
ladis