diff mbox series

[v4,01/20] driver core: Split devres APIs to device/devres.h

Message ID 20250210064906.2181867-2-raag.jadav@intel.com
State New
Headers show
Series Split devres APIs to device/devres.h and introduce devm_kmemdup_array() | expand

Commit Message

Raag Jadav Feb. 10, 2025, 6:48 a.m. UTC
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

device.h is a huge header which is hard to follow and easy to miss
something. Improve that by splitting devres APIs to device/devres.h.

In particular this helps to speedup the build of the code that includes
device.h solely for a devres APIs.

While at it, cast the error pointers to __iomem using IOMEM_ERR_PTR()
and fix sparse warnings.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
 include/linux/device.h        | 119 +-------------------------------
 include/linux/device/devres.h | 125 ++++++++++++++++++++++++++++++++++
 2 files changed, 126 insertions(+), 118 deletions(-)
 create mode 100644 include/linux/device/devres.h

Comments

kernel test robot Feb. 10, 2025, 2:08 p.m. UTC | #1
Hi Raag,

kernel test robot noticed the following build errors:

[auto build test ERROR on a1e062ab4a1f19bb0e94093ef90ab9a74f1f7744]

url:    https://github.com/intel-lab-lkp/linux/commits/Raag-Jadav/driver-core-Split-devres-APIs-to-device-devres-h/20250210-145732
base:   a1e062ab4a1f19bb0e94093ef90ab9a74f1f7744
patch link:    https://lore.kernel.org/r/20250210064906.2181867-2-raag.jadav%40intel.com
patch subject: [PATCH v4 01/20] driver core: Split devres APIs to device/devres.h
config: powerpc-randconfig-003-20250210 (https://download.01.org/0day-ci/archive/20250210/202502102137.SA3rtuTB-lkp@intel.com/config)
compiler: powerpc-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250210/202502102137.SA3rtuTB-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202502102137.SA3rtuTB-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from include/linux/device/devres.h:7,
                    from include/linux/device.h:31,
                    from arch/powerpc/include/asm/io.h:22,
                    from drivers/video/fbdev/sis/init.h:64,
                    from drivers/video/fbdev/sis/init.c:59:
   include/linux/io.h: In function 'pci_remap_cfgspace':
>> include/linux/io.h:106:16: error: implicit declaration of function 'ioremap_np' [-Wimplicit-function-declaration]
     106 |         return ioremap_np(offset, size) ?: ioremap(offset, size);
         |                ^~~~~~~~~~
>> include/linux/io.h:106:44: error: implicit declaration of function 'ioremap' [-Wimplicit-function-declaration]
     106 |         return ioremap_np(offset, size) ?: ioremap(offset, size);
         |                                            ^~~~~~~
>> include/linux/io.h:106:42: error: returning 'int' from a function with return type 'void *' makes pointer from integer without a cast [-Wint-conversion]
     106 |         return ioremap_np(offset, size) ?: ioremap(offset, size);
         |                ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
   arch/powerpc/include/asm/io.h: At top level:
>> arch/powerpc/include/asm/io.h:885:22: error: conflicting types for 'ioremap'; have 'void *(phys_addr_t,  long unsigned int)' {aka 'void *(unsigned int,  long unsigned int)'}
     885 | extern void __iomem *ioremap(phys_addr_t address, unsigned long size);
         |                      ^~~~~~~
   include/linux/io.h:106:44: note: previous implicit declaration of 'ioremap' with type 'int()'
     106 |         return ioremap_np(offset, size) ?: ioremap(offset, size);
         |                                            ^~~~~~~
   In file included from arch/powerpc/include/asm/io.h:1031:
>> include/asm-generic/io.h:1161:20: error: conflicting types for 'ioremap_np'; have 'void *(phys_addr_t,  size_t)' {aka 'void *(unsigned int,  unsigned int)'}
    1161 | #define ioremap_np ioremap_np
         |                    ^~~~~~~~~~
   include/asm-generic/io.h:1162:29: note: in expansion of macro 'ioremap_np'
    1162 | static inline void __iomem *ioremap_np(phys_addr_t offset, size_t size)
         |                             ^~~~~~~~~~
   include/linux/io.h:106:16: note: previous implicit declaration of 'ioremap_np' with type 'int()'
     106 |         return ioremap_np(offset, size) ?: ioremap(offset, size);
         |                ^~~~~~~~~~
--
   In file included from include/linux/device/devres.h:7,
                    from include/linux/device.h:31,
                    from arch/powerpc/include/asm/io.h:22,
                    from drivers/video/fbdev/sis/init301.h:64,
                    from drivers/video/fbdev/sis/init301.c:72:
   include/linux/io.h: In function 'pci_remap_cfgspace':
>> include/linux/io.h:106:16: error: implicit declaration of function 'ioremap_np' [-Wimplicit-function-declaration]
     106 |         return ioremap_np(offset, size) ?: ioremap(offset, size);
         |                ^~~~~~~~~~
>> include/linux/io.h:106:44: error: implicit declaration of function 'ioremap' [-Wimplicit-function-declaration]
     106 |         return ioremap_np(offset, size) ?: ioremap(offset, size);
         |                                            ^~~~~~~
>> include/linux/io.h:106:42: error: returning 'int' from a function with return type 'void *' makes pointer from integer without a cast [-Wint-conversion]
     106 |         return ioremap_np(offset, size) ?: ioremap(offset, size);
         |                ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
   arch/powerpc/include/asm/io.h: At top level:
>> arch/powerpc/include/asm/io.h:885:22: error: conflicting types for 'ioremap'; have 'void *(phys_addr_t,  long unsigned int)' {aka 'void *(unsigned int,  long unsigned int)'}
     885 | extern void __iomem *ioremap(phys_addr_t address, unsigned long size);
         |                      ^~~~~~~
   include/linux/io.h:106:44: note: previous implicit declaration of 'ioremap' with type 'int()'
     106 |         return ioremap_np(offset, size) ?: ioremap(offset, size);
         |                                            ^~~~~~~
   In file included from arch/powerpc/include/asm/io.h:1031:
>> include/asm-generic/io.h:1161:20: error: conflicting types for 'ioremap_np'; have 'void *(phys_addr_t,  size_t)' {aka 'void *(unsigned int,  unsigned int)'}
    1161 | #define ioremap_np ioremap_np
         |                    ^~~~~~~~~~
   include/asm-generic/io.h:1162:29: note: in expansion of macro 'ioremap_np'
    1162 | static inline void __iomem *ioremap_np(phys_addr_t offset, size_t size)
         |                             ^~~~~~~~~~
   include/linux/io.h:106:16: note: previous implicit declaration of 'ioremap_np' with type 'int()'
     106 |         return ioremap_np(offset, size) ?: ioremap(offset, size);
         |                ^~~~~~~~~~
   drivers/video/fbdev/sis/init301.c: In function 'SiS_SetCRT2ModeRegs':
   drivers/video/fbdev/sis/init301.c:2687:24: warning: variable 'modeflag' set but not used [-Wunused-but-set-variable]
    2687 |   unsigned short i, j, modeflag, tempah=0;
         |                        ^~~~~~~~
   drivers/video/fbdev/sis/init301.c: In function 'SiS_SetGroup1':
   drivers/video/fbdev/sis/init301.c:6233:52: warning: variable 'resinfo' set but not used [-Wunused-but-set-variable]
    6233 |   unsigned short  pushbx=0, CRT1Index=0, modeflag, resinfo=0;
         |                                                    ^~~~~~~


vim +/ioremap_np +106 include/linux/io.h

7d3dcf26a6559f Christoph Hellwig 2015-08-10   84  
4d312ac057da57 Arnd Bergmann     2023-05-16   85  /* architectures can override this */
4d312ac057da57 Arnd Bergmann     2023-05-16   86  pgprot_t __init early_memremap_pgprot_adjust(resource_size_t phys_addr,
4d312ac057da57 Arnd Bergmann     2023-05-16   87  					unsigned long size, pgprot_t prot);
4d312ac057da57 Arnd Bergmann     2023-05-16   88  
4d312ac057da57 Arnd Bergmann     2023-05-16   89  
cf9ea8ca4a0bea Lorenzo Pieralisi 2017-04-19   90  #ifdef CONFIG_PCI
cf9ea8ca4a0bea Lorenzo Pieralisi 2017-04-19   91  /*
cf9ea8ca4a0bea Lorenzo Pieralisi 2017-04-19   92   * The PCI specifications (Rev 3.0, 3.2.5 "Transaction Ordering and
b10eb2d50911f9 Hector Martin     2021-03-25   93   * Posting") mandate non-posted configuration transactions. This default
b10eb2d50911f9 Hector Martin     2021-03-25   94   * implementation attempts to use the ioremap_np() API to provide this
b10eb2d50911f9 Hector Martin     2021-03-25   95   * on arches that support it, and falls back to ioremap() on those that
b10eb2d50911f9 Hector Martin     2021-03-25   96   * don't. Overriding this function is deprecated; arches that properly
b10eb2d50911f9 Hector Martin     2021-03-25   97   * support non-posted accesses should implement ioremap_np() instead, which
b10eb2d50911f9 Hector Martin     2021-03-25   98   * this default implementation can then use to return mappings compliant with
b10eb2d50911f9 Hector Martin     2021-03-25   99   * the PCI specification.
cf9ea8ca4a0bea Lorenzo Pieralisi 2017-04-19  100   */
cf9ea8ca4a0bea Lorenzo Pieralisi 2017-04-19  101  #ifndef pci_remap_cfgspace
cf9ea8ca4a0bea Lorenzo Pieralisi 2017-04-19  102  #define pci_remap_cfgspace pci_remap_cfgspace
cf9ea8ca4a0bea Lorenzo Pieralisi 2017-04-19  103  static inline void __iomem *pci_remap_cfgspace(phys_addr_t offset,
cf9ea8ca4a0bea Lorenzo Pieralisi 2017-04-19  104  					       size_t size)
cf9ea8ca4a0bea Lorenzo Pieralisi 2017-04-19  105  {
b10eb2d50911f9 Hector Martin     2021-03-25 @106  	return ioremap_np(offset, size) ?: ioremap(offset, size);
cf9ea8ca4a0bea Lorenzo Pieralisi 2017-04-19  107  }
cf9ea8ca4a0bea Lorenzo Pieralisi 2017-04-19  108  #endif
cf9ea8ca4a0bea Lorenzo Pieralisi 2017-04-19  109  #endif
cf9ea8ca4a0bea Lorenzo Pieralisi 2017-04-19  110
Andy Shevchenko Feb. 10, 2025, 3:23 p.m. UTC | #2
+Cc: Arnd

On Mon, Feb 10, 2025 at 10:30:28PM +0800, kernel test robot wrote:
> Hi Raag,
> 
> kernel test robot noticed the following build errors:
> 
> [auto build test ERROR on a1e062ab4a1f19bb0e94093ef90ab9a74f1f7744]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Raag-Jadav/driver-core-Split-devres-APIs-to-device-devres-h/20250210-145732
> base:   a1e062ab4a1f19bb0e94093ef90ab9a74f1f7744
> patch link:    https://lore.kernel.org/r/20250210064906.2181867-2-raag.jadav%40intel.com
> patch subject: [PATCH v4 01/20] driver core: Split devres APIs to device/devres.h
> config: powerpc64-randconfig-002-20250210 (https://download.01.org/0day-ci/archive/20250210/202502102201.zLWaJC6V-lkp@intel.com/config)
> compiler: powerpc64-linux-gcc (GCC) 14.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250210/202502102201.zLWaJC6V-lkp@intel.com/reproduce)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202502102201.zLWaJC6V-lkp@intel.com/
> 
> All error/warnings (new ones prefixed by >>):

TBH I have no quick idea how to address this. It seems that io.h includes device.h
for no reason (but I haven't checked that carefully). OTOH, we need only
IOMEM_IS_ERR() definition which can simply be moved from io.h to err.h as the
former includes the latter and the definition depends only on compiler_types.h.

Arnd?

>    In file included from include/linux/device/devres.h:7,
>                     from include/linux/device.h:31,
>                     from arch/powerpc/include/asm/io.h:22,
>                     from include/linux/scatterlist.h:9,
>                     from crypto/rsassa-pkcs1.c:11:
>    include/linux/io.h: In function 'pci_remap_cfgspace':
>    include/linux/io.h:106:16: error: implicit declaration of function 'ioremap_np' [-Wimplicit-function-declaration]
>      106 |         return ioremap_np(offset, size) ?: ioremap(offset, size);
>          |                ^~~~~~~~~~
>    include/linux/io.h:106:44: error: implicit declaration of function 'ioremap' [-Wimplicit-function-declaration]
>      106 |         return ioremap_np(offset, size) ?: ioremap(offset, size);
>          |                                            ^~~~~~~
>    include/linux/io.h:106:42: error: returning 'int' from a function with return type 'void *' makes pointer from integer without a cast [-Wint-conversion]
>      106 |         return ioremap_np(offset, size) ?: ioremap(offset, size);
>          |                ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
>    arch/powerpc/include/asm/io.h: At top level:
> >> arch/powerpc/include/asm/io.h:885:22: error: conflicting types for 'ioremap'; have 'void *(phys_addr_t,  long unsigned int)' {aka 'void *(long long unsigned int,  long unsigned int)'}
>      885 | extern void __iomem *ioremap(phys_addr_t address, unsigned long size);
>          |                      ^~~~~~~
>    include/linux/io.h:106:44: note: previous implicit declaration of 'ioremap' with type 'int()'
>      106 |         return ioremap_np(offset, size) ?: ioremap(offset, size);
>          |                                            ^~~~~~~
>    In file included from include/asm-generic/io.h:17,
>                     from arch/powerpc/include/asm/io.h:1031:
> >> include/asm-generic/iomap.h:106:20: error: conflicting types for 'ioremap_np'; have 'void *(phys_addr_t,  size_t)' {aka 'void *(long long unsigned int,  long unsigned int)'}
>      106 | #define ioremap_np ioremap_np
>          |                    ^~~~~~~~~~
>    include/asm-generic/iomap.h:107:29: note: in expansion of macro 'ioremap_np'
>      107 | static inline void __iomem *ioremap_np(phys_addr_t offset, size_t size)
>          |                             ^~~~~~~~~~
>    include/linux/io.h:106:16: note: previous implicit declaration of 'ioremap_np' with type 'int()'
>      106 |         return ioremap_np(offset, size) ?: ioremap(offset, size);
>          |                ^~~~~~~~~~
> --
>    In file included from arch/powerpc/include/asm/io.h:274,
>                     from include/linux/io.h:14,
>                     from include/linux/device/devres.h:7,
>                     from include/linux/device.h:31,
>                     from include/linux/acpi.h:14,
>                     from include/linux/i2c.h:13,
>                     from drivers/input/touchscreen/ili210x.c:5:
> >> arch/powerpc/include/asm/eeh.h:304:45: warning: 'struct iommu_group' declared inside parameter list will not be visible outside of this definition or declaration
>      304 | struct eeh_pe *eeh_iommu_group_to_pe(struct iommu_group *group);
>          |                                             ^~~~~~~~~~~
> --
>    In file included from arch/powerpc/include/asm/io.h:274,
>                     from include/linux/io.h:14,
>                     from include/linux/device/devres.h:7,
>                     from include/linux/device.h:31,
>                     from include/linux/input.h:19,
>                     from drivers/input/touchscreen/touchright.c:17:
> >> arch/powerpc/include/asm/eeh.h:304:45: warning: 'struct iommu_group' declared inside parameter list will not be visible outside of this definition or declaration
>      304 | struct eeh_pe *eeh_iommu_group_to_pe(struct iommu_group *group);
>          |                                             ^~~~~~~~~~~
>    drivers/input/touchscreen/touchright.c: In function 'tr_connect':
>    drivers/input/touchscreen/touchright.c:114:49: warning: '/input0' directive output may be truncated writing 7 bytes into a region of size between 1 and 32 [-Wformat-truncation=]
>      114 |         snprintf(tr->phys, sizeof(tr->phys), "%s/input0", serio->phys);
>          |                                                 ^~~~~~~
>    drivers/input/touchscreen/touchright.c:114:9: note: 'snprintf' output between 8 and 39 bytes into a destination of size 32
>      114 |         snprintf(tr->phys, sizeof(tr->phys), "%s/input0", serio->phys);
>          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> --
>    In file included from arch/powerpc/include/asm/io.h:274,
>                     from include/linux/io.h:14,
>                     from include/linux/device/devres.h:7,
>                     from include/linux/device.h:31,
>                     from include/linux/input.h:19,
>                     from drivers/input/touchscreen/penmount.c:17:
> >> arch/powerpc/include/asm/eeh.h:304:45: warning: 'struct iommu_group' declared inside parameter list will not be visible outside of this definition or declaration
>      304 | struct eeh_pe *eeh_iommu_group_to_pe(struct iommu_group *group);
>          |                                             ^~~~~~~~~~~
>    drivers/input/touchscreen/penmount.c: In function 'pm_connect':
>    drivers/input/touchscreen/penmount.c:211:49: warning: '/input0' directive output may be truncated writing 7 bytes into a region of size between 1 and 32 [-Wformat-truncation=]
>      211 |         snprintf(pm->phys, sizeof(pm->phys), "%s/input0", serio->phys);
>          |                                                 ^~~~~~~
>    drivers/input/touchscreen/penmount.c:211:9: note: 'snprintf' output between 8 and 39 bytes into a destination of size 32
>      211 |         snprintf(pm->phys, sizeof(pm->phys), "%s/input0", serio->phys);
>          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> --
>    In file included from arch/powerpc/include/asm/io.h:274,
>                     from include/linux/io.h:14,
>                     from include/linux/device/devres.h:7,
>                     from include/linux/device.h:31,
>                     from include/linux/input.h:19,
>                     from drivers/input/touchscreen/inexio.c:19:
> >> arch/powerpc/include/asm/eeh.h:304:45: warning: 'struct iommu_group' declared inside parameter list will not be visible outside of this definition or declaration
>      304 | struct eeh_pe *eeh_iommu_group_to_pe(struct iommu_group *group);
>          |                                             ^~~~~~~~~~~
>    drivers/input/touchscreen/inexio.c: In function 'inexio_connect':
>    drivers/input/touchscreen/inexio.c:126:59: warning: '/input0' directive output may be truncated writing 7 bytes into a region of size between 1 and 32 [-Wformat-truncation=]
>      126 |         snprintf(pinexio->phys, sizeof(pinexio->phys), "%s/input0", serio->phys);
>          |                                                           ^~~~~~~
>    drivers/input/touchscreen/inexio.c:126:9: note: 'snprintf' output between 8 and 39 bytes into a destination of size 32
>      126 |         snprintf(pinexio->phys, sizeof(pinexio->phys), "%s/input0", serio->phys);
>          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> --
>    In file included from arch/powerpc/include/asm/io.h:274,
>                     from include/linux/io.h:14,
>                     from include/linux/device/devres.h:7,
>                     from include/linux/device.h:31,
>                     from include/linux/input.h:19,
>                     from drivers/input/touchscreen/touchwin.c:24:
> >> arch/powerpc/include/asm/eeh.h:304:45: warning: 'struct iommu_group' declared inside parameter list will not be visible outside of this definition or declaration
>      304 | struct eeh_pe *eeh_iommu_group_to_pe(struct iommu_group *group);
>          |                                             ^~~~~~~~~~~
>    drivers/input/touchscreen/touchwin.c: In function 'tw_connect':
>    drivers/input/touchscreen/touchwin.c:121:49: warning: '/input0' directive output may be truncated writing 7 bytes into a region of size between 1 and 32 [-Wformat-truncation=]
>      121 |         snprintf(tw->phys, sizeof(tw->phys), "%s/input0", serio->phys);
>          |                                                 ^~~~~~~
>    drivers/input/touchscreen/touchwin.c:121:9: note: 'snprintf' output between 8 and 39 bytes into a destination of size 32
>      121 |         snprintf(tw->phys, sizeof(tw->phys), "%s/input0", serio->phys);
>          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> --
>    In file included from arch/powerpc/include/asm/io.h:274,
>                     from include/linux/io.h:14,
>                     from include/linux/device/devres.h:7,
>                     from include/linux/device.h:31,
>                     from include/linux/input.h:19,
>                     from drivers/input/touchscreen/hampshire.c:19:
> >> arch/powerpc/include/asm/eeh.h:304:45: warning: 'struct iommu_group' declared inside parameter list will not be visible outside of this definition or declaration
>      304 | struct eeh_pe *eeh_iommu_group_to_pe(struct iommu_group *group);
>          |                                             ^~~~~~~~~~~
>    drivers/input/touchscreen/hampshire.c: In function 'hampshire_connect':
>    drivers/input/touchscreen/hampshire.c:122:21: warning: '/input0' directive output may be truncated writing 7 bytes into a region of size between 1 and 32 [-Wformat-truncation=]
>      122 |                  "%s/input0", serio->phys);
>          |                     ^~~~~~~
>    drivers/input/touchscreen/hampshire.c:121:9: note: 'snprintf' output between 8 and 39 bytes into a destination of size 32
>      121 |         snprintf(phampshire->phys, sizeof(phampshire->phys),
>          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>      122 |                  "%s/input0", serio->phys);
>          |                  ~~~~~~~~~~~~~~~~~~~~~~~~~
> --
>    In file included from arch/powerpc/include/asm/io.h:274,
>                     from include/linux/io.h:14,
>                     from include/linux/device/devres.h:7,
>                     from include/linux/device.h:31,
>                     from include/linux/input.h:19,
>                     from drivers/input/touchscreen/tsc40.c:12:
> >> arch/powerpc/include/asm/eeh.h:304:45: warning: 'struct iommu_group' declared inside parameter list will not be visible outside of this definition or declaration
>      304 | struct eeh_pe *eeh_iommu_group_to_pe(struct iommu_group *group);
>          |                                             ^~~~~~~~~~~
>    drivers/input/touchscreen/tsc40.c: In function 'tsc_connect':
>    drivers/input/touchscreen/tsc40.c:95:53: warning: '/input0' directive output may be truncated writing 7 bytes into a region of size between 1 and 32 [-Wformat-truncation=]
>       95 |         snprintf(ptsc->phys, sizeof(ptsc->phys), "%s/input0", serio->phys);
>          |                                                     ^~~~~~~
>    drivers/input/touchscreen/tsc40.c:95:9: note: 'snprintf' output between 8 and 39 bytes into a destination of size 32
>       95 |         snprintf(ptsc->phys, sizeof(ptsc->phys), "%s/input0", serio->phys);
>          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> --
>    In file included from arch/powerpc/include/asm/io.h:274,
>                     from include/linux/io.h:14,
>                     from include/linux/device/devres.h:7,
>                     from include/linux/device.h:31,
>                     from include/linux/input.h:19,
>                     from drivers/input/touchscreen/dynapro.c:20:
> >> arch/powerpc/include/asm/eeh.h:304:45: warning: 'struct iommu_group' declared inside parameter list will not be visible outside of this definition or declaration
>      304 | struct eeh_pe *eeh_iommu_group_to_pe(struct iommu_group *group);
>          |                                             ^~~~~~~~~~~
>    drivers/input/touchscreen/dynapro.c: In function 'dynapro_connect':
>    drivers/input/touchscreen/dynapro.c:123:21: warning: '/input0' directive output may be truncated writing 7 bytes into a region of size between 1 and 32 [-Wformat-truncation=]
>      123 |                  "%s/input0", serio->phys);
>          |                     ^~~~~~~
>    drivers/input/touchscreen/dynapro.c:122:9: note: 'snprintf' output between 8 and 39 bytes into a destination of size 32
>      122 |         snprintf(pdynapro->phys, sizeof(pdynapro->phys),
>          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>      123 |                  "%s/input0", serio->phys);
>          |                  ~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> 
> vim +885 arch/powerpc/include/asm/io.h
> 
> ^1da177e4c3f415 include/asm-ppc64/io.h        Linus Torvalds         2005-04-16  853  
> ^1da177e4c3f415 include/asm-ppc64/io.h        Linus Torvalds         2005-04-16  854  /**
> ^1da177e4c3f415 include/asm-ppc64/io.h        Linus Torvalds         2005-04-16  855   * ioremap     -   map bus memory into CPU space
> ^1da177e4c3f415 include/asm-ppc64/io.h        Linus Torvalds         2005-04-16  856   * @address:   bus address of the memory
> ^1da177e4c3f415 include/asm-ppc64/io.h        Linus Torvalds         2005-04-16  857   * @size:      size of the resource to map
> ^1da177e4c3f415 include/asm-ppc64/io.h        Linus Torvalds         2005-04-16  858   *
> ^1da177e4c3f415 include/asm-ppc64/io.h        Linus Torvalds         2005-04-16  859   * ioremap performs a platform specific sequence of operations to
> ^1da177e4c3f415 include/asm-ppc64/io.h        Linus Torvalds         2005-04-16  860   * make bus memory CPU accessible via the readb/readw/readl/writeb/
> ^1da177e4c3f415 include/asm-ppc64/io.h        Linus Torvalds         2005-04-16  861   * writew/writel functions and the other mmio helpers. The returned
> ^1da177e4c3f415 include/asm-ppc64/io.h        Linus Torvalds         2005-04-16  862   * address is not guaranteed to be usable directly as a virtual
> ^1da177e4c3f415 include/asm-ppc64/io.h        Linus Torvalds         2005-04-16  863   * address.
> 4cb3cee03d558fd include/asm-powerpc/io.h      Benjamin Herrenschmidt 2006-11-11  864   *
> 4cb3cee03d558fd include/asm-powerpc/io.h      Benjamin Herrenschmidt 2006-11-11  865   * We provide a few variations of it:
> 4cb3cee03d558fd include/asm-powerpc/io.h      Benjamin Herrenschmidt 2006-11-11  866   *
> 4cb3cee03d558fd include/asm-powerpc/io.h      Benjamin Herrenschmidt 2006-11-11  867   * * ioremap is the standard one and provides non-cacheable guarded mappings
> 4cb3cee03d558fd include/asm-powerpc/io.h      Benjamin Herrenschmidt 2006-11-11  868   *   and can be hooked by the platform via ppc_md
> 4cb3cee03d558fd include/asm-powerpc/io.h      Benjamin Herrenschmidt 2006-11-11  869   *
> 40f1ce7fb7e8b5d arch/powerpc/include/asm/io.h Anton Blanchard        2011-05-08  870   * * ioremap_prot allows to specify the page flags as an argument and can
> 40f1ce7fb7e8b5d arch/powerpc/include/asm/io.h Anton Blanchard        2011-05-08  871   *   also be hooked by the platform via ppc_md.
> 4cb3cee03d558fd include/asm-powerpc/io.h      Benjamin Herrenschmidt 2006-11-11  872   *
> be135f40899cb33 arch/powerpc/include/asm/io.h Anton Blanchard        2011-05-08  873   * * ioremap_wc enables write combining
> be135f40899cb33 arch/powerpc/include/asm/io.h Anton Blanchard        2011-05-08  874   *
> 86c391bd5f47101 arch/powerpc/include/asm/io.h Christophe Leroy       2018-10-09  875   * * ioremap_wt enables write through
> 86c391bd5f47101 arch/powerpc/include/asm/io.h Christophe Leroy       2018-10-09  876   *
> 86c391bd5f47101 arch/powerpc/include/asm/io.h Christophe Leroy       2018-10-09  877   * * ioremap_coherent maps coherent cached memory
> 86c391bd5f47101 arch/powerpc/include/asm/io.h Christophe Leroy       2018-10-09  878   *
> 4cb3cee03d558fd include/asm-powerpc/io.h      Benjamin Herrenschmidt 2006-11-11  879   * * iounmap undoes such a mapping and can be hooked
> 4cb3cee03d558fd include/asm-powerpc/io.h      Benjamin Herrenschmidt 2006-11-11  880   *
> 1cdab55d8a8313f arch/powerpc/include/asm/io.h Benjamin Herrenschmidt 2009-02-22  881   * * __ioremap_caller is the same as above but takes an explicit caller
> 1cdab55d8a8313f arch/powerpc/include/asm/io.h Benjamin Herrenschmidt 2009-02-22  882   *   reference rather than using __builtin_return_address(0)
> 1cdab55d8a8313f arch/powerpc/include/asm/io.h Benjamin Herrenschmidt 2009-02-22  883   *
> ^1da177e4c3f415 include/asm-ppc64/io.h        Linus Torvalds         2005-04-16  884   */
> 68a64357d15ae4f include/asm-powerpc/io.h      Benjamin Herrenschmidt 2006-11-13 @885  extern void __iomem *ioremap(phys_addr_t address, unsigned long size);
> 8d05554dca2af6a arch/powerpc/include/asm/io.h Christophe Leroy       2023-07-06  886  #define ioremap ioremap
> 8d05554dca2af6a arch/powerpc/include/asm/io.h Christophe Leroy       2023-07-06  887  #define ioremap_prot ioremap_prot
> be135f40899cb33 arch/powerpc/include/asm/io.h Anton Blanchard        2011-05-08  888  extern void __iomem *ioremap_wc(phys_addr_t address, unsigned long size);
> 894fa235eb4ca0b arch/powerpc/include/asm/io.h Christophe Leroy       2020-11-21  889  #define ioremap_wc ioremap_wc
> 894fa235eb4ca0b arch/powerpc/include/asm/io.h Christophe Leroy       2020-11-21  890
kernel test robot Feb. 10, 2025, 6:43 p.m. UTC | #3
Hi Raag,

