From patchwork Mon Sep 18 12:51:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 724327 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C046CD13DA for ; Mon, 18 Sep 2023 12:53:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241562AbjIRMwj (ORCPT ); Mon, 18 Sep 2023 08:52:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241532AbjIRMwH (ORCPT ); Mon, 18 Sep 2023 08:52:07 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB3A3EA for ; Mon, 18 Sep 2023 05:51:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695041519; x=1726577519; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GRxvVHMOdl0VJiNM4IdbWOIouQOVfpsuXRMcR4HnfMs=; b=DOqwweySrMX/XnEJ/sbdPEzNSXa/kX4byqajHZTrxufT29dG9aoWzqLo d262SDJ6+9JdPIkzrQXIlwyzAKSg2aC7FJnhn1ereWQLH3UcF6FiZfUg7 rz0A/F8diFIX1L3C9qCv3Uts/y//HY7o6HqIhS9BviZtBED4x1qcQ30n/ g+dTOeBiNClCgKzesXNvsaWLwVzt4PtSRuzgnnOLqsgZppr0JcvssY2o7 rOzNLNC922yaQpcT2nQqh08EfoPzMFP4yfHp0lm4wdbvEVh633sBnKQLz gMc9s3wSH0BjvATM3PBY4uwN1a1P6Ae2TwXwPgchihKaYHHJTWyDcoKbY Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="364688969" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="364688969" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 05:51:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="836005454" X-IronPort-AV: E=Sophos;i="6.02,156,1688454000"; d="scan'208";a="836005454" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Sep 2023 05:51:51 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 1051D11FB8E; Mon, 18 Sep 2023 15:51:47 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, Tianshu Qiu , Bingbu Cao , Tomi Valkeinen , Jacopo Mondi , Rui Miguel Silva , Martin Kepplinger Subject: [PATCH v2 07/12] media: ov2740: Enable runtime PM before registering the async subdev Date: Mon, 18 Sep 2023 15:51:33 +0300 Message-Id: <20230918125138.90002-8-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230918125138.90002-1-sakari.ailus@linux.intel.com> References: <20230918125138.90002-1-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Enable runtime PM before registering the async subdev as the driver UAPI may become accessible immediately after the registration. Runtime PM needs to be enabled by that time. Signed-off-by: Sakari Ailus Reviewed-by: Laurent Pinchart --- drivers/media/i2c/ov2740.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/media/i2c/ov2740.c b/drivers/media/i2c/ov2740.c index 41d4f85470fd..319dc00e47b4 100644 --- a/drivers/media/i2c/ov2740.c +++ b/drivers/media/i2c/ov2740.c @@ -1172,6 +1172,12 @@ static int ov2740_probe(struct i2c_client *client) goto probe_error_v4l2_ctrl_handler_free; } + /* Set the device's state to active if it's in D0 state. */ + if (full_power) + pm_runtime_set_active(&client->dev); + pm_runtime_enable(&client->dev); + pm_runtime_idle(&client->dev); + ret = v4l2_async_register_subdev_sensor(&ov2740->sd); if (ret < 0) { dev_err_probe(dev, ret, "failed to register V4L2 subdev\n"); @@ -1182,16 +1188,12 @@ static int ov2740_probe(struct i2c_client *client) if (ret) dev_warn(&client->dev, "register nvmem failed, ret %d\n", ret); - /* Set the device's state to active if it's in D0 state. */ - if (full_power) - pm_runtime_set_active(&client->dev); - pm_runtime_enable(&client->dev); - pm_runtime_idle(&client->dev); - return 0; probe_error_media_entity_cleanup: media_entity_cleanup(&ov2740->sd.entity); + pm_runtime_disable(&client->dev); + pm_runtime_set_suspended(&client->dev); probe_error_v4l2_ctrl_handler_free: v4l2_ctrl_handler_free(ov2740->sd.ctrl_handler);