media: atomisp: use list_splice_init in atomisp_compat_css20.c
authorBaokun Li <libaokun1@huawei.com>
Thu, 17 Jun 2021 14:09:26 +0000 (16:09 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 22 Jul 2021 12:01:55 +0000 (14:01 +0200)
Using list_splice_init() instead of entire while-loops
in atomisp_compat_css20.c.

Link: https://lore.kernel.org/linux-media/20210617140926.887680-1-libaokun1@huawei.com
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Baokun Li <libaokun1@huawei.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c

index f60198bb8a1a98247cbecbeffb8f3efbd756e3c5..99a632f33d2d690a558804515462f1bac22dc34b 100644 (file)
@@ -2102,9 +2102,6 @@ void atomisp_css_stop(struct atomisp_sub_device *asd,
                      enum ia_css_pipe_id pipe_id, bool in_reset)
 {
        struct atomisp_device *isp = asd->isp;
-       struct atomisp_s3a_buf *s3a_buf;
-       struct atomisp_dis_buf *dis_buf;
-       struct atomisp_metadata_buf *md_buf;
        unsigned long irqflags;
        unsigned int i;
 
@@ -2144,42 +2141,17 @@ void atomisp_css_stop(struct atomisp_sub_device *asd,
        }
 
        /* move stats buffers to free queue list */
-       while (!list_empty(&asd->s3a_stats_in_css)) {
-               s3a_buf = list_entry(asd->s3a_stats_in_css.next,
-                                    struct atomisp_s3a_buf, list);
-               list_del(&s3a_buf->list);
-               list_add_tail(&s3a_buf->list, &asd->s3a_stats);
-       }
-       while (!list_empty(&asd->s3a_stats_ready)) {
-               s3a_buf = list_entry(asd->s3a_stats_ready.next,
-                                    struct atomisp_s3a_buf, list);
-               list_del(&s3a_buf->list);
-               list_add_tail(&s3a_buf->list, &asd->s3a_stats);
-       }
+       list_splice_init(&asd->s3a_stats_in_css, &asd->s3a_stats);
+       list_splice_init(&asd->s3a_stats_ready, &asd->s3a_stats);
 
        spin_lock_irqsave(&asd->dis_stats_lock, irqflags);
-       while (!list_empty(&asd->dis_stats_in_css)) {
-               dis_buf = list_entry(asd->dis_stats_in_css.next,
-                                    struct atomisp_dis_buf, list);
-               list_del(&dis_buf->list);
-               list_add_tail(&dis_buf->list, &asd->dis_stats);
-       }
+       list_splice_init(&asd->dis_stats_in_css, &asd->dis_stats);
        asd->params.dis_proj_data_valid = false;
        spin_unlock_irqrestore(&asd->dis_stats_lock, irqflags);
 
        for (i = 0; i < ATOMISP_METADATA_TYPE_NUM; i++) {
-               while (!list_empty(&asd->metadata_in_css[i])) {
-                       md_buf = list_entry(asd->metadata_in_css[i].next,
-                                           struct atomisp_metadata_buf, list);
-                       list_del(&md_buf->list);
-                       list_add_tail(&md_buf->list, &asd->metadata[i]);
-               }
-               while (!list_empty(&asd->metadata_ready[i])) {
-                       md_buf = list_entry(asd->metadata_ready[i].next,
-                                           struct atomisp_metadata_buf, list);
-                       list_del(&md_buf->list);
-                       list_add_tail(&md_buf->list, &asd->metadata[i]);
-               }
+               list_splice_init(&asd->metadata_in_css[i], &asd->metadata[i]);
+               list_splice_init(&asd->metadata_ready[i], &asd->metadata[i]);
        }
 
        atomisp_flush_params_queue(&asd->video_out_capture);