fix: regulator: set ioexpander direction in regulator gpio init.

Signed-off-by: songnannan <songnannan@xiaomi.com>
This commit is contained in:
songnannan 2021-12-21 21:33:36 +08:00 committed by Xiang Xiao
parent aa41b9732a
commit 0a62701c1a
1 changed files with 18 additions and 6 deletions

View File

@ -125,6 +125,7 @@ int regulator_gpio_init(FAR struct ioexpander_dev_s *iodev,
FAR const struct regulator_desc_s *desc) FAR const struct regulator_desc_s *desc)
{ {
FAR struct regulator_gpio_priv *priv; FAR struct regulator_gpio_priv *priv;
int ret;
if (!iodev || !desc) if (!iodev || !desc)
{ {
@ -138,13 +139,24 @@ int regulator_gpio_init(FAR struct ioexpander_dev_s *iodev,
} }
priv->iodev = iodev; priv->iodev = iodev;
priv->rdev = regulator_register(desc, &g_regulator_gpio_ops,
priv); ret = IOEXP_SETDIRECTION(priv->iodev, desc->enable_reg,
if (!priv->rdev) IOEXPANDER_DIRECTION_OUT);
if (ret >= 0)
{ {
kmm_free(priv); priv->rdev = regulator_register(desc,
return -EINVAL; &g_regulator_gpio_ops,
priv);
if (priv->rdev == NULL)
{
ret = -EINVAL;
}
} }
return 0; if (ret < 0)
{
kmm_free(priv);
}
return ret;
} }