summaryrefslogtreecommitdiffstats
path: root/drivers/media/platform/ti-vpe/cal.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-07-06 20:36:36 +0200
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2020-07-19 10:37:10 +0200
commit0a8e64ed2100511454d652d03f5ec9098ded5c44 (patch)
treecb05132c346ebdaed91edce4fee02df4125685f8 /drivers/media/platform/ti-vpe/cal.c
parent1b22b7a0ec9c505ac9b55adeb84a7c15cbd0bbb0 (diff)
downloadlinux-0a8e64ed2100511454d652d03f5ec9098ded5c44.tar.bz2
media: ti-vpe: cal: Allocate cal_ctx active_fmt array dynamically
To avoid making the cal_ctx structure layoug depend on the size of the cal_formats array, allocate the active_fmt array dynamically. This prepares for splitting the driver in multiple files. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/media/platform/ti-vpe/cal.c')
-rw-r--r--drivers/media/platform/ti-vpe/cal.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
index 26747e6da358..31878a32f6a1 100644
--- a/drivers/media/platform/ti-vpe/cal.c
+++ b/drivers/media/platform/ti-vpe/cal.c
@@ -325,7 +325,7 @@ struct cal_ctx {
struct v4l2_mbus_framefmt m_fmt;
/* Current subdev enumerated format */
- const struct cal_fmt *active_fmt[ARRAY_SIZE(cal_formats)];
+ const struct cal_fmt **active_fmt;
unsigned int num_active_fmt;
unsigned int sequence;
@@ -1957,7 +1957,13 @@ static int cal_ctx_v4l2_init_formats(struct cal_ctx *ctx)
int ret = 0;
/* Enumerate sub device formats and enable all matching local formats */
+ ctx->active_fmt = devm_kcalloc(ctx->cal->dev, ARRAY_SIZE(cal_formats),
+ sizeof(*ctx->active_fmt), GFP_KERNEL);
+ if (!ctx->active_fmt)
+ return -ENOMEM;
+
ctx->num_active_fmt = 0;
+
for (j = 0, i = 0; ret != -EINVAL; ++j) {
memset(&mbus_code, 0, sizeof(mbus_code));