linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: linux-watchdog@vger.kernel.org,
	linux-renesas-soc@vger.kernel.org,
	Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Subject: Re: [RFC PATCH v3 1/4] watchdog: core: add mechanism to prevent removing if NOWAYOUT
Date: Wed, 29 Aug 2018 09:14:38 -0700	[thread overview]
Message-ID: <20180829161438.GA6723@roeck-us.net> (raw)
In-Reply-To: <20180829074241.1943-2-wsa+renesas@sang-engineering.com>

On Wed, Aug 29, 2018 at 09:42:38AM +0200, Wolfram Sang wrote:
> To prevent removing if NOWAYOUT, we invalidate the .remove function and
> suppress the bind/unbind attributes in sysfs. These are driver
> capabilities, so we need to set it up at runtime during init. To avoid
> boilerplate, introduce module_watchdog_driver() similar to
> module_driver(). On top of that, we then build
> module_watchdog_platform_driver(). Others may follow, if needed.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
>  include/linux/watchdog.h | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h
> index 44985c4a1e86..c8ecbc53c807 100644
> --- a/include/linux/watchdog.h
> +++ b/include/linux/watchdog.h
> @@ -216,4 +216,21 @@ extern void watchdog_unregister_device(struct watchdog_device *);
>  /* devres register variant */
>  int devm_watchdog_register_device(struct device *dev, struct watchdog_device *);
>  
> +#define module_watchdog_driver(__driver, __register, __unregister, __nowayout, ...) \

Another option might be to add another argument to this macro. Something like:

#define module_watchdog_driver(__wdriver, __driver, __register, __unregister, __nowayout, ...) \
static int __init __wdriver##_init(void) \
{ \
	__driver->suppress_bind_attrs = !!(__nowayout); \
	return __register(&(__wdriver)  ##__VA_ARGS__); \
} \
module_init(__wdriver##_init); \
static void __exit __wdriver##_exit(void) \
{ \
	__unregister(&(__wdriver), ##__VA_ARGS__); \
} \
module_exit(__wdriver##_exit)

#define module_watchdog_platform_driver(__platform_driver, __nowayout) \
	module_watchdog_driver(__platform_driver, &__platform_driver->driver, \
				platform_driver_register, \
				platform_driver_unregister, __nowayout)

This would avoid the dependency of having a ".driver" structure in each
supported bus driver structure.

Would that make sense ?

Guenter

  reply	other threads:[~2018-08-29 20:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-29  7:42 [RFC PATCH v3 0/4] watchdog: prevent removing a driver if NOWAYOUT Wolfram Sang
2018-08-29  7:42 ` [RFC PATCH v3 1/4] watchdog: core: add mechanism to prevent removing " Wolfram Sang
2018-08-29 16:14   ` Guenter Roeck [this message]
2018-08-29 20:55   ` Jerry Hoemann
2018-09-05 13:54     ` Geert Uytterhoeven
2018-09-05 15:33       ` Wolfram Sang
2018-08-29  7:42 ` [RFC PATCH v3 2/4] watchdog: renesas_wdt: avoid " Wolfram Sang
2018-08-29  7:42 ` [RFC PATCH v3 3/4] watchdog: core: add module_watchdog_pci_driver() Wolfram Sang
2018-08-29  7:42 ` [RFC PATCH v3 4/4] watchdog: i6300esb: avoid removing if NOWAYOUT Wolfram Sang

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=20180829161438.GA6723@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=wsa+renesas@sang-engineering.com \
    --cc=yoshihiro.shimoda.uh@renesas.com \
    /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;
as well as URLs for NNTP newsgroup(s).