From patchwork Sun May 16 16:20:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12260437 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.3 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,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 93AD8C433ED for ; Sun, 16 May 2021 16:22:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 77AD461074 for ; Sun, 16 May 2021 16:22:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230075AbhEPQXR (ORCPT ); Sun, 16 May 2021 12:23:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:50006 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbhEPQXP (ORCPT ); Sun, 16 May 2021 12:23:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2EED6610CA; Sun, 16 May 2021 16:21:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621182120; bh=cjiaeV4CHYOMvMhEtpFe6vThP4kt6L9eT0GKs9Usf/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZdpZsgCPwlJGdnN2A/bPF9WfCrnS3EGWzXo8LY0Yx+87CRlt/uFm5Fg7qRZgW6N8/ fBSvRVJvEW2oZnwn2sa2DfwmmGLsbBb6yd3K5faOXWm3Y7L2dSSTHFy50t4u/+zvaQ ValRWZrBUt08WIcZHoHQZONlom78KsWu/fbGNsjUV4xoIm32VstWxYucrVQxQFCIq9 rp7gAyldcJwNz/yhXT0notU8ef7RPBOXh/5wgF1LY+7ppaGun6qpdoCsHfQkJWuktW RuR3m3slW9gqmLYmSO5Su61enWOpkvFKhlWIssVIL2fxwMj78iV5DmBv6gkp5ov9vl OwfKdN3xZWxLg== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Jonathan Cameron , Jean-Baptiste Maneyrol Subject: [PATCH v2 1/6] iio: imu: mpu6050: Balance runtime pm + use pm_runtime_resume_and_get() Date: Sun, 16 May 2021 17:20:58 +0100 Message-Id: <20210516162103.1332291-2-jic23@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210516162103.1332291-1-jic23@kernel.org> References: <20210516162103.1332291-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Remove an unblanced pm_runtime_put_sync_suspend() call in inv_pu_pm_disable(). Not this call is not a bug, because the runtime pm core will not allow the reference counter to go negative. It is however confusing and serves no purpose. pm_runtime_resume_and_get() case found using coccicheck script under review at: https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@inria.fr/ pm_runtime_resume_and_get() returns <= 0 only so simplify related checks to bring this more inline with nearby calls. This is a prequel to taking a closer look at the runtime pm in IIO drivers in general. Signed-off-by: Jonathan Cameron Cc: Jean-Baptiste Maneyrol Reviewed-by: Mauro Carvalho Chehab --- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 19 ++++++------------- drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c | 6 ++---- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c index 6244a07048df..4cae3765e327 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -570,11 +570,9 @@ static int inv_mpu6050_read_channel_data(struct iio_dev *indio_dev, freq_hz = INV_MPU6050_DIVIDER_TO_FIFO_RATE(st->chip_config.divider); period_us = 1000000 / freq_hz; - result = pm_runtime_get_sync(pdev); - if (result < 0) { - pm_runtime_put_noidle(pdev); + result = pm_runtime_resume_and_get(pdev); + if (result) return result; - } switch (chan->type) { case IIO_ANGL_VEL: @@ -812,11 +810,9 @@ static int inv_mpu6050_write_raw(struct iio_dev *indio_dev, return result; mutex_lock(&st->lock); - result = pm_runtime_get_sync(pdev); - if (result < 0) { - pm_runtime_put_noidle(pdev); + result = pm_runtime_resume_and_get(pdev); + if (result) goto error_write_raw_unlock; - } switch (mask) { case IIO_CHAN_INFO_SCALE: @@ -930,11 +926,9 @@ inv_mpu6050_fifo_rate_store(struct device *dev, struct device_attribute *attr, result = 0; goto fifo_rate_fail_unlock; } - result = pm_runtime_get_sync(pdev); - if (result < 0) { - pm_runtime_put_noidle(pdev); + result = pm_runtime_resume_and_get(pdev); + if (result) goto fifo_rate_fail_unlock; - } result = regmap_write(st->map, st->reg->sample_rate_div, d); if (result) @@ -1422,7 +1416,6 @@ static void inv_mpu_pm_disable(void *data) { struct device *dev = data; - pm_runtime_put_sync_suspend(dev); pm_runtime_disable(dev); } diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c index e21ba778595a..2d0e8cdd4848 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c @@ -173,11 +173,9 @@ static int inv_mpu6050_set_enable(struct iio_dev *indio_dev, bool enable) if (enable) { scan = inv_scan_query(indio_dev); - result = pm_runtime_get_sync(pdev); - if (result < 0) { - pm_runtime_put_noidle(pdev); + result = pm_runtime_resume_and_get(pdev); + if (result) return result; - } /* * In case autosuspend didn't trigger, turn off first not * required sensors. From patchwork Sun May 16 16:20:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12260439 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.3 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,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 EC454C433B4 for ; Sun, 16 May 2021 16:22:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CAE6F61074 for ; Sun, 16 May 2021 16:22:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229506AbhEPQXS (ORCPT ); Sun, 16 May 2021 12:23:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:50014 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230032AbhEPQXR (ORCPT ); Sun, 16 May 2021 12:23:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6D11761076; Sun, 16 May 2021 16:22:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621182122; bh=Y1fnkHnFpkS2lZG/Y3hJviZQfBlot/NohwnJdg7WXA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CG5NnC3R4qDex/HZEss5jENGwo/YkVdKSAvKZMZx6Tfls3cL8B/ZGz4cj8OKVcTgK UpBVlzxZzK5rSGByqpY40ak1NKD9nQKilqg0dFUyEyQ4NHzFOfJu8yI6BNX8oQvUDd oMDmbbM/H4yhNh771oKKLeJ/LQPgeWNROsDS5N1Q7+NXEZkG+UlH7tbEmkE+0Zit+Q CflGwH098V6anHGPkAiy9IxX9o6ojXqylgn74xRHNHJk87XZp/9KaF2Dr0wSCgXNiX Md5ASwb06fbXJJ8WqNHDUoUlNnitkIEyYPv6Lzsmbnctl0oK62qJC0MqOMFMhQPx42 bOn9qgajKtuIQ== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Jonathan Cameron Subject: [PATCH v2 2/6] iio: adc: ads1015: Balance runtime pm + pm_runtime_resume_and_get() Date: Sun, 16 May 2021 17:20:59 +0100 Message-Id: <20210516162103.1332291-3-jic23@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210516162103.1332291-1-jic23@kernel.org> References: <20210516162103.1332291-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron The call to pm_runtime_put_noidle() in remove() is not balancing a counter increment. Note this doesn't matter as the runtime pm core will not allow the counter to go negative. However, it is confusing to the reader so let's remove it. The pm_runtime_resume_and_get() replacement was found using coccicheck script under review at: https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@inria.fr/ This is a prequel to taking a closer look at the runtime pm in IIO drivers in general. Signed-off-by: Jonathan Cameron Reviewed-by: Mauro Carvalho Chehab --- drivers/iio/adc/ti-ads1015.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c index 5b828428be77..b0352e91ac16 100644 --- a/drivers/iio/adc/ti-ads1015.c +++ b/drivers/iio/adc/ti-ads1015.c @@ -323,9 +323,7 @@ static int ads1015_set_power_state(struct ads1015_data *data, bool on) struct device *dev = regmap_get_device(data->regmap); if (on) { - ret = pm_runtime_get_sync(dev); - if (ret < 0) - pm_runtime_put_noidle(dev); + ret = pm_runtime_resume_and_get(dev); } else { pm_runtime_mark_last_busy(dev); ret = pm_runtime_put_autosuspend(dev); @@ -1070,7 +1068,6 @@ static int ads1015_remove(struct i2c_client *client) pm_runtime_disable(&client->dev); pm_runtime_set_suspended(&client->dev); - pm_runtime_put_noidle(&client->dev); /* power down single shot mode */ return ads1015_set_conv_mode(data, ADS1015_SINGLESHOT); From patchwork Sun May 16 16:21:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12260441 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.3 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,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 580A1C43461 for ; Sun, 16 May 2021 16:22:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 35D0461074 for ; Sun, 16 May 2021 16:22:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230144AbhEPQXU (ORCPT ); Sun, 16 May 2021 12:23:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:50024 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230032AbhEPQXT (ORCPT ); Sun, 16 May 2021 12:23:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5F8FB61183; Sun, 16 May 2021 16:22:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621182124; bh=L3DLCO5r4p/bxGtDFmXFiv1GSgRpjZHdnwSC6swVnao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PP9tsnF4W2DduFl3gHjj/o0vl1nTG2YSZshoAFrIMIfgcxvpsx1CuHP+1UnSViLBm bjcF9liczCpRTCe7VujpPEGX6idVLPpCDUj47fsuizAN3q7PJ4vi6VlAWrrSLJFhVb +cgJkoQbSQRF9EQyW6XBr5r6uftUn/4yMO+/bZkhp/NViePMkcSFsHTr0ZtlMzXYsh Sw+lCyxHvjll6BwoQUZoWfv8tnnd8Hwyolg4JIODUpBuFx3n+cj1y+QSdRe42J6TPb k7iJmostRjVb3cIb1Wj7wHRBTAQsPkPeR7jE8JGnfxA8wFATomPsEOeDNsN5LrNV8v g1k53N3iPyAcw== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Jonathan Cameron , Matt Ranostay Subject: [PATCH v2 3/6] iio: chemical: atlas-sensor: Balance runtime pm + pm_runtime_resume_and_get() Date: Sun, 16 May 2021 17:21:00 +0100 Message-Id: <20210516162103.1332291-4-jic23@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210516162103.1332291-1-jic23@kernel.org> References: <20210516162103.1332291-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron The pm_runtime_put_noidle() call in remove isn't balanced with any get, so drop it. Note this isn't a bug as the runtime pm core will not allow the reference count to go negative, making this a noop. However, it is confusing to the reader so let's drop it. pm_runtime_resume_and_get() replacement found using the coccicheck script under review at: https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@inria.fr/ As pm_runtime_resume_and_get() returns <= 0 take advantage of that to change the error checking to if (ret) which is more in keeping with the rest of this driver. This is a prequel to taking a closer look at the runtime pm in IIO drivers in general. Signed-off-by: Jonathan Cameron Cc: Matt Ranostay Acked-by: Matt Ranostay Reviewed-by: Mauro Carvalho Chehab --- drivers/iio/chemical/atlas-sensor.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/iio/chemical/atlas-sensor.c b/drivers/iio/chemical/atlas-sensor.c index 0fdb3b29c5eb..9cb99585b6ff 100644 --- a/drivers/iio/chemical/atlas-sensor.c +++ b/drivers/iio/chemical/atlas-sensor.c @@ -410,11 +410,9 @@ static int atlas_buffer_postenable(struct iio_dev *indio_dev) struct atlas_data *data = iio_priv(indio_dev); int ret; - ret = pm_runtime_get_sync(&data->client->dev); - if (ret < 0) { - pm_runtime_put_noidle(&data->client->dev); + ret = pm_runtime_resume_and_get(&data->client->dev); + if (ret) return ret; - } return atlas_set_interrupt(data, true); } @@ -487,11 +485,9 @@ static int atlas_read_measurement(struct atlas_data *data, int reg, __be32 *val) int suspended = pm_runtime_suspended(dev); int ret; - ret = pm_runtime_get_sync(dev); - if (ret < 0) { - pm_runtime_put_noidle(dev); + ret = pm_runtime_resume_and_get(dev); + if (ret) return ret; - } if (suspended) msleep(data->chip->delay); @@ -741,7 +737,6 @@ static int atlas_remove(struct i2c_client *client) pm_runtime_disable(&client->dev); pm_runtime_set_suspended(&client->dev); - pm_runtime_put_noidle(&client->dev); return atlas_set_powermode(data, 0); } From patchwork Sun May 16 16:21:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12260443 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.3 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,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 7AFBAC433B4 for ; Sun, 16 May 2021 16:22:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5BA86610CA for ; Sun, 16 May 2021 16:22:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230192AbhEPQXW (ORCPT ); Sun, 16 May 2021 12:23:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:50034 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230032AbhEPQXV (ORCPT ); Sun, 16 May 2021 12:23:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 521F661185; Sun, 16 May 2021 16:22:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621182126; bh=tBn+opqtx59CTi7Z4hyip0XeuQ4Dw77jLk5qiNAGbQY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J86Q3hBSLt4aX/3qonMBnAuJ25hN8Qh86xLp6VRSU3P3lmiYSKTLzIWiLrdUecDD8 I17B4L92NqbFCoBnypW4qwk+YNwijDB4seo6dEw/lW1M6GwNV3onqkfli84poqYzlm afjx5BqOaKIM+YnmSIb5ie+qAGZS9o4L4oYl2V2QO4xnkDo89dU7o/f8YvFi+p/jCc ygRQp6TpvYHAHb6AORKWbhEGMljwhmKx+1d8bO4ltxS0G1UVQ/IVHiWyYZg+w+Qq5T 6jkCmFc9gVbtEc+eeE7LfPLsNjrRfiig42DZTvU5xmrgD+k+mVpP5sbkIGcl/tAYDf 6MDxFZ9ODNJjA== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Jonathan Cameron , Matt Ranostay Subject: [PATCH v2 4/6] iio: prox: pulsed-light-v2: Fix misbalance runtime pm in error path Date: Sun, 16 May 2021 17:21:01 +0100 Message-Id: <20210516162103.1332291-5-jic23@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210516162103.1332291-1-jic23@kernel.org> References: <20210516162103.1332291-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron There is one path in which we don't do a runtime pm put and so leave the device enabled for ever more. Reported-by: Mauro Carvalho Chehab Fixes: 4ac4e086fd8c ("iio: pulsedlight-lidar-lite: add runtime PM") Signed-off-by: Jonathan Cameron Cc: Matt Ranostay Acked-by: Matt Ranostay Reviewed-by: Mauro Carvalho Chehab --- drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c index 822a68ae5e03..ecaeb1e11007 100644 --- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c +++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c @@ -164,7 +164,7 @@ static int lidar_get_measurement(struct lidar_data *data, u16 *reg) ret = lidar_write_control(data, LIDAR_REG_CONTROL_ACQUIRE); if (ret < 0) { dev_err(&client->dev, "cannot send start measurement command"); - return ret; + goto err; } while (tries--) { @@ -188,6 +188,7 @@ static int lidar_get_measurement(struct lidar_data *data, u16 *reg) } ret = -EIO; } +err: pm_runtime_mark_last_busy(&client->dev); pm_runtime_put_autosuspend(&client->dev); From patchwork Sun May 16 16:21:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12260445 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.3 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,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 01278C433B4 for ; Sun, 16 May 2021 16:22:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D278A61074 for ; Sun, 16 May 2021 16:22:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230260AbhEPQXY (ORCPT ); Sun, 16 May 2021 12:23:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:50044 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230032AbhEPQXX (ORCPT ); Sun, 16 May 2021 12:23:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A938C61076; Sun, 16 May 2021 16:22:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621182129; bh=uf6PjSav2mP74fAaaWRXlTVQrUL+VFrQt8ewiXUnVfs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F21dBSGpNV1xqgKWzKKPLpt0G/Rz1RqnQA3ytcRCzflLnDmWpg5UaxoBEI41ia6kW zHf9Pt49g3XSVzREIcz0fUpdTyHbT/rCg7awjwdy0m5pZwFwENL7JCyqvtvAwHv2xu RQ4iM5erXLwkwjpSCnbwZrTK1bGXWVEi2tqDBwLfAAE0/doM25E/9x6haJOOzAznh4 +rbCeTnL0ITYpIIdiZ/hs/PeoWZ5HPETpMSNUqMHcd+knlc7n2OUlQJUr6vroKWxTY u8/F/28rSlZ/+WjTpZ52HuwwffAh0V30iwa9zjTma+DEX3eomj7/bOMW7666R0Is6i hTtriJ6tia7HA== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Jonathan Cameron , Matt Ranostay Subject: [PATCH v2 5/6] iio: prox: pulsed-light-v2: Use pm_runtime_resume_and_get() Date: Sun, 16 May 2021 17:21:02 +0100 Message-Id: <20210516162103.1332291-6-jic23@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210516162103.1332291-1-jic23@kernel.org> References: <20210516162103.1332291-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Using this new call makes it easy to handle any errors as a result of runtime resume as it exits without leaving the reference count elevated. Signed-off-by: Jonathan Cameron Cc: Matt Ranostay Acked-by: Matt Ranostay Reviewed-by: Mauro Carvalho Chehab --- drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c index ecaeb1e11007..e94f63932edb 100644 --- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c +++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c @@ -158,7 +158,9 @@ static int lidar_get_measurement(struct lidar_data *data, u16 *reg) int tries = 10; int ret; - pm_runtime_get_sync(&client->dev); + ret = pm_runtime_resume_and_get(&client->dev); + if (ret < 0) + return ret; /* start sample */ ret = lidar_write_control(data, LIDAR_REG_CONTROL_ACQUIRE); From patchwork Sun May 16 16:21:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12260447 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.3 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,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 63B21C43460 for ; Sun, 16 May 2021 16:22:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 44D3961074 for ; Sun, 16 May 2021 16:22:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230339AbhEPQX0 (ORCPT ); Sun, 16 May 2021 12:23:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:50054 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230210AbhEPQXZ (ORCPT ); Sun, 16 May 2021 12:23:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9CD3E610CA; Sun, 16 May 2021 16:22:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621182130; bh=WwsiPze7dj1of2AXA77/CyGgH0wvLu7RLi+6yEbP3fY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TQ/cQpu4co0s65sZYyBd6RMs/8xBlXecTVdYxIioIY9ojhG25R2lfo6zbkvZSbWOD 6firTC0CrB/APZLes3vV8CPZbf3OgqWRPemskLnqeBJJ20g00afuKuHmVXD+ifNeWm /rscKQRcx9zRP07ByOnKW3b5MJ2e9uG2+vhjAdyPvyvX9rjsy9w9jeVlKaV2VkrEgn ysgRwjr2U4iJeZ7eUUY3vHK1jXmpVieDI+dlFaNLCgbDCl39O4KI5JdXGltyQh40hG JsCoinUMf6Ymw71o0q2oU0TBQYQPLjx9pqzIIKV7w6pYF68rZdCw7sRTB3BD7FOphq F/shnchuhuybw== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Jonathan Cameron , Jean-Baptiste Maneyrol Subject: [PATCH v2 6/6] iio: pressure: icp10100: Balance runtime pm + use pm_runtime_resume_and_get() Date: Sun, 16 May 2021 17:21:03 +0100 Message-Id: <20210516162103.1332291-7-jic23@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210516162103.1332291-1-jic23@kernel.org> References: <20210516162103.1332291-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron The devm_ handled runtime pm disable calls pm_runtime_put_sync_suspend() which isn't balancing a matching get call. It isn't a bug as such, because the runtime pm core doesn't decrement the reference count below zero, but it is missleading so let's drop it. Using pm_runtime_resume_and_get() new call makes it easy to handle failures in resume as it doesn't hold a reference count if it exits with an error. Signed-off-by: Jonathan Cameron Cc: Jean-Baptiste Maneyrol Reviewed-by: Mauro Carvalho Chehab --- drivers/iio/pressure/icp10100.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/iio/pressure/icp10100.c b/drivers/iio/pressure/icp10100.c index 48759fc4bf18..af4621eaa6b5 100644 --- a/drivers/iio/pressure/icp10100.c +++ b/drivers/iio/pressure/icp10100.c @@ -250,7 +250,9 @@ static int icp10100_get_measures(struct icp10100_state *st, __be16 measures[3]; int ret; - pm_runtime_get_sync(&st->client->dev); + ret = pm_runtime_resume_and_get(&st->client->dev); + if (ret < 0) + return ret; mutex_lock(&st->lock); cmd = &icp10100_cmd_measure[st->mode]; @@ -525,7 +527,6 @@ static void icp10100_pm_disable(void *data) { struct device *dev = data; - pm_runtime_put_sync_suspend(dev); pm_runtime_disable(dev); }