diff options
author | Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> | 2021-09-15 03:50:13 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2021-10-05 09:36:51 +0200 |
commit | 5f4eecd5e903ec0f59f71e85f469ee2315b81550 (patch) | |
tree | 82c854277270108982c97cd2df2525fc53b7998a /drivers | |
parent | 984166720eb42e59c0c651f161c291b32dc360fc (diff) |
media: rcar-csi2: Serialize access to set_fmt and get_fmt
The access to the internal storage of the format rcar_csi2.mf should be
serialized, extend the existing lock mutex to also cover this.
While at it document the mutex.
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/platform/rcar-vin/rcar-csi2.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c index 0967ae3bed7e..11848d0c4a55 100644 --- a/drivers/media/platform/rcar-vin/rcar-csi2.c +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c @@ -468,9 +468,8 @@ struct rcar_csi2 { struct v4l2_subdev *remote; unsigned int remote_pad; + struct mutex lock; /* Protects mf and stream_count. */ struct v4l2_mbus_framefmt mf; - - struct mutex lock; int stream_count; unsigned short lanes; @@ -836,6 +835,8 @@ static int rcsi2_set_pad_format(struct v4l2_subdev *sd, struct rcar_csi2 *priv = sd_to_csi2(sd); struct v4l2_mbus_framefmt *framefmt; + mutex_lock(&priv->lock); + if (!rcsi2_code_to_fmt(format->format.code)) format->format.code = rcar_csi2_formats[0].code; @@ -846,6 +847,8 @@ static int rcsi2_set_pad_format(struct v4l2_subdev *sd, *framefmt = format->format; } + mutex_unlock(&priv->lock); + return 0; } @@ -855,11 +858,15 @@ static int rcsi2_get_pad_format(struct v4l2_subdev *sd, { struct rcar_csi2 *priv = sd_to_csi2(sd); + mutex_lock(&priv->lock); + if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) format->format = priv->mf; else format->format = *v4l2_subdev_get_try_format(sd, sd_state, 0); + mutex_unlock(&priv->lock); + return 0; } |