[U-Boot] [PATCH v2 2/5] dm: video: bridge: don't fail to activate bridge if reset or sleep GPIO is missing

Vasily Khoruzhick
2018-10-17T05:09:29Z

Both GPIOs are optional, so we shouldn't fail if any is missing. Without
this fix reset is not deasserted when sleep GPIO is missing.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
---
drivers/video/bridge/video-bridge-uclass.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/video/bridge/video-bridge-uclass.c b/drivers/video/bridge/video-bridge-uclass.c
index cd4959cc71..7542097769 100644
--- a/drivers/video/bridge/video-bridge-uclass.c
+++ b/drivers/video/bridge/video-bridge-uclass.c
@@ -109,10 +109,16 @@ int video_bridge_set_active(struct udevice *dev, bool active)
int ret;

debug("%s: %d\n", __func__, active);
- ret = dm_gpio_set_value(&uc_priv->sleep, !active);
- if (ret)
- return ret;
- if (active) {
+ if (uc_priv->sleep.dev) {
+ ret = dm_gpio_set_value(&uc_priv->sleep, !active);
+ if (ret)
+ return ret;
+ }
+
+ if (!active)
+ return 0;
+
+ if (uc_priv->reset.dev) {
ret = dm_gpio_set_value(&uc_priv->reset, true);
if (ret)
return ret;
--
2.19.0