kernel test robot noticed the following build warnings:

[auto build test WARNING on a1e062ab4a1f19bb0e94093ef90ab9a74f1f7744]

url:    https://github.com/intel-lab-lkp/linux/commits/Raag-Jadav/driver-core-Split-devres-APIs-to-device-devres-h/20250210-145732
base:   a1e062ab4a1f19bb0e94093ef90ab9a74f1f7744
patch link:    https://lore.kernel.org/r/20250210064906.2181867-2-raag.jadav%40intel.com
patch subject: [PATCH v4 01/20] driver core: Split devres APIs to device/devres.h
config: powerpc-allyesconfig (https://download.01.org/0day-ci/archive/20250211/202502110256.ZtYROQTy-lkp@intel.com/config)
compiler: clang version 16.0.6 (https://github.com/llvm/llvm-project 7cbf1a2591520c2491aa35339f227775f4d3adf6)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250211/202502110256.ZtYROQTy-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202502110256.ZtYROQTy-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from drivers/input/input.c:14:
   In file included from include/linux/input/mt.h:11:
   In file included from include/linux/input.h:19:
   In file included from include/linux/device.h:31:
   In file included from include/linux/device/devres.h:7:
   In file included from include/linux/io.h:14:
   In file included from arch/powerpc/include/asm/io.h:274:
>> arch/powerpc/include/asm/eeh.h:304:45: warning: declaration of 'struct iommu_group' will not be visible outside of this function [-Wvisibility]
   struct eeh_pe *eeh_iommu_group_to_pe(struct iommu_group *group);
                                               ^
   1 warning generated.
--
   In file included from drivers/input/touchscreen/mms114.c:10:
   In file included from include/linux/i2c.h:13:
   In file included from include/linux/acpi.h:14:
   In file included from include/linux/device.h:31:
   In file included from include/linux/device/devres.h:7:
   In file included from include/linux/io.h:14:
   In file included from arch/powerpc/include/asm/io.h:274:
>> arch/powerpc/include/asm/eeh.h:304:45: warning: declaration of 'struct iommu_group' will not be visible outside of this function [-Wvisibility]
   struct eeh_pe *eeh_iommu_group_to_pe(struct iommu_group *group);
                                               ^
   drivers/input/touchscreen/mms114.c:507:15: warning: cast to smaller integer type 'enum mms_type' from 'const void *' [-Wvoid-pointer-to-enum-cast]
           data->type = (enum mms_type)match_data;
                        ^~~~~~~~~~~~~~~~~~~~~~~~~
   2 warnings generated.
--
   In file included from drivers/input/touchscreen/wdt87xx_i2c.c:12:
   In file included from include/linux/i2c.h:13:
   In file included from include/linux/acpi.h:14:
   In file included from include/linux/device.h:31:
   In file included from include/linux/device/devres.h:7:
   In file included from include/linux/io.h:14:
   In file included from arch/powerpc/include/asm/io.h:274:
>> arch/powerpc/include/asm/eeh.h:304:45: warning: declaration of 'struct iommu_group' will not be visible outside of this function [-Wvisibility]
   struct eeh_pe *eeh_iommu_group_to_pe(struct iommu_group *group);
                                               ^
   drivers/input/touchscreen/wdt87xx_i2c.c:1156:36: warning: unused variable 'wdt87xx_acpi_id' [-Wunused-const-variable]
   static const struct acpi_device_id wdt87xx_acpi_id[] = {
                                      ^
   2 warnings generated.


vim +304 arch/powerpc/include/asm/eeh.h

55037d176107c3 arch/powerpc/include/asm/eeh.h Gavin Shan        2012-09-07  292  
c44e4ccadaca58 arch/powerpc/include/asm/eeh.h Sam Bobroff       2019-08-16  293  void eeh_show_enabled(void);
d125aedb404204 arch/powerpc/include/asm/eeh.h Oliver O'Halloran 2020-09-18  294  int __init eeh_init(struct eeh_ops *ops);
3e938052fb7655 arch/powerpc/include/asm/eeh.h Gavin Shan        2014-09-30  295  int eeh_check_failure(const volatile void __iomem *token);
f8f7d63fd96ead arch/powerpc/include/asm/eeh.h Gavin Shan        2012-09-07  296  int eeh_dev_check_failure(struct eeh_dev *edev);
685a0bc00abcf1 arch/powerpc/include/asm/eeh.h Sam Bobroff       2019-08-16  297  void eeh_addr_cache_init(void);
e86350f70a02e5 arch/powerpc/include/asm/eeh.h Oliver O'Halloran 2020-03-06  298  void eeh_probe_device(struct pci_dev *pdev);
807a827d4e7455 arch/powerpc/include/asm/eeh.h Gavin Shan        2013-07-24  299  void eeh_remove_device(struct pci_dev *);
188fdea69fa91d arch/powerpc/include/asm/eeh.h Sam Bobroff       2018-11-29  300  int eeh_unfreeze_pe(struct eeh_pe *pe);
5cfb20b96f624e arch/powerpc/include/asm/eeh.h Gavin Shan        2014-09-30  301  int eeh_pe_reset_and_recover(struct eeh_pe *pe);
212d16cdca2d0f arch/powerpc/include/asm/eeh.h Gavin Shan        2014-06-10  302  int eeh_dev_open(struct pci_dev *pdev);
212d16cdca2d0f arch/powerpc/include/asm/eeh.h Gavin Shan        2014-06-10  303  void eeh_dev_release(struct pci_dev *pdev);
212d16cdca2d0f arch/powerpc/include/asm/eeh.h Gavin Shan        2014-06-10 @304  struct eeh_pe *eeh_iommu_group_to_pe(struct iommu_group *group);
212d16cdca2d0f arch/powerpc/include/asm/eeh.h Gavin Shan        2014-06-10  305  int eeh_pe_set_option(struct eeh_pe *pe, int option);
212d16cdca2d0f arch/powerpc/include/asm/eeh.h Gavin Shan        2014-06-10  306  int eeh_pe_get_state(struct eeh_pe *pe);
1ef52073fd25ea arch/powerpc/include/asm/eeh.h Sam Bobroff       2018-11-29  307  int eeh_pe_reset(struct eeh_pe *pe, int option, bool include_passed);
212d16cdca2d0f arch/powerpc/include/asm/eeh.h Gavin Shan        2014-06-10  308  int eeh_pe_configure(struct eeh_pe *pe);
ec33d36e5ab5d5 arch/powerpc/include/asm/eeh.h Gavin Shan        2015-03-26  309  int eeh_pe_inject_err(struct eeh_pe *pe, int type, int func,
ec33d36e5ab5d5 arch/powerpc/include/asm/eeh.h Gavin Shan        2015-03-26  310  		      unsigned long addr, unsigned long mask);
b0e2b828dfca64 arch/powerpc/include/asm/eeh.h Narayana Murty N  2024-09-09  311  int eeh_pe_inject_mmio_error(struct pci_dev *pdev);
e2a296eeaa3444 include/asm-powerpc/eeh.h      Linas Vepstas     2005-11-03  312
Raag Jadav Feb. 10, 2025, 9:35 p.m. UTC | #4
On Mon, Feb 10, 2025 at 05:23:33PM +0200, Andy Shevchenko wrote:
> +Cc: Arnd
> 
> On Mon, Feb 10, 2025 at 10:30:28PM +0800, kernel test robot wrote:
> > Hi Raag,
> > 
> > kernel test robot noticed the following build errors:
> > 
> > [auto build test ERROR on a1e062ab4a1f19bb0e94093ef90ab9a74f1f7744]
> > 
> > url:    https://github.com/intel-lab-lkp/linux/commits/Raag-Jadav/driver-core-Split-devres-APIs-to-device-devres-h/20250210-145732
> > base:   a1e062ab4a1f19bb0e94093ef90ab9a74f1f7744
> > patch link:    https://lore.kernel.org/r/20250210064906.2181867-2-raag.jadav%40intel.com
> > patch subject: [PATCH v4 01/20] driver core: Split devres APIs to device/devres.h
> > config: powerpc64-randconfig-002-20250210 (https://download.01.org/0day-ci/archive/20250210/202502102201.zLWaJC6V-lkp@intel.com/config)
> > compiler: powerpc64-linux-gcc (GCC) 14.2.0
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250210/202502102201.zLWaJC6V-lkp@intel.com/reproduce)
> > 
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202502102201.zLWaJC6V-lkp@intel.com/
> > 
> > All error/warnings (new ones prefixed by >>):
> 
> TBH I have no quick idea how to address this. It seems that io.h includes device.h
> for no reason (but I haven't checked that carefully). OTOH, we need only
> IOMEM_IS_ERR() definition which can simply be moved from io.h to err.h as the
> former includes the latter and the definition depends only on compiler_types.h.

I atleast managed to build this after dropping device.h from asm/io.h however
eeh.h is just something else.

Raag

> Arnd?
> 
> >    In file included from include/linux/device/devres.h:7,
> >                     from include/linux/device.h:31,
> >                     from arch/powerpc/include/asm/io.h:22,
> >                     from include/linux/scatterlist.h:9,
> >                     from crypto/rsassa-pkcs1.c:11:
> >    include/linux/io.h: In function 'pci_remap_cfgspace':
> >    include/linux/io.h:106:16: error: implicit declaration of function 'ioremap_np' [-Wimplicit-function-declaration]
> >      106 |         return ioremap_np(offset, size) ?: ioremap(offset, size);
> >          |                ^~~~~~~~~~
> >    include/linux/io.h:106:44: error: implicit declaration of function 'ioremap' [-Wimplicit-function-declaration]
> >      106 |         return ioremap_np(offset, size) ?: ioremap(offset, size);
> >          |                                            ^~~~~~~
> >    include/linux/io.h:106:42: error: returning 'int' from a function with return type 'void *' makes pointer from integer without a cast [-Wint-conversion]
> >      106 |         return ioremap_np(offset, size) ?: ioremap(offset, size);
> >          |                ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
> >    arch/powerpc/include/asm/io.h: At top level:
> > >> arch/powerpc/include/asm/io.h:885:22: error: conflicting types for 'ioremap'; have 'void *(phys_addr_t,  long unsigned int)' {aka 'void *(long long unsigned int,  long unsigned int)'}
> >      885 | extern void __iomem *ioremap(phys_addr_t address, unsigned long size);
> >          |                      ^~~~~~~
> >    include/linux/io.h:106:44: note: previous implicit declaration of 'ioremap' with type 'int()'
> >      106 |         return ioremap_np(offset, size) ?: ioremap(offset, size);
> >          |                                            ^~~~~~~
> >    In file included from include/asm-generic/io.h:17,
> >                     from arch/powerpc/include/asm/io.h:1031:
> > >> include/asm-generic/iomap.h:106:20: error: conflicting types for 'ioremap_np'; have 'void *(phys_addr_t,  size_t)' {aka 'void *(long long unsigned int,  long unsigned int)'}
> >      106 | #define ioremap_np ioremap_np
> >          |                    ^~~~~~~~~~
> >    include/asm-generic/iomap.h:107:29: note: in expansion of macro 'ioremap_np'
> >      107 | static inline void __iomem *ioremap_np(phys_addr_t offset, size_t size)
> >          |                             ^~~~~~~~~~
> >    include/linux/io.h:106:16: note: previous implicit declaration of 'ioremap_np' with type 'int()'
> >      106 |         return ioremap_np(offset, size) ?: ioremap(offset, size);
> >          |                ^~~~~~~~~~
> > --
> >    In file included from arch/powerpc/include/asm/io.h:274,
> >                     from include/linux/io.h:14,
> >                     from include/linux/device/devres.h:7,
> >                     from include/linux/device.h:31,
> >                     from include/linux/acpi.h:14,
> >                     from include/linux/i2c.h:13,
> >                     from drivers/input/touchscreen/ili210x.c:5:
> > >> arch/powerpc/include/asm/eeh.h:304:45: warning: 'struct iommu_group' declared inside parameter list will not be visible outside of this definition or declaration
> >      304 | struct eeh_pe *eeh_iommu_group_to_pe(struct iommu_group *group);
> >          |                                             ^~~~~~~~~~~
> > --
> >    In file included from arch/powerpc/include/asm/io.h:274,
> >                     from include/linux/io.h:14,
> >                     from include/linux/device/devres.h:7,
> >                     from include/linux/device.h:31,
> >                     from include/linux/input.h:19,
> >                     from drivers/input/touchscreen/touchright.c:17:
> > >> arch/powerpc/include/asm/eeh.h:304:45: warning: 'struct iommu_group' declared inside parameter list will not be visible outside of this definition or declaration
> >      304 | struct eeh_pe *eeh_iommu_group_to_pe(struct iommu_group *group);
> >          |                                             ^~~~~~~~~~~
> >    drivers/input/touchscreen/touchright.c: In function 'tr_connect':
> >    drivers/input/touchscreen/touchright.c:114:49: warning: '/input0' directive output may be truncated writing 7 bytes into a region of size between 1 and 32 [-Wformat-truncation=]
> >      114 |         snprintf(tr->phys, sizeof(tr->phys), "%s/input0", serio->phys);
> >          |                                                 ^~~~~~~
> >    drivers/input/touchscreen/touchright.c:114:9: note: 'snprintf' output between 8 and 39 bytes into a destination of size 32
> >      114 |         snprintf(tr->phys, sizeof(tr->phys), "%s/input0", serio->phys);
> >          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > --
> >    In file included from arch/powerpc/include/asm/io.h:274,
> >                     from include/linux/io.h:14,
> >                     from include/linux/device/devres.h:7,
> >                     from include/linux/device.h:31,
> >                     from include/linux/input.h:19,
> >                     from drivers/input/touchscreen/penmount.c:17:
> > >> arch/powerpc/include/asm/eeh.h:304:45: warning: 'struct iommu_group' declared inside parameter list will not be visible outside of this definition or declaration
> >      304 | struct eeh_pe *eeh_iommu_group_to_pe(struct iommu_group *group);
> >          |                                             ^~~~~~~~~~~
> >    drivers/input/touchscreen/penmount.c: In function 'pm_connect':
> >    drivers/input/touchscreen/penmount.c:211:49: warning: '/input0' directive output may be truncated writing 7 bytes into a region of size between 1 and 32 [-Wformat-truncation=]
> >      211 |         snprintf(pm->phys, sizeof(pm->phys), "%s/input0", serio->phys);
> >          |                                                 ^~~~~~~
> >    drivers/input/touchscreen/penmount.c:211:9: note: 'snprintf' output between 8 and 39 bytes into a destination of size 32
> >      211 |         snprintf(pm->phys, sizeof(pm->phys), "%s/input0", serio->phys);
> >          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > --
> >    In file included from arch/powerpc/include/asm/io.h:274,
> >                     from include/linux/io.h:14,
> >                     from include/linux/device/devres.h:7,
> >                     from include/linux/device.h:31,
> >                     from include/linux/input.h:19,
> >                     from drivers/input/touchscreen/inexio.c:19:
> > >> arch/powerpc/include/asm/eeh.h:304:45: warning: 'struct iommu_group' declared inside parameter list will not be visible outside of this definition or declaration
> >      304 | struct eeh_pe *eeh_iommu_group_to_pe(struct iommu_group *group);
> >          |                                             ^~~~~~~~~~~
> >    drivers/input/touchscreen/inexio.c: In function 'inexio_connect':
> >    drivers/input/touchscreen/inexio.c:126:59: warning: '/input0' directive output may be truncated writing 7 bytes into a region of size between 1 and 32 [-Wformat-truncation=]
> >      126 |         snprintf(pinexio->phys, sizeof(pinexio->phys), "%s/input0", serio->phys);
> >          |                                                           ^~~~~~~
> >    drivers/input/touchscreen/inexio.c:126:9: note: 'snprintf' output between 8 and 39 bytes into a destination of size 32
> >      126 |         snprintf(pinexio->phys, sizeof(pinexio->phys), "%s/input0", serio->phys);
> >          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > --
> >    In file included from arch/powerpc/include/asm/io.h:274,
> >                     from include/linux/io.h:14,
> >                     from include/linux/device/devres.h:7,
> >                     from include/linux/device.h:31,
> >                     from include/linux/input.h:19,
> >                     from drivers/input/touchscreen/touchwin.c:24:
> > >> arch/powerpc/include/asm/eeh.h:304:45: warning: 'struct iommu_group' declared inside parameter list will not be visible outside of this definition or declaration
> >      304 | struct eeh_pe *eeh_iommu_group_to_pe(struct iommu_group *group);
> >          |                                             ^~~~~~~~~~~
> >    drivers/input/touchscreen/touchwin.c: In function 'tw_connect':
> >    drivers/input/touchscreen/touchwin.c:121:49: warning: '/input0' directive output may be truncated writing 7 bytes into a region of size between 1 and 32 [-Wformat-truncation=]
> >      121 |         snprintf(tw->phys, sizeof(tw->phys), "%s/input0", serio->phys);
> >          |                                                 ^~~~~~~
> >    drivers/input/touchscreen/touchwin.c:121:9: note: 'snprintf' output between 8 and 39 bytes into a destination of size 32
> >      121 |         snprintf(tw->phys, sizeof(tw->phys), "%s/input0", serio->phys);
> >          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > --
> >    In file included from arch/powerpc/include/asm/io.h:274,
> >                     from include/linux/io.h:14,
> >                     from include/linux/device/devres.h:7,
> >                     from include/linux/device.h:31,
> >                     from include/linux/input.h:19,
> >                     from drivers/input/touchscreen/hampshire.c:19:
> > >> arch/powerpc/include/asm/eeh.h:304:45: warning: 'struct iommu_group' declared inside parameter list will not be visible outside of this definition or declaration
> >      304 | struct eeh_pe *eeh_iommu_group_to_pe(struct iommu_group *group);
> >          |                                             ^~~~~~~~~~~
> >    drivers/input/touchscreen/hampshire.c: In function 'hampshire_connect':
> >    drivers/input/touchscreen/hampshire.c:122:21: warning: '/input0' directive output may be truncated writing 7 bytes into a region of size between 1 and 32 [-Wformat-truncation=]
> >      122 |                  "%s/input0", serio->phys);
> >          |                     ^~~~~~~
> >    drivers/input/touchscreen/hampshire.c:121:9: note: 'snprintf' output between 8 and 39 bytes into a destination of size 32
> >      121 |         snprintf(phampshire->phys, sizeof(phampshire->phys),
> >          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >      122 |                  "%s/input0", serio->phys);
> >          |                  ~~~~~~~~~~~~~~~~~~~~~~~~~
> > --
> >    In file included from arch/powerpc/include/asm/io.h:274,
> >                     from include/linux/io.h:14,
> >                     from include/linux/device/devres.h:7,
> >                     from include/linux/device.h:31,
> >                     from include/linux/input.h:19,
> >                     from drivers/input/touchscreen/tsc40.c:12:
> > >> arch/powerpc/include/asm/eeh.h:304:45: warning: 'struct iommu_group' declared inside parameter list will not be visible outside of this definition or declaration
> >      304 | struct eeh_pe *eeh_iommu_group_to_pe(struct iommu_group *group);
> >          |                                             ^~~~~~~~~~~
> >    drivers/input/touchscreen/tsc40.c: In function 'tsc_connect':
> >    drivers/input/touchscreen/tsc40.c:95:53: warning: '/input0' directive output may be truncated writing 7 bytes into a region of size between 1 and 32 [-Wformat-truncation=]
> >       95 |         snprintf(ptsc->phys, sizeof(ptsc->phys), "%s/input0", serio->phys);
> >          |                                                     ^~~~~~~
> >    drivers/input/touchscreen/tsc40.c:95:9: note: 'snprintf' output between 8 and 39 bytes into a destination of size 32
> >       95 |         snprintf(ptsc->phys, sizeof(ptsc->phys), "%s/input0", serio->phys);
> >          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > --
> >    In file included from arch/powerpc/include/asm/io.h:274,
> >                     from include/linux/io.h:14,
> >                     from include/linux/device/devres.h:7,
> >                     from include/linux/device.h:31,
> >                     from include/linux/input.h:19,
> >                     from drivers/input/touchscreen/dynapro.c:20:
> > >> arch/powerpc/include/asm/eeh.h:304:45: warning: 'struct iommu_group' declared inside parameter list will not be visible outside of this definition or declaration
> >      304 | struct eeh_pe *eeh_iommu_group_to_pe(struct iommu_group *group);
> >          |                                             ^~~~~~~~~~~
> >    drivers/input/touchscreen/dynapro.c: In function 'dynapro_connect':
> >    drivers/input/touchscreen/dynapro.c:123:21: warning: '/input0' directive output may be truncated writing 7 bytes into a region of size between 1 and 32 [-Wformat-truncation=]
> >      123 |                  "%s/input0", serio->phys);
> >          |                     ^~~~~~~
> >    drivers/input/touchscreen/dynapro.c:122:9: note: 'snprintf' output between 8 and 39 bytes into a destination of size 32
> >      122 |         snprintf(pdynapro->phys, sizeof(pdynapro->phys),
> >          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >      123 |                  "%s/input0", serio->phys);
> >          |                  ~~~~~~~~~~~~~~~~~~~~~~~~~
> > 
> > 
> > vim +885 arch/powerpc/include/asm/io.h
> > 
> > ^1da177e4c3f415 include/asm-ppc64/io.h        Linus Torvalds         2005-04-16  853  
> > ^1da177e4c3f415 include/asm-ppc64/io.h        Linus Torvalds         2005-04-16  854  /**
> > ^1da177e4c3f415 include/asm-ppc64/io.h        Linus Torvalds         2005-04-16  855   * ioremap     -   map bus memory into CPU space
> > ^1da177e4c3f415 include/asm-ppc64/io.h        Linus Torvalds         2005-04-16  856   * @address:   bus address of the memory
> > ^1da177e4c3f415 include/asm-ppc64/io.h        Linus Torvalds         2005-04-16  857   * @size:      size of the resource to map
> > ^1da177e4c3f415 include/asm-ppc64/io.h        Linus Torvalds         2005-04-16  858   *
> > ^1da177e4c3f415 include/asm-ppc64/io.h        Linus Torvalds         2005-04-16  859   * ioremap performs a platform specific sequence of operations to
> > ^1da177e4c3f415 include/asm-ppc64/io.h        Linus Torvalds         2005-04-16  860   * make bus memory CPU accessible via the readb/readw/readl/writeb/
> > ^1da177e4c3f415 include/asm-ppc64/io.h        Linus Torvalds         2005-04-16  861   * writew/writel functions and the other mmio helpers. The returned
> > ^1da177e4c3f415 include/asm-ppc64/io.h        Linus Torvalds         2005-04-16  862   * address is not guaranteed to be usable directly as a virtual
> > ^1da177e4c3f415 include/asm-ppc64/io.h        Linus Torvalds         2005-04-16  863   * address.
> > 4cb3cee03d558fd include/asm-powerpc/io.h      Benjamin Herrenschmidt 2006-11-11  864   *
> > 4cb3cee03d558fd include/asm-powerpc/io.h      Benjamin Herrenschmidt 2006-11-11  865   * We provide a few variations of it:
> > 4cb3cee03d558fd include/asm-powerpc/io.h      Benjamin Herrenschmidt 2006-11-11  866   *
> > 4cb3cee03d558fd include/asm-powerpc/io.h      Benjamin Herrenschmidt 2006-11-11  867   * * ioremap is the standard one and provides non-cacheable guarded mappings
> > 4cb3cee03d558fd include/asm-powerpc/io.h      Benjamin Herrenschmidt 2006-11-11  868   *   and can be hooked by the platform via ppc_md
> > 4cb3cee03d558fd include/asm-powerpc/io.h      Benjamin Herrenschmidt 2006-11-11  869   *
> > 40f1ce7fb7e8b5d arch/powerpc/include/asm/io.h Anton Blanchard        2011-05-08  870   * * ioremap_prot allows to specify the page flags as an argument and can
> > 40f1ce7fb7e8b5d arch/powerpc/include/asm/io.h Anton Blanchard        2011-05-08  871   *   also be hooked by the platform via ppc_md.
> > 4cb3cee03d558fd include/asm-powerpc/io.h      Benjamin Herrenschmidt 2006-11-11  872   *
> > be135f40899cb33 arch/powerpc/include/asm/io.h Anton Blanchard        2011-05-08  873   * * ioremap_wc enables write combining
> > be135f40899cb33 arch/powerpc/include/asm/io.h Anton Blanchard        2011-05-08  874   *
> > 86c391bd5f47101 arch/powerpc/include/asm/io.h Christophe Leroy       2018-10-09  875   * * ioremap_wt enables write through
> > 86c391bd5f47101 arch/powerpc/include/asm/io.h Christophe Leroy       2018-10-09  876   *
> > 86c391bd5f47101 arch/powerpc/include/asm/io.h Christophe Leroy       2018-10-09  877   * * ioremap_coherent maps coherent cached memory
> > 86c391bd5f47101 arch/powerpc/include/asm/io.h Christophe Leroy       2018-10-09  878   *
> > 4cb3cee03d558fd include/asm-powerpc/io.h      Benjamin Herrenschmidt 2006-11-11  879   * * iounmap undoes such a mapping and can be hooked
> > 4cb3cee03d558fd include/asm-powerpc/io.h      Benjamin Herrenschmidt 2006-11-11  880   *
> > 1cdab55d8a8313f arch/powerpc/include/asm/io.h Benjamin Herrenschmidt 2009-02-22  881   * * __ioremap_caller is the same as above but takes an explicit caller
> > 1cdab55d8a8313f arch/powerpc/include/asm/io.h Benjamin Herrenschmidt 2009-02-22  882   *   reference rather than using __builtin_return_address(0)
> > 1cdab55d8a8313f arch/powerpc/include/asm/io.h Benjamin Herrenschmidt 2009-02-22  883   *
> > ^1da177e4c3f415 include/asm-ppc64/io.h        Linus Torvalds         2005-04-16  884   */
> > 68a64357d15ae4f include/asm-powerpc/io.h      Benjamin Herrenschmidt 2006-11-13 @885  extern void __iomem *ioremap(phys_addr_t address, unsigned long size);
> > 8d05554dca2af6a arch/powerpc/include/asm/io.h Christophe Leroy       2023-07-06  886  #define ioremap ioremap
> > 8d05554dca2af6a arch/powerpc/include/asm/io.h Christophe Leroy       2023-07-06  887  #define ioremap_prot ioremap_prot
> > be135f40899cb33 arch/powerpc/include/asm/io.h Anton Blanchard        2011-05-08  888  extern void __iomem *ioremap_wc(phys_addr_t address, unsigned long size);
> > 894fa235eb4ca0b arch/powerpc/include/asm/io.h Christophe Leroy       2020-11-21  889  #define ioremap_wc ioremap_wc
> > 894fa235eb4ca0b arch/powerpc/include/asm/io.h Christophe Leroy       2020-11-21  890  
> 
> -- 
> With Best Regards,
> Andy Shevchenko
> 
>
Andy Shevchenko Feb. 11, 2025, 10:11 a.m. UTC | #5
On Tue, Feb 11, 2025 at 10:39:16AM +0100, Arnd Bergmann wrote:
> On Tue, Feb 11, 2025, at 10:27, Andy Shevchenko wrote:
> > On Tue, Feb 11, 2025 at 08:36:47AM +0100, Arnd Bergmann wrote:
> >> On Mon, Feb 10, 2025, at 16:23, Andy Shevchenko wrote:
> >> >
> >> > TBH I have no quick idea how to address this. It seems that io.h 
> >> > includes device.h
> >> > for no reason (but I haven't checked that carefully). OTOH, we need only
> >> > IOMEM_IS_ERR() definition which can simply be moved from io.h to err.h 
> >> > as the
> >> > former includes the latter and the definition depends only on 
> >> > compiler_types.h.
> >> >
> >> > Arnd?
> >> 
> >> Removing linux/device.h from asm/io.h is probably the right step,
> >> it really has no business in there and no other architecture
> >> includes it. I don't see an IOMEM_IS_ERR() definition, do you 
> >> mean EEH_POSSIBLE_ERROR?
> >
> > The definition is in the generic header and patch here relies on
> > that definition to fix the sparse warning. The simplest solution
> > is to add another patch that simply moves the macro from
> > linux/io.h to linux/err.h.
> 
> Ah, IOMEM_ERR_PTR(), not IOMEM_IS_ERR().

Oh, yes, sorry for the confusion.

> I don't mind moving that if it helps you, but don't see what
> the problem is here. Is this missing because of a circular
> #include list with linux/device.h including asm/io.h and vice
> versa? If that is the root cause, then I assume there will be
> additional problems either way until the loop can be broken.

I don't see how. io.h already includes err.h, so whoever includes io.h should
have that as previously.

> >> Most of asm/eeh.h probably shouldn't be included by asm/io.h
> >> either, my guess is that we can get away with the
> >> eeh_{s,}{b,w,l,q}{_be} helpers, eeh_memcpy_fromio() and
> >> eeh_check_failure(), which have no dependency on 'struct
> >> device' in the header.
> >> 
> >> Removing a giant header inclusion from another one likely causes
> >> build regressions in drivers that should have included the
> >> header (linux/device.h or something included by that) themselves,
> >> so ideally there should be some separate build testing of
> >> powerpc kernels.
> >
> > I believe this might be far out of scope for this series due to potential
> > fallouts here and there. But would be good to have it separately.
> 
> It certainly gets towards yak-shaving, but it does look like
> the best solution. It really depends on how much breaks -- if there
> are only a couple of missing #include statements, I can see those
> get merged early as a bugfix or as part of another series. If there
> are a lot of them, it is probably not worth it.
Andy Shevchenko Feb. 11, 2025, 11:37 a.m. UTC | #6
On Tue, Feb 11, 2025 at 11:23:07AM +0100, Arnd Bergmann wrote:
> On Tue, Feb 11, 2025, at 11:11, Andy Shevchenko wrote:
> > On Tue, Feb 11, 2025 at 10:39:16AM +0100, Arnd Bergmann wrote:
> >> On Tue, Feb 11, 2025, at 10:27, Andy Shevchenko wrote:
> >
> >> I don't mind moving that if it helps you, but don't see what
> >> the problem is here. Is this missing because of a circular
> >> #include list with linux/device.h including asm/io.h and vice
> >> versa? If that is the root cause, then I assume there will be
> >> additional problems either way until the loop can be broken.
> >
> > I don't see how. io.h already includes err.h, so whoever includes io.h should
> > have that as previously.
> 
> I mean I never understood what problem you are trying to solve
> exactly. From the log, it appears that the problem is an include
> loop between linux/device.h, linux/device/devres.h and asm/io.h,
> and anything that breaks the loop should work. Your suggestion of
> stopping asm/io.h from including linux/device.h sounds like
> the most promising here, but this should be possible regardless
> of whether IOMEM_ERR_PTR() gets moved.

The problem this series solves at the beginning is that not all the consumers
of device.h needs it, in many cases the device/devres.h (or subset of
device/*.h) is enough to include. While solving this, it appears that
the current code uses ERR_PTR() instead of IOMEM_ERR_PTR() in devm_*io*() APIs
and kernel test robot found this and complained about. While solving
this new issue, LKP found another issue that is circular dependency.
But the original code only wants to have an access to IOMEM_ERR_PTR() which
is in io.h and can be moved to err.h AFAICS. Does this sound reasonable?
diff mbox series

Patch

diff --git a/include/linux/device.h b/include/linux/device.h
index 80a5b3268986..78ca7fd0e625 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -26,9 +26,9 @@ 
 #include <linux/atomic.h>
 #include <linux/uidgid.h>
 #include <linux/gfp.h>
-#include <linux/overflow.h>
 #include <linux/device/bus.h>
 #include <linux/device/class.h>
+#include <linux/device/devres.h>
 #include <linux/device/driver.h>
 #include <linux/cleanup.h>
 #include <asm/device.h>
@@ -281,123 +281,6 @@  int __must_check device_create_bin_file(struct device *dev,
 void device_remove_bin_file(struct device *dev,
 			    const struct bin_attribute *attr);
 
-/* device resource management */
-typedef void (*dr_release_t)(struct device *dev, void *res);
-typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data);
-
-void *__devres_alloc_node(dr_release_t release, size_t size, gfp_t gfp,
-			  int nid, const char *name) __malloc;
-#define devres_alloc(release, size, gfp) \
-	__devres_alloc_node(release, size, gfp, NUMA_NO_NODE, #release)
-#define devres_alloc_node(release, size, gfp, nid) \
-	__devres_alloc_node(release, size, gfp, nid, #release)
-
-void devres_for_each_res(struct device *dev, dr_release_t release,
-			 dr_match_t match, void *match_data,
-			 void (*fn)(struct device *, void *, void *),
-			 void *data);
-void devres_free(void *res);
-void devres_add(struct device *dev, void *res);
-void *devres_find(struct device *dev, dr_release_t release,
-		  dr_match_t match, void *match_data);
-void *devres_get(struct device *dev, void *new_res,
-		 dr_match_t match, void *match_data);
-void *devres_remove(struct device *dev, dr_release_t release,
-		    dr_match_t match, void *match_data);
-int devres_destroy(struct device *dev, dr_release_t release,
-		   dr_match_t match, void *match_data);
-int devres_release(struct device *dev, dr_release_t release,
-		   dr_match_t match, void *match_data);
-
-/* devres group */
-void * __must_check devres_open_group(struct device *dev, void *id, gfp_t gfp);
-void devres_close_group(struct device *dev, void *id);
-void devres_remove_group(struct device *dev, void *id);
-int devres_release_group(struct device *dev, void *id);
-
-/* managed devm_k.alloc/kfree for device drivers */
-void *devm_kmalloc(struct device *dev, size_t size, gfp_t gfp) __alloc_size(2);
-void *devm_krealloc(struct device *dev, void *ptr, size_t size,
-		    gfp_t gfp) __must_check __realloc_size(3);
-__printf(3, 0) char *devm_kvasprintf(struct device *dev, gfp_t gfp,
-				     const char *fmt, va_list ap) __malloc;
-__printf(3, 4) char *devm_kasprintf(struct device *dev, gfp_t gfp,
-				    const char *fmt, ...) __malloc;
-static inline void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp)
-{
-	return devm_kmalloc(dev, size, gfp | __GFP_ZERO);
-}
-static inline void *devm_kmalloc_array(struct device *dev,
-				       size_t n, size_t size, gfp_t flags)
-{
-	size_t bytes;
-
-	if (unlikely(check_mul_overflow(n, size, &bytes)))
-		return NULL;
-
-	return devm_kmalloc(dev, bytes, flags);
-}
-static inline void *devm_kcalloc(struct device *dev,
-				 size_t n, size_t size, gfp_t flags)
-{
-	return devm_kmalloc_array(dev, n, size, flags | __GFP_ZERO);
-}
-static inline __realloc_size(3, 4) void * __must_check
-devm_krealloc_array(struct device *dev, void *p, size_t new_n, size_t new_size, gfp_t flags)
-{
-	size_t bytes;
-
-	if (unlikely(check_mul_overflow(new_n, new_size, &bytes)))
-		return NULL;
-
-	return devm_krealloc(dev, p, bytes, flags);
-}
-
-void devm_kfree(struct device *dev, const void *p);
-char *devm_kstrdup(struct device *dev, const char *s, gfp_t gfp) __malloc;
-const char *devm_kstrdup_const(struct device *dev, const char *s, gfp_t gfp);
-void *devm_kmemdup(struct device *dev, const void *src, size_t len, gfp_t gfp)
-	__realloc_size(3);
-
-unsigned long devm_get_free_pages(struct device *dev,
-				  gfp_t gfp_mask, unsigned int order);
-void devm_free_pages(struct device *dev, unsigned long addr);
-
-#ifdef CONFIG_HAS_IOMEM
-void __iomem *devm_ioremap_resource(struct device *dev,
-				    const struct resource *res);
-void __iomem *devm_ioremap_resource_wc(struct device *dev,
-				       const struct resource *res);
-
-void __iomem *devm_of_iomap(struct device *dev,
-			    struct device_node *node, int index,
-			    resource_size_t *size);
-#else
-
-static inline
-void __iomem *devm_ioremap_resource(struct device *dev,
-				    const struct resource *res)
-{
-	return ERR_PTR(-EINVAL);
-}
-
-static inline
-void __iomem *devm_ioremap_resource_wc(struct device *dev,
-				       const struct resource *res)
-{
-	return ERR_PTR(-EINVAL);
-}
-
-static inline
-void __iomem *devm_of_iomap(struct device *dev,
-			    struct device_node *node, int index,
-			    resource_size_t *size)
-{
-	return ERR_PTR(-EINVAL);
-}
-
-#endif
-
 /* allows to add/remove a custom action to devres stack */
 int devm_remove_action_nowarn(struct device *dev, void (*action)(void *), void *data);
 
diff --git a/include/linux/device/devres.h b/include/linux/device/devres.h
new file mode 100644
index 000000000000..4ec4c658879a
--- /dev/null
+++ b/include/linux/device/devres.h
@@ -0,0 +1,125 @@ 
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _DEVICE_DEVRES_H_
+#define _DEVICE_DEVRES_H_
+
+#include <linux/errno.h>
+#include <linux/gfp_types.h>
+#include <linux/io.h>
+#include <linux/numa.h>
+#include <linux/overflow.h>
+#include <linux/stdarg.h>
+#include <linux/types.h>
+
+struct device;
+struct device_node;
+struct resource;
+
+/* device resource management */
+typedef void (*dr_release_t)(struct device *dev, void *res);
+typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data);
+
+void * __malloc
+__devres_alloc_node(dr_release_t release, size_t size, gfp_t gfp, int nid, const char *name);
+#define devres_alloc(release, size, gfp) \
+	__devres_alloc_node(release, size, gfp, NUMA_NO_NODE, #release)
+#define devres_alloc_node(release, size, gfp, nid) \
+	__devres_alloc_node(release, size, gfp, nid, #release)
+
+void devres_for_each_res(struct device *dev, dr_release_t release,
+			 dr_match_t match, void *match_data,
+			 void (*fn)(struct device *, void *, void *),
+			 void *data);
+void devres_free(void *res);
+void devres_add(struct device *dev, void *res);
+void *devres_find(struct device *dev, dr_release_t release, dr_match_t match, void *match_data);
+void *devres_get(struct device *dev, void *new_res, dr_match_t match, void *match_data);
+void *devres_remove(struct device *dev, dr_release_t release, dr_match_t match, void *match_data);
+int devres_destroy(struct device *dev, dr_release_t release, dr_match_t match, void *match_data);
+int devres_release(struct device *dev, dr_release_t release, dr_match_t match, void *match_data);
+
+/* devres group */
+void * __must_check devres_open_group(struct device *dev, void *id, gfp_t gfp);
+void devres_close_group(struct device *dev, void *id);
+void devres_remove_group(struct device *dev, void *id);
+int devres_release_group(struct device *dev, void *id);
+
+/* managed devm_k.alloc/kfree for device drivers */
+void * __alloc_size(2)
+devm_kmalloc(struct device *dev, size_t size, gfp_t gfp);
+void * __must_check __realloc_size(3)
+devm_krealloc(struct device *dev, void *ptr, size_t size, gfp_t gfp);
+static inline void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp)
+{
+	return devm_kmalloc(dev, size, gfp | __GFP_ZERO);
+}
+static inline void *devm_kmalloc_array(struct device *dev, size_t n, size_t size, gfp_t flags)
+{
+	size_t bytes;
+
+	if (unlikely(check_mul_overflow(n, size, &bytes)))
+		return NULL;
+
+	return devm_kmalloc(dev, bytes, flags);
+}
+static inline void *devm_kcalloc(struct device *dev, size_t n, size_t size, gfp_t flags)
+{
+	return devm_kmalloc_array(dev, n, size, flags | __GFP_ZERO);
+}
+static inline __realloc_size(3, 4) void * __must_check
+devm_krealloc_array(struct device *dev, void *p, size_t new_n, size_t new_size, gfp_t flags)
+{
+	size_t bytes;
+
+	if (unlikely(check_mul_overflow(new_n, new_size, &bytes)))
+		return NULL;
+
+	return devm_krealloc(dev, p, bytes, flags);
+}
+
+void devm_kfree(struct device *dev, const void *p);
+
+void * __realloc_size(3)
+devm_kmemdup(struct device *dev, const void *src, size_t len, gfp_t gfp);
+
+char * __malloc
+devm_kstrdup(struct device *dev, const char *s, gfp_t gfp);
+const char *devm_kstrdup_const(struct device *dev, const char *s, gfp_t gfp);
+char * __printf(3, 0) __malloc
+devm_kvasprintf(struct device *dev, gfp_t gfp, const char *fmt, va_list ap);
+char * __printf(3, 4) __malloc
+devm_kasprintf(struct device *dev, gfp_t gfp, const char *fmt, ...);
+
+unsigned long devm_get_free_pages(struct device *dev, gfp_t gfp_mask, unsigned int order);
+void devm_free_pages(struct device *dev, unsigned long addr);
+
+#ifdef CONFIG_HAS_IOMEM
+
+void __iomem *devm_ioremap_resource(struct device *dev, const struct resource *res);
+void __iomem *devm_ioremap_resource_wc(struct device *dev, const struct resource *res);
+
+void __iomem *devm_of_iomap(struct device *dev, struct device_node *node, int index,
+			    resource_size_t *size);
+#else
+
+static inline
+void __iomem *devm_ioremap_resource(struct device *dev, const struct resource *res)
+{
+	return IOMEM_ERR_PTR(-EINVAL);
+}
+
+static inline
+void __iomem *devm_ioremap_resource_wc(struct device *dev, const struct resource *res)
+{
+	return IOMEM_ERR_PTR(-EINVAL);
+}
+
+static inline
+void __iomem *devm_of_iomap(struct device *dev, struct device_node *node, int index,
+			    resource_size_t *size)
+{
+	return IOMEM_ERR_PTR(-EINVAL);
+}
+
+#endif
+
+#endif /* _DEVICE_DEVRES_H_ */