Linux-Watchdog Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] watchdog: pm8916_wdt: Add system sleep callbacks
@ 2020-02-11 15:38 Loic Poulain
  2020-02-11 15:51 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Loic Poulain @ 2020-02-11 15:38 UTC (permalink / raw)
  To: linux; +Cc: linux-watchdog, Loic Poulain

Add suspend and resume pm operations.
Tested on dragonboard-410c.

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
---
 drivers/watchdog/pm8916_wdt.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/watchdog/pm8916_wdt.c b/drivers/watchdog/pm8916_wdt.c
index 1213179..0937b8d3 100644
--- a/drivers/watchdog/pm8916_wdt.c
+++ b/drivers/watchdog/pm8916_wdt.c
@@ -192,6 +192,7 @@ static int pm8916_wdt_probe(struct platform_device *pdev)
 	wdt->wdev.timeout = PM8916_WDT_DEFAULT_TIMEOUT;
 	wdt->wdev.pretimeout = 0;
 	watchdog_set_drvdata(&wdt->wdev, wdt);
+	platform_set_drvdata(pdev, wdt);
 
 	watchdog_init_timeout(&wdt->wdev, 0, dev);
 	pm8916_wdt_configure_timers(&wdt->wdev);
@@ -199,6 +200,29 @@ static int pm8916_wdt_probe(struct platform_device *pdev)
 	return devm_watchdog_register_device(dev, &wdt->wdev);
 }
 
+static int __maybe_unused pm8916_wdt_suspend(struct device *dev)
+{
+	struct pm8916_wdt *wdt = dev_get_drvdata(dev);
+
+	if (watchdog_active(&wdt->wdev))
+		return pm8916_wdt_stop(&wdt->wdev);
+
+	return 0;
+}
+
+static int __maybe_unused pm8916_wdt_resume(struct device *dev)
+{
+	struct pm8916_wdt *wdt = dev_get_drvdata(dev);
+
+	if (watchdog_active(&wdt->wdev))
+		return pm8916_wdt_start(&wdt->wdev);
+
+	return 0;
+}
+
+static SIMPLE_DEV_PM_OPS(pm8916_wdt_pm_ops, pm8916_wdt_suspend,
+			 pm8916_wdt_resume);
+
 static const struct of_device_id pm8916_wdt_id_table[] = {
 	{ .compatible = "qcom,pm8916-wdt" },
 	{ }
@@ -210,6 +234,7 @@ static struct platform_driver pm8916_wdt_driver = {
 	.driver = {
 		.name = "pm8916-wdt",
 		.of_match_table = of_match_ptr(pm8916_wdt_id_table),
+		.pm = &pm8916_wdt_pm_ops,
 	},
 };
 module_platform_driver(pm8916_wdt_driver);
-- 
2.7.4


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

* Re: [PATCH] watchdog: pm8916_wdt: Add system sleep callbacks
  2020-02-11 15:38 [PATCH] watchdog: pm8916_wdt: Add system sleep callbacks Loic Poulain
@ 2020-02-11 15:51 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2020-02-11 15:51 UTC (permalink / raw)
  To: Loic Poulain; +Cc: linux-watchdog

On Tue, Feb 11, 2020 at 04:38:03PM +0100, Loic Poulain wrote:
> Add suspend and resume pm operations.
> Tested on dragonboard-410c.
> 
> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  drivers/watchdog/pm8916_wdt.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/watchdog/pm8916_wdt.c b/drivers/watchdog/pm8916_wdt.c
> index 1213179..0937b8d3 100644
> --- a/drivers/watchdog/pm8916_wdt.c
> +++ b/drivers/watchdog/pm8916_wdt.c
> @@ -192,6 +192,7 @@ static int pm8916_wdt_probe(struct platform_device *pdev)
>  	wdt->wdev.timeout = PM8916_WDT_DEFAULT_TIMEOUT;
>  	wdt->wdev.pretimeout = 0;
>  	watchdog_set_drvdata(&wdt->wdev, wdt);
> +	platform_set_drvdata(pdev, wdt);
>  
>  	watchdog_init_timeout(&wdt->wdev, 0, dev);
>  	pm8916_wdt_configure_timers(&wdt->wdev);
> @@ -199,6 +200,29 @@ static int pm8916_wdt_probe(struct platform_device *pdev)
>  	return devm_watchdog_register_device(dev, &wdt->wdev);
>  }
>  
> +static int __maybe_unused pm8916_wdt_suspend(struct device *dev)
> +{
> +	struct pm8916_wdt *wdt = dev_get_drvdata(dev);
> +
> +	if (watchdog_active(&wdt->wdev))
> +		return pm8916_wdt_stop(&wdt->wdev);
> +
> +	return 0;
> +}
> +
> +static int __maybe_unused pm8916_wdt_resume(struct device *dev)
> +{
> +	struct pm8916_wdt *wdt = dev_get_drvdata(dev);
> +
> +	if (watchdog_active(&wdt->wdev))
> +		return pm8916_wdt_start(&wdt->wdev);
> +
> +	return 0;
> +}
> +
> +static SIMPLE_DEV_PM_OPS(pm8916_wdt_pm_ops, pm8916_wdt_suspend,
> +			 pm8916_wdt_resume);
> +
>  static const struct of_device_id pm8916_wdt_id_table[] = {
>  	{ .compatible = "qcom,pm8916-wdt" },
>  	{ }
> @@ -210,6 +234,7 @@ static struct platform_driver pm8916_wdt_driver = {
>  	.driver = {
>  		.name = "pm8916-wdt",
>  		.of_match_table = of_match_ptr(pm8916_wdt_id_table),
> +		.pm = &pm8916_wdt_pm_ops,
>  	},
>  };
>  module_platform_driver(pm8916_wdt_driver);
> -- 
> 2.7.4
> 

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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-11 15:38 [PATCH] watchdog: pm8916_wdt: Add system sleep callbacks Loic Poulain
2020-02-11 15:51 ` Guenter Roeck

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
	public-inbox-index linux-watchdog

Example config snippet for mirrors

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.git