From patchwork Thu Apr 16 10:40:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11492655 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 AD04B913 for ; Thu, 16 Apr 2020 10:40:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 953CE21D92 for ; Thu, 16 Apr 2020 10:40:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2505081AbgDPKkJ (ORCPT ); Thu, 16 Apr 2020 06:40:09 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:34761 "EHLO relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2505338AbgDPKiZ (ORCPT ); Thu, 16 Apr 2020 06:38:25 -0400 X-Originating-IP: 2.224.242.101 Received: from uno.homenet.telecomitalia.it (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 5B6E160022; Thu, 16 Apr 2020 10:38:21 +0000 (UTC) From: Jacopo Mondi To: kieran.bingham+renesas@ideasonboard.com, linux-renesas-soc@vger.kernel.org Cc: Jacopo Mondi , laurent.pinchart@ideasonboard.com, niklas.soderlund@ragnatech.se, hyunk@xilinx.com, manivannan.sadhasivam@linaro.org Subject: [v8-rc1 12/20] sqaush! max9286: Lock format changes Date: Thu, 16 Apr 2020 12:40:44 +0200 Message-Id: <20200416104052.2643098-13-jacopo+renesas@jmondi.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200416104052.2643098-1-jacopo+renesas@jmondi.org> References: <20200416104052.2643098-1-jacopo+renesas@jmondi.org> 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 From: Kieran Bingham 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 84173b8c2706..49b4d1830747 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);