From: Johan Hovold <johan@kernel.org>
To: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org,
cphealy@gmail.com, Lucas Stach <l.stach@pengutronix.de>,
Nikita Yushchenko <nikita.yoush@cogentembedded.com>,
Lee Jones <lee.jones@linaro.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Pavel Machek <pavel@ucw.cz>,
Andy Shevchenko <andy.shevchenko@gmail.com>,
Guenter Roeck <linux@roeck-us.net>, Rob Herring <robh@kernel.org>,
Johan Hovold <johan@kernel.org>,
Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Subject: Re: [PATCH v10 4/5] watchdog: Add RAVE SP watchdog driver
Date: Sun, 5 Nov 2017 16:47:25 +0100 [thread overview]
Message-ID: <20171105154725.GA11226@localhost> (raw)
In-Reply-To: <20171031163656.24552-5-andrew.smirnov@gmail.com>
On Tue, Oct 31, 2017 at 09:36:55AM -0700, Andrey Smirnov wrote:
> This driver provides access to RAVE SP watchdog functionality.
>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-watchdog@vger.kernel.org
> Cc: cphealy@gmail.com
> Cc: Lucas Stach <l.stach@pengutronix.de>
> Cc: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
> Cc: Lee Jones <lee.jones@linaro.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: Rob Herring <robh@kernel.org>
> Cc: Johan Hovold <johan@kernel.org>
> Cc: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
> Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> +static const struct of_device_id rave_sp_wdt_of_match[] = {
> + { .compatible = "zii,rave-sp-watchdog" },
> + {}
> +};
> +static const struct of_device_id rave_sp_wdt_variants[] = {
> + { .compatible = COMPATIBLE_RAVE_SP_NIU, .data = &rave_sp_wdt_legacy },
> + { .compatible = COMPATIBLE_RAVE_SP_MEZZ, .data = &rave_sp_wdt_legacy },
> + { .compatible = COMPATIBLE_RAVE_SP_ESB, .data = &rave_sp_wdt_legacy },
> + { .compatible = COMPATIBLE_RAVE_SP_RDU1, .data = &rave_sp_wdt_rdu },
> + { .compatible = COMPATIBLE_RAVE_SP_RDU2, .data = &rave_sp_wdt_rdu },
> + { /* sentinel */ }
> +};
> +
> +static int rave_sp_wdt_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + const struct of_device_id *id;
> + struct watchdog_device *wdd;
> + struct rave_sp_wdt *sp_wd;
> + struct nvmem_cell *cell;
> + __le16 timeout = 0;
> + int ret;
> +
> + id = of_match_device(rave_sp_wdt_variants, dev->parent);
So as I already mentioned in a comment on an earlier version of the MFD
driver, I find this matching on the parent of_node to be an odd
pattern, which also does not seem to have any precedent in mainline.
It seems you really should be using two compatible strings for the
watchdog (for the legacy and rdu variants) rather than keep an entry for
every parent compatible-string in every child/cell driver (which all
need to be kept in sync).
But let's see what Rob and Lee says about this.
> + if (!id) {
> + dev_err(dev, "Unknown parent device variant. Bailing out\n");
> + return -ENODEV;
> + }
> +
> + sp_wd = devm_kzalloc(dev, sizeof(*sp_wd), GFP_KERNEL);
> + if (!sp_wd)
> + return -ENOMEM;
> +
> + sp_wd->variant = id->data;
> + sp_wd->sp = dev_get_drvdata(dev->parent);
> +
> + wdd = &sp_wd->wdd;
> + wdd->parent = dev;
> + wdd->info = &rave_sp_wdt_info;
> + wdd->ops = &rave_sp_wdt_ops;
> + wdd->min_timeout = sp_wd->variant->min_timeout;
> + wdd->max_timeout = sp_wd->variant->max_timeout;
> + wdd->status = WATCHDOG_NOWAYOUT_INIT_STATUS;
> + wdd->timeout = 60;
> +
> + cell = nvmem_cell_get(dev, "wdt-timeout");
> + if (!IS_ERR(cell)) {
> + size_t len;
> + void *value = nvmem_cell_read(cell, &len);
> +
> + if (!IS_ERR(value)) {
> + memcpy(&timeout, value, min(len, sizeof(timeout)));
> + kfree(value);
> + }
> + nvmem_cell_put(cell);
> + }
> + watchdog_init_timeout(wdd, le16_to_cpu(timeout), dev);
> + watchdog_set_restart_priority(wdd, 255);
> +
> + sp_wd->reboot_notifier.notifier_call = rave_sp_wdt_reboot_notifier;
> + ret = devm_register_reboot_notifier(dev, &sp_wd->reboot_notifier);
> + if (ret) {
> + dev_err(dev, "Failed to register reboot notifier\n");
> + return ret;
> + }
> +
> + /*
> + * We don't know if watchdog is running now. To be sure, let's
> + * start it and depend on watchdog core to ping it
> + */
> + wdd->max_hw_heartbeat_ms = wdd->max_timeout * 1000;
> + ret = rave_sp_wdt_start(wdd);
> + if (ret) {
> + dev_err(dev, "Watchdog didn't start\n");
> + return ret;
> + }
> +
> + return devm_watchdog_register_device(dev, wdd);
What about stopping the watchdog on errors here?
And does watchdog core take care of calling stop() on unregister (i.e.
at unbind)?
> +}
> +
> +static struct platform_driver rave_sp_wdt_driver = {
> + .probe = rave_sp_wdt_probe,
> + .driver = {
> + .name = KBUILD_MODNAME,
> + .of_match_table = rave_sp_wdt_of_match,
> + },
> +};
Johan
next prev parent reply other threads:[~2017-11-05 15:47 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-31 16:36 [PATCH v10 0/5] ZII RAVE platform driver Andrey Smirnov
2017-10-31 16:36 ` [PATCH v10 1/5] serdev: Make .remove in struct serdev_device_driver optional Andrey Smirnov
2017-11-01 23:48 ` Rob Herring
2017-11-04 11:24 ` Greg Kroah-Hartman
2017-11-04 17:05 ` Sebastian Reichel
2017-10-31 16:36 ` [PATCH v10 2/5] serdev: Introduce devm_serdev_device_open() Andrey Smirnov
2017-11-01 23:48 ` Rob Herring
2017-11-05 15:38 ` Johan Hovold
2017-11-05 22:19 ` Andrey Smirnov
2017-10-31 16:36 ` [PATCH v10 3/5] mfd: Add driver for RAVE Supervisory Processor Andrey Smirnov
2017-11-05 15:38 ` Johan Hovold
2017-11-05 22:02 ` Andrey Smirnov
2017-10-31 16:36 ` [PATCH v10 4/5] watchdog: Add RAVE SP watchdog driver Andrey Smirnov
2017-10-31 17:21 ` Guenter Roeck
2017-11-04 11:24 ` Greg Kroah-Hartman
2017-11-05 15:55 ` Guenter Roeck
2017-11-05 15:47 ` Johan Hovold [this message]
2017-11-05 18:34 ` Guenter Roeck
2017-11-05 21:59 ` Andrey Smirnov
2017-10-31 16:36 ` [PATCH v10 5/5] dt-bindings: watchdog: Add bindings for " Andrey Smirnov
2017-10-31 17:22 ` Guenter Roeck
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=20171105154725.GA11226@localhost \
--to=johan@kernel.org \
--cc=andrew.smirnov@gmail.com \
--cc=andy.shevchenko@gmail.com \
--cc=cphealy@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=l.stach@pengutronix.de \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=nikita.yoush@cogentembedded.com \
--cc=pavel@ucw.cz \
--cc=robh@kernel.org \
--cc=sebastian.reichel@collabora.co.uk \
/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