regulator: da9063: Fix get_mode() functions to read sleep field

get_mode() is used to retrieve the active mode state. Settings-A
config is used during active state, whilst Settings-B is for
suspend. This means we only need to check the sleep field of each
buck and LDO as that field solely relates to Settings-A config.

This change is a clone of the get_mode() update which was committed
as part of:
 - regulator: da9062: fix suspend_enable/disable preparation
   [a72865f057]

Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Link: https://lore.kernel.org/r/20200324092516.60B5C3FB8D@swsrvapps-01.diasemi.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Adam Thomson 2020-03-24 09:25:16 +00:00 коммит произвёл Mark Brown
Родитель 99f75ce666
Коммит fc69bab1ec
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 24D68B725D5487D0
1 изменённых файлов: 2 добавлений и 26 удалений

Просмотреть файл

@ -226,7 +226,6 @@ static int da9063_buck_set_mode(struct regulator_dev *rdev, unsigned mode)
static unsigned da9063_buck_get_mode(struct regulator_dev *rdev)
{
struct da9063_regulator *regl = rdev_get_drvdata(rdev);
struct regmap_field *field;
unsigned int val;
int ret;
@ -247,18 +246,7 @@ static unsigned da9063_buck_get_mode(struct regulator_dev *rdev)
return REGULATOR_MODE_NORMAL;
}
/* Detect current regulator state */
ret = regmap_field_read(regl->suspend, &val);
if (ret < 0)
return 0;
/* Read regulator mode from proper register, depending on state */
if (val)
field = regl->suspend_sleep;
else
field = regl->sleep;
ret = regmap_field_read(field, &val);
ret = regmap_field_read(regl->sleep, &val);
if (ret < 0)
return 0;
@ -295,21 +283,9 @@ static int da9063_ldo_set_mode(struct regulator_dev *rdev, unsigned mode)
static unsigned da9063_ldo_get_mode(struct regulator_dev *rdev)
{
struct da9063_regulator *regl = rdev_get_drvdata(rdev);
struct regmap_field *field;
int ret, val;
/* Detect current regulator state */
ret = regmap_field_read(regl->suspend, &val);
if (ret < 0)
return 0;
/* Read regulator mode from proper register, depending on state */
if (val)
field = regl->suspend_sleep;
else
field = regl->sleep;
ret = regmap_field_read(field, &val);
ret = regmap_field_read(regl->sleep, &val);
if (ret < 0)
return 0;