Linux-Watchdog Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] watchdog: fix watchdog_pretimeout.c build error when no default gov. is set
@ 2019-05-07 23:33 Randy Dunlap
  2019-05-08  0:07 ` Guenter Roeck
  0 siblings, 1 reply; 3+ messages in thread
From: Randy Dunlap @ 2019-05-07 23:33 UTC (permalink / raw)
  To: LKML, linux-watchdog; +Cc: Vladimir Zapolskiy, Wim Van Sebroeck, Guenter Roeck

From: Randy Dunlap <rdunlap@infradead.org>

Fix build error when
CONFIG_WATCHDOG_PRETIMEOUT_GOV=y
# CONFIG_WATCHDOG_PRETIMEOUT_GOV_NOOP is not set
# CONFIG_WATCHDOG_PRETIMEOUT_GOV_PANIC is not set

Fixes this build error:

../drivers/watchdog/watchdog_pretimeout.c: In function ‘watchdog_register_governor’:
../drivers/watchdog/watchdog_pretimeout.c:139:26: error: ‘WATCHDOG_PRETIMEOUT_DEFAULT_GOV’ undeclared (first use in this function)
  if (!strncmp(gov->name, WATCHDOG_PRETIMEOUT_DEFAULT_GOV,

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: linux-watchdog@vger.kernel.org
---
Found in linux-next but applies to mainline.

 drivers/watchdog/watchdog_pretimeout.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

--- linux-next-20190507.orig/drivers/watchdog/watchdog_pretimeout.c
+++ linux-next-20190507/drivers/watchdog/watchdog_pretimeout.c
@@ -118,7 +118,6 @@ EXPORT_SYMBOL_GPL(watchdog_notify_pretim
 
 int watchdog_register_governor(struct watchdog_governor *gov)
 {
-	struct watchdog_pretimeout *p;
 	struct governor_priv *priv;
 
 	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
@@ -136,8 +135,11 @@ int watchdog_register_governor(struct wa
 	priv->gov = gov;
 	list_add(&priv->entry, &governor_list);
 
+#if defined(WATCHDOG_PRETIMEOUT_DEFAULT_GOV)
 	if (!strncmp(gov->name, WATCHDOG_PRETIMEOUT_DEFAULT_GOV,
 		     WATCHDOG_GOV_NAME_MAXLEN)) {
+		struct watchdog_pretimeout *p;
+
 		spin_lock_irq(&pretimeout_lock);
 		default_gov = gov;
 
@@ -146,6 +148,7 @@ int watchdog_register_governor(struct wa
 				p->wdd->gov = default_gov;
 		spin_unlock_irq(&pretimeout_lock);
 	}
+#endif
 
 	mutex_unlock(&governor_lock);
 



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] watchdog: fix watchdog_pretimeout.c build error when no default gov. is set
  2019-05-07 23:33 [PATCH] watchdog: fix watchdog_pretimeout.c build error when no default gov. is set Randy Dunlap
@ 2019-05-08  0:07 ` Guenter Roeck
  2019-05-08  0:22   ` Randy Dunlap
  0 siblings, 1 reply; 3+ messages in thread
From: Guenter Roeck @ 2019-05-08  0:07 UTC (permalink / raw)
  To: Randy Dunlap, LKML, linux-watchdog; +Cc: Vladimir Zapolskiy, Wim Van Sebroeck

On 5/7/19 4:33 PM, Randy Dunlap wrote:
> From: Randy Dunlap <rdunlap@infradead.org>
> 
> Fix build error when
> CONFIG_WATCHDOG_PRETIMEOUT_GOV=y
> # CONFIG_WATCHDOG_PRETIMEOUT_GOV_NOOP is not set
> # CONFIG_WATCHDOG_PRETIMEOUT_GOV_PANIC is not set
> 
> Fixes this build error:
> 
> ../drivers/watchdog/watchdog_pretimeout.c: In function ‘watchdog_register_governor’:
> ../drivers/watchdog/watchdog_pretimeout.c:139:26: error: ‘WATCHDOG_PRETIMEOUT_DEFAULT_GOV’ undeclared (first use in this function)
>    if (!strncmp(gov->name, WATCHDOG_PRETIMEOUT_DEFAULT_GOV,
> 

Ah, I knew I missed something. The following would be a better fix,
though, since it enforces that at least one pretimeout governor is enabled
(matching the old code):

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index e19960ace0c0..4a3461afa96f 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -71,6 +71,12 @@ config WATCHDOG_PRETIMEOUT_GOV
         help
           The option allows to select watchdog pretimeout governors.

+config WATCHDOG_PRETIMEOUT_GOV_SEL
+       tristate
+       depends on WATCHDOG_PRETIMEOUT_GOV
+       default m
+       select WATCHDOG_PRETIMEOUT_GOV_PANIC if WATCHDOG_PRETIMEOUT_GOV_NOOP=n
+
  if WATCHDOG_PRETIMEOUT_GOV

Can you send v2 with the above, or do you want me to send it and give you credit ?

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] watchdog: fix watchdog_pretimeout.c build error when no default gov. is set
  2019-05-08  0:07 ` Guenter Roeck
