]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
staging: media: atomisp: extract ISP2401 cleanup into helper function
authorJose A. Perez de Azpillaga <azpijr@gmail.com>
Thu, 26 Mar 2026 21:34:08 +0000 (22:34 +0100)
committerSakari Ailus <sakari.ailus@linux.intel.com>
Wed, 20 May 2026 08:29:31 +0000 (11:29 +0300)
To reduce indentation and improve the readability of
ia_css_stream_destroy(), extract the ISP2401-specific cleanup block into
a new static helper function, ia_css_stream_destroy_isp2401().

Signed-off-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
drivers/staging/media/atomisp/pci/sh_css.c

index 456c0b2df231e03c0577a8a24505130fbd42bf2d..dcfb602c53e3b59a1952914b38cb351c77a89c14 100644 (file)
@@ -8187,10 +8187,53 @@ ERR:
        return err;
 }
 
+static void ia_css_stream_destroy_isp2401(struct ia_css_stream *stream)
+{
+       int i, j;
+
+       for (i = 0; i < stream->num_pipes; i++) {
+               struct ia_css_pipe *entry = stream->pipes[i];
+               unsigned int sp_thread_id;
+               struct sh_css_sp_pipeline_terminal *terminal;
+
+               assert(entry);
+               if (entry) {
+                       if (!ia_css_pipeline_get_sp_thread_id(
+                               ia_css_pipe_get_pipe_num(entry), &sp_thread_id))
+                               return;
+
+                       terminal = &sh_css_sp_group.pipe_io[sp_thread_id].input;
+
+                       for (j = 0; j < IA_CSS_STREAM_MAX_ISYS_STREAM_PER_CH; j++) {
+                               ia_css_isys_stream_h isys_stream =
+                                       &terminal->context.virtual_input_system_stream[j];
+                               if (stream->config.isys_config[j].valid && isys_stream->valid)
+                                       ia_css_isys_stream_destroy(isys_stream);
+                       }
+               }
+       }
+
+       if (stream->config.mode == IA_CSS_INPUT_MODE_BUFFERED_SENSOR) {
+               for (i = 0; i < stream->num_pipes; i++) {
+                       struct ia_css_pipe *entry = stream->pipes[i];
+                       /*
+                        * free any mipi frames that are remaining:
+                        * some test stream create-destroy cycles do
+                        * not generate output frames
+                        * and the mipi buffer is not freed in the
+                        * deque function
+                        */
+                       if (entry)
+                               free_mipi_frames(entry);
+               }
+       }
+       stream_unregister_with_csi_rx(stream);
+}
+
 int
 ia_css_stream_destroy(struct ia_css_stream *stream)
 {
-       int i, j;
+       int i;
        int err = 0;
 
        IA_CSS_ENTER_PRIVATE("stream = %p", stream);
@@ -8204,48 +8247,8 @@ ia_css_stream_destroy(struct ia_css_stream *stream)
 
        if ((stream->last_pipe) &&
            ia_css_pipeline_is_mapped(stream->last_pipe->pipe_num)) {
-               if (IS_ISP2401) {
-                       for (i = 0; i < stream->num_pipes; i++) {
-                               struct ia_css_pipe *entry = stream->pipes[i];
-                               unsigned int sp_thread_id;
-                               struct sh_css_sp_pipeline_terminal *sp_pipeline_input_terminal;
-
-                               assert(entry);
-                               if (entry) {
-                                       /* get the SP thread id */
-                                       if (!ia_css_pipeline_get_sp_thread_id(
-                                                       ia_css_pipe_get_pipe_num(entry), &sp_thread_id))
-                                               return -EINVAL;
-
-                                       /* get the target input terminal */
-                                       sp_pipeline_input_terminal =
-                                               &sh_css_sp_group.pipe_io[sp_thread_id].input;
-
-                                       for (j = 0; j < IA_CSS_STREAM_MAX_ISYS_STREAM_PER_CH; j++) {
-                                               ia_css_isys_stream_h isys_stream =
-                                                       &sp_pipeline_input_terminal->context.virtual_input_system_stream[j];
-                                               if (stream->config.isys_config[j].valid && isys_stream->valid)
-                                                       ia_css_isys_stream_destroy(isys_stream);
-                                       }
-                               }
-                       }
-
-                       if (stream->config.mode == IA_CSS_INPUT_MODE_BUFFERED_SENSOR) {
-                               for (i = 0; i < stream->num_pipes; i++) {
-                                       struct ia_css_pipe *entry = stream->pipes[i];
-                                       /*
-                                        * free any mipi frames that are remaining:
-                                        * some test stream create-destroy cycles do
-                                        * not generate output frames
-                                        * and the mipi buffer is not freed in the
-                                        * deque function
-                                        */
-                                       if (entry)
-                                               free_mipi_frames(entry);
-                               }
-                       }
-                       stream_unregister_with_csi_rx(stream);
-               }
+               if (IS_ISP2401)
+                       ia_css_stream_destroy_isp2401(stream);
 
                for (i = 0; i < stream->num_pipes; i++) {
                        struct ia_css_pipe *curr_pipe = stream->pipes[i];