linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: unlisted-recipients:; (no To-header on input)
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
	"Daniel W. S. Almeida" <dwlsalmeida@gmail.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-kernel@vger.kernel.org, linux-media@vger.kernel.org
Subject: [PATCH 23/31] media: vidtv: cleanup PSI table header function
Date: Tue, 24 Nov 2020 12:06:19 +0100	[thread overview]
Message-ID: <2169ee8f40e97b70fab8efe920db9eda16ae1b73.1606215584.git.mchehab+huawei@kernel.org> (raw)
In-Reply-To: <cover.1606215584.git.mchehab+huawei@kernel.org>

- Pass struct header_write_args as a pointer, instead of
  passing as a var;

- Initialize the psi_args struct only once.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 drivers/media/test-drivers/vidtv/vidtv_psi.c | 42 +++++++++-----------
 1 file changed, 19 insertions(+), 23 deletions(-)

diff --git a/drivers/media/test-drivers/vidtv/vidtv_psi.c b/drivers/media/test-drivers/vidtv/vidtv_psi.c
index 754c32353ac2..1bc13b0d5fc6 100644
--- a/drivers/media/test-drivers/vidtv/vidtv_psi.c
+++ b/drivers/media/test-drivers/vidtv/vidtv_psi.c
@@ -754,26 +754,22 @@ static u32 vidtv_psi_desc_write_into(struct desc_write_args *args)
 }
 
 static u32
-vidtv_psi_table_header_write_into(struct header_write_args args)
+vidtv_psi_table_header_write_into(struct header_write_args *args)
 {
-	struct psi_write_args psi_args = {};
-	/* the number of bytes written by this function */
-	u32 nbytes = 0;
+	struct psi_write_args psi_args = {
+		.dest_buf           = args->dest_buf,
+		.from               = args->h,
+		.len                = sizeof(struct vidtv_psi_table_header),
+		.dest_offset        = args->dest_offset,
+		.pid                = args->pid,
+		.new_psi_section    = true,
+		.continuity_counter = args->continuity_counter,
+		.is_crc             = false,
+		.dest_buf_sz        = args->dest_buf_sz,
+		.crc                = args->crc,
+	};
 
-	psi_args.dest_buf           = args.dest_buf;
-	psi_args.from               = args.h;
-	psi_args.len                = sizeof(struct vidtv_psi_table_header);
-	psi_args.dest_offset        = args.dest_offset;
-	psi_args.pid                = args.pid;
-	psi_args.new_psi_section    = true;
-	psi_args.continuity_counter = args.continuity_counter;
-	psi_args.is_crc             = false;
-	psi_args.dest_buf_sz        = args.dest_buf_sz;
-	psi_args.crc                = args.crc;
-
-	nbytes += vidtv_psi_ts_psi_write_into(&psi_args);
-
-	return nbytes;
+	return vidtv_psi_ts_psi_write_into(&psi_args);
 }
 
 void
@@ -985,7 +981,7 @@ u32 vidtv_psi_pat_write_into(struct vidtv_psi_pat_write_args args)
 	h_args.dest_buf_sz        = args.buf_sz;
 	h_args.crc = &crc;
 
-	nbytes += vidtv_psi_table_header_write_into(h_args);
+	nbytes += vidtv_psi_table_header_write_into(&h_args);
 
 	/* note that the field 'u16 programs' is not really part of the PAT */
 
@@ -1182,7 +1178,7 @@ u32 vidtv_psi_pmt_write_into(struct vidtv_psi_pmt_write_args args)
 	h_args.dest_buf_sz        = args.buf_sz;
 	h_args.crc                = &crc;
 
-	nbytes += vidtv_psi_table_header_write_into(h_args);
+	nbytes += vidtv_psi_table_header_write_into(&h_args);
 
 	/* write the two bitfields */
 	psi_args.dest_buf = args.buf;
