Return an error in the registered handler if the device can't be powered
on.

Signed-off-by: Laurent Pinchart <laurent.pinch...@ideasonboard.com>
---
 drivers/media/video/as3645a.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

Hi everybody,

This second version of the as3645a power on patch fixes a problem with the power
on operation that would leave the chip powered when it can't be initialized. It
still applies on top of the as3645a driver that I'm going to submit for
v3.3.

diff --git a/drivers/media/video/as3645a.c b/drivers/media/video/as3645a.c
index d583a9c..0ed52ee 100644
--- a/drivers/media/video/as3645a.c
+++ b/drivers/media/video/as3645a.c
@@ -523,7 +523,16 @@ static int __as3645a_set_power(struct as3645a *flash, int 
on)
                        return ret;
        }
 
-       return on ? as3645a_setup(flash) : 0;
+       if (!on)
+               return 0;
+
+       ret = as3645a_setup(flash);
+       if (ret < 0) {
+               if (flash->pdata->set_power)
+                       flash->pdata->set_power(&flash->subdev, 0);
+       }
+
+       return ret;
 }
 
 static int as3645a_set_power(struct v4l2_subdev *sd, int on)
@@ -557,7 +566,9 @@ static int as3645a_registered(struct v4l2_subdev *sd)
        /* Power up the flash driver and read manufacturer ID, model ID, RFU
         * and version.
         */
-       as3645a_set_power(&flash->subdev, 1);
+       rval = as3645a_set_power(&flash->subdev, 1);
+       if (rval < 0)
+               return rval;
 
        rval = as3645a_read(flash, AS_DESIGN_INFO_REG);
        if (rval < 0)
-- 
Regards,

Laurent Pinchart

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to