Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: meson: vdec: hevc: Refactor vdec_hevc_start and vdec_hevc_stop

Make a new function __vdec_hevc_start(), that does all the
initialization, except the clock initialization for G12A and SM1.

Factor out all the stop logic, except the clk_disable_unprepare(), to a
new function __vdec_hevc_stop. This allows vdec_hevc_start() to
explicitly celan-out the clock during the error-path.

The following smatch warnings are fixed:

drivers/staging/media/meson/vdec/vdec_hevc.c:227 vdec_hevc_start() warn: 'core->vdec_hevc_clk' from clk_prepare_enable() not released on lines: 227.
drivers/staging/media/meson/vdec/vdec_hevc.c:227 vdec_hevc_start() warn: 'core->vdec_hevcf_clk' from clk_prepare_enable() not released on lines: 227.

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>

authored by

Ricardo Ribalda and committed by
Hans Verkuil
57343cbb bc24a85d

+32 -11
+32 -11
drivers/staging/media/meson/vdec/vdec_hevc.c
··· 110 110 return readl_relaxed(sess->core->dos_base + HEVC_STREAM_LEVEL); 111 111 } 112 112 113 - static int vdec_hevc_stop(struct amvdec_session *sess) 113 + static void __vdec_hevc_stop(struct amvdec_session *sess) 114 114 { 115 115 struct amvdec_core *core = sess->core; 116 116 struct amvdec_codec_ops *codec_ops = sess->fmt_out->codec_ops; ··· 142 142 else 143 143 regmap_update_bits(core->regmap_ao, AO_RTI_GEN_PWR_SLEEP0, 144 144 GEN_PWR_VDEC_HEVC, GEN_PWR_VDEC_HEVC); 145 + } 146 + 147 + static int vdec_hevc_stop(struct amvdec_session *sess) 148 + { 149 + struct amvdec_core *core = sess->core; 150 + 151 + __vdec_hevc_stop(sess); 145 152 146 153 clk_disable_unprepare(core->vdec_hevc_clk); 147 154 if (core->platform->revision == VDEC_REVISION_G12A || ··· 158 151 return 0; 159 152 } 160 153 161 - static int vdec_hevc_start(struct amvdec_session *sess) 154 + static int __vdec_hevc_start(struct amvdec_session *sess) 162 155 { 163 156 int ret; 164 157 struct amvdec_core *core = sess->core; 165 158 struct amvdec_codec_ops *codec_ops = sess->fmt_out->codec_ops; 166 - 167 - if (core->platform->revision == VDEC_REVISION_G12A || 168 - core->platform->revision == VDEC_REVISION_SM1) { 169 - clk_set_rate(core->vdec_hevcf_clk, 666666666); 170 - ret = clk_prepare_enable(core->vdec_hevcf_clk); 171 - if (ret) 172 - return ret; 173 - } 174 159 175 160 clk_set_rate(core->vdec_hevc_clk, 666666666); 176 161 ret = clk_prepare_enable(core->vdec_hevc_clk); ··· 222 223 return 0; 223 224 224 225 stop: 225 - vdec_hevc_stop(sess); 226 + __vdec_hevc_stop(sess); 227 + clk_disable_unprepare(core->vdec_hevc_clk); 226 228 return ret; 229 + } 230 + 231 + static int vdec_hevc_start(struct amvdec_session *sess) 232 + { 233 + struct amvdec_core *core = sess->core; 234 + int ret; 235 + 236 + if (core->platform->revision == VDEC_REVISION_G12A || 237 + core->platform->revision == VDEC_REVISION_SM1) { 238 + clk_set_rate(core->vdec_hevcf_clk, 666666666); 239 + ret = clk_prepare_enable(core->vdec_hevcf_clk); 240 + if (ret) 241 + return ret; 242 + 243 + ret = __vdec_hevc_start(sess); 244 + if (ret) 245 + clk_disable_unprepare(core->vdec_hevcf_clk); 246 + return ret; 247 + } 248 + 249 + return __vdec_hevc_start(sess); 227 250 } 228 251 229 252 struct amvdec_ops vdec_hevc_ops = {