Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1945453pxy; Fri, 23 Apr 2021 23:56:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbJE/Ra3yNnTtwiDkwlsxVxBQa6ZIS1K0kRdLjRICaImIsklpqmdL5asdGGIgiTAaIw06l X-Received: by 2002:aa7:8c47:0:b029:25c:8bbd:908 with SMTP id e7-20020aa78c470000b029025c8bbd0908mr7326712pfd.54.1619247363609; Fri, 23 Apr 2021 23:56:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619247363; cv=none; d=google.com; s=arc-20160816; b=q+nnOIEW6LyN4jWp7ww0O/VjMV2LeLZVez6AMTjTaxDCZWwbE+bQHQygRi5nj+KIui 1v+29DkH0KwF7cRAfLsNmMPPViQrhexkODjDRsKI4e7GeqVJmMuJKSDfYCXE1u/PkT25 n3LiH5nInVqM9vacCH34gbiBPsMVRb1adnboBwATwpNw8NGVClxIfoW1LQ+s1B/yMN8i I6zvwdii5rT5UWFubqx9Fhc7OQOn15TaRwFMY3kZjg5nvUOLLO+mBWBNSU0KOkIF3GO0 Xjdl6BLNP2qsa+R34ntzVwARF7tba+65Ky+uESBpefHl/UvVivxE7BJgiqtxDM60R85b QaaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=Ky4t1L19mYkE3zf2FMJaLWMXpFSdPvq0+hVvpWJZZ68=; b=NRu922d0LiBS/X5IpoX5WPAIa3FfwAvVbPwaT256mSMIz48JqtbPKqlcN7hCO2u+hU ydo/YzDfO2H6ZHxndr8u2byKUv9jZiplaCC7zoHqpibWP8r/bz2GgAmQzuP1bzuockEH 6DndIRP72pzi9ppMgFjmr/Xc575c4OCYzOYtzbz8+YO/QYrlxKCbY2baz4xiod2zvnBr 7HsJcZFTmNjwbzY+MXhBsvZ5DbOCASEmdASYTftRlGvtmh5gWyWru44PpGZGhb0DL3oT a+VfQvx15w3mlrMoDvBXmQiChdb2yqRWf9EHWfYkImA9o1+0QL6DM/lFW0zt4TwijkmT MvfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=EojMO9FX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n19si9381308pgv.400.2021.04.23.23.55.50; Fri, 23 Apr 2021 23:56:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=EojMO9FX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244769AbhDXGyt (ORCPT + 99 others); Sat, 24 Apr 2021 02:54:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:35726 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237190AbhDXGql (ORCPT ); Sat, 24 Apr 2021 02:46:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DE77661949; Sat, 24 Apr 2021 06:45:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619246734; bh=xpeO+TqQL6lcPMvPb2Bdk8szQoSs+InwQYAk6UJzVbA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EojMO9FXSFHyxT7wcTLwfBO+LP3dFMh71/mr6tVQ86V0IDwOroL/JmtRbx5wF6QY1 V7DVxtNg9fsZyBvZV3/eNpaM+vNAspnats775oaSl46h0TDRVjAFN9rQzGwntE85rN rCo5zwFSM1WSNxBfI7lsauwSHh34jIBG0OEdvMDAKsW8c5o/N71fHoX/ycyXCRrVdC RsE1lYSG9Ub8rFzzziU1YnX6j22F8CvjYcFLqyrRYvsqJZJmlPDns5myNl+kEk8tue Ho4SXO0gyrjQpF1QRkSLhJ3DRzB9nsgb9TkjvobMZVH84LqavWSOy0Bkblj5rYPkls eDST0qplfsVig== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1laC2m-004JgK-Eh; Sat, 24 Apr 2021 08:45:32 +0200 From: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Matt Ranostay , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH 54/78] media: i2c: video-i2c: use pm_runtime_resume_and_get() Date: Sat, 24 Apr 2021 08:45:04 +0200 Message-Id: <3990190ef127055dc87cbc6b3f9065dd919b8508.1619191723.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Mauro Carvalho Chehab To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") added pm_runtime_resume_and_get() in order to automatically handle dev->power.usage_count decrement on errors. Use the new API, in order to cleanup the error check logic. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/i2c/video-i2c.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/media/i2c/video-i2c.c b/drivers/media/i2c/video-i2c.c index 0465832a4090..5cde7da698bd 100644 --- a/drivers/media/i2c/video-i2c.c +++ b/drivers/media/i2c/video-i2c.c @@ -286,11 +286,9 @@ static int amg88xx_read(struct device *dev, enum hwmon_sensor_types type, __le16 buf; int tmp; - tmp = pm_runtime_get_sync(regmap_get_device(data->regmap)); - if (tmp < 0) { - pm_runtime_put_noidle(regmap_get_device(data->regmap)); + tmp = pm_runtime_resume_and_get(regmap_get_device(data->regmap)); + if (tmp < 0) return tmp; - } tmp = regmap_bulk_read(data->regmap, AMG88XX_REG_TTHL, &buf, 2); pm_runtime_mark_last_busy(regmap_get_device(data->regmap)); @@ -512,11 +510,9 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count) if (data->kthread_vid_cap) return 0; - ret = pm_runtime_get_sync(dev); - if (ret < 0) { - pm_runtime_put_noidle(dev); + ret = pm_runtime_resume_and_get(dev); + if (ret < 0) goto error_del_list; - } ret = data->chip->setup(data); if (ret) @@ -893,7 +889,7 @@ static int video_i2c_remove(struct i2c_client *client) { struct video_i2c_data *data = i2c_get_clientdata(client); - pm_runtime_get_sync(&client->dev); + pm_runtime_resume_and_get(&client->dev); pm_runtime_disable(&client->dev); pm_runtime_set_suspended(&client->dev); pm_runtime_put_noidle(&client->dev); -- 2.30.2