All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Wolfram Sang <w.sang@pengutronix.de>
Cc: linux-watchdog@vger.kernel.org, rtc-linux@googlegroups.com,
	Wim Van Sebroeck <wim@iguana.be>,
	Alessandro Zummo <alessandro.zummo@towertech.it>
Subject: Re: [PATCH 1/3] rtc: stmp3xxx: add wdt-accessor function
Date: Tue, 24 Jan 2012 16:59:58 -0800	[thread overview]
Message-ID: <20120124165958.2091fa94.akpm@linux-foundation.org> (raw)
In-Reply-To: <1327347185-620-2-git-send-email-w.sang@pengutronix.de>

On Mon, 23 Jan 2012 20:33:03 +0100
Wolfram Sang <w.sang@pengutronix.de> wrote:

> This RTC also includes a watchdog timer. Provide an accessor function
> for it to be picked up by a watchdog driver. Also register the
> platform_device here to get the boot-time dependencies right.
> 
>
> ...
>
>  struct stmp3xxx_rtc_data {
>  	struct rtc_device *rtc;
>  	void __iomem *io;
>  	int irq_alarm;
>  };
>  
> +#if defined(CONFIG_STMP3XXX_RTC_WATCHDOG) || defined(CONFIG_STMP3XXX_RTC_WATCHDOG_MODULE)

You can use IS_ENABLED() here.

> +/**
> + * stmp3xxx_wdt_set_timeout - configure the watchdog inside the STMP3xxx RTC
> + * @dev: the parent device of the watchdog (= the RTC)
> + * @timeout: the desired value for the timeout register of the watchdog.
> + *           0 disables the watchdog
> + *
> + * The watchdog needs one register and two bits which are in the RTC domain.
> + * To handle the resource conflict, the RTC driver will create another
> + * platform_device for the watchdog driver as a child of the RTC device.
> + * The watchdog driver is passed the below accessor function via platform_data
> + * to configure the watchdog. Locking is not needed because accessing SET/CLR
> + * registers is atomic.
> + */
> +
> +void stmp3xxx_wdt_set_timeout(struct device *dev, u32 timeout)
> +{
> +	struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev);
> +	void __iomem *base;
> +
> +	if (timeout) {
> +		writel(timeout, rtc_data->io + STMP3XXX_RTC_WATCHDOG);
> +		base = rtc_data->io + MXS_SET_ADDR;
> +	} else {
> +		base = rtc_data->io + MXS_CLR_ADDR;
> +	}
> +	writel(STMP3XXX_RTC_CTRL_WATCHDOGEN, base + STMP3XXX_RTC_CTRL);
> +	writel(STMP3XXX_RTC_PERSISTENT1_FORCE_UPDATER,
> +		base + STMP3XXX_RTC_PERSISTENT1);
> +}

This wants EXPORT_SYMBOL(), surely?

Which points suspicious fingers at your testing ;) Please test all
combinations of y, n and m on both config symbols.

> +static struct stmp3xxx_wdt_pdata wdt_pdata = {
> +	.wdt_set_timeout = stmp3xxx_wdt_set_timeout,
> +};
> +
> +static struct platform_device stmp3xxx_wdt_pdev = {
> +	.name = "stmp3xxx_rtc_wdt",
> +	.dev = {
> +		.platform_data = &wdt_pdata,
> +	},
> +};
> +
> +static void stmp3xxx_wdt_register(struct platform_device *rtc_pdev)
> +{
> +	stmp3xxx_wdt_pdev.dev.parent = &rtc_pdev->dev;
> +	stmp3xxx_wdt_pdev.id = rtc_pdev->id;
> +	platform_device_register(&stmp3xxx_wdt_pdev);
> +}
> +#else
> +static void stmp3xxx_wdt_register(struct device *dev)
> +{
> +}

This stub is unfortunate.  If
!IS_ENABLED(CONFIG_STMP3XXX_RTC_WATCHDOG), the user still must load
this module just to get a silly empty function.  If the
stmp3xxx_wdt_register() stub were made static inline in a header file,
the user won't need to compile or load this module at all.  There may
be other (initialisation?) reasons why the user must still load this
module?

  reply	other threads:[~2012-01-25  1:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-23 19:33 [PATCH RESEND 0/3] watchdog: new driver for STMP3xxx/MX23/MX28 Wolfram Sang
2012-01-23 19:33 ` [PATCH 1/3] rtc: stmp3xxx: add wdt-accessor function Wolfram Sang
2012-01-25  0:59   ` Andrew Morton [this message]
2012-01-23 19:33 ` [PATCH 2/3] watchdog: add new driver for STMP3xxx and i.MX23/28 Wolfram Sang
2012-01-25  1:02 ` [PATCH RESEND 0/3] watchdog: new driver for STMP3xxx/MX23/MX28 Andrew Morton
  -- strict thread matches above, loose matches on Subject: below --
2013-01-04 13:58 [PATCH 0/3] improved watchdog driver for STMP3xyz/imx23/imx28 Wolfram Sang
2013-01-04 13:58 ` [PATCH 1/3] rtc: stmp3xxx: add wdt-accessor function Wolfram Sang
2013-01-07 23:53   ` Andrew Morton
2011-12-08 17:19 [PATCH 0/3] watchdog: new driver for STMP3xxx/MX23/MX28 Wolfram Sang
2011-12-08 17:19 ` [PATCH 1/3] rtc: stmp3xxx: add wdt-accessor function Wolfram Sang
2011-12-08 17:19   ` Wolfram Sang
2011-12-09  0:27   ` Shawn Guo
2011-12-09  0:27     ` Shawn Guo
2011-12-09  9:22     ` Wolfram Sang
2011-12-09  9:22       ` 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=20120124165958.2091fa94.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=alessandro.zummo@towertech.it \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=rtc-linux@googlegroups.com \
    --cc=w.sang@pengutronix.de \
    --cc=wim@iguana.be \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.