LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Finn Thain <fthain@linux-m68k.org>
To: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Randy Dunlap <rdunlap@infradead.org>,
	"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] macintosh/via-pmu: Fix compiler warnings when CONFIG_PROC_FS is disabled
Date: Mon, 21 Mar 2022 19:50:41 +1100 (AEDT)	[thread overview]
Message-ID: <7b16264-dfef-414-8195-87c14a89fb40@linux-m68k.org> (raw)
In-Reply-To: <39f63c1b-5a1b-8c8e-5991-813d3d3c2576@linux-m68k.org>

[-- Attachment #1: Type: text/plain, Size: 2702 bytes --]

Hi Christophe,

On Mon, 21 Mar 2022, Finn Thain wrote:

> On Mon, 21 Mar 2022, Christophe Leroy wrote:
> 
> > Le 19/03/2022 à 08:20, Finn Thain a écrit :
> > > 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)
> > >              ^~~~~~~~~~~~~~~~~~
> > > 
> > > Rearrange some code and add some #ifdefs to avoid unused code warnings
> > > when CONFIG_PROC_FS is disabled.
> > 
> > Why not just put those three functions inside an #ifdef CONFIG_PROC_FS ?
> > 
> 
> You'd get a warning about the prototypes ("declared static but never 
> defined"). Rather than add an ifdef around the prototypes as well, I 
> just reordered things a little.

Oops, I was forgetting that I also added an ifdef around the new 
prototype.

The simplest solution is probably the patch below, as it better exploits 
the stubbed-out proc_* API in include/linux/proc_fs.h.

Was this what you had in mind?

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 */

  reply	other threads:[~2022-03-21  8:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-19  7:20 [PATCH] macintosh/via-pmu: Fix compiler warnings when CONFIG_PROC_FS is disabled Finn Thain
2022-03-19 15:26 ` Randy Dunlap
2022-03-21  6:42 ` Christophe Leroy
2022-03-21  8:33   ` Finn Thain
2022-03-21  8:50     ` Finn Thain [this message]
2022-03-21  8:56       ` Christophe Leroy
2022-03-21  9:11         ` Finn Thain
2022-03-21  8:55     ` Christophe Leroy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7b16264-dfef-414-8195-87c14a89fb40@linux-m68k.org \
    --to=fthain@linux-m68k.org \
    --cc=christophe.leroy@csgroup.eu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=rdunlap@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox