Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3257779yba; Mon, 8 Apr 2019 14:45:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVyGMmFIM+NYUYeZbcNCFpOFUUGyTNqiU5V6ORS83VU8hwahFJy+0JOD56DuvBLtinli4H X-Received: by 2002:a17:902:b407:: with SMTP id x7mr33507812plr.288.1554759932449; Mon, 08 Apr 2019 14:45:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554759932; cv=none; d=google.com; s=arc-20160816; b=AlIzQDmgc5vh24hp+Y6D4uMycLejdzVl4Vhey0FsOoJaRYbjr/xheEb9HhbSuVluJw 1SYxIdlApmlc1YcRehRLs3XrbCXUW6z+KH0ggaSE/Rze9gVUepaFx8mD7/pFZyYqNR9s Gg3pQ4GHd9MCVmsQB1JxYLqp+nPWxJaajCHPt330qXssqFifPN2zxHcPq5FrmEkZMlkz UrEDtPHu1Ik6jpR6CaiAS2p5M+ez+meGGyouMnRFfKcZ+H6E9p3+vYxfgYbxn/s2oqEY h+SMJ5Hbi/CbMRdD3OxrgcvPPRogR/hH9JoCD0XF6Ag2ikIkpYzYkBYAodd7GvTO4pNR FJgg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dapVIysTDyZCwZbl3QKUERGjrDSrapcmOu05WaEF+Qo=; b=i4veNLCAzhXA6jfSAxdzQs4gl6La2nMAPYJu9cKVaQXP+v2wmSGizSI8y/rBC4MIGy o6eMxLJ4KkAD2E9NLVdUsFq7gWfvGXo79yuz+foNavKkot+Aw5MWaYFSyqaIO2O/gQ9m yTyzdkxvGOXUF6KLfFK9ptzO+MdwPqCldANH3Zevr5mN93LEc9Fd75HkLzv5qMj8UTbE aPFN7b1Dc2hMRWo0sYiEooFDBHzElQ+a5Eq0up1vDamzY4kH/h1IxgRAjkXLctJZpXXj p1KlVSsIem48s1w4daV867Lia0gvSD+qYA32r3vq+dw7wVGmT0zJkKY0JctRdpLHp/OM 6DtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vVUKrlW+; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si28402733plj.417.2019.04.08.14.45.17; Mon, 08 Apr 2019 14:45:32 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=vVUKrlW+; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727951AbfDHVn2 (ORCPT + 99 others); Mon, 8 Apr 2019 17:43:28 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:42574 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727300AbfDHVnZ (ORCPT ); Mon, 8 Apr 2019 17:43:25 -0400 Received: by mail-lj1-f193.google.com with SMTP id v22so12617991lje.9; Mon, 08 Apr 2019 14:43:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dapVIysTDyZCwZbl3QKUERGjrDSrapcmOu05WaEF+Qo=; b=vVUKrlW+MHCjzgLRsR79p9GnKX8WigbpLjV8YQ8y4x8R+SbRbTMwekeHOxPL4SU6A3 RpKzxX+f7PecTdCKy8d23gKaUtJKUUOKB69yjMtuK1orEz4kPlQLR6CJuJve/GlPvP3f bEMQ6pZ8MAIrFrS93enDYvl8ic9CTyYG/dO+tuA4LIGHHj837tCCZdpQxgA4kdI9lUnn P1jrYUmRFkXaHNG+MQnPhrZ+xZnULx9y26bTdFz0VMLh6P7GagvVq3iqiIxRwdTT/Anx IG0k2D3fzzUaLquSU6db7XNyWdr1rM0Kv3EQ38IEesUTp5+Y3jPRQvchwFAjxwrDou7E y6uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dapVIysTDyZCwZbl3QKUERGjrDSrapcmOu05WaEF+Qo=; b=q0z+IbXv2MMQ/3FO1c0zGQFF9r6NM7AAowzp9LuYUMoc2naW9tZVpj5BEAMQL6WNCc vECqOO82ANDvpSh4eHhFSFmFCJZGhXSas0tU6blTwZRg+pSeDWxbjk4I7fEvBdSWw0J9 M3MtubUQsgy4NO6npSkExhjiflB8brEErG0m4d1qumBAkk/KWFk7FwpMNRqs6/VTnxZN hOSsG2dW6nnXpk1d1Tis6RZd0ihZ42vtLEklcrQnJS9bQKqVySN1NYdWoXnR/0tzo9eo je0T02oDJ2nujrBN1IQ2qlAspdU67Qj5LuWHNO7SB9PANBEhmAI9rnuXm2HCvlz5/ifU 4TBQ== X-Gm-Message-State: APjAAAWz+YpvRvQX/CyVPMFPKseBKdeKO/wQE3O4+sIPMKmW9dJ29SLN Y2WJ+ZJ741jUY71TnW6fJg4= X-Received: by 2002:a2e:86c7:: with SMTP id n7mr13163553ljj.44.1554759802787; Mon, 08 Apr 2019 14:43:22 -0700 (PDT) Received: from z50.gdansk-morena.vectranet.pl (109241207190.gdansk.vectranet.pl. [109.241.207.190]) by smtp.gmail.com with ESMTPSA id j6sm5286048ljc.0.2019.04.08.14.43.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 14:43:22 -0700 (PDT) From: Janusz Krzysztofik To: Mauro Carvalho Chehab Cc: Sakari Ailus , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH 13/14] media: ov6650: Fix stored frame format not in sync with hardware Date: Mon, 8 Apr 2019 23:42:41 +0200 Message-Id: <20190408214242.9603-14-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190408214242.9603-1-jmkrzyszt@gmail.com> References: <20190408214242.9603-1-jmkrzyszt@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 host 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 Cc: stable@vger.kernel.org --- 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 8013afea0c02..001457d39742 100644 --- a/drivers/media/i2c/ov6650.c +++ b/drivers/media/i2c/ov6650.c @@ -643,7 +643,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) { @@ -664,7 +663,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; @@ -682,8 +680,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; return ret; } -- 2.21.0