From patchwork Thu Apr 9 12:11:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11481685 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4D4B614DD for ; Thu, 9 Apr 2020 12:12:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 229E92078E for ; Thu, 9 Apr 2020 12:12:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="HIoPxHit" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725970AbgDIMMP (ORCPT ); Thu, 9 Apr 2020 08:12:15 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:48748 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726082AbgDIMMP (ORCPT ); Thu, 9 Apr 2020 08:12:15 -0400 Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 57E32198C; Thu, 9 Apr 2020 14:12:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1586434332; bh=JbIOqp55h9Iyjdgg6lrfMYhU0LSQfUFZYn8XYjGi5Rc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HIoPxHitps3y7/iBR6yf58NxPdguzXwUbnMpVm6mIkp26VCPw2tFyILHX/suZuim9 jJXoMcv53+wVy3uXPKwu9316ZMbkMgwMn2j9nLxKQ+s2eMMpgfgGi6sZ205j6GUySI 4HGl3ahVvAHCN2XFVYPh/Ke4sPrPCsaiEB5ftrac= From: Kieran Bingham To: linux-renesas-soc@vger.kernel.org, Jacopo Mondi , Laurent Pinchart , =?utf-8?q?Niklas_S?= =?utf-8?q?=C3=B6derlund?= , Hyun Kwon , Manivannan Sadhasivam Cc: Kieran Bingham Subject: [PATCH v8 09/13] sqaush! max9286: Lock format changes Date: Thu, 9 Apr 2020 13:11:58 +0100 Message-Id: <20200409121202.11130-10-kieran.bingham+renesas@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> References: <20200409121202.11130-1-kieran.bingham+renesas@ideasonboard.com> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Provide a mutex to protect against format changes on the pads. The mutex can also be used to protect against control changes, or other userspace facing interactions as necessary Signed-off-by: Kieran Bingham --- drivers/media/i2c/max9286.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index 911323d6d3c4..17830c362a50 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -157,6 +158,9 @@ struct max9286_priv { struct v4l2_mbus_framefmt fmt[MAX9286_N_SINKS]; + /* Protects controls and fmt structures */ + struct mutex mutex; + unsigned int nsources; unsigned int source_mask; unsigned int route_mask; @@ -680,7 +684,9 @@ static int max9286_set_fmt(struct v4l2_subdev *sd, if (!cfg_fmt) return -EINVAL; + mutex_lock(&priv->mutex); *cfg_fmt = format->format; + mutex_unlock(&priv->mutex); return 0; } @@ -699,7 +705,9 @@ static int max9286_get_fmt(struct v4l2_subdev *sd, if (!cfg_fmt) return -EINVAL; + mutex_lock(&priv->mutex); format->format = *cfg_fmt; + mutex_unlock(&priv->mutex); return 0; } @@ -1148,6 +1156,8 @@ static int max9286_probe(struct i2c_client *client) if (!priv) return -ENOMEM; + mutex_init(&priv->mutex); + priv->client = client; i2c_set_clientdata(client, priv);