staging: vchiq_arm: Make vchiq_platform_init() static
Subsystems (2)
PATCH 1/1 staging: vchiq_arm: Make vchiq_platform_init() static
vchiq_platform_init() is only used in this file so it can be static.
clang-16 with W=1 reports:
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:465:5: error: no previous prototype for function 'vchiq_platform_init' [-Werror,-Wmissing-prototypes] int vchiq_platform_init(struct platform_device *pdev, struct vchiq_state *state)
^
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:465:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
--- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +2 -1
@@ -462,7 +462,8 @@ free_pagelist(struct vchiq_instance *instance, struct vchiq_pagelist_info *pagelcleanup_pagelistinfo (instance, pagelistinfo); } -int vchiq_platform_init (struct platform_device *pdev,struct vchiq_state *state) +static int +vchiq_platform_init (struct platform_device *pdev,struct vchiq_state *state) {struct device *dev = &pdev->dev;struct vchiq_drvdata *drvdata =platform_get_drvdata (pdev);
Quoted 11 lines · Simon Horman
vchiq_platform_init()is only used in this file so it can be static.clang-16 with W=1 reports:
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:465:5: error: no previous prototype for function 'vchiq_platform_init' [-Werror,-Wmissing-prototypes] intvchiq_platform_init(struct platform_device *pdev, struct vchiq_state *state)^
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:465:1: note: declare 'static' if the function is not intended to be used outside of this translation unitSigned-off-by Simon Horman <[email protected]>
I would have kept the return type on the original line and just added the explicit linkage on top, but it's fine and checkpatch doesn't complain. Thanks for the patch!
Quoted 19 lines
--- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +2
-1@@ -462,7 +462,8 @@ free_pagelist(struct vchiq_instance *instance, struct vchiq_pagelist_info *pagelcleanup_pagelistinfo (instance, pagelistinfo); } -int vchiq_platform_init (struct platform_device *pdev,struct vchiq_state *state) +static int +vchiq_platform_init (struct platform_device *pdev,struct vchiq_state *state) {struct device *dev = &pdev->dev;struct vchiq_drvdata *drvdata =platform_get_drvdata (pdev);
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 11 lines · Nick Desaulniers
Quoted 10 lines · Simon Horman
vchiq_platform_init()is only used in this file so it can be static.clang-16 with W=1 reports:
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:465:5: error: no previous prototype for function 'vchiq_platform_init' [-Werror,-Wmissing-prototypes] intvchiq_platform_init(struct platform_device *pdev, struct vchiq_state *state)^
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:465:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
Quoted 5 lines
Quoted 1 line
Signed-off-by Simon Horman <[email protected]>I would have kept the return type on the original line and just added the explicit linkage on top, but it's fine and checkpatch doesn't complain. Thanks for the patch!
Thanks, I wasn't sure which was the best way to to on that. I'll keep this in mind in future.
Quoted 27 lines
Reviewed-by Nick Desaulniers <[email protected]>Quoted 19 lines
--- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +2
-1@@ -462,7 +462,8 @@ free_pagelist(struct vchiq_instance *instance, struct vchiq_pagelist_info *pagelcleanup_pagelistinfo (instance, pagelistinfo); } -int vchiq_platform_init (struct platform_device *pdev,struct vchiq_state *state) +static int +vchiq_platform_init (struct platform_device *pdev,struct vchiq_state *state) {struct device *dev = &pdev->dev;struct vchiq_drvdata *drvdata =platform_get_drvdata (pdev);Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 10 lines · Simon Horman
vchiq_platform_init()is only used in this file so it can be static.clang-16 with W=1 reports:
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:465:5: error: no previous prototype for function 'vchiq_platform_init' [-Werror,-Wmissing-prototypes] intvchiq_platform_init(struct platform_device *pdev, struct vchiq_state *state)^
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:465:1: note: declare 'static' if the function is not intended to be used outside of this translation unitSigned-off-by Simon Horman <[email protected]>
Introduced by commit 89cc4218f640 ("staging: vchiq_arm: drop unnecessary declarations"), not sure it is worth a fixes tag since it is a W=1 warning.
Quoted 19 lines
--- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +2
-1@@ -462,7 +462,8 @@ free_pagelist(struct vchiq_instance *instance, struct vchiq_pagelist_info *pagelcleanup_pagelistinfo (instance, pagelistinfo); } -int vchiq_platform_init (struct platform_device *pdev,struct vchiq_state *state) +static int +vchiq_platform_init (struct platform_device *pdev,struct vchiq_state *state) {struct device *dev = &pdev->dev;struct vchiq_drvdata *drvdata =platform_get_drvdata (pdev);
Quoted 10 lines · Nathan Chancellor
Quoted 9 lines · Simon Horman
vchiq_platform_init()is only used in this file so it can be static.clang-16 with W=1 reports:
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:465:5: error: no previous prototype for function 'vchiq_platform_init' [-Werror,-Wmissing-prototypes] intvchiq_platform_init(struct platform_device *pdev, struct vchiq_state *state)^
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:465:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
Quoted 5 lines
Quoted 1 line
Signed-off-by Simon Horman <[email protected]>Introduced by commit
89cc4218f640("staging:vchiq_arm: drop unnecessary declarations"), not sure it is worth a fixes tag since it is a W=1 warning.
Thanks. For some reason it didn't occur to me to check which patch introduced the issue. Perhaps because, as you say, it's a W=1 issue, and I don't think that warrants a fixes tag.
I could include some information in the commit message, like "Introduced by ..." if desired.
Quoted 22 lines
Reviewed-by Nathan Chancellor <[email protected]>Quoted 19 lines
--- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +2
-1@@ -462,7 +462,8 @@ free_pagelist(struct vchiq_instance *instance, struct vchiq_pagelist_info *pagelcleanup_pagelistinfo (instance, pagelistinfo); } -int vchiq_platform_init (struct platform_device *pdev,struct vchiq_state *state) +static int +vchiq_platform_init (struct platform_device *pdev,struct vchiq_state *state) {struct device *dev = &pdev->dev;struct vchiq_drvdata *drvdata =platform_get_drvdata (pdev);
Hi Simon,
Am 18.04.23 um 13:23 schrieb Simon Horman:
Quoted 10 lines
vchiq_platform_init()is only used in this file so it can be static.clang-16 with W=1 reports:
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:465:5: error: no previous prototype for function 'vchiq_platform_init' [-Werror,-Wmissing-prototypes] intvchiq_platform_init(struct platform_device *pdev, struct vchiq_state *state)^
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:465:1: note: declare 'static' if the function is not intended to be used outside of this translation unitSigned-off-by Simon Horman <[email protected]>
this is not the first attempt to fix this [1]. But maybe this has been fixed in the meantime.
[1] - https://lore.kernel.org/linux-staging/[email protected]/#t
Quoted 12 lines · Stefan Wahren
Hi Simon,
Am 18.04.23 um 13:23 schrieb Simon Horman:
Quoted 9 lines
vchiq_platform_init()is only used in this file so it can be static.clang-16 with W=1 reports:
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:465:5: error: no previous prototype for function 'vchiq_platform_init' [-Werror,-Wmissing-prototypes] intvchiq_platform_init(struct platform_device *pdev, struct vchiq_state *state)^
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:465:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
Quoted 6 lines
Quoted 1 line
Signed-off-by Simon Horman <[email protected]>this is not the first attempt to fix this [1]. But maybe this has been fixed in the meantime.
[1] - https://lore.kernel.org/linux-staging/[email protected]/#t
Thanks,
I see in that thread that Greg notes that "this breaks the build in a very horrible and strange way" [2].
I'm a bit surprised as I didn't observe such a thing. But I also don't dispute it - clearly my testing was inadequate.
I'll try and dig a bit deeper into this one.
Perhaps starting with the report from the kernel test robot [3]
[2] https://lore.kernel.org/linux-staging/[email protected]/
[3] https://lore.kernel.org/linux-staging/[email protected]/
+ Arnd
Quoted 19 lines · Simon Horman
Quoted 17 lines · Stefan Wahren
Hi Simon,
Am 18.04.23 um 13:23 schrieb Simon Horman:
Quoted 10 lines
vchiq_platform_init()is only used in this file so it can be static.clang-16 with W=1 reports:
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:465:5: error: no previous prototype for function 'vchiq_platform_init' [-Werror,-Wmissing-prototypes] intvchiq_platform_init(struct platform_device *pdev, struct vchiq_state *state)^
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:465:1: note: declare 'static' if the function is not intended to be used outside of this translation unitSigned-off-by Simon Horman <[email protected]>this is not the first attempt to fix this [1]. But maybe this has been fixed in the meantime.
Quoted 6 lines
Quoted 1 line
[1] - https://lore.kernel.org/linux-staging/[email protected]/#t
Thanks,
I see in that thread that Greg notes that "this breaks the build in a very horrible and strange way" [2].
So Arnd had a Kconfig suggestion later in that thread:
https://lore.kernel.org/linux-staging/[email protected]/
Marking something as depends on OF_DYNAMIC. (Not sure whether Arnd meant that for BCM2835_VCHIQ or BCM_VIDEOCORE).
Perhaps try that?
Quoted 9 lines
I'm a bit surprised as I didn't observe such a thing. But I also don't dispute it - clearly my testing was inadequate.
I'll try and dig a bit deeper into this one.
Perhaps starting with the report from the kernel test robot [3][2] https://lore.kernel.org/linux-staging/[email protected]/
[3] https://lore.kernel.org/linux-staging/[email protected]/
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 12 lines · Nick Desaulniers
On Wed, Apr 19, 2023 at 1:51 AM Simon Horman <[email protected]> wrote:
Marking something as
depends on OF_DYNAMIC. (Not sure whether Arnd meant that forBCM2835_VCHIQorBCM_VIDEOCORE).
Perhaps try that?Quoted 6 lines
I'm a bit surprised as I didn't observe such a thing. But I also don't dispute it - clearly my testing was inadequate.
I'll try and dig a bit deeper into this one.
Perhaps starting with the report from the kernel test robot [3]
I have this in my randconfig build tree, but it looks like I never sent it out.
----
From bb01f96d7dd66fc437302785f623a3ab323d486e Mon Sep 17 00:00:00 2001
From: Arnd Bergmann <[email protected]>
Date: Mon, 20 Mar 2023 11:33:52 +0100
Subject: [PATCH] staging: vchiq_arm: mark vchiq_platform_init() static
This function has no callers from other files, and the declaration was removed a while ago, causing a W=1 warning:
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:465:5: error: no previous prototype for 'vchiq_platform_init'
Marking it static solves this problem but introduces a new warning since gcc determines that 'g_fragments_base' is never initialized in some kernel configurations:
In file included from include/linux/string.h:254,
from include/linux/bitmap.h:11,
from include/linux/cpumask.h:12,
from include/linux/mm_types_task.h:14,
from include/linux/mm_types.h:5,
from include/linux/buildid.h:5,
from include/linux/module.h:14,
from drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:8:
In function 'memcpy_to_page',
inlined from 'free_pagelist' at drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:433:4:include/linux/fortify-string.h:57:33: error: argument 2 null where non-null expected [-Werror=nonnull] include/linux/highmem.h:427:9: note: in expansion of macro 'memcpy'
427 | memcpy(to + offset, from, len);
| ^~~~~~Add a NULL pointer check for this in addition to the static annotation to avoid both.
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +2 -2
@@ -415,7 +415,7 @@ free_pagelist(struct vchiq_instance *instance, struct vchiq_pagelist_info *pagel pagelistinfo->scatterlist_mapped =0 ;/* Deal with any partial cache lines (fragments) */ -if (pagelist->type >=PAGELIST_READ_WITH_FRAGMENTS ) { +if (pagelist->type >=PAGELIST_READ_WITH_FRAGMENTS && g_fragments_base) {char *fragments = g_fragments_base + (pagelist->type -PAGELIST_READ_WITH_FRAGMENTS ) * g_fragments_size;
@@ -462,7 +462,7 @@ free_pagelist(struct vchiq_instance *instance, struct vchiq_pagelist_info *pagelcleanup_pagelistinfo (instance, pagelistinfo); } -int vchiq_platform_init (struct platform_device *pdev,struct vchiq_state *state) +static int vchiq_platform_init (struct platform_device *pdev,struct vchiq_state *state) {struct device *dev = &pdev->dev;struct vchiq_drvdata *drvdata =platform_get_drvdata (pdev);
Nick Desaulniers
Reviewed-byQuoted 9 lines · Arnd Bergmann
Quoted 7 lines · Nick Desaulniers
On Wed, Apr 19, 2023 at 1:51 AM Simon Horman <[email protected]> wrote:
Marking something as
depends on OF_DYNAMIC. (Not sure whether Arnd meant that forBCM2835_VCHIQorBCM_VIDEOCORE).
Perhaps try that?Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
I'm a bit surprised as I didn't observe such a thing. But I also don't dispute it - clearly my testing was inadequate.
I'll try and dig a bit deeper into this one.
Perhaps starting with the report from the kernel test robot [3]I have this in my randconfig build tree, but it looks like I never sent it out.
What else have you got hidden up in there? ;)
Quoted 60 lines
----
Frombb01f96d7dd66fc437302785f623a3ab323d486eMon Sep 17 00:00:00 2001
From: Arnd Bergmann <[email protected]>
Date: Mon, 20 Mar 2023 11:33:52 +0100
Subject: [PATCH] staging:vchiq_arm: markvchiq_platform_init()staticThis function has no callers from other files, and the declaration was removed a while ago, causing a W=1 warning:
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:465:5: error: no previous prototype for 'vchiq_platform_init'Marking it static solves this problem but introduces a new warning since gcc determines that '
g_fragments_base' is never initialized in some kernel configurations:In file included from
include/linux/string.h:254,
frominclude/linux/bitmap.h:11,
frominclude/linux/cpumask.h:12,
frominclude/linux/mm_types_task.h:14,
frominclude/linux/mm_types.h:5,
frominclude/linux/buildid.h:5,
frominclude/linux/module.h:14,
fromdrivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:8:
In function 'memcpy_to_page',
inlined from 'free_pagelist' atdrivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c:433:4:include/linux/fortify-string.h:57:33: error: argument 2 null where non-null expected [-Werror=nonnull]include/linux/highmem.h:427:9: note: in expansion of macro 'memcpy'427 | memcpy(to + offset, from, len); | ^~~~~~Add a NULL pointer check for this in addition to the static annotation to avoid both.
Fixes 89cc4218f640 ("staging: vchiq_arm: drop unnecessary declarations")Signed-off-by Arnd Bergmann <[email protected]>drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +2
-2@@ -415,7 +415,7 @@ free_pagelist(struct vchiq_instance *instance, struct vchiq_pagelist_info *pagel pagelistinfo->scatterlist_mapped =0 ;/* Deal with any partial cache lines (fragments) */ -if (pagelist->type >=PAGELIST_READ_WITH_FRAGMENTS ) { +if (pagelist->type >=PAGELIST_READ_WITH_FRAGMENTS && g_fragments_base) {char *fragments = g_fragments_base + (pagelist->type -PAGELIST_READ_WITH_FRAGMENTS ) * g_fragments_size;@@ -462,7 +462,7 @@ free_pagelist(struct vchiq_instance *instance, struct vchiq_pagelist_info *pagelcleanup_pagelistinfo (instance, pagelistinfo); } -int vchiq_platform_init (struct platform_device *pdev,struct vchiq_state *state) +static int vchiq_platform_init (struct platform_device *pdev,struct vchiq_state *state) {struct device *dev = &pdev->dev;struct vchiq_drvdata *drvdata =platform_get_drvdata (pdev);
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 13 lines · Nick Desaulniers
Quoted 12 lines · Arnd Bergmann
Quoted 10 lines · Nick Desaulniers
On Wed, Apr 19, 2023 at 1:51 AM Simon Horman <[email protected]> wrote:
Marking something as
depends on OF_DYNAMIC. (Not sure whether Arnd meant that forBCM2835_VCHIQorBCM_VIDEOCORE).
Perhaps try that?Quoted 4 lines
I'm a bit surprised as I didn't observe such a thing. But I also don't dispute it - clearly my testing was inadequate.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
I'll try and dig a bit deeper into this one.
Perhaps starting with the report from the kernel test robot [3]I have this in my randconfig build tree, but it looks like I never sent it out.
What else have you got hidden up in there? ;)
Reviewed-by Nick Desaulniers <[email protected]>
Actually, I have fixes for all missing-prototype warnings in my tree, just remembered that this one is part of my longer series. I have about 150 patches that are already split up and just need to be sent out, plus more that are currently sitting in a combined changeset.
Arnd
Quoted 21 lines · Arnd Bergmann
Quoted 19 lines · Nick Desaulniers
Quoted 17 lines · Arnd Bergmann
Quoted 12 lines · Nick Desaulniers
On Wed, Apr 19, 2023 at 1:51 AM Simon Horman <[email protected]> wrote:
Marking something as
depends on OF_DYNAMIC. (Not sure whether Arnd meant that forBCM2835_VCHIQorBCM_VIDEOCORE).
Perhaps try that?Quoted 6 lines
I'm a bit surprised as I didn't observe such a thing. But I also don't dispute it - clearly my testing was inadequate.
I'll try and dig a bit deeper into this one.
Perhaps starting with the report from the kernel test robot [3]I have this in my randconfig build tree, but it looks like I never sent it out.
Quoted 8 lines
Quoted 2 lines
What else have you got hidden up in there? ;)
Reviewed-by Nick Desaulniers <[email protected]>Actually, I have fixes for all missing-prototype warnings in my tree, just remembered that this one is part of my longer series. I have about 150 patches that are already split up and just need to be sent out, plus more that are currently sitting in a combined changeset.
All? Wanna bet we can introduce new instances of that warning faster than you can fix all of them? Actually, no I would not take that bet.
I'm just having fun, thanks for all of that cleanup work!
Signature · 2 lines
Thanks, ~Nick Desaulniers