Skip to content

Commit 076354a

Browse files
Fabio EstevamWim Van Sebroeck
authored andcommitted
watchdog: da9063: Do not use a global variable
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 <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Wim Van Sebroeck <[email protected]>
1 parent 3a6a399 commit 076354a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

drivers/watchdog/da9063_wdt.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
* others: timeout = 2048 ms * 2^(TWDSCALE-1).
2828
*/
2929
static const unsigned int wdt_timeout[] = { 0, 2, 4, 8, 16, 32, 65, 131 };
30-
static bool use_sw_pm;
3130

3231
#define DA9063_TWDSCALE_DISABLE 0
3332
#define DA9063_TWDSCALE_MIN 1
@@ -230,7 +229,7 @@ static int da9063_wdt_probe(struct platform_device *pdev)
230229
if (!wdd)
231230
return -ENOMEM;
232231

233-
use_sw_pm = device_property_present(dev, "dlg,use-sw-pm");
232+
da9063->use_sw_pm = device_property_present(dev, "dlg,use-sw-pm");
234233

235234
wdd->info = &da9063_watchdog_info;
236235
wdd->ops = &da9063_watchdog_ops;
@@ -267,8 +266,9 @@ static int da9063_wdt_probe(struct platform_device *pdev)
267266
static int __maybe_unused da9063_wdt_suspend(struct device *dev)
268267
{
269268
struct watchdog_device *wdd = dev_get_drvdata(dev);
269+
struct da9063 *da9063 = watchdog_get_drvdata(wdd);
270270

271-
if (!use_sw_pm)
271+
if (!da9063->use_sw_pm)
272272
return 0;
273273

274274
if (watchdog_active(wdd))
@@ -280,8 +280,9 @@ static int __maybe_unused da9063_wdt_suspend(struct device *dev)
280280
static int __maybe_unused da9063_wdt_resume(struct device *dev)
281281
{
282282
struct watchdog_device *wdd = dev_get_drvdata(dev);
283+
struct da9063 *da9063 = watchdog_get_drvdata(wdd);
283284

284-
if (!use_sw_pm)
285+
if (!da9063->use_sw_pm)
285286
return 0;
286287

287288
if (watchdog_active(wdd))

include/linux/mfd/da9063/core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ struct da9063 {
7878
enum da9063_type type;
7979
unsigned char variant_code;
8080
unsigned int flags;
81+
bool use_sw_pm;
8182

8283
/* Control interface */
8384
struct regmap *regmap;

0 commit comments

Comments
 (0)