You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/12/21 14:47:23 UTC
[incubator-nuttx] branch master updated: fix: regulator: set ioexpander direction in regulator gpio init.
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 0a62701 fix: regulator: set ioexpander direction in regulator gpio init.
0a62701 is described below
commit 0a62701c1a5e13d86cea5390318659364fd088f6
Author: songnannan <so...@xiaomi.com>
AuthorDate: Tue Dec 21 21:33:36 2021 +0800
fix: regulator: set ioexpander direction in regulator gpio init.
Signed-off-by: songnannan <so...@xiaomi.com>
---
drivers/power/regulator_gpio.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/drivers/power/regulator_gpio.c b/drivers/power/regulator_gpio.c
index 4d92389..c53d80e 100644
--- a/drivers/power/regulator_gpio.c
+++ b/drivers/power/regulator_gpio.c
@@ -125,6 +125,7 @@ int regulator_gpio_init(FAR struct ioexpander_dev_s *iodev,
FAR const struct regulator_desc_s *desc)
{
FAR struct regulator_gpio_priv *priv;
+ int ret;
if (!iodev || !desc)
{
@@ -138,13 +139,24 @@ int regulator_gpio_init(FAR struct ioexpander_dev_s *iodev,
}
priv->iodev = iodev;
- priv->rdev = regulator_register(desc, &g_regulator_gpio_ops,
- priv);
- if (!priv->rdev)
+
+ ret = IOEXP_SETDIRECTION(priv->iodev, desc->enable_reg,
+ IOEXPANDER_DIRECTION_OUT);
+ if (ret >= 0)
+ {
+ priv->rdev = regulator_register(desc,
+ &g_regulator_gpio_ops,
+ priv);
+ if (priv->rdev == NULL)
+ {
+ ret = -EINVAL;
+ }
+ }
+
+ if (ret < 0)
{
kmm_free(priv);
- return -EINVAL;
}
- return 0;
+ return ret;
}