Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

media: i2c: imx290: Factor out format retrieval to separate function

The driver duplicates the same pattern to access the try or active
format in multiple locations. Factor it out to a separate function.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>

authored by

Laurent Pinchart and committed by
Sakari Ailus
b25537ef 0b274ef2

+14 -10
+14 -10
drivers/media/i2c/imx290.c
··· 519 519 .s_ctrl = imx290_set_ctrl, 520 520 }; 521 521 522 + static struct v4l2_mbus_framefmt * 523 + imx290_get_pad_format(struct imx290 *imx290, struct v4l2_subdev_state *state, 524 + u32 which) 525 + { 526 + if (which == V4L2_SUBDEV_FORMAT_ACTIVE) 527 + return &imx290->current_format; 528 + else 529 + return v4l2_subdev_get_try_format(&imx290->sd, state, 0); 530 + } 531 + 522 532 static int imx290_enum_mbus_code(struct v4l2_subdev *sd, 523 533 struct v4l2_subdev_state *sd_state, 524 534 struct v4l2_subdev_mbus_code_enum *code) ··· 572 562 573 563 mutex_lock(&imx290->lock); 574 564 575 - if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) 576 - framefmt = v4l2_subdev_get_try_format(&imx290->sd, sd_state, 577 - fmt->pad); 578 - else 579 - framefmt = &imx290->current_format; 580 - 565 + framefmt = imx290_get_pad_format(imx290, sd_state, fmt->which); 581 566 fmt->format = *framefmt; 582 567 583 568 mutex_unlock(&imx290->lock); ··· 632 627 fmt->format.code = imx290_formats[i].code; 633 628 fmt->format.field = V4L2_FIELD_NONE; 634 629 635 - if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { 636 - format = v4l2_subdev_get_try_format(sd, sd_state, fmt->pad); 637 - } else { 638 - format = &imx290->current_format; 630 + format = imx290_get_pad_format(imx290, sd_state, fmt->which); 631 + 632 + if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) { 639 633 imx290->current_mode = mode; 640 634 imx290->bpp = imx290_formats[i].bpp; 641 635