@ 2019-05-08  0:22   ` Randy Dunlap
  0 siblings, 0 replies; 3+ messages in thread
From: Randy Dunlap @ 2019-05-08  0:22 UTC (permalink / raw)
  To: Guenter Roeck, LKML, linux-watchdog; +Cc: Vladimir Zapolskiy, Wim Van Sebroeck

On 5/7/19 5:07 PM, Guenter Roeck wrote:
> On 5/7/19 4:33 PM, Randy Dunlap wrote:
>> From: Randy Dunlap <rdunlap@infradead.org>
>>
>> Fix build error when
>> CONFIG_WATCHDOG_PRETIMEOUT_GOV=y
>> # CONFIG_WATCHDOG_PRETIMEOUT_GOV_NOOP is not set
>> # CONFIG_WATCHDOG_PRETIMEOUT_GOV_PANIC is not set
>>
>> Fixes this build error:
>>
>> ../drivers/watchdog/watchdog_pretimeout.c: In function ‘watchdog_register_governor’:
>> ../drivers/watchdog/watchdog_pretimeout.c:139:26: error: ‘WATCHDOG_PRETIMEOUT_DEFAULT_GOV’ undeclared (first use in this function)
>>    if (!strncmp(gov->name, WATCHDOG_PRETIMEOUT_DEFAULT_GOV,
>>
> 
> Ah, I knew I missed something. The following would be a better fix,
> though, since it enforces that at least one pretimeout governor is enabled
> (matching the old code):
> 
> diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
> index e19960ace0c0..4a3461afa96f 100644
> --- a/drivers/watchdog/Kconfig
> +++ b/drivers/watchdog/Kconfig
> @@ -71,6 +71,12 @@ config WATCHDOG_PRETIMEOUT_GOV
>         help
>           The option allows to select watchdog pretimeout governors.
> 
> +config WATCHDOG_PRETIMEOUT_GOV_SEL
> +       tristate
> +       depends on WATCHDOG_PRETIMEOUT_GOV
> +       default m
> +       select WATCHDOG_PRETIMEOUT_GOV_PANIC if WATCHDOG_PRETIMEOUT_GOV_NOOP=n
> +
>  if WATCHDOG_PRETIMEOUT_GOV
> 
> Can you send v2 with the above, or do you want me to send it and give you credit ?
> 
> Thanks,
> Guenter

Hi Guenter,
That's your patch.  You can send it.  :)
No credit needed.

cheers.
-- 
~Randy

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-07 23:33 [PATCH] watchdog: fix watchdog_pretimeout.c build error when no default gov. is set Randy Dunlap
2019-05-08  0:07 ` Guenter Roeck
2019-05-08  0:22   ` Randy Dunlap

Linux-Watchdog Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-watchdog/0 linux-watchdog/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-watchdog linux-watchdog/ https://lore.kernel.org/linux-watchdog \
		linux-watchdog@vger.kernel.org linux-watchdog@archiver.kernel.org
	public-inbox-index linux-watchdog


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-watchdog


AGPL code for this site: git clone https://public-inbox.org/ public-inbox