2022-03-21 15:41:10

by Finn Thain

[permalink] [raw]
Subject: [PATCH v2] macintosh/via-pmu: Avoid compiler warnings when CONFIG_PROC_FS is disabled

drivers/macintosh/via-pmu.c:897:12: warning: 'pmu_battery_proc_show' defined but not used [-Wunused-function]
static int pmu_battery_proc_show(struct seq_file *m, void *v)
^~~~~~~~~~~~~~~~~~~~~
drivers/macintosh/via-pmu.c:871:12: warning: 'pmu_irqstats_proc_show' defined but not used [-Wunused-function]
static int pmu_irqstats_proc_show(struct seq_file *m, void *v)
^~~~~~~~~~~~~~~~~~~~~~
drivers/macintosh/via-pmu.c:860:12: warning: 'pmu_info_proc_show' defined but not used [-Wunused-function]
static int pmu_info_proc_show(struct seq_file *m, void *v)
^~~~~~~~~~~~~~~~~~

Add some #ifdefs to avoid unused code warnings when CONFIG_PROC_FS is
disabled.

Cc: Randy Dunlap <[email protected]>
Cc: Christophe Leroy <[email protected]>
Reported-by: Randy Dunlap <[email protected]>
Suggested-by: Christophe Leroy <[email protected]>
Signed-off-by: Finn Thain <[email protected]>
---
Changed since v1:
- Simplified to take advantage of the fact that proc_mkdir() is stubbed
out when CONFIG_PROC_FS=n. Hence that call doesn't need to move
within the #ifdef.
---
drivers/macintosh/via-pmu.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 2109129ea1bb..495fd35b11de 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -204,9 +204,11 @@ static int init_pmu(void);
static void pmu_start(void);
static irqreturn_t via_pmu_interrupt(int irq, void *arg);
static irqreturn_t gpio1_interrupt(int irq, void *arg);
+#ifdef CONFIG_PROC_FS
static int pmu_info_proc_show(struct seq_file *m, void *v);
static int pmu_irqstats_proc_show(struct seq_file *m, void *v);
static int pmu_battery_proc_show(struct seq_file *m, void *v);
+#endif
static void pmu_pass_intr(unsigned char *data, int len);
static const struct proc_ops pmu_options_proc_ops;

@@ -857,6 +859,7 @@ query_battery_state(void)
2, PMU_SMART_BATTERY_STATE, pmu_cur_battery+1);
}

+#ifdef CONFIG_PROC_FS
static int pmu_info_proc_show(struct seq_file *m, void *v)
{
seq_printf(m, "PMU driver version : %d\n", PMU_DRIVER_VERSION);
@@ -977,6 +980,7 @@ static const struct proc_ops pmu_options_proc_ops = {
.proc_release = single_release,
.proc_write = pmu_options_proc_write,
};
+#endif

#ifdef CONFIG_ADB
/* Send an ADB command */
--
2.32.0


2022-03-21 23:23:55

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH v2] macintosh/via-pmu: Avoid compiler warnings when CONFIG_PROC_FS is disabled



On 3/21/22 02:28, Finn Thain wrote:
> drivers/macintosh/via-pmu.c:897:12: warning: 'pmu_battery_proc_show' defined but not used [-Wunused-function]
> static int pmu_battery_proc_show(struct seq_file *m, void *v)
> ^~~~~~~~~~~~~~~~~~~~~
> drivers/macintosh/via-pmu.c:871:12: warning: 'pmu_irqstats_proc_show' defined but not used [-Wunused-function]
> static int pmu_irqstats_proc_show(struct seq_file *m, void *v)
> ^~~~~~~~~~~~~~~~~~~~~~
> drivers/macintosh/via-pmu.c:860:12: warning: 'pmu_info_proc_show' defined but not used [-Wunused-function]
> static int pmu_info_proc_show(struct seq_file *m, void *v)
> ^~~~~~~~~~~~~~~~~~
>
> Add some #ifdefs to avoid unused code warnings when CONFIG_PROC_FS is
> disabled.
>
> Cc: Randy Dunlap <[email protected]>
> Cc: Christophe Leroy <[email protected]>
> Reported-by: Randy Dunlap <[email protected]>
> Suggested-by: Christophe Leroy <[email protected]>
> Signed-off-by: Finn Thain <[email protected]>

Tested-by: Randy Dunlap <[email protected]>
Acked-by: Randy Dunlap <[email protected]>

Thanks.

> ---
> Changed since v1:
> - Simplified to take advantage of the fact that proc_mkdir() is stubbed
> out when CONFIG_PROC_FS=n. Hence that call doesn't need to move
> within the #ifdef.
> ---
> drivers/macintosh/via-pmu.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
> index 2109129ea1bb..495fd35b11de 100644
> --- a/drivers/macintosh/via-pmu.c
> +++ b/drivers/macintosh/via-pmu.c
> @@ -204,9 +204,11 @@ static int init_pmu(void);
> static void pmu_start(void);
> static irqreturn_t via_pmu_interrupt(int irq, void *arg);
> static irqreturn_t gpio1_interrupt(int irq, void *arg);
> +#ifdef CONFIG_PROC_FS
> static int pmu_info_proc_show(struct seq_file *m, void *v);
> static int pmu_irqstats_proc_show(struct seq_file *m, void *v);
> static int pmu_battery_proc_show(struct seq_file *m, void *v);
> +#endif
> static void pmu_pass_intr(unsigned char *data, int len);
> static const struct proc_ops pmu_options_proc_ops;
>
> @@ -857,6 +859,7 @@ query_battery_state(void)
> 2, PMU_SMART_BATTERY_STATE, pmu_cur_battery+1);
> }
>
> +#ifdef CONFIG_PROC_FS
> static int pmu_info_proc_show(struct seq_file *m, void *v)
> {
> seq_printf(m, "PMU driver version : %d\n", PMU_DRIVER_VERSION);
> @@ -977,6 +980,7 @@ static const struct proc_ops pmu_options_proc_ops = {
> .proc_release = single_release,
> .proc_write = pmu_options_proc_write,
> };
> +#endif
>
> #ifdef CONFIG_ADB
> /* Send an ADB command */

--
~Randy

2022-11-30 10:44:01

by Michael Ellerman

[permalink] [raw]
Subject: Re: [PATCH v2] macintosh/via-pmu: Avoid compiler warnings when CONFIG_PROC_FS is disabled

On Mon, 21 Mar 2022 20:28:00 +1100, Finn Thain wrote:
> drivers/macintosh/via-pmu.c:897:12: warning: 'pmu_battery_proc_show' defined but not used [-Wunused-function]
> static int pmu_battery_proc_show(struct seq_file *m, void *v)
> ^~~~~~~~~~~~~~~~~~~~~
> drivers/macintosh/via-pmu.c:871:12: warning: 'pmu_irqstats_proc_show' defined but not used [-Wunused-function]
> static int pmu_irqstats_proc_show(struct seq_file *m, void *v)
> ^~~~~~~~~~~~~~~~~~~~~~
> drivers/macintosh/via-pmu.c:860:12: warning: 'pmu_info_proc_show' defined but not used [-Wunused-function]
> static int pmu_info_proc_show(struct seq_file *m, void *v)
> ^~~~~~~~~~~~~~~~~~
>
> [...]

Applied to powerpc/next.

[1/1] macintosh/via-pmu: Avoid compiler warnings when CONFIG_PROC_FS is disabled
https://git.kernel.org/powerpc/c/27f9690a81d7acf185b78be8d03d4b3a243116b1

cheers