From patchwork Tue Oct 9 06:48:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Bobrowicz X-Patchwork-Id: 10632019 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A266112B for ; Tue, 9 Oct 2018 06:48:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BB90286F2 for ; Tue, 9 Oct 2018 06:48:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 002032891A; Tue, 9 Oct 2018 06:48:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E0A6286F2 for ; Tue, 9 Oct 2018 06:48:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726160AbeJIODx (ORCPT ); Tue, 9 Oct 2018 10:03:53 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:39320 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725855AbeJIODx (ORCPT ); Tue, 9 Oct 2018 10:03:53 -0400 Received: by mail-pl1-f196.google.com with SMTP id w14-v6so319958plp.6 for ; Mon, 08 Oct 2018 23:48:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=elite-embedded-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sCDJnRsfbVEeNvCMszpbP9M4AA9wOWcgIDxNKrFLowU=; b=TwFnH5GCO3A4kNr0wVNuqCs3pJkWy2Kit9CRtYEJ2UKREkk5F2rZKBriIOYU133P4v 3OMKqIsYcwsQF/84twSkvvB4fM2ddy6hIPhwrdRYuT41FJZl82dx28V3hWuqGvJsiBwl afaBaF7GBBMWoAq3w7V3Ms+igYwOdu8WT0LFyBYbF0u7RZbleecX87rIudBzJCMYkKK0 zi0N9uESgHrHV9AFOHQKOr4BNZbthgNSSIt5LCFOv+tP+aVZsTvYRHUZm98hxvsRqDWZ MLhnW10Ak9hIghdZwXq5dlwTzKEPRm6TKggCat2tgpIVSuP+6K7GGBxXmXfcypOip5xe empQ== 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; bh=sCDJnRsfbVEeNvCMszpbP9M4AA9wOWcgIDxNKrFLowU=; b=Rn7pnhzwHdgshnbjZacKzntUjAOggLcB5u0uSB3LGOTixMO2o9f217hfDfXdNgvgHc 7FoflGHIC3KujHjjNY8JCvzbII+8Qo1iz7R4h/WYWwirvDMIrPC3X9yYH0EaN4/Fjx4W qX/DDHbRNR7pwqz7Szj+TWCARze99GdPsvt0VUEgL0LQSa8D30BDGq+4UWRnY/EBkafU v0vwOx8J97UHKXBBe+iwsRGjQUVtz1KaMpIanz8SgOz3QXnFe/xcQ5Y+UJQEUzt4CLRS L4w4gDoXPDcM7e8VorKmNrMuLktXer0uDxK4wZCDsvdPRv/MGV8+6tRVowKF/TQ4Hhku EQzg== X-Gm-Message-State: ABuFfoiiP1PEiw3zTihtBeIQ3sE3wSI64l9bctMpt+QgB1e68f4Yi48D vG4TQ7n0pSl8iFx8imivIglneEf4QOWl X-Google-Smtp-Source: ACcGV616JvEkRQGRt7orE4nWNFQoYsxv+k0BZsPyU7BBue3XlAZpO/suBUsZpx92F1ZhL1x2Zk/8kg== X-Received: by 2002:a17:902:ceb:: with SMTP id 98-v6mr16757929plt.331.1539067708179; Mon, 08 Oct 2018 23:48:28 -0700 (PDT) Received: from ubuntu.localdomain (97-113-94-157.tukw.qwest.net. [97.113.94.157]) by smtp.gmail.com with ESMTPSA id h77-v6sm38960457pfh.13.2018.10.08.23.48.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 Oct 2018 23:48:27 -0700 (PDT) From: Sam Bobrowicz To: linux-media@vger.kernel.org Cc: Sam Bobrowicz Subject: [PATCH 3/4] media: ov5640: Don't access ctrl regs when off Date: Mon, 8 Oct 2018 23:48:01 -0700 Message-Id: <1539067682-60604-4-git-send-email-sam@elite-embedded.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1539067682-60604-1-git-send-email-sam@elite-embedded.com> References: <1539067682-60604-1-git-send-email-sam@elite-embedded.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a check to g_volatile_ctrl to prevent trying to read registers when the sensor is not powered. Signed-off-by: Sam Bobrowicz Acked-by: Jacopo Mondi --- drivers/media/i2c/ov5640.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c index f183222..a50d884 100644 --- a/drivers/media/i2c/ov5640.c +++ b/drivers/media/i2c/ov5640.c @@ -2336,6 +2336,13 @@ static int ov5640_g_volatile_ctrl(struct v4l2_ctrl *ctrl) /* v4l2_ctrl_lock() locks our own mutex */ + /* + * If the sensor is not powered up by the host driver, do + * not try to access it to update the volatile controls. + */ + if (sensor->power_count == 0) + return 0; + switch (ctrl->id) { case V4L2_CID_AUTOGAIN: val = ov5640_get_gain(sensor);