if (ret != 0) {
dev_err(data->dev,
"Failed to sync registers: %d\n", ret);
- goto regcache_sync_failed;
+ regcache_cache_only(data->regmap, true);
+ if (data->power_gpio >= 0)
+ gpio_set_value(data->power_gpio, 0);
+ ret2 = regulator_disable(data->supply);
+ if (ret2 != 0)
+ dev_err(data->dev,
+ "Failed to disable supply: %d\n", ret2);
+ return ret;
}
} else {
/* Powered off device does not retain registers. While device
* happen in cache only.
*/
regcache_mark_dirty(data->regmap);
-regcache_sync_failed:
regcache_cache_only(data->regmap, true);
/* Power off */
if (data->power_gpio >= 0)
gpio_set_value(data->power_gpio, 0);
- ret2 = regulator_disable(data->supply);
- if (ret2 != 0) {
+ ret = regulator_disable(data->supply);
+ if (ret != 0) {
dev_err(data->dev,
- "Failed to disable supply: %d\n", ret2);
- return ret ? ret : ret2;
+ "Failed to disable supply: %d\n", ret);
+ return ret;
}
}