Skip to content

Commit 9e00674

Browse files
committed
media: vidtv: simplify the crc writing logic
Cleanup the table_section_crc32_write_into() function by initializing struct psi_write_args only once and by passing the args as a pointer. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
1 parent 5edbd33 commit 9e00674

1 file changed

Lines changed: 18 additions & 21 deletions

File tree

drivers/media/test-drivers/vidtv/vidtv_psi.c

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -254,26 +254,23 @@ static u32 vidtv_psi_ts_psi_write_into(struct psi_write_args *args)
254254
return nbytes;
255255
}
256256

257-
static u32 table_section_crc32_write_into(struct crc32_write_args args)
257+
static u32 table_section_crc32_write_into(struct crc32_write_args *args)
258258
{
259-
struct psi_write_args psi_args = {};
260-
u32 nbytes = 0;
259+
struct psi_write_args psi_args = {
260+
.dest_buf = args->dest_buf,
261+
.from = &args->crc,
262+
.len = CRC_SIZE_IN_BYTES,
263+
.dest_offset = args->dest_offset,
264+
.pid = args->pid,
265+
.new_psi_section = false,
266+
.continuity_counter = args->continuity_counter,
267+
.is_crc = true,
268+
.dest_buf_sz = args->dest_buf_sz,
269+
};
261270

262271
/* the CRC is the last entry in the section */
263272

264-
psi_args.dest_buf = args.dest_buf;
265-
psi_args.from = &args.crc;
266-
psi_args.len = CRC_SIZE_IN_BYTES;
267-
psi_args.dest_offset = args.dest_offset;
268-
psi_args.pid = args.pid;
269-
psi_args.new_psi_section = false;
270-
psi_args.continuity_counter = args.continuity_counter;
271-
psi_args.is_crc = true;
272-
psi_args.dest_buf_sz = args.dest_buf_sz;
273-
274-
nbytes += vidtv_psi_ts_psi_write_into(&psi_args);
275-
276-
return nbytes;
273+
return vidtv_psi_ts_psi_write_into(&psi_args);
277274
}
278275

279276
static void vidtv_psi_desc_chain(struct vidtv_psi_desc *head, struct vidtv_psi_desc *desc)
@@ -1023,7 +1020,7 @@ u32 vidtv_psi_pat_write_into(struct vidtv_psi_pat_write_args args)
10231020
c_args.dest_buf_sz = args.buf_sz;
10241021

10251022
/* Write the CRC32 at the end */
1026-
nbytes += table_section_crc32_write_into(c_args);
1023+
nbytes += table_section_crc32_write_into(&c_args);
10271024

10281025
return nbytes;
10291026
}
@@ -1258,7 +1255,7 @@ u32 vidtv_psi_pmt_write_into(struct vidtv_psi_pmt_write_args args)
12581255
c_args.dest_buf_sz = args.buf_sz;
12591256

12601257
/* Write the CRC32 at the end */
1261-
nbytes += table_section_crc32_write_into(c_args);
1258+
nbytes += table_section_crc32_write_into(&c_args);
12621259

12631260
return nbytes;
12641261
}
@@ -1397,7 +1394,7 @@ u32 vidtv_psi_sdt_write_into(struct vidtv_psi_sdt_write_args args)
13971394
c_args.dest_buf_sz = args.buf_sz;
13981395

13991396
/* Write the CRC at the end */
1400-
nbytes += table_section_crc32_write_into(c_args);
1397+
nbytes += table_section_crc32_write_into(&c_args);
14011398

14021399
return nbytes;
14031400
}
@@ -1754,7 +1751,7 @@ u32 vidtv_psi_nit_write_into(struct vidtv_psi_nit_write_args args)
17541751
c_args.dest_buf_sz = args.buf_sz;
17551752

17561753
/* Write the CRC32 at the end */
1757-
nbytes += table_section_crc32_write_into(c_args);
1754+
nbytes += table_section_crc32_write_into(&c_args);
17581755

17591756
return nbytes;
17601757
}
@@ -1944,7 +1941,7 @@ u32 vidtv_psi_eit_write_into(struct vidtv_psi_eit_write_args args)
19441941
c_args.dest_buf_sz = args.buf_sz;
19451942

19461943
/* Write the CRC at the end */
1947-
nbytes += table_section_crc32_write_into(c_args);
1944+
nbytes += table_section_crc32_write_into(&c_args);
19481945

19491946
return nbytes;
19501947
}

0 commit comments

Comments
 (0)