Skip to content

Commit

Permalink
media: ti-vpe: cal: Allocate cal_ctx active_fmt array dynamically
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Benoit Parrot <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
pinchartl authored and sigmaris committed Aug 8, 2020
1 parent e410850 commit 2acd91b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/media/platform/ti-vpe/cal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 2acd91b

Please sign in to comment.