The clk_prepare_enable() function can fail so check the return
value and propagate the error in case of a failure.

Signed-off-by: Javier Martinez Canillas <[email protected]>

---

 drivers/mfd/twl6040.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/twl6040.c b/drivers/mfd/twl6040.c
index 4de92c16dfb8..852d5874aabb 100644
--- a/drivers/mfd/twl6040.c
+++ b/drivers/mfd/twl6040.c
@@ -291,7 +291,11 @@ int twl6040_power(struct twl6040 *twl6040, int on)
                if (twl6040->power_count++)
                        goto out;
 
-               clk_prepare_enable(twl6040->clk32k);
+               ret = clk_prepare_enable(twl6040->clk32k);
+               if (ret) {
+                       twl6040->power_count = 0;
+                       goto out;
+               }
 
                /* Allow writes to the chip */
                regcache_cache_only(twl6040->regmap, false);
-- 
2.5.5

Reply via email to