* [PATCH v2 1/2] watchdog: da9063: Do not use a global variable
@ 2024-10-18 13:58 Fabio Estevam
2024-10-18 13:58 ` [PATCH v2 2/2] watchdog: da9063: Remove __maybe_unused notations Fabio Estevam
0 siblings, 1 reply; 3+ messages in thread
From: Fabio Estevam @ 2024-10-18 13:58 UTC (permalink / raw)
To: wim; +Cc: linux, support.opensource, linux-watchdog, Fabio Estevam
From: Fabio Estevam <festevam@denx.de>
Using the 'use_sw_pm' variable as global is not recommended
as it prevents multi instances of the driver to run.
Make it a member of the da9063 structure instead.
Signed-off-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
---
Changes since v1:
- None.
drivers/watchdog/da9063_wdt.c | 9 +++++----
include/linux/mfd/da9063/core.h | 1 +
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/watchdog/da9063_wdt.c b/drivers/watchdog/da9063_wdt.c
index 684667469b10..69f884cf1a7b 100644
--- a/drivers/watchdog/da9063_wdt.c
+++ b/drivers/watchdog/da9063_wdt.c
@@ -27,7 +27,6 @@
* others: timeout = 2048 ms * 2^(TWDSCALE-1).
*/
static const unsigned int wdt_timeout[] = { 0, 2, 4, 8, 16, 32, 65, 131 };
-static bool use_sw_pm;
#define DA9063_TWDSCALE_DISABLE 0
#define DA9063_TWDSCALE_MIN 1
@@ -230,7 +229,7 @@ static int da9063_wdt_probe(struct platform_device *pdev)
if (!wdd)
return -ENOMEM;
- use_sw_pm = device_property_present(dev, "dlg,use-sw-pm");
+ da9063->use_sw_pm = device_property_present(dev, "dlg,use-sw-pm");
wdd->info = &da9063_watchdog_info;
wdd->ops = &da9063_watchdog_ops;
@@ -267,8 +266,9 @@ static int da9063_wdt_probe(struct platform_device *pdev)
static int __maybe_unused da9063_wdt_suspend(struct device *dev)
{
struct watchdog_device *wdd = dev_get_drvdata(dev);
+ struct da9063 *da9063 = watchdog_get_drvdata(wdd);
- if (!use_sw_pm)
+ if (!da9063->use_sw_pm)
return 0;
if (watchdog_active(wdd))
@@ -280,8 +280,9 @@ static int __maybe_unused da9063_wdt_suspend(struct device *dev)
static int __maybe_unused da9063_wdt_resume(struct device *dev)
{
struct watchdog_device *wdd = dev_get_drvdata(dev);
+ struct da9063 *da9063 = watchdog_get_drvdata(wdd);
- if (!use_sw_pm)
+ if (!da9063->use_sw_pm)
return 0;
if (watchdog_active(wdd))
diff --git a/include/linux/mfd/da9063/core.h b/include/linux/mfd/da9063/core.h
index 8db52324f416..eae82f421414 100644
--- a/include/linux/mfd/da9063/core.h
+++ b/include/linux/mfd/da9063/core.h
@@ -78,6 +78,7 @@ struct da9063 {
enum da9063_type type;
unsigned char variant_code;
unsigned int flags;
+ bool use_sw_pm;
/* Control interface */
struct regmap *regmap;
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2 2/2] watchdog: da9063: Remove __maybe_unused notations
2024-10-18 13:58 [PATCH v2 1/2] watchdog: da9063: Do not use a global variable Fabio Estevam
@ 2024-10-18 13:58 ` Fabio Estevam
2024-10-18 14:19 ` Guenter Roeck
0 siblings, 1 reply; 3+ messages in thread
From: Fabio Estevam @ 2024-10-18 13:58 UTC (permalink / raw)
To: wim; +Cc: linux, support.opensource, linux-watchdog, Fabio Estevam
From: Fabio Estevam <festevam@denx.de>
Use the DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() macros to
handle the .suspend/.resume callbacks.
These macros allow the suspend and resume functions to be automatically
dropped by the compiler when CONFIG_SUSPEND is disabled, without having
to use __maybe_unused notation.
Signed-off-by: Fabio Estevam <festevam@denx.de>
---
Changes since v1:
- Newly introduced.
drivers/watchdog/da9063_wdt.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/watchdog/da9063_wdt.c b/drivers/watchdog/da9063_wdt.c
index 69f884cf1a7b..92e1b78ff481 100644
--- a/drivers/watchdog/da9063_wdt.c
+++ b/drivers/watchdog/da9063_wdt.c
@@ -263,7 +263,7 @@ static int da9063_wdt_probe(struct platform_device *pdev)
return devm_watchdog_register_device(dev, wdd);
}
-static int __maybe_unused da9063_wdt_suspend(struct device *dev)
+static int da9063_wdt_suspend(struct device *dev)
{
struct watchdog_device *wdd = dev_get_drvdata(dev);
struct da9063 *da9063 = watchdog_get_drvdata(wdd);
@@ -277,7 +277,7 @@ static int __maybe_unused da9063_wdt_suspend(struct device *dev)
return 0;
}
-static int __maybe_unused da9063_wdt_resume(struct device *dev)
+static int da9063_wdt_resume(struct device *dev)
{
struct watchdog_device *wdd = dev_get_drvdata(dev);
struct da9063 *da9063 = watchdog_get_drvdata(wdd);
@@ -291,14 +291,14 @@ static int __maybe_unused da9063_wdt_resume(struct device *dev)
return 0;
}
-static SIMPLE_DEV_PM_OPS(da9063_wdt_pm_ops,
- da9063_wdt_suspend, da9063_wdt_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(da9063_wdt_pm_ops, da9063_wdt_suspend,
+ da9063_wdt_resume);
static struct platform_driver da9063_wdt_driver = {
.probe = da9063_wdt_probe,
.driver = {
.name = DA9063_DRVNAME_WATCHDOG,
- .pm = &da9063_wdt_pm_ops,
+ .pm = pm_sleep_ptr(&da9063_wdt_pm_ops),
},
};
module_platform_driver(da9063_wdt_driver);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 2/2] watchdog: da9063: Remove __maybe_unused notations
2024-10-18 13:58 ` [PATCH v2 2/2] watchdog: da9063: Remove __maybe_unused notations Fabio Estevam
@ 2024-10-18 14:19 ` Guenter Roeck
0 siblings, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2024-10-18 14:19 UTC (permalink / raw)
To: Fabio Estevam, wim; +Cc: support.opensource, linux-watchdog, Fabio Estevam
On 10/18/24 06:58, Fabio Estevam wrote:
> From: Fabio Estevam <festevam@denx.de>
>
> Use the DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() macros to
> handle the .suspend/.resume callbacks.
>
> These macros allow the suspend and resume functions to be automatically
> dropped by the compiler when CONFIG_SUSPEND is disabled, without having
> to use __maybe_unused notation.
>
> Signed-off-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-18 14:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-18 13:58 [PATCH v2 1/2] watchdog: da9063: Do not use a global variable Fabio Estevam
2024-10-18 13:58 ` [PATCH v2 2/2] watchdog: da9063: Remove __maybe_unused notations Fabio Estevam
2024-10-18 14:19 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox