Commit bef63005 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab
Browse files

media: imx: imx7_mipi_csis: Move link setup check out of locked section



Checking if the link setup operation is called for the sink or source
pad doesn't require any locking. Move it out of the section protected by
the mutex.

Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: default avatarRui Miguel Silva <rmfrfs@gmail.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 57b94933
Loading
Loading
Loading
Loading
+12 −9
Original line number Diff line number Diff line
@@ -668,21 +668,24 @@ static int mipi_csis_link_setup(struct media_entity *entity,
	dev_dbg(state->dev, "link setup %s -> %s", remote_pad->entity->name,
		local_pad->entity->name);

	/* We only care about the link to the source. */
	if (!(local_pad->flags & MEDIA_PAD_FL_SINK))
		return 0;

	remote_sd = media_entity_to_v4l2_subdev(remote_pad->entity);

	mutex_lock(&state->lock);

	if (local_pad->flags & MEDIA_PAD_FL_SINK) {
	if (flags & MEDIA_LNK_FL_ENABLED) {
		if (state->src_sd) {
			ret = -EBUSY;
			goto out;
		}

		state->src_sd = remote_sd;
	} else {
		state->src_sd = NULL;
	}
	}

out:
	mutex_unlock(&state->lock);