Re: [PATCH 16/16] char: mem: Provide local prototype for non-static function

From: Arnd Bergmann
Date: Thu May 20 2021 - 08:34:28 EST


On Thu, May 20, 2021 at 2:13 PM Lee Jones <lee.jones@xxxxxxxxxx> wrote:
>
> Fixes the following W=1 kernel build warning(s):
>
> drivers/char/mem.c:95:29: warning: no previous prototype for ‘unxlate_dev_mem_ptr’ [-Wmissing-prototypes]
> drivers/char/mem.c:96:13: note: in expansion of macro ‘unxlate_dev_mem_ptr’
>
> Cc: Arnd Bergmann <arnd@xxxxxxxx>
> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> Cc: "C. Scott Ananian" <cananian@xxxxxxxxxxxxxxxxxxxx>
> Cc: Kanoj Sarcar <kanoj@xxxxxxx>
> Signed-off-by: Lee Jones <lee.jones@xxxxxxxxxx>
> ---
> drivers/char/mem.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/char/mem.c b/drivers/char/mem.c
> index 95741f93a6cd0..7969ac85491df 100644
> --- a/drivers/char/mem.c
> +++ b/drivers/char/mem.c
> @@ -40,6 +40,8 @@
> #define DEVMEM_MINOR 1
> #define DEVPORT_MINOR 4
>
> +void unxlate_dev_mem_ptr(phys_addr_t phys, void *addr);
> +

This one doesn't look quite right to me, won't it break on architectures
that use the static inline unxlate_dev_mem_ptr() definition from
asm-generic?

I think the correct way would be to remove the __weak annotation
as well as the inline definition, and replace the local definition with
a static inline version.

Arnd