From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB7D4C433B4 for ; Sun, 9 May 2021 11:37:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8EE10613E5 for ; Sun, 9 May 2021 11:37:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229700AbhEILi4 (ORCPT ); Sun, 9 May 2021 07:38:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:54650 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229712AbhEILi4 (ORCPT ); Sun, 9 May 2021 07:38:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B6A2B613D6; Sun, 9 May 2021 11:37:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560273; bh=F9CGTM7syg6rMDyuEAZU/s4AUgmiXP8BljnCUbKbZM0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SBsY2ird4Ec+7Aq49attMbRVisVXkBPHgAiYS7pt5FJRdinP8JsTZlU/PBflot/T6 tFWaniDmz66dfgiiU+EbZKJr4Al2X5A+qVn/AJEoD2nx8MTPoEcs/IQUcPDzE5rrHV N+JHU+56RLcsWMqZITqNkfqygKbZCCrWWBoa2kpMXGFH4UjR83JUfIBWOndcXGX6+t cuxS7wiZygKZcC3ZnEvctbYw/UF/UEI6GErtT5owZIFaZ/JQg8fiGxMDqewqWtqFt4 ehsPowPg+COjgALFsW6dANBzPmgOZkrPkYJQUiRsc8dHNE3XWBB1z/4AHwdFuCCrvq jyalyqkfzZREQ== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron , Marek Vasut Subject: [PATCH 28/28] iio: adc: rcar-gyroadc: Use pm_runtime_resume_and_get() and check in probe() Date: Sun, 9 May 2021 12:33:54 +0100 Message-Id: <20210509113354.660190-29-jic23@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210509113354.660190-1-jic23@kernel.org> References: <20210509113354.660190-1-jic23@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron 1 instance found using coccicheck script under review at: https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@inria.fr/ The other instance changed did not check for failure of the pm_runtime_get_sync() so that is added. Note the remaining pm_runtime_get_sync() call is left alone because it is not obvious what to do on failure to power up in remove() This is a prequel to taking a closer look at the runtime pm in IIO drivers in general. Signed-off-by: Jonathan Cameron Cc: Marek Vasut --- drivers/iio/adc/rcar-gyroadc.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/iio/adc/rcar-gyroadc.c b/drivers/iio/adc/rcar-gyroadc.c index 9f38cf3c7dc2..a48895046408 100644 --- a/drivers/iio/adc/rcar-gyroadc.c +++ b/drivers/iio/adc/rcar-gyroadc.c @@ -162,18 +162,13 @@ static const struct iio_chan_spec rcar_gyroadc_iio_channels_3[] = { static int rcar_gyroadc_set_power(struct rcar_gyroadc *priv, bool on) { struct device *dev = priv->dev; - int ret; if (on) { - ret = pm_runtime_get_sync(dev); - if (ret < 0) - pm_runtime_put_noidle(dev); + return pm_runtime_resume_and_get(dev); } else { pm_runtime_mark_last_busy(dev); - ret = pm_runtime_put_autosuspend(dev); + return pm_runtime_put_autosuspend(dev); } - - return ret; } static int rcar_gyroadc_read_raw(struct iio_dev *indio_dev, @@ -535,7 +530,10 @@ static int rcar_gyroadc_probe(struct platform_device *pdev) pm_runtime_use_autosuspend(dev); pm_runtime_enable(dev); - pm_runtime_get_sync(dev); + ret = pm_runtime_resume_and_get(dev); + if (ret) + goto err_power_up; + rcar_gyroadc_hw_init(priv); rcar_gyroadc_hw_start(priv); @@ -552,6 +550,7 @@ static int rcar_gyroadc_probe(struct platform_device *pdev) err_iio_device_register: rcar_gyroadc_hw_stop(priv); pm_runtime_put_sync(dev); +err_power_up: pm_runtime_disable(dev); pm_runtime_set_suspended(dev); clk_disable_unprepare(priv->clk); -- 2.31.1