Skip to content

Commit

Permalink
media: rkisp1: isp: Add container_of wrapper to cast subdev to rkisp1…
Browse files Browse the repository at this point in the history
…_isp

Replace manual container_of() calls with a static inline wrapper to
increase readability.

Signed-off-by: Laurent Pinchart <[email protected]>
Reviewed-by: Dafna Hirschfeld <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
  • Loading branch information
pinchartl authored and mchehab committed Jul 17, 2022
1 parent 745ba74 commit 8c1aa19
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,11 @@ static void rkisp1_isp_start(struct rkisp1_device *rkisp1)
* Subdev pad operations
*/

static inline struct rkisp1_isp *to_rkisp1_isp(struct v4l2_subdev *sd)
{
return container_of(sd, struct rkisp1_isp, sd);
}

static int rkisp1_isp_enum_mbus_code(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_mbus_code_enum *code)
Expand Down Expand Up @@ -625,7 +630,7 @@ static int rkisp1_isp_get_fmt(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_format *fmt)
{
struct rkisp1_isp *isp = container_of(sd, struct rkisp1_isp, sd);
struct rkisp1_isp *isp = to_rkisp1_isp(sd);

mutex_lock(&isp->ops_lock);
fmt->format = *rkisp1_isp_get_pad_fmt(isp, sd_state, fmt->pad,
Expand All @@ -638,7 +643,7 @@ static int rkisp1_isp_set_fmt(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_format *fmt)
{
struct rkisp1_isp *isp = container_of(sd, struct rkisp1_isp, sd);
struct rkisp1_isp *isp = to_rkisp1_isp(sd);

mutex_lock(&isp->ops_lock);
if (fmt->pad == RKISP1_ISP_PAD_SINK_VIDEO)
Expand All @@ -659,7 +664,7 @@ static int rkisp1_isp_get_selection(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_selection *sel)
{
struct rkisp1_isp *isp = container_of(sd, struct rkisp1_isp, sd);
struct rkisp1_isp *isp = to_rkisp1_isp(sd);
int ret = 0;

if (sel->pad != RKISP1_ISP_PAD_SOURCE_VIDEO &&
Expand Down Expand Up @@ -701,7 +706,7 @@ static int rkisp1_isp_set_selection(struct v4l2_subdev *sd,
{
struct rkisp1_device *rkisp1 =
container_of(sd->v4l2_dev, struct rkisp1_device, v4l2_dev);
struct rkisp1_isp *isp = container_of(sd, struct rkisp1_isp, sd);
struct rkisp1_isp *isp = to_rkisp1_isp(sd);
int ret = 0;

if (sel->target != V4L2_SEL_TGT_CROP)
Expand Down Expand Up @@ -748,7 +753,7 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable)
{
struct rkisp1_device *rkisp1 =
container_of(sd->v4l2_dev, struct rkisp1_device, v4l2_dev);
struct rkisp1_isp *isp = &rkisp1->isp;
struct rkisp1_isp *isp = to_rkisp1_isp(sd);
struct rkisp1_sensor_async *asd;
int ret;

Expand Down

0 comments on commit 8c1aa19

Please sign in to comment.