@@ -1334,7 +1330,7 @@ u32 vidtv_psi_sdt_write_into(struct vidtv_psi_sdt_write_args args)
 	h_args.dest_buf_sz        = args.buf_sz;
 	h_args.crc                = &crc;
 
-	nbytes += vidtv_psi_table_header_write_into(h_args);
+	nbytes += vidtv_psi_table_header_write_into(&h_args);
 
 	psi_args.dest_buf = args.buf;
 	psi_args.from     = &args.sdt->network_id;
@@ -1670,7 +1666,7 @@ u32 vidtv_psi_nit_write_into(struct vidtv_psi_nit_write_args args)
 	h_args.dest_buf_sz        = args.buf_sz;
 	h_args.crc                = &crc;
 
-	nbytes += vidtv_psi_table_header_write_into(h_args);
+	nbytes += vidtv_psi_table_header_write_into(&h_args);
 
 	/* write the bitfield */
 	psi_args.dest_buf = args.buf;
@@ -1880,7 +1876,7 @@ u32 vidtv_psi_eit_write_into(struct vidtv_psi_eit_write_args args)
 	h_args.dest_buf_sz        = args.buf_sz;
 	h_args.crc                = &crc;
 
-	nbytes += vidtv_psi_table_header_write_into(h_args);
+	nbytes += vidtv_psi_table_header_write_into(&h_args);
 
 	psi_args.dest_buf = args.buf;
 	psi_args.from     = &args.eit->transport_id;
-- 
2.28.0


  parent reply	other threads:[~2020-11-24 11:07 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-24 11:05 [PATCH 00/31] vidtv: address several issues at the driver Mauro Carvalho Chehab
2020-11-24 11:05 ` [PATCH 01/31] media: vidtv: reorganize includes Mauro Carvalho Chehab
2020-11-24 11:05 ` [PATCH 02/31] media: vidtv: add error checks Mauro Carvalho Chehab
2020-11-24 11:05 ` [PATCH 03/31] media: vidtv: don't use recursive functions Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 04/31] media: vidtv: fix the name of the program Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 05/31] media: vidtv: fix the tone generator logic Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 06/31] media: vidtv: fix some notes at the tone generator Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 07/31] media: vidtv: avoid data copy when initializing the multiplexer Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 08/31] media: vidtv: avoid copying data for PES structs Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 09/31] media: vidtv: do some cleanups at the driver Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 10/31] media: vidtv: remove some unused functions Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 11/31] media: vidtv: pre-initialize mux arrays Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 12/31] media: vidtv: cleanup null packet initialization logic Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 13/31] media: vidtv: improve EIT data Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 14/31] media: vidtv: fix the network ID range Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 15/31] media: vidtv: properly fill EIT service_id Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 16/31] media: vidtv: add a PID entry for the NIT table Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 17/31] media: vidtv: fix service type Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 18/31] media: vidtv: fix service_id at SDT table Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 19/31] media: vidtv: add date to the current event Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 20/31] media: vidtv: simplify PSI write function Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 21/31] media: vidtv: simplify the crc writing logic Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 22/31] media: vidtv: cleanup PSI descriptor write function Mauro Carvalho Chehab
2020-11-24 11:06 ` Mauro Carvalho Chehab [this message]
2020-11-24 11:06 ` [PATCH 24/31] media: vidtv: cleanup PAT " Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 25/31] media: vidtv: cleanup PMT write table function Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 26/31] media: vidtv: simplify SDT write function Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 27/31] media: vidtv: simplify NIT " Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 28/31] media: vidtv: simplify EIT " Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 29/31] media: vidtv.rst: update vidtv documentation Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 30/31] media: vidtv.rst: add kernel-doc markups Mauro Carvalho Chehab
2020-11-24 11:06 ` [PATCH 31/31] media: vidtv: cleanup a few coding style issues Mauro Carvalho Chehab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2169ee8f40e97b70fab8efe920db9eda16ae1b73.1606215584.git.mchehab+huawei@kernel.org \
    --to=mchehab+huawei@kernel.org \
    --cc=dwlsalmeida@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).