Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13472797ybl; Sun, 29 Dec 2019 12:44:39 -0800 (PST) X-Google-Smtp-Source: APXvYqytq6nhruZYY6lIHgd1vGDjSmrPoCuaaLvwObUV17S+h1X/echnCzywEILURZexW+2pej4T X-Received: by 2002:a05:6830:1715:: with SMTP id 21mr25630173otk.145.1577652279441; Sun, 29 Dec 2019 12:44:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577652279; cv=none; d=google.com; s=arc-20160816; b=zRqLDYynPaJe5zujrDR8VK/DgQCXBOM1HpBjg7VALqWS4+1x/G0zeGLxRbZDuN77IW p6Sy28Sgu2BUg51kCZnFXbEuGF3zsMM4gaVPY7hl/nnItJNRtOpwOKYp7rka+A0UX1Sn 5ClNh2WfDZGWAg0nRjPiRJatqRUDzD/MIvkXIWF/I/cDoAgmQTgnZclVIyLEzpWzxJTW DLVAbJq5Cyg8eb6asYYb7r6KtMYfJegZVIbRXrt3f20gIRVUay5VBptTQahgln7KDKkH hcsZTeSsf6gozrS0D+g2VVDyuqzjp4nCpFEjlbCMFozNXXlPxpTwX/9c6/FYkkV1hUTj nTZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AAvFNH/UyAHm58IJNbXtosj2K+eJnJpPCb8nO98zrhI=; b=FEdavVjEPvrYXKAEoWLuZwTRWUXrTGN2bnJkbE4EN0vET8PMV1OE2qOXQ3oZTWjL/X 8PWtZLb1eIWymCAsWG+70sk7ASMxHE1UVnwlK++wbubUcDAS75QFQMEZd3wEIYQcx99Z UEKfhbV1Jf4A7vSQqwW0Ov9DFBHtJ6jxL26PEhV3ECKCYZQb6lFoGnwFgingEP7SDjv7 MUWvaSq1hucN7AOgltGRvjlH+ANSNPmVmqgfUc1DJKwHpHZBh/mO2FWw08VgSKsIYFIN 1Qn+Uqv0rEsXeH/s96u7E8XxK48FCDD2Tjj8XAO2qjrcpKN5NuKk711CVnYjISA3sNkp gxEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=txCNfvPP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y14si21605009otk.237.2019.12.29.12.44.29; Sun, 29 Dec 2019 12:44:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=txCNfvPP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730294AbfL2Roo (ORCPT + 99 others); Sun, 29 Dec 2019 12:44:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:53060 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730733AbfL2Ron (ORCPT ); Sun, 29 Dec 2019 12:44:43 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EF557206A4; Sun, 29 Dec 2019 17:44:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577641482; bh=H300QFv4GjbTJFT+JHicaTY8yQc+JevL/9P4PXtybxM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=txCNfvPP0XqLLMXZl+7ICKV5XvoZW81wn87hYpqfuUx45mIxCwjwYLC97gtVqc+z+ evNIlYNm8XRdJwaoFIQjzvNFX9gDDG3xAQLqWskDq8Aq8RPa2AQCPimKv1ulju7Ihg r5pM85dPOv94ZGLyIGIB1+Rm0RHXr/fPup2Y7pcQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Janusz Krzysztofik , Sakari Ailus , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.4 084/434] media: ov6650: Fix stored frame format not in sync with hardware Date: Sun, 29 Dec 2019 18:22:17 +0100 Message-Id: <20191229172707.133773336@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229172702.393141737@linuxfoundation.org> References: <20191229172702.393141737@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Janusz Krzysztofik [ Upstream commit 3143b459de4cdcce67b36827476c966e93c1cf01 ] The driver stores frame format settings supposed to be in line with hardware state in a device private structure. Since the driver initial submission, those settings are updated before they are actually applied on hardware. If an error occurs on device update, the stored settings my not reflect hardware state anymore and consecutive calls to .get_fmt() may return incorrect information. That in turn may affect ability of a bridge device to use correct DMA transfer settings if such incorrect informmation on active frame format returned by .get_fmt() is used. Assuming a failed device update means its state hasn't changed, update frame format related settings stored in the device private structure only after they are successfully applied so the stored values always reflect hardware state as closely as possible. Fixes: 2f6e2404799a ("[media] SoC Camera: add driver for OV6650 sensor") Signed-off-by: Janusz Krzysztofik Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/i2c/ov6650.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c index c6af72553258..5426fed2574e 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -609,7 +609,6 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) dev_err(&client->dev, "Pixel format not handled: 0x%x\n", code); return -EINVAL; } - priv->code = code; if (code == MEDIA_BUS_FMT_Y8_1X8 || code == MEDIA_BUS_FMT_SBGGR8_1X8) { @@ -635,7 +634,6 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) dev_dbg(&client->dev, "max resolution: CIF\n"); coma_mask |= COMA_QCIF; } - priv->half_scale = half_scale; clkrc = CLKRC_12MHz; mclk = 12000000; @@ -653,8 +651,13 @@ static int ov6650_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) ret = ov6650_reg_rmw(client, REG_COMA, coma_set, coma_mask); if (!ret) ret = ov6650_reg_write(client, REG_CLKRC, clkrc); - if (!ret) + if (!ret) { + priv->half_scale = half_scale; + ret = ov6650_reg_rmw(client, REG_COML, coml_set, coml_mask); + } + if (!ret) + priv->code = code; if (!ret) { mf->colorspace = priv->colorspace; -- 2.20.1