[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <YHIDufKhTEeuxyl5@kali>
Date: Sun, 11 Apr 2021 01:29:53 +0530
From: Mitali Borkar <mitaliborkar810@...il.com>
To: narmstrong@...libre.com, mchehab@...nel.org,
gregkh@...uxfoundation.org, khilman@...libre.com,
jbrunet@...libre.com, martin.blumenstingl@...glemail.com
Cc: linux-media@...r.kernel.org, linux-staging@...ts.linux.dev,
linux-kernel@...r.kernel.org, outreachy-kernel@...glegroups.com,
mitali_s@...iitr.ac.in, linux-amlogic@...ts.infradead.org
Subject: [PATCH v2] staging: media: meson: vdec: declare u32 as const and
static const
Declared 32 bit unsigned int as static constant inside a function and
replaced u32[] {x,y} as canvas1, canvas2 in codec_mpeg12.c
This indicates the value of canvas indexes will remain constant throughout execution.
Replaced u32 reg_base and u32 reg_name with const u32 reg_base and const
u32 reg_name as it will contain data/registry bases to write static
const indexes declared above and will keep track of of contiguos
registers after each reg_base.
This makes code look better, neater. It improves readability.
Signed-off-by: Mitali Borkar <mitaliborkar810@...il.com>
---
drivers/staging/media/meson/vdec/codec_mpeg12.c | 5 +++--
drivers/staging/media/meson/vdec/vdec_helpers.c | 2 +-
drivers/staging/media/meson/vdec/vdec_helpers.h | 2 +-
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/media/meson/vdec/codec_mpeg12.c b/drivers/staging/media/meson/vdec/codec_mpeg12.c
index 21e93a13356c..861d8584f22f 100644
--- a/drivers/staging/media/meson/vdec/codec_mpeg12.c
+++ b/drivers/staging/media/meson/vdec/codec_mpeg12.c
@@ -65,6 +65,8 @@ static int codec_mpeg12_start(struct amvdec_session *sess)
struct amvdec_core *core = sess->core;
struct codec_mpeg12 *mpeg12;
int ret;
+ static const u32 canvas1[] = { AV_SCRATCH_0, 0 };
+ static const u32 canvas2[] = { 8, 0 }
mpeg12 = kzalloc(sizeof(*mpeg12), GFP_KERNEL);
if (!mpeg12)
@@ -80,8 +82,7 @@ static int codec_mpeg12_start(struct amvdec_session *sess)
goto free_mpeg12;
}
- ret = amvdec_set_canvases(sess, (u32[]){ AV_SCRATCH_0, 0 },
- (u32[]){ 8, 0 });
+ ret = amvdec_set_canvases(sess, canvas1, canvas2);
if (ret)
goto free_workspace;
diff --git a/drivers/staging/media/meson/vdec/vdec_helpers.c b/drivers/staging/media/meson/vdec/vdec_helpers.c
index 7f07a9175815..df5c27266c44 100644
--- a/drivers/staging/media/meson/vdec/vdec_helpers.c
+++ b/drivers/staging/media/meson/vdec/vdec_helpers.c
@@ -177,7 +177,7 @@ static int set_canvas_nv12m(struct amvdec_session *sess,
}
int amvdec_set_canvases(struct amvdec_session *sess,
- u32 reg_base[], u32 reg_num[])
+ const u32 reg_base[], const u32 reg_num[])
{
struct v4l2_m2m_buffer *buf;
u32 pixfmt = sess->pixfmt_cap;
diff --git a/drivers/staging/media/meson/vdec/vdec_helpers.h b/drivers/staging/media/meson/vdec/vdec_helpers.h
index cfaed52ab526..ace8897c34fe 100644
--- a/drivers/staging/media/meson/vdec/vdec_helpers.h
+++ b/drivers/staging/media/meson/vdec/vdec_helpers.h
@@ -17,7 +17,7 @@
* @reg_num: number of contiguous registers after each reg_base (including it)
*/
int amvdec_set_canvases(struct amvdec_session *sess,
- u32 reg_base[], u32 reg_num[]);
+ const u32 reg_base[], const u32 reg_num[]);
/* Helpers to read/write to the various IPs (DOS, PARSER) */
u32 amvdec_read_dos(struct amvdec_core *core, u32 reg);
--
2.30.2
Powered by blists - more mailing lists