mfd: stpmic1: Attempt system shutdown twice in case PMIC is confused
Subsystems (2)
PATCH v3 1/1 mfd: stpmic1: Attempt system shutdown twice in case PMIC is confused
Attempt to shut down again, in case the first attempt failed. The STPMIC1 might get confused and the first regmap_update_bits() returns with -ETIMEDOUT / -110 . If that or similar transient failure occurs, try to shut down again. If the second attempt fails, there is some bigger problem, report it to user.
---
Cc: Lee Jones <[email protected]>
Cc: Pascal PAILLET-LME <[email protected]>
Cc: Paul Cercueil <[email protected]>
Cc: Sean Nyekjaer <[email protected]>
Cc: [email protected]
---
V2: - Use a retry loop
- Cc stable
V3: Adjust the loop further, define STPMIC1_MAX_RETRIES, rename
the loop control variable, print error message only when the loop ran STPMIC1_MAX_RETRIES times
--- drivers/mfd/stpmic1.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
drivers/mfd/stpmic1.c +18 -2
@@ -16,6 +16,8 @@#include <dt-bindings/mfd/st,stpmic1.h> +#define STPMIC1_MAX_RETRIES 2 +#define STPMIC1_MAIN_IRQ 0static const struct regmap_range stpmic1_readable_ranges[] = {
@@ -121,9 +123,23 @@ static const struct regmap_irq_chip stpmic1_regmap_irq_chip = {static int stpmic1_power_off (struct sys_off_data *data) {struct stpmic1 *ddata = data->cb_data; +int ret; + +/* +* Attempt to shut down again, in case the first attempt failed. +* The STPMIC1 might get confused and the first regmap_update_bits() +* returns with -ETIMEDOUT / -110 . If that or similar transient +* failure occurs, try to shut down again. If the second attempt +* fails, there is some bigger problem, report it to user. +*/ +for (int retries =0 ; retries <STPMIC1_MAX_RETRIES ; retries++) { + ret =regmap_update_bits (ddata->regmap,MAIN_CR ,SOFTWARE_SWITCH_OFF , +SOFTWARE_SWITCH_OFF ); +if (!ret) +return NOTIFY_DONE ; + } -regmap_update_bits (ddata->regmap,MAIN_CR , -SOFTWARE_SWITCH_OFF ,SOFTWARE_SWITCH_OFF ); +dev_err (ddata->dev,"Failed to access PMIC I2C bus (%d)\n" , ret);return NOTIFY_DONE ; }
Signature · 1 line
2.51.0
Re: (subset) [PATCH v3] mfd: stpmic1: Attempt system shutdown twice in case PMIC is confused
Quoted 8 lines · Marek Vasut
Attempt to shut down again, in case the first attempt failed. The STPMIC1 might get confused and the first
regmap_update_bits()returns with-ETIMEDOUT/ -110 . If that or similar transient failure occurs, try to shut down again. If the second attempt fails, there is some bigger problem, report it to user.[...]
Applied, thanks!
[1/1] mfd: stpmic1: Attempt system shutdown twice in case PMIC is confused
commit: ff05fecc5007a1680e2e828e708586ae5ffb30a5
--
Lee Jones [李琼斯]