From: Wim Van Sebroeck <wim@iguana.be>
To: Ian Lartey <ian@slimlogic.co.uk>
Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-leds@vger.kernel.org,
linux-watchdog@vger.kernel.org,
devicetree-discuss@lists.ozlabs.org, swarren@wwwdotorg.org,
grant.likely@secretlab.ca, broonie@opensource.wolfsonmicro.com,
rob.herring@calxeda.com, rob@landley.net, mturquette@linaro.org,
linus.walleij@linaro.org, cooloney@gmail.com,
sfr@canb.auug.org.au, rpurdie@rpsys.net,
akpm@linux-foundation.org, sameo@linux.intel.com,
lgirdwood@gmail.com, gg@slimlogic.co.uk, j-keerthy@ti.com,
ldewangan@nvidia.com, t-kristo@ti.com
Subject: Re: [PATCH v10 04/12] watchdog: add Palmas Watchdog support
Date: Tue, 20 Aug 2013 22:31:03 +0200 [thread overview]
Message-ID: <20130820203103.GA20762@spo001.leaseweb.com> (raw)
In-Reply-To: <1363964122-19201-5-git-send-email-ian@slimlogic.co.uk>
Hi Ian,
> +static int palmas_wdt_set_timeout(struct watchdog_device *wdt, unsigned timeout)
> +{
> + struct palmas_wdt *driver_data = watchdog_get_drvdata(wdt);
> +
> + if (timeout < 1 || timeout > 128) {
> + dev_warn(driver_data->dev,
> + "Timeout can only be in the range [1-128] seconds");
> + return -EINVAL;
> + }
> + driver_data->timer_margin = fls(timeout) - 1;
> + return 0;
> +}
The core can test this also with the .min_timeout and .max_timeout fields of the watchdog_device.
> +
> +static const struct watchdog_info palmas_wdt_info = {
> + .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
> + .identity = "Palmas Watchdog",
> + .firmware_version = 0,
> +};
> +
> +static const struct watchdog_ops palmas_wdt_ops = {
> + .owner = THIS_MODULE,
> + .start = palmas_wdt_enable,
> + .stop = palmas_wdt_disable,
> + .ping = palmas_wdt_enable,
Since .ping is the same as .start you don't need to add .ping .
> + .set_timeout = palmas_wdt_set_timeout,
> +};
> +
> +static int palmas_wdt_probe(struct platform_device *pdev)
> +{
> + struct palmas *palmas = dev_get_drvdata(pdev->dev.parent);
> + struct palmas_wdt *driver_data;
> + struct watchdog_device *palmas_wdt;
> + int ret = 0;
> +
> + driver_data = devm_kzalloc(&pdev->dev, sizeof(*driver_data),
> + GFP_KERNEL);
> + if (!driver_data) {
> + dev_err(&pdev->dev, "Unable to alloacate watchdog device\n");
> + ret = -ENOMEM;
> + goto err;
> + }
> +
> + driver_data->palmas = palmas;
> +
> + palmas_wdt = &driver_data->wdt;
> +
> + palmas_wdt->info = &palmas_wdt_info;
> + palmas_wdt->ops = &palmas_wdt_ops;
> + watchdog_set_nowayout(palmas_wdt, nowayout);
> + watchdog_set_drvdata(palmas_wdt, driver_data);
I think you want a watchdog_init_timeout(struct watchdog_device *wdd, unsigned int timeout_parm, struct device *dev); here.
And also make sure that the watchdog isn't running.
> +
> + ret = watchdog_register_device(&driver_data->wdt);
> + if (ret) {
> + platform_set_drvdata(pdev, NULL);
> + goto err;
> + }
> +
> + dev_set_drvdata(&pdev->dev, driver_data);
> +
> + return 0;
> +err:
> + return ret;
> +}
> +
> +static int palmas_wdt_remove(struct platform_device *pdev)
> +{
> + struct palmas_wdt *driver_data = dev_get_drvdata(&pdev->dev);
> +
> + watchdog_unregister_device(&driver_data->wdt);
> +
> + return 0;
> +}
> +
> +static struct of_device_id of_palmas_match_tbl[] = {
> + { .compatible = "ti,palmas-wdt", },
> + { .compatible = "ti,twl6035-wdt", },
> + { .compatible = "ti,twl6036-wdt", },
> + { .compatible = "ti,twl6037-wdt", },
> + { .compatible = "ti,tps65913-wdt", },
> + { .compatible = "ti,tps65914-wdt", },
> + { .compatible = "ti,tps80036-wdt", },
> + { /* end */ }
> +};
> +
> +static struct platform_driver palmas_wdt_driver = {
> + .probe = palmas_wdt_probe,
> + .remove = palmas_wdt_remove,
> + .driver = {
> + .owner = THIS_MODULE,
> + .of_match_table = of_palmas_match_tbl,
> + .name = "palmas-wdt",
> + },
> +};
> +
> +module_platform_driver(palmas_wdt_driver);
> +
> +MODULE_AUTHOR("Graeme Gregory <gg@slimlogic.co.uk>");
> +MODULE_LICENSE("GPL");
> +MODULE_ALIAS("platform:palmas-wdt");
> +MODULE_DEVICE_TABLE(of, of_palmas_match_tbl);
> --
> 1.7.0.4
>
If you can add the devicetree bindings Documentation and the Kconfig patch together with the revised version of this patch into a single patch then we can complete the review.
Kind regards,
Wim.
next prev parent reply other threads:[~2013-08-20 20:59 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-22 14:55 [PATCH v10 0/12] Palmas updates Ian Lartey
2013-03-22 14:55 ` [PATCH v10 01/12] mfd: DT bindings for the palmas family MFD Ian Lartey
2013-03-25 17:59 ` Stephen Warren
2013-03-25 19:47 ` Mark Brown
2013-05-30 11:33 ` keerthy
2013-05-30 23:03 ` Stephen Warren
[not found] ` <DC88CAD03C0052499C1907B327FC63229E662E@DBDE04.ent.ti.com>
2013-06-04 6:24 ` gg
2013-03-22 14:55 ` [PATCH v10 02/12] mfd: palmas: is_palmas_charger needed by multiple drivers Ian Lartey
2013-04-08 15:51 ` Samuel Ortiz
2013-03-22 14:55 ` [PATCH v10 03/12] mfd: palmas add variant and OTP detection Ian Lartey
2013-04-05 16:32 ` Samuel Ortiz
2013-03-22 14:55 ` [PATCH v10 04/12] watchdog: add Palmas Watchdog support Ian Lartey
2013-03-24 3:19 ` Guenter Roeck
2013-08-20 20:31 ` Wim Van Sebroeck [this message]
2013-03-22 14:55 ` [PATCH v10 05/12] watchdog: Kconfig for Palmas watchdog Ian Lartey
2013-03-24 4:09 ` Guenter Roeck
2013-03-22 14:55 ` [PATCH v10 06/12] gpio: palmas: add in GPIO support for palmas charger Ian Lartey
2013-03-22 14:55 ` [PATCH v10 07/12] gpio: palmas: Enable DT support for palmas gpio Ian Lartey
2013-03-22 14:55 ` [PATCH v10 08/12] gpio: Palmas palmas_gpio_(read|write|update) factoring Ian Lartey
2013-03-22 14:55 ` [PATCH v10 09/12] leds: Add support for Palmas LEDs Ian Lartey
2013-03-22 14:55 ` [PATCH v10 10/12] clk: add a clock driver for palmas Ian Lartey
2013-03-22 14:55 ` [PATCH v10 11/12] clk: Kconfig for Palmas clock driver Ian Lartey
2013-03-22 14:55 ` [PATCH v10 12/12] regulator: palmas remove palmas-charger option from DT bindings Ian Lartey
2013-03-25 1:07 ` Mark Brown
2013-03-22 19:04 ` [PATCH v10 0/12] Palmas updates Stephen Rothwell
2013-03-24 21:13 ` Mark Brown
2013-04-05 16:30 ` Samuel Ortiz
2013-04-08 15:55 ` Graeme Gregory
2013-04-08 16:11 ` Samuel Ortiz
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=20130820203103.GA20762@spo001.leaseweb.com \
--to=wim@iguana.be \
--cc=akpm@linux-foundation.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=cooloney@gmail.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=gg@slimlogic.co.uk \
--cc=grant.likely@secretlab.ca \
--cc=ian@slimlogic.co.uk \
--cc=j-keerthy@ti.com \
--cc=ldewangan@nvidia.com \
--cc=lgirdwood@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=mturquette@linaro.org \
--cc=rob.herring@calxeda.com \
--cc=rob@landley.net \
--cc=rpurdie@rpsys.net \
--cc=sameo@linux.intel.com \
--cc=sfr@canb.auug.org.au \
--cc=swarren@wwwdotorg.org \
--cc=t-kristo@ti.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
all inboxes | Powered by JetHome®