media: i2c: s5c73m3: Move clk_prepare to its own function
authorRicardo Ribalda <ribalda@chromium.org>
Fri, 16 Aug 2024 12:32:01 +0000 (12:32 +0000)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Sat, 31 Aug 2024 07:40:43 +0000 (09:40 +0200)
Smatch is very confused by a clk_prepare_enable() being called in an
error-path. Fix this warning by moving the clk_prepare_enable() to its
own function.

drivers/media/i2c/s5c73m3/s5c73m3-core.c:1425 __s5c73m3_power_off() warn: 'state->clock' from clk_prepare_enable() not released on lines: 1425.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/i2c/s5c73m3/s5c73m3-core.c

index e89e888f028e9641dbec9a72290278589787615e..7716dfe2b8c9e04d03e50bd726a98f7fc11fc670 100644 (file)
@@ -1392,6 +1392,16 @@ err_reg_dis:
        return ret;
 }
 
+/*
+ * This function has been created just to avoid a smatch warning,
+ * please do not merge into __s5c73m3_power_off() until you have
+ * confirmed that it does not introduce a new warning.
+ */
+static void s5c73m3_enable_clk(struct s5c73m3 *state)
+{
+       clk_prepare_enable(state->clock);
+}
+
 static int __s5c73m3_power_off(struct s5c73m3 *state)
 {
        int i, ret;
@@ -1421,7 +1431,8 @@ err:
                                 state->supplies[i].supply, r);
        }
 
-       clk_prepare_enable(state->clock);
+       s5c73m3_enable_clk(state);
+
        return ret;
 }