Skip to content

Commit f4e6960

Browse files
zevweissgroeck
authored andcommitted
hwmon: (nct6775) Fix platform driver suspend regression
Commit c3963bc ("hwmon: (nct6775) Split core and platform driver") introduced a slight change in nct6775_suspend() in order to avoid an otherwise-needless symbol export for nct6775_update_device(), replacing a call to that function with a simple dev_get_drvdata() instead. As it turns out, there is no guarantee that nct6775_update_device() is ever called prior to suspend. If this happens, the resume function ends up writing bad data into the various chip registers, which results in a crash shortly after resume. To fix the problem, just add the symbol export and return to using nct6775_update_device() as was employed previously. Reported-by: Zoltán Kővágó <dirty.ice.hu@gmail.com> Tested-by: Zoltán Kővágó <dirty.ice.hu@gmail.com> Fixes: c3963bc ("hwmon: (nct6775) Split core and platform driver") Cc: stable@kernel.org Signed-off-by: Zev Weiss <zev@bewilderbeest.net> Link: https://lore.kernel.org/r/20220810052646.13825-1-zev@bewilderbeest.net [groeck: Updated description] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent 7aeef15 commit f4e6960

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

drivers/hwmon/nct6775-core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1480,7 +1480,7 @@ static int nct6775_update_pwm_limits(struct device *dev)
14801480
return 0;
14811481
}
14821482

1483-
static struct nct6775_data *nct6775_update_device(struct device *dev)
1483+
struct nct6775_data *nct6775_update_device(struct device *dev)
14841484
{
14851485
struct nct6775_data *data = dev_get_drvdata(dev);
14861486
int i, j, err = 0;
@@ -1615,6 +1615,7 @@ static struct nct6775_data *nct6775_update_device(struct device *dev)
16151615
mutex_unlock(&data->update_lock);
16161616
return err ? ERR_PTR(err) : data;
16171617
}
1618+
EXPORT_SYMBOL_GPL(nct6775_update_device);
16181619

16191620
/*
16201621
* Sysfs callback functions

drivers/hwmon/nct6775-platform.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ static int __maybe_unused nct6775_suspend(struct device *dev)
359359
{
360360
int err;
361361
u16 tmp;
362-
struct nct6775_data *data = dev_get_drvdata(dev);
362+
struct nct6775_data *data = nct6775_update_device(dev);
363363

364364
if (IS_ERR(data))
365365
return PTR_ERR(data);

drivers/hwmon/nct6775.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ static inline int nct6775_write_value(struct nct6775_data *data, u16 reg, u16 va
196196
return regmap_write(data->regmap, reg, value);
197197
}
198198

199+
struct nct6775_data *nct6775_update_device(struct device *dev);
200+
199201
bool nct6775_reg_is_word_sized(struct nct6775_data *data, u16 reg);
200202
int nct6775_probe(struct device *dev, struct nct6775_data *data,
201203
const struct regmap_config *regmapcfg);

0 commit comments

Comments
 (0)