From patchwork Sun May 9 11:33:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246345 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,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 26EEAC43460 for ; Sun, 9 May 2021 11:36:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 05C5E6141D for ; Sun, 9 May 2021 11:36:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229591AbhEILhy (ORCPT ); Sun, 9 May 2021 07:37:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:53328 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229563AbhEILhy (ORCPT ); Sun, 9 May 2021 07:37:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1A457613F0; Sun, 9 May 2021 11:36:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560211; bh=4O8smvbRXT3ZKhx7nXvkIeuGltwgvdG5B/V8nM0pC8w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bsd4OL7n9VrkJGtSvHLqhEQ49J3L7HFfiZbDLikjI7nHKK4n98MRSJwtZTenYg3a5 JHO/4pezpZWy1F8uOzzZVH3Amq9T2UwtLlzAGPAf9jwQdub5ConvhpVApiSHgRZVgZ W9esjnpVWaLJW1dDqCtYnAVqx60cCzGOx6Ln0obsHnWLw7zt4x3Daznr7cr3jDtQ0H ReQR8NeTDiyplC/vcq5RsbTADNeD3yzIQsnMpYCHg7MnwQ4bSuzKzbsqtmaqrYpNnF zQxOQp9HxAcW8B5/Hn//ChyS4qSgj1gNiAd5LAWIbyvsJXjzFr9AG+vEVEdiWAF1NB 2h9hVWIy+wuOQ== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron , Rui Miguel Silva Subject: [PATCH 01/28] iio: gyro: fxa210002c: Balance runtime pm + use pm_runtime_resume_and_get(). Date: Sun, 9 May 2021 12:33:27 +0100 Message-Id: <20210509113354.660190-2-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron In both the probe() error path and remove() pm_runtime_put_noidle() is called which will decrement the runtime pm reference count. However, there is no matching function to have raised the reference count. Not this isn't a fix as the runtime pm core will stop the reference count going negative anyway. An alternative would have been to raise the count in these paths, but it is not clear why that would be necessary. Whilst we are here replace some boilerplate with pm_runtime_resume_and_get() Found using coccicheck script under review at: https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@inria.fr/ Signed-off-by: Jonathan Cameron Cc: Rui Miguel Silva Reviewed-by: Rui Miguel Silva Reviewed-by: Mauro Carvalho Chehab Signed-off-by: Rui Miguel Silva --- drivers/iio/gyro/fxas21002c_core.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/iio/gyro/fxas21002c_core.c b/drivers/iio/gyro/fxas21002c_core.c index 5af7b48ff01a..539585b0d300 100644 --- a/drivers/iio/gyro/fxas21002c_core.c +++ b/drivers/iio/gyro/fxas21002c_core.c @@ -366,14 +366,7 @@ static int fxas21002c_write(struct fxas21002c_data *data, static int fxas21002c_pm_get(struct fxas21002c_data *data) { - struct device *dev = regmap_get_device(data->regmap); - int ret; - - ret = pm_runtime_get_sync(dev); - if (ret < 0) - pm_runtime_put_noidle(dev); - - return ret; + return pm_runtime_resume_and_get(regmap_get_device(data->regmap)); } static int fxas21002c_pm_put(struct fxas21002c_data *data) @@ -1002,7 +995,6 @@ int fxas21002c_core_probe(struct device *dev, struct regmap *regmap, int irq, pm_disable: pm_runtime_disable(dev); pm_runtime_set_suspended(dev); - pm_runtime_put_noidle(dev); return ret; } @@ -1016,7 +1008,6 @@ void fxas21002c_core_remove(struct device *dev) pm_runtime_disable(dev); pm_runtime_set_suspended(dev); - pm_runtime_put_noidle(dev); } EXPORT_SYMBOL_GPL(fxas21002c_core_remove); From patchwork Sun May 9 11:33:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246347 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,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 C3D5CC433B4 for ; Sun, 9 May 2021 11:36:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A1E756140A for ; Sun, 9 May 2021 11:36:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229607AbhEILh5 (ORCPT ); Sun, 9 May 2021 07:37:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:53380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229563AbhEILh5 (ORCPT ); Sun, 9 May 2021 07:37:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 89B4661401; Sun, 9 May 2021 11:36:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560214; bh=bz2NiDRgW5QIwNjnTW3+GXd1guZ1feyFrulM4D9Rs08=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mCTIwWQjdeegfLK+wBK3+wKhfILSxPMUY4AQIpW7dZpXZEmu9esH0NzicURIC7+5N eHlcVUpmlmE55dSaSM/hjtjYyWnODoQyfGH8Uh3ty/R8lcatFy0jYlWI/WeUuGqZZ0 u+zYqnsrkCCwz6TZEWSnLg0JG9IzS2b5X+fPfJVoCZyTy0sPRUlQ6IDk9yQ03+Sfct VTr8jFqSNFCUd8q7d9PuaKpxt0BIaMiBUzubPutw2n/zsHRszoPYIZXouPngTdhQJv xtjnAluv8FWf+oYVKkXLelkJTyffFXFLOEj5CD8D7drKPGbYrxnc28iqDlIHqSinIL +rMP0/WXDuozQ== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron , Sebastian Reichel Subject: [PATCH 02/28] iio: light: isl29028: Balance runtime pm + use pm_runtime_resume_and_get() Date: Sun, 9 May 2021 12:33:28 +0100 Message-Id: <20210509113354.660190-3-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron In remove this driver called pm_runtime_put_noidle() but there is no matching get operation. This does not cause any problems because the reference counter will not change if already zero, but it does make the code harder to reason about so should be dropped. Whilst we are here, use pm_runtime_resume_and_get() to replace open coded version. Found using coccicheck script under review at: https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@inria.fr/ Signed-off-by: Jonathan Cameron Cc: Sebastian Reichel Reviewed-by: Mauro Carvalho Chehab Reviewed-by: Linus Walleij --- drivers/iio/light/isl29028.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/iio/light/isl29028.c b/drivers/iio/light/isl29028.c index 2f8b494f3e08..9de3262aa688 100644 --- a/drivers/iio/light/isl29028.c +++ b/drivers/iio/light/isl29028.c @@ -339,9 +339,7 @@ static int isl29028_set_pm_runtime_busy(struct isl29028_chip *chip, bool on) int ret; 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); @@ -647,7 +645,6 @@ static int isl29028_remove(struct i2c_client *client) pm_runtime_disable(&client->dev); pm_runtime_set_suspended(&client->dev); - pm_runtime_put_noidle(&client->dev); return isl29028_clear_configure_reg(chip); } From patchwork Sun May 9 11:33:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246349 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,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 03BE0C433B4 for ; Sun, 9 May 2021 11:36:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D69E06140A for ; Sun, 9 May 2021 11:36:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229563AbhEILiA (ORCPT ); Sun, 9 May 2021 07:38:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:53438 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbhEILh7 (ORCPT ); Sun, 9 May 2021 07:37:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3700B613F0; Sun, 9 May 2021 11:36:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560216; bh=JoSRT0A6ceDRVtGT0yRgUMKUXJujQvpSDyvqSXuKFhU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p1tx/WecwjmxlJtrAcT/tLT1Bb2hXYbov1+lluXWgvCtotySITRPah1kWKKrYTMUk iLrmtwv6CwAuklndLAmJ0JOVvwycMipUYsAr360tJjnHfqsbOx5gRY7okbdrURUpnw QskPLr1lM84cIJPu40Wx3n65C0Y8ncEsouT9ek2cWPWrS3HtkvHrOe4XxR8HsSH5a4 uP+YwuqkRjRwVLRLhN+Sp81LDTpcXO0tZbOtJjedma0CIh0H4hzVrA7fbmxfepgXvv DZtMHTqdWZz7rmWiKnvzsOpHdRSDXFGl1ro7zhhXjGicX+gf8vVJWH3AXlCkV4rOrj xHIldUqzAhogA== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron , Brian Masney Subject: [PATCH 03/28] iio: light: tsl2583: Balance runtime pm + use pm_runtime_resume_and_get() Date: Sun, 9 May 2021 12:33:29 +0100 Message-Id: <20210509113354.660190-4-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Error paths in read_raw() and write_raw() callbacks failed to perform and type of runtime pm put(). Remove called pm_runtime_put_noidle() but there is no equivalent get (this is safe because the reference count is protected against going below zero, but it is misleading. Whilst here use pm_runtime_resume_and_get() to replace boilerplate. Signed-off-by: Jonathan Cameron Cc: Brian Masney Reviewed-by: Brian Masney Reviewed-by: Mauro Carvalho Chehab --- drivers/iio/light/tsl2583.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/iio/light/tsl2583.c b/drivers/iio/light/tsl2583.c index 0f787bfc88fc..1f4ad4047a86 100644 --- a/drivers/iio/light/tsl2583.c +++ b/drivers/iio/light/tsl2583.c @@ -636,9 +636,7 @@ static int tsl2583_set_pm_runtime_busy(struct tsl2583_chip *chip, bool on) int ret; if (on) { - ret = pm_runtime_get_sync(&chip->client->dev); - if (ret < 0) - pm_runtime_put_noidle(&chip->client->dev); + ret = pm_runtime_resume_and_get(&chip->client->dev); } else { pm_runtime_mark_last_busy(&chip->client->dev); ret = pm_runtime_put_autosuspend(&chip->client->dev); @@ -721,8 +719,10 @@ static int tsl2583_read_raw(struct iio_dev *indio_dev, read_done: mutex_unlock(&chip->als_mutex); - if (ret < 0) + if (ret < 0) { + tsl2583_set_pm_runtime_busy(chip, false); return ret; + } /* * Preserve the ret variable if the call to @@ -783,8 +783,10 @@ static int tsl2583_write_raw(struct iio_dev *indio_dev, mutex_unlock(&chip->als_mutex); - if (ret < 0) + if (ret < 0) { + tsl2583_set_pm_runtime_busy(chip, false); return ret; + } ret = tsl2583_set_pm_runtime_busy(chip, false); if (ret < 0) @@ -872,7 +874,6 @@ static int tsl2583_remove(struct i2c_client *client) pm_runtime_disable(&client->dev); pm_runtime_set_suspended(&client->dev); - pm_runtime_put_noidle(&client->dev); return tsl2583_set_power_state(chip, TSL2583_CNTL_PWR_OFF); } From patchwork Sun May 9 11:33:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246351 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,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 7DC4FC433ED for ; Sun, 9 May 2021 11:37:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5ABF06140B for ; Sun, 9 May 2021 11:37:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229602AbhEILiD (ORCPT ); Sun, 9 May 2021 07:38:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:53488 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbhEILiC (ORCPT ); Sun, 9 May 2021 07:38:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8E4E96140B; Sun, 9 May 2021 11:36:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560219; bh=mFBTbu4veWJ9vAdRhDSlxS48yXps33WUKtff0aPHXbg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ErJb2kAr2D/NLDp74GgLXpSNlTZWEckg8NBixBVhZQw5m8UzsBVnUyYq3Q+5wyydo +QN31xUl6QKD+CXSEZK5SCdyufrqAinf9/rzRUBmb+a9yIiYqNt/9qg7c7xkPU/jdu l6M8uD+aN8S74Al4oVMbO1nkHjxB987X4abjcP8SDpYdXMun1mUTxtu3EvVlAFXkCH Wzgf9N+c1PHp3PSJ3Wwlhw8/uzuBv3cq4gv7Dvdo08LeuG+mhIIF32i1wEBU+dsA1w jHgIzay8xgN5MdzQLB2vhrs7DwJAVDoJJRwJZ7MblDkKlLeTr/O+Vo6PwJcb/GgJAJ nh6W8zimSFF0g== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron , Hans de Goede Subject: [PATCH 04/28] iio: accel: bmc150-accel: Balanced runtime pm + use pm_runtime_resume_and_get() Date: Sun, 9 May 2021 12:33:30 +0100 Message-Id: <20210509113354.660190-5-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron A call to pm_runtime_put_noidle() doesn't match any call that would result in a get(). It is safe because runtime pm core protects against the reference counter going 0, but it makes it harder to understand the code. Whilst here use pm_runtime_resume_and_get() to tidy things up. The Coccinelle script didn't get this one due to more complex code structure. Signed-off-by: Jonathan Cameron Cc: Hans de Goede Reviewed-by: Hans de Goede Reviewed-by: Mauro Carvalho Chehab --- drivers/iio/accel/bmc150-accel-core.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c index 62a164a7b852..43cfadf8f6b7 100644 --- a/drivers/iio/accel/bmc150-accel-core.c +++ b/drivers/iio/accel/bmc150-accel-core.c @@ -389,7 +389,7 @@ static int bmc150_accel_set_power_state(struct bmc150_accel_data *data, bool on) int ret; if (on) { - ret = pm_runtime_get_sync(dev); + ret = pm_runtime_resume_and_get(dev); } else { pm_runtime_mark_last_busy(dev); ret = pm_runtime_put_autosuspend(dev); @@ -398,9 +398,6 @@ static int bmc150_accel_set_power_state(struct bmc150_accel_data *data, bool on) if (ret < 0) { dev_err(dev, "Failed: %s for %d\n", __func__, on); - if (on) - pm_runtime_put_noidle(dev); - return ret; } @@ -1836,7 +1833,6 @@ int bmc150_accel_core_remove(struct device *dev) pm_runtime_disable(dev); pm_runtime_set_suspended(dev); - pm_runtime_put_noidle(dev); bmc150_accel_unregister_triggers(data, BMC150_ACCEL_TRIGGERS - 1); From patchwork Sun May 9 11:33:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246353 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 F163AC433B4 for ; Sun, 9 May 2021 11:37:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D049C6141D for ; Sun, 9 May 2021 11:37:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229614AbhEILiF (ORCPT ); Sun, 9 May 2021 07:38:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:53528 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229618AbhEILiE (ORCPT ); Sun, 9 May 2021 07:38:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B1B6C613F0; Sun, 9 May 2021 11:36:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560221; bh=9/fypVOuUPMlqQi8+HubR/7gSqQgko5wh+rE1ez/cFI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ELAxqBVYDuy+u1VXlOP/00EkxzLRrFoDF8DkIN12gner2k3q/GlZrtTEGEAC3hZFP JGevS6XjgdamATHznzX+Y/d+SQ5A1nWqVigtmdo2aiiyUakNh565Dr5V9a9kr8W/AO amZf884hVrFAGXZGJmMD+fyAdjdghAZb7S05HKbf3OsGw0+lvfvnPVJDi52Ny12EHP lmZthzqHkQhx/gtVXIpJccXg+x29zDi9Rg+JTIWbH1Ztk5WPk2uU7HosBKzuXKuqM0 b5vsY5/brEknFK4kEebjISuEHE+j8LGZRV90eNx4ZotxqY3i9rsywoVztNLem2UZMH 1DOKaw2kmK9bg== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron , Sean Nyekjaer Subject: [PATCH 05/28] iio: accel: mma8452: Balance runtime pm + use pm_runtime_resume_and_get() Date: Sun, 9 May 2021 12:33:31 +0100 Message-Id: <20210509113354.660190-6-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Remove() callback calls pm_runtime_put_noidle() but there it is not balancing a get. No actual affect because the runtime pm core prevents the reference count going negative. Whilst here use pm_runtime_resume_and_get() rather than open coded version. Again, coccinelle script missed this one due to more complex code structure. Signed-off-by: Jonathan Cameron Cc: Sean Nyekjaer Reviewed-by: Mauro Carvalho Chehab --- drivers/iio/accel/mma8452.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index 464a6bfe6746..715b8138fb71 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -221,7 +221,7 @@ static int mma8452_set_runtime_pm_state(struct i2c_client *client, bool on) int ret; if (on) { - ret = pm_runtime_get_sync(&client->dev); + ret = pm_runtime_resume_and_get(&client->dev); } else { pm_runtime_mark_last_busy(&client->dev); ret = pm_runtime_put_autosuspend(&client->dev); @@ -230,8 +230,6 @@ static int mma8452_set_runtime_pm_state(struct i2c_client *client, bool on) if (ret < 0) { dev_err(&client->dev, "failed to change power state to %d\n", on); - if (on) - pm_runtime_put_noidle(&client->dev); return ret; } @@ -1711,7 +1709,6 @@ static int mma8452_remove(struct i2c_client *client) pm_runtime_disable(&client->dev); pm_runtime_set_suspended(&client->dev); - pm_runtime_put_noidle(&client->dev); iio_triggered_buffer_cleanup(indio_dev); mma8452_trigger_cleanup(indio_dev); From patchwork Sun May 9 11:33:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246355 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,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 64F04C43461 for ; Sun, 9 May 2021 11:37:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 499BD61401 for ; Sun, 9 May 2021 11:37:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229615AbhEILiG (ORCPT ); Sun, 9 May 2021 07:38:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:53584 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbhEILiG (ORCPT ); Sun, 9 May 2021 07:38:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D65A46128C; Sun, 9 May 2021 11:37:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560223; bh=COlNwdsy8cN95NksVrFjzekcFOqH+PQtUQxdo+BsKOc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R8W0mwfEilUglq7rYNhvankmA1RctnW131NWbTTNiRhUVJXLuGLebRhRWYpkAFQOw V+5HMq287fpC0CKfjhfdTeixsm6YqJIPrPy0vhTeMRV8g6z6UeP+T0CbIFGyd3mSI8 FFVcX/6EmL7vaV8RL3yiiXdtq74pGNak07KQ5eI30G2W62iuCUxg9W41OJfA4JbGxY 7P2sUlaJ0gmKmje4UdiRoAg7Xyw4SCLxUOlVsJNuWxmW8uOZjMYbCwpJWqEtPXe6CC 3uc9wWV24uRONobzXOYiTH+DoElI/PmlrqItWxdMVpKcuKWcC7f8TfbDMlV5oxYx+m +GDtLED/S0GhA== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron Subject: [PATCH 06/28] iio: accel: mma9551/3: Balance untime pm + use pm_runtime_resume_and_get() Date: Sun, 9 May 2021 12:33:32 +0100 Message-Id: <20210509113354.660190-7-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Both these drivers call pm_runtime_put_no_idle() when the reference count should already be zero as there is no matching get() Whilst here use pm_runtime_resume_and_get() rather than open coding. Signed-off-by: Jonathan Cameron Reviewed-by: Mauro Carvalho Chehab --- drivers/iio/accel/mma9551.c | 1 - drivers/iio/accel/mma9551_core.c | 4 +--- drivers/iio/accel/mma9553.c | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/iio/accel/mma9551.c b/drivers/iio/accel/mma9551.c index 08a2303cc9df..4c359fb05480 100644 --- a/drivers/iio/accel/mma9551.c +++ b/drivers/iio/accel/mma9551.c @@ -515,7 +515,6 @@ static int mma9551_remove(struct i2c_client *client) pm_runtime_disable(&client->dev); pm_runtime_set_suspended(&client->dev); - pm_runtime_put_noidle(&client->dev); mutex_lock(&data->mutex); mma9551_set_device_state(data->client, false); diff --git a/drivers/iio/accel/mma9551_core.c b/drivers/iio/accel/mma9551_core.c index 666e7a04a7d7..fbf2e2c45678 100644 --- a/drivers/iio/accel/mma9551_core.c +++ b/drivers/iio/accel/mma9551_core.c @@ -664,7 +664,7 @@ int mma9551_set_power_state(struct i2c_client *client, bool on) int ret; if (on) - ret = pm_runtime_get_sync(&client->dev); + ret = pm_runtime_resume_and_get(&client->dev); else { pm_runtime_mark_last_busy(&client->dev); ret = pm_runtime_put_autosuspend(&client->dev); @@ -673,8 +673,6 @@ int mma9551_set_power_state(struct i2c_client *client, bool on) if (ret < 0) { dev_err(&client->dev, "failed to change power state to %d\n", on); - if (on) - pm_runtime_put_noidle(&client->dev); return ret; } diff --git a/drivers/iio/accel/mma9553.c b/drivers/iio/accel/mma9553.c index c15908faa381..ba3ecb3b57dc 100644 --- a/drivers/iio/accel/mma9553.c +++ b/drivers/iio/accel/mma9553.c @@ -1154,7 +1154,6 @@ static int mma9553_remove(struct i2c_client *client) pm_runtime_disable(&client->dev); pm_runtime_set_suspended(&client->dev); - pm_runtime_put_noidle(&client->dev); mutex_lock(&data->mutex); mma9551_set_device_state(data->client, false); From patchwork Sun May 9 11:33:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246357 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,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 C2C3EC433B4 for ; Sun, 9 May 2021 11:37:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A032B6140B for ; Sun, 9 May 2021 11:37:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229616AbhEILiJ (ORCPT ); Sun, 9 May 2021 07:38:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:53626 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbhEILiI (ORCPT ); Sun, 9 May 2021 07:38:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 07324613F0; Sun, 9 May 2021 11:37:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560225; bh=cJngXrvFUs6hR//juFsPm9bJ/pJKZFHgVYA73AHf/Fk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u9WhqDrt4PBOwXUUsrT0PkTbxgegwNLUvtEoSM6LfvyPR0iPlzTIpiGIUBUqHQuHU tujGkBlsh1lHvNAlE1RqRpTiKfzyfFTM/wHuiQWCQR+qArEoKpb6bv6bY8RlDNflur gyA/bryYJ3cfRBNzRxc0+0CNR8Vsjkfs9sqTPNoRkjDERsk7/L9kO+DNSUzLypU+lU G/kEpQb2u2j54SwlxxFrJt3DHWw5OPPH6eTS8JQ/Hkl63xGh9Ss1dUwRKZf2xw2WQw JnULKwHTHWDiTWRXK/bJCcoJmhJxfn7vz4NTqhJVwJbk6LnNagv/tjJZGAfLSmT707 tOWsXy8miSQGw== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron , Hans de Goede Subject: [PATCH 07/28] iio: accel: kxcjk-1013: Balance runtime pm + use pm_runtime_resume_and_get() Date: Sun, 9 May 2021 12:33:33 +0100 Message-Id: <20210509113354.660190-8-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron This driver alls pm_runtime_put_noidle() in it's remove function, but there is no matching get call. This isn't a bug as runtime pm will not allow the reference counter to go negative, but it is missleading so lets remove it. Whilst here use pm_runtime_resume_and_get() to tidy up some boilerplate. The coccicheck script didn't get this one due to the less obvious structure. Found by inspection. Signed-off-by: Jonathan Cameron Cc: Hans de Goede Reviewed-by: Hans de Goede Reviewed-by: Mauro Carvalho Chehab --- drivers/iio/accel/kxcjk-1013.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c index 283e6a3feffc..a9e3dae43ac5 100644 --- a/drivers/iio/accel/kxcjk-1013.c +++ b/drivers/iio/accel/kxcjk-1013.c @@ -478,7 +478,7 @@ static int kxcjk1013_set_power_state(struct kxcjk1013_data *data, bool on) int ret; if (on) - ret = pm_runtime_get_sync(&data->client->dev); + ret = pm_runtime_resume_and_get(&data->client->dev); else { pm_runtime_mark_last_busy(&data->client->dev); ret = pm_runtime_put_autosuspend(&data->client->dev); @@ -486,8 +486,6 @@ static int kxcjk1013_set_power_state(struct kxcjk1013_data *data, bool on) if (ret < 0) { dev_err(&data->client->dev, "Failed: %s for %d\n", __func__, on); - if (on) - pm_runtime_put_noidle(&data->client->dev); return ret; } #endif @@ -1485,7 +1483,6 @@ static int kxcjk1013_remove(struct i2c_client *client) pm_runtime_disable(&client->dev); pm_runtime_set_suspended(&client->dev); - pm_runtime_put_noidle(&client->dev); if (data->dready_trig) { iio_triggered_buffer_cleanup(indio_dev); From patchwork Sun May 9 11:33:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246359 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,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 2820DC433B4 for ; Sun, 9 May 2021 11:37:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 00D956140B for ; Sun, 9 May 2021 11:37:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229618AbhEILiL (ORCPT ); Sun, 9 May 2021 07:38:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:53678 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbhEILiK (ORCPT ); Sun, 9 May 2021 07:38:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2C05B61401; Sun, 9 May 2021 11:37:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560228; bh=rVbI4Gr++tq/9a+iXLs0VL/yh09VWbY10FGE3C9nngM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XcC+sRm4lJaKtCZjB+kMRU8ZoaUkwsQ0LllJ65NjWG0IdBlQA1UP6Q7tTQ1Ew7A/U p7oZoU7jJdFvrxKs6e749y4Ki08vDmqXJEp2AkH+miX1CgTsdwUEX0W748zZ4h2mop Bf8ARDBbYTl0N7SlMvrzczdf+L0w1LudDsGYtXMtbRLo8TEWMMPxqAkwedg49hNveB Srl2QMIeQWQpl9ekiKYuMTf9mUS6KcIZ/w2lpCITbMqGVOqiRfKm8p5x3JyZjWwZPt HmNBw8XahzLUFfCAfQYKp7qlskB8P4ju46RMZneEr7qVTdxQySzOUGgc6unent3OUf /fd47b6bap8VA== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron , Srinivas Pandruvada Subject: [PATCH 08/28] iio: hid: trigger: Balance runtime pm + use pm_runtime_resume_and_get() Date: Sun, 9 May 2021 12:33:34 +0100 Message-Id: <20210509113354.660190-9-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron The call to pm_runtime_put_noidle() in remove() callback is not balanced by any gets Note this doesn't cause any problems beyond reader confusion as the runtime pm core protects against the reference counter going negative. Whilst here, use pm_runtiem_resume_and_get() to simplify code a little. Signed-off-by: Jonathan Cameron Cc: Srinivas Pandruvada Reviewed-by: Mauro Carvalho Chehab --- drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c index 5a7b3e253e58..c06537e106e9 100644 --- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c +++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c @@ -163,18 +163,15 @@ int hid_sensor_power_state(struct hid_sensor_common *st, bool state) if (state) { atomic_inc(&st->user_requested_state); - ret = pm_runtime_get_sync(&st->pdev->dev); + ret = pm_runtime_resume_and_get(&st->pdev->dev); } else { atomic_dec(&st->user_requested_state); pm_runtime_mark_last_busy(&st->pdev->dev); pm_runtime_use_autosuspend(&st->pdev->dev); ret = pm_runtime_put_autosuspend(&st->pdev->dev); } - if (ret < 0) { - if (state) - pm_runtime_put_noidle(&st->pdev->dev); + if (ret < 0) return ret; - } return 0; #else @@ -222,7 +219,6 @@ void hid_sensor_remove_trigger(struct iio_dev *indio_dev, pm_runtime_disable(&attrb->pdev->dev); pm_runtime_set_suspended(&attrb->pdev->dev); - pm_runtime_put_noidle(&attrb->pdev->dev); cancel_work_sync(&attrb->work); iio_trigger_unregister(attrb->trigger); From patchwork Sun May 9 11:33:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246361 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,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 A78D2C433ED for ; Sun, 9 May 2021 11:37:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A7786128C for ; Sun, 9 May 2021 11:37:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229641AbhEILiQ (ORCPT ); Sun, 9 May 2021 07:38:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:53734 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbhEILiN (ORCPT ); Sun, 9 May 2021 07:38:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9B7D5613F0; Sun, 9 May 2021 11:37:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560230; bh=itbBRgIGcJitaSPlfQsKcJgN02UaghCL9Ye6hKHiibI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jFMxFIiCirbV8cukS6fydY19rwmClOS3sIpaHu4rhIcHQCn2Oaggpu1Ex+I45Zoj8 VI0OCHY4DYBPuOAfy0JdlAQ+vfX5ZLENb+zlQCMtFmHh6IgrM0DPbFDA0qIR/Tw/B3 10qjVCMswZxtDq3jOzsGAla0mKgn61Tak2cI9hKt+IKoJ5PRcgR0vjIK2korP8fgbI HEtSwjoM+gvNXXsF/xFO+9WWN24HPKMCq9kCvW9dTkJEBgl198Foa5bpl47v8iVYbM FlkHbUj6NJoCmN9E5S1DEZlBC8oA0z+oGaq+iKN6kb3Xqy89LitpDFNYL44b1E0JGK g0SIYYVVZvFdg== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron Subject: [PATCH 09/28] iio: imu: kmx61: Balance runtime pm + use pm_runtime_resume_and_get() Date: Sun, 9 May 2021 12:33:35 +0100 Message-Id: <20210509113354.660190-10-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron No point in calling pm_runtime_put_noidle() that isn't balancing a get. Note no actual impact because the runtime pm core protects against a negative reference counter. For the pm_runtime_resume_and_get() main interest is in clearing out this old pattern to avoid it getting coppied into new submissions. Signed-off-by: Jonathan Cameron Reviewed-by: Mauro Carvalho Chehab --- drivers/iio/imu/kmx61.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/iio/imu/kmx61.c b/drivers/iio/imu/kmx61.c index d3e06ce99c1e..1dabfd615dab 100644 --- a/drivers/iio/imu/kmx61.c +++ b/drivers/iio/imu/kmx61.c @@ -750,7 +750,7 @@ static int kmx61_set_power_state(struct kmx61_data *data, bool on, u8 device) } if (on) { - ret = pm_runtime_get_sync(&data->client->dev); + ret = pm_runtime_resume_and_get(&data->client->dev); } else { pm_runtime_mark_last_busy(&data->client->dev); ret = pm_runtime_put_autosuspend(&data->client->dev); @@ -759,8 +759,6 @@ static int kmx61_set_power_state(struct kmx61_data *data, bool on, u8 device) dev_err(&data->client->dev, "Failed: kmx61_set_power_state for %d, ret %d\n", on, ret); - if (on) - pm_runtime_put_noidle(&data->client->dev); return ret; } @@ -1426,7 +1424,6 @@ static int kmx61_remove(struct i2c_client *client) pm_runtime_disable(&client->dev); pm_runtime_set_suspended(&client->dev); - pm_runtime_put_noidle(&client->dev); if (client->irq > 0) { iio_triggered_buffer_cleanup(data->acc_indio_dev); From patchwork Sun May 9 11:33:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246363 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 5293EC433B4 for ; Sun, 9 May 2021 11:37:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2EF57613E5 for ; Sun, 9 May 2021 11:37:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229605AbhEILiR (ORCPT ); Sun, 9 May 2021 07:38:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:53778 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229636AbhEILiQ (ORCPT ); Sun, 9 May 2021 07:38:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8E4E8613E5; Sun, 9 May 2021 11:37:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560232; bh=BjFaB4e8c2quSnvq6wulqkx+WCG7UJ5/yLEZuIpMXsU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fLZsuO+vDjyP6k0O30RqGmdHuWTKgZ27oiVEmsGfYmZuSbXKbzonVgFwCT6nPqg1u Afh1tVTDXpOzfHXQDrntG93hhIZo7YwnU92bHrUikEIDjOvDpf0W1Pi2rYcwnwC4NI dGYSk6Oj7l+Zzn0I6ZlGOYJB/Q/XFBrCe8zB82K8emWyPdzbo466ESwc8zdC4MzIyS DGzGCz7ajWQ3dOFnBUzOLkCK8+EHE7gqjL7/tdCovPDm8otLPRYzdUcgALq6GzLDTf L2tLTbpXa7P03JDvM8DzQ7NIyXwS2BPl8QfIqcs9c8Hnvv9I11bB1nI7mXd8Hvprso YDAmUDLZESVrg== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron , Mikko Koivunen Subject: [PATCH 10/28] iio: light: rpr0521: Balance runtime pm + use pm_runtime_resume_and_get() Date: Sun, 9 May 2021 12:33:36 +0100 Message-Id: <20210509113354.660190-11-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Calls to pm_runtime_put_noidle in probe() error path and remove() are not match to any get() calls. The runtime pm core protects against negative reference counts, so this doesn't have any visible impact beyond confusing the reader. Whilst here use pm_runtime_resume_and_get() to replace boilerplate. Signed-off-by: Jonathan Cameron Cc: Mikko Koivunen Reviewed-by: Mauro Carvalho Chehab --- drivers/iio/light/rpr0521.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/iio/light/rpr0521.c b/drivers/iio/light/rpr0521.c index 7e332de0e6a5..c2dd8a3d4217 100644 --- a/drivers/iio/light/rpr0521.c +++ b/drivers/iio/light/rpr0521.c @@ -360,7 +360,7 @@ static int rpr0521_set_power_state(struct rpr0521_data *data, bool on, * both stay enabled until _suspend(). */ if (on) { - ret = pm_runtime_get_sync(&data->client->dev); + ret = pm_runtime_resume_and_get(&data->client->dev); } else { pm_runtime_mark_last_busy(&data->client->dev); ret = pm_runtime_put_autosuspend(&data->client->dev); @@ -369,9 +369,6 @@ static int rpr0521_set_power_state(struct rpr0521_data *data, bool on, dev_err(&data->client->dev, "Failed: rpr0521_set_power_state for %d, ret %d\n", on, ret); - if (on) - pm_runtime_put_noidle(&data->client->dev); - return ret; } @@ -1038,7 +1035,6 @@ static int rpr0521_probe(struct i2c_client *client, err_pm_disable: pm_runtime_disable(&client->dev); pm_runtime_set_suspended(&client->dev); - pm_runtime_put_noidle(&client->dev); err_poweroff: rpr0521_poweroff(data); @@ -1053,7 +1049,6 @@ static int rpr0521_remove(struct i2c_client *client) pm_runtime_disable(&client->dev); pm_runtime_set_suspended(&client->dev); - pm_runtime_put_noidle(&client->dev); rpr0521_poweroff(iio_priv(indio_dev)); From patchwork Sun May 9 11:33:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246365 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,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 0189CC43460 for ; Sun, 9 May 2021 11:37:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC480613EE for ; Sun, 9 May 2021 11:37:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229619AbhEILiS (ORCPT ); Sun, 9 May 2021 07:38:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:53820 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbhEILiR (ORCPT ); Sun, 9 May 2021 07:38:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 23D35613D6; Sun, 9 May 2021 11:37:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560234; bh=7EXmWwkks8vw5xbBzmoA69o4jnn5v7rNcAuK5krjy8A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jprZUt/kenqi8MCyyPnJ7hzg0bxP8UFFfOwwyg80d5vSPTjbFBhzHzuz7ooWdOWxJ dFQGWLGHo2Ri1G1JgzRsV1RY+Hkk9GLjlIP1gp7ZBR7blwfs9b+7S5NZnIoN5ox3pN y1QDB5ope99phNOhTOPmNKNrpy/XPY8c5hbUsCHKfhLlQkgzflKbXNhb1TFSBgIcC1 JByS0Pisvu5wkzVeDwulQPXsFl24o6UMDCxyuG+wONWvmpqGBQEoe0P9hDgbbcfV6N mXa9lqyHddRy2AcU1D1NyrGSSOuHpbDi/oKdfLD5YBOM8x4uU9a1qWyOs5ian7pccA mnf2DBsfFG8Lg== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron , Linus Walleij Subject: [PATCH 11/28] iio: magn: bmc150: Balance runtime pm + use pm_runtime_resume_and_get() Date: Sun, 9 May 2021 12:33:37 +0100 Message-Id: <20210509113354.660190-12-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron probe() error paths after runtime pm is enabled, should disable it. remove() should not call pm_runtime_put_noidle() as there is no matching get() to have raised the reference count. This case has no affect a the runtime pm core protects against going negative. Whilst here use pm_runtime_resume_and_get() to tidy things up a little. coccicheck script didn't get this one due to complex code structure so found by inspection. Signed-off-by: Jonathan Cameron Cc: Linus Walleij Reviewed-by: Mauro Carvalho Chehab Reviewed-by: Linus Walleij --- drivers/iio/magnetometer/bmc150_magn.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/iio/magnetometer/bmc150_magn.c b/drivers/iio/magnetometer/bmc150_magn.c index d75b437a43f2..39920cb764bf 100644 --- a/drivers/iio/magnetometer/bmc150_magn.c +++ b/drivers/iio/magnetometer/bmc150_magn.c @@ -262,7 +262,7 @@ static int bmc150_magn_set_power_state(struct bmc150_magn_data *data, bool on) int ret; if (on) { - ret = pm_runtime_get_sync(data->dev); + ret = pm_runtime_resume_and_get(data->dev); } else { pm_runtime_mark_last_busy(data->dev); ret = pm_runtime_put_autosuspend(data->dev); @@ -271,9 +271,6 @@ static int bmc150_magn_set_power_state(struct bmc150_magn_data *data, bool on) if (ret < 0) { dev_err(data->dev, "failed to change power state to %d\n", on); - if (on) - pm_runtime_put_noidle(data->dev); - return ret; } #endif @@ -963,12 +960,14 @@ int bmc150_magn_probe(struct device *dev, struct regmap *regmap, ret = iio_device_register(indio_dev); if (ret < 0) { dev_err(dev, "unable to register iio device\n"); - goto err_buffer_cleanup; + goto err_disable_runtime_pm; } dev_dbg(dev, "Registered device %s\n", name); return 0; +err_disable_runtime_pm: + pm_runtime_disable(dev); err_buffer_cleanup: iio_triggered_buffer_cleanup(indio_dev); err_free_irq: @@ -992,7 +991,6 @@ int bmc150_magn_remove(struct device *dev) pm_runtime_disable(dev); pm_runtime_set_suspended(dev); - pm_runtime_put_noidle(dev); iio_triggered_buffer_cleanup(indio_dev); From patchwork Sun May 9 11:33:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246367 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 3DA2DC433ED for ; Sun, 9 May 2021 11:37:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1FCCE613EE for ; Sun, 9 May 2021 11:37:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229620AbhEILiU (ORCPT ); Sun, 9 May 2021 07:38:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:53896 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbhEILiU (ORCPT ); Sun, 9 May 2021 07:38:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 609A6613E5; Sun, 9 May 2021 11:37:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560237; bh=Bt6iH9LmLdkBHOSApLIgZ9nj8aZXC9374Cw5CiyHiNU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kOZz+rFNcai7AwQ+ZFl1CPbUFFafkaDK8Gpy5H7yywRC9t4hreRj76o9FXTJWATPh 3Cesd5fHN0czUgf0eMC1tMIoiZGC+RY3ktil4O3i8NagLQcac1aTmq22zpVo4DsWyo TKn2XbwAcQVXK9Hh7nKApJ2HDnDpjC85YT2yWVKot0+D4RlUDBvslo5qzhr3nQ2BWF tOlytWkNpBPuzQJdvVuOxqLhS0C7LpKcu5+UPpt8i17Yv3ZTNnZaJn2fgg0rTN+aQY BiMsdTlPA5kvyMEkLFqFTxYs8dkbG4sUoA6GLirZYcVEtXDbjqUWIlIJ+LixPpyTCA Tp0zzF9kGXKng== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron , Mike Looijmans Subject: [PATCH 12/28] iio: accel: bmi088: Balance runtime pm + use pm_runtime_resume_and_get() Date: Sun, 9 May 2021 12:33:38 +0100 Message-Id: <20210509113354.660190-13-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 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 balanced by a get so drop it. Using pm_runtime_resume_and_get() allows for simple introduction of error handling to allow for runtime resume failing. Signed-off-by: Jonathan Cameron Cc: Mike Looijmans Reviewed-by: Mauro Carvalho Chehab --- drivers/iio/accel/bmi088-accel-core.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/iio/accel/bmi088-accel-core.c b/drivers/iio/accel/bmi088-accel-core.c index 61aaaf48c040..a06dae5c971d 100644 --- a/drivers/iio/accel/bmi088-accel-core.c +++ b/drivers/iio/accel/bmi088-accel-core.c @@ -285,11 +285,17 @@ static int bmi088_accel_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_RAW: switch (chan->type) { case IIO_TEMP: - pm_runtime_get_sync(dev); + ret = pm_runtime_resume_and_get(dev); + if (ret) + return ret; + ret = bmi088_accel_get_temp(data, val); goto out_read_raw_pm_put; case IIO_ACCEL: - pm_runtime_get_sync(dev); + ret = pm_runtime_resume_and_get(dev); + if (ret) + return ret; + ret = iio_device_claim_direct_mode(indio_dev); if (ret) goto out_read_raw_pm_put; @@ -319,7 +325,10 @@ static int bmi088_accel_read_raw(struct iio_dev *indio_dev, *val = BMI088_ACCEL_TEMP_UNIT; return IIO_VAL_INT; case IIO_ACCEL: - pm_runtime_get_sync(dev); + ret = pm_runtime_resume_and_get(dev); + if (ret) + return ret; + ret = regmap_read(data->regmap, BMI088_ACCEL_REG_ACC_RANGE, val); if (ret) @@ -334,7 +343,10 @@ static int bmi088_accel_read_raw(struct iio_dev *indio_dev, return -EINVAL; } case IIO_CHAN_INFO_SAMP_FREQ: - pm_runtime_get_sync(dev); + ret = pm_runtime_resume_and_get(dev); + if (ret) + return ret; + ret = bmi088_accel_get_sample_freq(data, val, val2); goto out_read_raw_pm_put; default: @@ -376,7 +388,10 @@ static int bmi088_accel_write_raw(struct iio_dev *indio_dev, switch (mask) { case IIO_CHAN_INFO_SAMP_FREQ: - pm_runtime_get_sync(dev); + ret = pm_runtime_resume_and_get(dev); + if (ret) + return ret; + ret = bmi088_accel_set_sample_freq(data, val); pm_runtime_mark_last_busy(dev); pm_runtime_put_autosuspend(dev); @@ -530,7 +545,6 @@ int bmi088_accel_core_remove(struct device *dev) pm_runtime_disable(dev); pm_runtime_set_suspended(dev); - pm_runtime_put_noidle(dev); bmi088_accel_power_down(data); return 0; From patchwork Sun May 9 11:33:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246369 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,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 CFA7CC433B4 for ; Sun, 9 May 2021 11:37:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AD939613EE for ; Sun, 9 May 2021 11:37:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229634AbhEILiX (ORCPT ); Sun, 9 May 2021 07:38:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:53930 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbhEILiW (ORCPT ); Sun, 9 May 2021 07:38:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B74C6613D6; Sun, 9 May 2021 11:37:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560239; bh=NWbDf8vvr8Gm+S0uBrLWZ+h++EgCVr/4Rs9Pm18Mf24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UeVNuIqgQWIfqVcNEMmBXCZL83/697pN2st1sIYGCqcH01MhpEIztRQ3JwokWKyVk NdCwJ37vp5CbXCEzyPh9Q8IU5BCNsAoDmzBmRVRAHzd45HRZYCWQSyO/4Dmh/c5jIg 8j/gsNlMkS/o1rLHWsobU0a4Z03NsSzBRy3xQdtCPCpcBW8iKmDJeA224KYNq94VU4 mU5e03JgObG4ZusUIw/R9CcKl/An6lP/WW5YJhS5Bo6EWreanx625MRs2w1Z8Hdoin gWqPGSlhN03CIsyqjsjBNyG2O0xc4DKCmGYKQ8Q8x04oPfoOFuz3nH1VfZskklElwI xR4OamxDGQTJw== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron Subject: [PATCH 13/28] iio: imu: mpu6050: Use pm_runtime_resume_and_get() to replace open coding. Date: Sun, 9 May 2021 12:33:39 +0100 Message-Id: <20210509113354.660190-14-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron 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 --- drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 18 ++++++------------ drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c | 6 ++---- 2 files changed, 8 insertions(+), 16 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..06b9c84f6bfb 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) 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 9 11:33:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246371 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,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 BD1FDC433B4 for ; Sun, 9 May 2021 11:37:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A25BA613F0 for ; Sun, 9 May 2021 11:37:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229609AbhEILiZ (ORCPT ); Sun, 9 May 2021 07:38:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:53968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229640AbhEILiY (ORCPT ); Sun, 9 May 2021 07:38:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4C012613E5; Sun, 9 May 2021 11:37:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560242; bh=LHeK3JUudoE8lSVlcvjMgN8jPFPiMkYf7y2tLY1zTU4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lq9n8zzxaFEQ8b+9N29pwbLoslssBI6D7r+zISE1Ebehjagv60+FQblvFrsadTWr6 ds7C6nQouHXNspJYEbWhJDQdNyKhC2WtrOv7UWBWYL3WVEEbKeR84spXqwwn5G1Op+ Xi5C9UbtUGUCLWCGT8lM3TbTBSsi5+XF7MY/mCEVg6Yr7iaUKPDaMtiu6oAzoTqV1X kPCecOXSb998XX8mBk1H7DaZ1KlEcVGsKBQXwVSuWNmKNPhUH2HmakAOsPYCSJMYdz kdOS+ip9kbTL8eRfDbEB7GCi/YZuhzZtF483pi6HTiTTU2V8ju84VnQGL6QJM/EBDE VGpGfxE2E+G+A== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron , Fabrice Gasnier Subject: [PATCH 14/28] iio: adc: stm32-adc: Use pm_runtime_resume_and_get() to replace open coding. Date: Sun, 9 May 2021 12:33:40 +0100 Message-Id: <20210509113354.660190-15-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron 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 Cc: Fabrice Gasnier Reviewed-by: Fabrice Gasnier Reviewed-by: Mauro Carvalho Chehab --- drivers/iio/adc/stm32-adc.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c index c9d36c88ee6a..5088de835bb1 100644 --- a/drivers/iio/adc/stm32-adc.c +++ b/drivers/iio/adc/stm32-adc.c @@ -1158,11 +1158,9 @@ static int stm32_adc_single_conv(struct iio_dev *indio_dev, adc->bufi = 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) return ret; - } /* Apply sampling time settings */ stm32_adc_writel(adc, regs->smpr[0], adc->smpr_val[0]); @@ -1364,11 +1362,9 @@ static int stm32_adc_update_scan_mode(struct iio_dev *indio_dev, struct device *dev = indio_dev->dev.parent; 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 < 0) return ret; - } adc->num_conv = bitmap_weight(scan_mask, indio_dev->masklength); @@ -1413,11 +1409,9 @@ static int stm32_adc_debugfs_reg_access(struct iio_dev *indio_dev, struct device *dev = indio_dev->dev.parent; 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 < 0) return ret; - } if (!readval) stm32_adc_writel(adc, reg, writeval); @@ -1537,11 +1531,9 @@ static int stm32_adc_buffer_postenable(struct iio_dev *indio_dev) struct device *dev = indio_dev->dev.parent; 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 < 0) return ret; - } ret = stm32_adc_set_trig(indio_dev, indio_dev->trig); if (ret) { From patchwork Sun May 9 11:33:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246373 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,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 7E8E3C43460 for ; Sun, 9 May 2021 11:37:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 62AC161401 for ; Sun, 9 May 2021 11:37:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229636AbhEILi1 (ORCPT ); Sun, 9 May 2021 07:38:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:54020 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229640AbhEILi1 (ORCPT ); Sun, 9 May 2021 07:38:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 899E5613D6; Sun, 9 May 2021 11:37:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560244; bh=ktz9ZZL/vgz6pv7ouc/rfrcq/t+oLYtKqjGKA4vzExM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tCXcRdYT10ijQzkHxFBorzp0oOXCbUz/2ZdC9WpI1vQdtE+ZJYpJHttfS41JC/7IL 1U+svRvSsEuHDVCcSQG762kWVzUjbMiMM+vHkjV0l3WjDTuRxhccs0j1Rs6csB14we Jo9t3bDa/uIZWlUujHgf5k18ZxnU7wo6COE4mUTAVdKUCZeTuO/uoiU4xDpBz08sY/ MweNh0vsBHjZx/YUfiNGXqqISDPGg6WrQOe/wH1d4j0h60BL1NyJ+t+uRGlOjaoAVF GblRJ0LteA/AokFOYLs7HgItn1k1aFCxwMHqX1QPc5D+u4in9NwlpRlcM6sWUZ7nyS JnkBuRutXXvWQ== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron , Fabrice Gasnier Subject: [PATCH 15/28] iio: adc: stm32-dfsdm: Use pm_runtime_resume_and_get() to replace open coding. Date: Sun, 9 May 2021 12:33:41 +0100 Message-Id: <20210509113354.660190-16-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron 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 Cc: Fabrice Gasnier Reviewed-by: Fabrice Gasnier Reviewed-by: Mauro Carvalho Chehab --- drivers/iio/adc/stm32-dfsdm-core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/stm32-dfsdm-core.c b/drivers/iio/adc/stm32-dfsdm-core.c index bb925a11c8ae..a627af9a825e 100644 --- a/drivers/iio/adc/stm32-dfsdm-core.c +++ b/drivers/iio/adc/stm32-dfsdm-core.c @@ -135,11 +135,9 @@ int stm32_dfsdm_start_dfsdm(struct stm32_dfsdm *dfsdm) int ret; if (atomic_inc_return(&priv->n_active_ch) == 1) { - 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_ret; - } /* select clock source, e.g. 0 for "dfsdm" or 1 for "audio" */ clk_src = priv->aclk ? 1 : 0; From patchwork Sun May 9 11:33:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246375 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,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 C7063C433B4 for ; Sun, 9 May 2021 11:37:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AD82D613D6 for ; Sun, 9 May 2021 11:37:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229649AbhEILi3 (ORCPT ); Sun, 9 May 2021 07:38:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:54050 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229640AbhEILi3 (ORCPT ); Sun, 9 May 2021 07:38:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C854C613F0; Sun, 9 May 2021 11:37:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560246; bh=nUYCEpZ4d5x4PUSJjh7b5cyzrnTJXFaXEP3ADX/XbeQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ctGUjowZP7p9xLopvCdAgnrFVlQD44VVRwTBap3WvlDz2TdXLPQLbRNPWG7rAHx3U zcaI6scEVP5HPqcGE71h1W9eaMHUacXp0YQcC0nXBBFGi9p1BGNzQw3j9+RBwOiUgj 9f1GdLyTd+1pC1qA8w67pjfMbzrAA2WECZ/fMyJ7m1Tjqs8GFR9NdwJIEE6TDOMZP9 PH9V+luzgSv6XjuICqFjvoYzH+2/pXqE190NHgyPZFf8vmyztRxgwcW+M6MfEL3Xp4 xXEfXQ/2j9J7wTHfUAgDfgopQBbFaucHqtutGZzAp1SagZkaB9fqTNAVGoINpFUwKP YnKIVcsagSXUw== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron , Fabrice Gasnier Subject: [PATCH 16/28] iio: dac: stm32-dac: Use pm_runtime_resume_and_get() to replace open coding. Date: Sun, 9 May 2021 12:33:42 +0100 Message-Id: <20210509113354.660190-17-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron 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 Cc: Fabrice Gasnier Reviewed-by: Fabrice Gasnier Reviewed-by: Mauro Carvalho Chehab --- drivers/iio/dac/stm32-dac.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/iio/dac/stm32-dac.c b/drivers/iio/dac/stm32-dac.c index a5b0a52bf86e..dd2e306824e7 100644 --- a/drivers/iio/dac/stm32-dac.c +++ b/drivers/iio/dac/stm32-dac.c @@ -69,9 +69,8 @@ static int stm32_dac_set_enable_state(struct iio_dev *indio_dev, int ch, } if (enable) { - ret = pm_runtime_get_sync(dev); + ret = pm_runtime_resume_and_get(dev); if (ret < 0) { - pm_runtime_put_noidle(dev); mutex_unlock(&dac->lock); return ret; } From patchwork Sun May 9 11:33:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246377 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,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 E6C54C433ED for ; Sun, 9 May 2021 11:37:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C7E24613F0 for ; Sun, 9 May 2021 11:37:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229640AbhEILic (ORCPT ); Sun, 9 May 2021 07:38:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:54084 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229645AbhEILib (ORCPT ); Sun, 9 May 2021 07:38:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 29DB3613E5; Sun, 9 May 2021 11:37:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560248; bh=L6bvA0UdHArtdy5oOTzfgym9WzGpT/8959l9seqgw0A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OAXddpyOVlyLb/vpGu5MJAN5j0iz0MVC6tKQcvwVp4H3ma8TQBCi96mosOb0A/tx6 Ry0msRZ6o+VkUeARfSVsqtekR5eGM3+bs5Af05SRC3BNXqhoc/kyV2Ln2YwmfVPu6w ipP3QgF+IuixdjtxUn4zDAN6/cBcrq8HnH0fcxkrzHe6cKAL7ni1MIO9z77TKl7/4s aUODkkGj6iifnKjYZCZt2mlPVdzCV6jYAYN1nftQPT/7WfjfXCjnAgnP71x+BA9Nw5 j7dwh1fvcH2ysftSinxokW8lmb2fX/8HC1pWumV49h7tCBfENSD0GefoZ9aZkxUztx 3BG80TWu87zhg== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron Subject: [PATCH 17/28] iio: adc: ads1015: Use pm_runtime_resume_and_get() to replace open coding. Date: Sun, 9 May 2021 12:33:43 +0100 Message-Id: <20210509113354.660190-18-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron 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 --- drivers/iio/adc/ti-ads1015.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c index 9fef39bcf997..4b61ee3d2501 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); From patchwork Sun May 9 11:33:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246379 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,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 14A8CC433B4 for ; Sun, 9 May 2021 11:37:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ECF23613EE for ; Sun, 9 May 2021 11:37:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229658AbhEILie (ORCPT ); Sun, 9 May 2021 07:38:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:54134 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229645AbhEILid (ORCPT ); Sun, 9 May 2021 07:38:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 04D6A6128C; Sun, 9 May 2021 11:37:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560251; bh=283NxLrX//BLHBD8UnO4ihT6aUasQ2WS1A9+8nSljug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rz5OworksElthKM1tHOmlw8fKtERf2/ZINfRRNEVRyXLwGPPHJgmzXyMnRTTfLZlv pEmQgh/lsRs/MCOlxkcGUUnvecvuD4+WB73o1nKkI6o57BwS0iRDOScaw+ox8Uz11S 84DyDo3bcReXDOMImpeBUJDFkQNDqb4R2LYwnhpMtefv/tplsxC4UjpRX8zvhtwCx3 hLQLLHSHQDX6lBgDPi8dTMkiaYxEdPI8pzP0OLurcdpjdIWmViK2djhSwAHhX8Ouwt L0wgfR2w0FrCYOf8hfv3kEt2mjHFpw8BxxdAq4fn6wu5MxWoSOHkRGtMmUJVSaS7PD dOry17GBcd9LQ== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron , Matt Ranostay Subject: [PATCH 18/28] iio: chemical: atlas-sensor: Use pm_runtime_resume_and_get() to replace open coding. Date: Sun, 9 May 2021 12:33:44 +0100 Message-Id: <20210509113354.660190-19-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Found using 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 --- drivers/iio/chemical/atlas-sensor.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/iio/chemical/atlas-sensor.c b/drivers/iio/chemical/atlas-sensor.c index d10f921b233a..90bb3f5bff19 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); From patchwork Sun May 9 11:33:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246385 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,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 28867C43461 for ; Sun, 9 May 2021 11:37:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0BD1461401 for ; Sun, 9 May 2021 11:37:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229695AbhEILii (ORCPT ); Sun, 9 May 2021 07:38:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:54164 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229660AbhEILif (ORCPT ); Sun, 9 May 2021 07:38:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7377A613E5; Sun, 9 May 2021 11:37:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560252; bh=ZIxGBvcZWUCfOZOMlWvE57HoHtq0JE4s5ZIJx7Ye7yw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qsBNBJvY8Wh4q8x3VIWbnH8idtZb908RMl6cHAtwKP752xRdymIUBsbiWQG2oIDAP EIINq8Ga2k8Fa3NGqoAN9SoSqwd1HlxWjcpGV6op8CgrBOqMzofkR9HkfZzDXDq7r4 6/vufDj1Sib6z5VtnY/qyL410IV5TxAkcK233jwiEfrIqI3AP6i+W9eFfNO4XPFBCo 5oM3vlbQnjg18QjxIWWzmuQbjLLP3AnrWmPxy9P5qJs4yopMq1B0Z2M7EnsUv3KLi4 dkSkwaJzoswwSrNF22CqQbWHeYxyVZgd7o3CcfbH8onvZU3tFFfTC59WrqLzHGE+xT mBPLK8l0CUC/w== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron Subject: [PATCH 19/28] iio: light: pa12203001: Use pm_runtime_resume_and_get() to replace open coding. Date: Sun, 9 May 2021 12:33:45 +0100 Message-Id: <20210509113354.660190-20-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron 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/light/pa12203001.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/iio/light/pa12203001.c b/drivers/iio/light/pa12203001.c index bfade6577a38..a52b2c788540 100644 --- a/drivers/iio/light/pa12203001.c +++ b/drivers/iio/light/pa12203001.c @@ -186,9 +186,7 @@ static int pa12203001_set_power_state(struct pa12203001_data *data, bool on, } if (on) { - 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); } else { pm_runtime_mark_last_busy(&data->client->dev); From patchwork Sun May 9 11:33:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246383 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,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 6B6B9C43462 for ; Sun, 9 May 2021 11:37:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4A6846128C for ; Sun, 9 May 2021 11:37:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229662AbhEILik (ORCPT ); Sun, 9 May 2021 07:38:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:54208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229669AbhEILih (ORCPT ); Sun, 9 May 2021 07:38:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4CE146128C; Sun, 9 May 2021 11:37:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560254; bh=b+tLoTv+lsAjiHxUo1wQsVHVNEJiZp1wTwI5sOMa2DA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jNB8IPxinP3SF1RjmYrEDBaD0t9naoRn1jvS5Q8NZQ1UIWV1vE88ng0k6Pi1HvXXQ 8g+1qSsXfNUF+RE+ZzeIhLKm+V8HERMiIXOg3rHhTntBxPQDrf/Iwgt3LdWTGMqT8v CLYQoPFa96O7A1e2PY25cJWPY3HKcmFLIW4p1XL8Yp5jmR/+XVTeoKgXHIaNxJCXI8 XEkw5GKTcOTr5RIkUemcfU8VaA1pltL747/7ANWZc3axAERLfpWmOjW8fKVDuFU/El Xs3KTrrAMGisp4N55LVsP5qNjUF0Cwxv5GwGZuchkGwELxQ+dbC8BKx5Fc3uz4v9Wo s1Lcb4KxwcVYg== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron Subject: [PATCH 20/28] iio: light: us5182: Use pm_runtime_resume_and_get() to replace open coding. Date: Sun, 9 May 2021 12:33:46 +0100 Message-Id: <20210509113354.660190-21-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron 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/light/us5182d.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/iio/light/us5182d.c b/drivers/iio/light/us5182d.c index 393f27b75c75..96e4a66ddf28 100644 --- a/drivers/iio/light/us5182d.c +++ b/drivers/iio/light/us5182d.c @@ -367,9 +367,7 @@ static int us5182d_set_power_state(struct us5182d_data *data, bool on) return 0; if (on) { - 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); } else { pm_runtime_mark_last_busy(&data->client->dev); ret = pm_runtime_put_autosuspend(&data->client->dev); From patchwork Sun May 9 11:33:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246381 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,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 78E56C433ED for ; Sun, 9 May 2021 11:37:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 597B8613D6 for ; Sun, 9 May 2021 11:37:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229666AbhEILil (ORCPT ); Sun, 9 May 2021 07:38:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:54250 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229657AbhEILik (ORCPT ); Sun, 9 May 2021 07:38:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4EFFE613F0; Sun, 9 May 2021 11:37:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560257; bh=ucchPJLzLENSH6ctEOWu0Junud0viddaAFGSJU4LJjM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WEOEQdw7QZnHTj8zgJH8SWtJTCV1zng5b9pVs8KUQHPqoOIfCSJpQam5Xu2xoDIEf JyYGxAxRudOLrDkr5hqX+y1RRIgUxm/oUUK71slQpnyXrFU8VQPSByJower/m7l/qU v6f3PLPkoaXgtd0hNFXtnw9flMDfrOmNRZLSTjpEI9VJH1AFd8aNSBQDZQlMQ2Rbyl mWL7/lj1fzSAnN4O5t4eQqH/PgUeaV0QY6ZhZ7qd+PeLtoQjDr1yqmlNgqiLz2vgsQ JitcdK8itye0NwaNoUIczLlpr/IzjTBTZVT3rIzj8lu5ftXqv63bYZjnNqb993sy+g lWGSB5i8t/UQg== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron , Mathieu Othacehe Subject: [PATCH 21/28] iio: light: vcnl4000: Use pm_runtime_resume_and_get() to replace open coding. Date: Sun, 9 May 2021 12:33:47 +0100 Message-Id: <20210509113354.660190-22-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron 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 Cc: Mathieu Othacehe Reviewed-by: Mauro Carvalho Chehab --- drivers/iio/light/vcnl4000.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c index 4a61865d01cd..01772327a947 100644 --- a/drivers/iio/light/vcnl4000.c +++ b/drivers/iio/light/vcnl4000.c @@ -413,9 +413,7 @@ static int vcnl4000_set_pm_runtime_state(struct vcnl4000_data *data, bool on) int ret; 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); From patchwork Sun May 9 11:33:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246387 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,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 3F554C433B4 for ; Sun, 9 May 2021 11:37:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 25F8C613F0 for ; Sun, 9 May 2021 11:37:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229669AbhEILin (ORCPT ); Sun, 9 May 2021 07:38:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:54298 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229657AbhEILim (ORCPT ); Sun, 9 May 2021 07:38:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 07BC2613EE; Sun, 9 May 2021 11:37:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560260; bh=M0IMqKdFCid+M1KBfS16bbhW1sSjpLh6tdQvUW00caM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cA1bRg/nqdYFbnD2403Pph5/oMhirkCaeMfaztfI1NVTZF/DkrTQ3pP319rbZt+fA yNliBJShOu/R0iY6nRKmcNF3LuZ1ESO02cjzQ3ZES4Exoh/spAIVNMvAcNkf6Xy2zg ZNfCGNsKj2zEnFz4Z/JJ3VoT27/sEKtRRLMy/PdZdP2JnAhclLdXgj0jUc0IHk7GlZ 7y6+5ODGOHclqCERzDfawp9kp1Fxh1LK5lKJX3ZH7tl6wYjlZaDyS7rkFvnXhLwYi0 h4cuodMtjcdSHCRN/85uU6RSFGHJx7Hf/0aIILp+ajYxNospjxjg+9pk3puuiM7QG/ 5ufV0k6f3IDeQ== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron , Parthiban Nallathambi Subject: [PATCH 22/28] iio: light: vcnl4035: Use pm_runtime_resume_and_get() to replace open coding. Date: Sun, 9 May 2021 12:33:48 +0100 Message-Id: <20210509113354.660190-23-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron 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 Cc: Parthiban Nallathambi Reviewed-by: Mauro Carvalho Chehab --- drivers/iio/light/vcnl4035.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/iio/light/vcnl4035.c b/drivers/iio/light/vcnl4035.c index 691a54b763e1..fd2f181b16db 100644 --- a/drivers/iio/light/vcnl4035.c +++ b/drivers/iio/light/vcnl4035.c @@ -144,9 +144,7 @@ static int vcnl4035_set_pm_runtime_state(struct vcnl4035_data *data, bool on) struct device *dev = &data->client->dev; 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); From patchwork Sun May 9 11:33:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246389 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,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 ED6E7C433ED for ; Sun, 9 May 2021 11:37:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D2BD6613EE for ; Sun, 9 May 2021 11:37:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229679AbhEILip (ORCPT ); Sun, 9 May 2021 07:38:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:54390 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229657AbhEILip (ORCPT ); Sun, 9 May 2021 07:38:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8F8EF613E5; Sun, 9 May 2021 11:37:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560262; bh=WR/hHX1upp02qFBvL+bQp1Y9uVClwFLSn4QFgAnXTvU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=msG9AqdZKP9uIbbYIVVFrArinH2x4pETlxR9GezSuBMAAs5WYCdH9ME4Yu9ViGW9g Y0BATI/7wcJoqt8/TvyBh9wxpnhv4Ac/MaHdoj3MlOnuifYhvLOBXlLHo0g8h8InvZ fqflQ3+ZOyaOu1uZzaMkTdd/YU9JKWlffR7BDENR14vc10T7rTcKI8rmGJGfhSsc8r mDWewS0pZRvSlEG0+wunLnEswIGqkOK5T7Xk3fwEAYaD0qP5a6ZDBOlJjly8H77vmA UVOW/84/45uT+Rpw/blPmtgU8YRlldcPGSTP+uN5gdXD5yejaHKO5HEYOnSChP1m4W iTtoVYdnZsFdA== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron Subject: [PATCH 23/28] iio: pressure: zpa2326: fix potential extra call of runtime suspend. Date: Sun, 9 May 2021 12:33:49 +0100 Message-Id: <20210509113354.660190-24-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron This case illustrates why the new pm_runtime_sync_and_get() is good in that it makes clear the correct way to handle errors. Calling pm_runtime_put() on failure of the _get() in pm_runtime_get_sync() will potentially result in powering down an already powered down device (as we never successfully powered it up. Unlikely to cause any problems in reality. Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/zpa2326.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/iio/pressure/zpa2326.c b/drivers/iio/pressure/zpa2326.c index 89295c90f801..97ac3ba399f7 100644 --- a/drivers/iio/pressure/zpa2326.c +++ b/drivers/iio/pressure/zpa2326.c @@ -664,11 +664,9 @@ static int zpa2326_resume(const struct iio_dev *indio_dev) { int err; - err = pm_runtime_get_sync(indio_dev->dev.parent); - if (err < 0) { - pm_runtime_put(indio_dev->dev.parent); + err = pm_runtime_resume_and_get(indio_dev->dev.parent); + if (err < 0) return err; - } if (err > 0) { /* From patchwork Sun May 9 11:33:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246391 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 3B23AC433B4 for ; Sun, 9 May 2021 11:37:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1D057613EE for ; Sun, 9 May 2021 11:37:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229657AbhEILir (ORCPT ); Sun, 9 May 2021 07:38:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:54444 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229680AbhEILir (ORCPT ); Sun, 9 May 2021 07:38:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E65B1613D6; Sun, 9 May 2021 11:37:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560264; bh=G86oKthfBTbE6RFM+J9h/HyBpkVw/lQIkO42NvpTY2I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UMwb8KTwV9KJ6keiqQjvANmKpD37j3ufn8cvkp8gNo2jhmlyF1EFrU6kRh/3utnl6 lR78MW41TF6nZ7j743OnXBBIjDEbmgjEI+KC2I+kH5hwR9SBPtiu2ODVA+DOqs+Gs9 nimpXiqL6e+vC24XT3OrYLBENEkYBGREga4LLFMfdFHEBTXShFM5D8pJEyDGNSWUQL UfgAMA8FHVNpMx93P/IBXDQNm1vNsU1n6/5S4b3OjbkYkQMy0NR0/nPd/xNy40sSP1 WeAFIJ0OWQo3l3XS3jVWk9jNVee5fj0UTCj+METu1hnfPZscEfqJ232W1r3SMjeRlK 7mELja68MH7Vw== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron Subject: [PATCH 24/28] iio: temp: mlx90614: Handle failure in pm_runtime_resume_and_get() Date: Sun, 9 May 2021 12:33:50 +0100 Message-Id: <20210509113354.660190-25-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Converts from using pm_runtime_get_sync() with no error handling over to pm_runtime_resume_and_get() which will ensure we don't end up holding a reference. Ensure this error return is then handled at calls to mlx90614_power_get(). These are all direct returns. Signed-off-by: Jonathan Cameron Reviewed-by: Mauro Carvalho Chehab --- drivers/iio/temperature/mlx90614.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/iio/temperature/mlx90614.c b/drivers/iio/temperature/mlx90614.c index ef0fec94d269..afcb10ea7c44 100644 --- a/drivers/iio/temperature/mlx90614.c +++ b/drivers/iio/temperature/mlx90614.c @@ -176,11 +176,14 @@ static inline s32 mlx90614_iir_search(const struct i2c_client *client, static int mlx90614_power_get(struct mlx90614_data *data, bool startup) { unsigned long now; + int ret; if (!data->wakeup_gpio) return 0; - pm_runtime_get_sync(&data->client->dev); + ret = pm_runtime_resume_and_get(&data->client->dev); + if (ret < 0) + return ret; if (startup) { now = jiffies; @@ -267,7 +270,10 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev, *val = MLX90614_CONST_SCALE; return IIO_VAL_INT; case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */ - mlx90614_power_get(data, false); + ret = mlx90614_power_get(data, false); + if (ret < 0) + return ret; + mutex_lock(&data->lock); ret = i2c_smbus_read_word_data(data->client, MLX90614_EMISSIVITY); @@ -287,7 +293,10 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev, return IIO_VAL_INT_PLUS_NANO; case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: /* IIR setting with FIR = 1024 */ - mlx90614_power_get(data, false); + ret = mlx90614_power_get(data, false); + if (ret < 0) + return ret; + mutex_lock(&data->lock); ret = i2c_smbus_read_word_data(data->client, MLX90614_CONFIG); mutex_unlock(&data->lock); @@ -319,7 +328,10 @@ static int mlx90614_write_raw(struct iio_dev *indio_dev, val = val * MLX90614_CONST_RAW_EMISSIVITY_MAX + val2 / MLX90614_CONST_EMISSIVITY_RESOLUTION; - mlx90614_power_get(data, false); + ret = mlx90614_power_get(data, false); + if (ret < 0) + return ret; + mutex_lock(&data->lock); ret = mlx90614_write_word(data->client, MLX90614_EMISSIVITY, val); @@ -331,7 +343,10 @@ static int mlx90614_write_raw(struct iio_dev *indio_dev, if (val < 0 || val2 < 0) return -EINVAL; - mlx90614_power_get(data, false); + ret = mlx90614_power_get(data, false); + if (ret < 0) + return ret; + mutex_lock(&data->lock); ret = mlx90614_iir_search(data->client, val * 100 + val2 / 10000); From patchwork Sun May 9 11:33:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246393 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 105DAC433ED for ; Sun, 9 May 2021 11:37:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E90E3613F0 for ; Sun, 9 May 2021 11:37:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229706AbhEILit (ORCPT ); Sun, 9 May 2021 07:38:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:54508 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229680AbhEILit (ORCPT ); Sun, 9 May 2021 07:38:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F28D8613E5; Sun, 9 May 2021 11:37:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560266; bh=imY20ovebcqBf7cNzjDi3fO25ReTmkGg9LKTWNxnulM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=koWoyR+35wcTMLQOlvfRWq/R2J6Qul+U79KnRaL8a3ldrM8WxkjNeh4x/1mDrV7EL 3FDjD92sb3G21uQi6rtaU8sH/0u0CuDUM6kzXRIZpxyhv5yIWcZ01ws7QSfx7VGoW6 6ROmbz++6sbb0YZFgICIFDy6rtWPOLI5GxUzzJtA1jQ9kMHFaLxkodt+4xwVi1vgBz 6OcJpAY5wwVq6tqzNn4gglyzqd8mPk57ptJKVFptjIHoReeldK/3DKC1Y9WOrecd2N NcOCl35yjgOVks9pbxmjjMiyHocaYUwjj3vKbmy4Ec/ewccnY9dE//qaIo3VYDcId5 Jeuk+NVCYWrDw== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron , Andreas Klinger Subject: [PATCH 25/28] iio: proximity: srf04: Use pm_runtime_resume_and_get() and handle error Date: Sun, 9 May 2021 12:33:51 +0100 Message-Id: <20210509113354.660190-26-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Previously this driver used pm_runtime_sync_get() and did not handle any errors that occurred. Moving to the new pm_runtime_resume_and_get() + handle errors. Signed-off-by: Jonathan Cameron Cc: Andreas Klinger Reviewed-by: Mauro Carvalho Chehab --- drivers/iio/proximity/srf04.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/iio/proximity/srf04.c b/drivers/iio/proximity/srf04.c index 420c37c72de4..fe88b2bb60bc 100644 --- a/drivers/iio/proximity/srf04.c +++ b/drivers/iio/proximity/srf04.c @@ -100,9 +100,11 @@ static int srf04_read(struct srf04_data *data) u64 dt_ns; u32 time_ns, distance_mm; - if (data->gpiod_power) - pm_runtime_get_sync(data->dev); - + if (data->gpiod_power) { + ret = pm_runtime_resume_and_get(data->dev); + if (ret < 0) + return ret; + } /* * just one read-echo-cycle can take place at a time * ==> lock against concurrent reading calls From patchwork Sun May 9 11:33:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246395 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 E18C0C433ED for ; Sun, 9 May 2021 11:37:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C89E2613F0 for ; Sun, 9 May 2021 11:37:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229680AbhEILiv (ORCPT ); Sun, 9 May 2021 07:38:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:54540 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229709AbhEILiv (ORCPT ); Sun, 9 May 2021 07:38:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2340C613D6; Sun, 9 May 2021 11:37:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560268; bh=LipBXefBz7bSe1o0CYNXZthCsijVbOZLw8xiVRTmZEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K+NoutvWeewfSJym9uPtxJ9tz0gjzCkElXl+J8mGnciRg1uK6j55ornhQPunYvxxt H2bjHVIquEI/bVUBY/1TlrQMzGKPqIL0byDS7zCDEKqxKisMLlv43ff0onqgTGyEpG zDPX/dimBEToWf2N8lhijnu/FgteBDnyiXWE5nnWWIHtjAcasczEuGnyu96t+1maY/ cl7MGa7dkrl5n+T6KPO0EdXoQeqB2WQB9jt2z4QNp/A6kjyDWYYsWLKMKQvNQ7Elh2 RR/MhBMhRTFE/JzBtd2xlFF4RPg/z7ghCpukIBSsHyI1GaJkVC50fGlLLO7uLI0+T7 QtBHzqkCxb4qg== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron Subject: [PATCH 26/28] iio: prox: pulsed-light-v2: Switch pm_runtime_resume_and_get() Date: Sun, 9 May 2021 12:33:52 +0100 Message-Id: <20210509113354.660190-27-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 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 --- 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 c685f10b5ae4..ca8dc5cc209a 100644 --- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c +++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c @@ -154,7 +154,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 9 11:33:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246397 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,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 3A66FC433ED for ; Sun, 9 May 2021 11:37:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 189E5613F0 for ; Sun, 9 May 2021 11:37:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229709AbhEILiy (ORCPT ); Sun, 9 May 2021 07:38:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:54600 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229707AbhEILiy (ORCPT ); Sun, 9 May 2021 07:38:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5FEA9613E5; Sun, 9 May 2021 11:37:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620560271; bh=7v361hqgBE1lMuKYO6LrJ64ROS0EptwwvqD6k3sa+SQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QFmz36ZtVKpWge7aPwcyXX2zxS4l2kOYeoFSx4/rYyXrdR3cC1V8bfDJv84cxtqmo ipqaRfxX0vnSeLDU0xdl4+DC0Ubc1Kf3jsKL2kYuk/MIq8zMIfK22k0BfxMLyGj9UP 286QHMLh9F/NZrRdmo6aH6WEcFHWoiRuP2+DnODLCRi32145inCvvuEaVsgPMb8mCh dn3myC33jO8VnAWOF6vOqwGSUYzG0A3JxdUhEPPA2C3udsDNsVQAd7VQIj6BLrpQcu wxBYbykobJrv+HlZk6ah6z7aebvWYGthN4LEmt/oDCMviSqdKQTw4ff6p8nGT2p9JO +68vVM4QspNEw== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Mauro Carvalho Chehab , Julia Lawall , "Rafael J . Wysocki" , Jonathan Cameron , Jean-Baptiste Maneyrol Subject: [PATCH 27/28] iio: pressure: icp10100: Use pm_runtime_resume_and_get() + handle errors Date: Sun, 9 May 2021 12:33:53 +0100 Message-Id: <20210509113354.660190-28-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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron Using this 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 --- drivers/iio/pressure/icp10100.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/iio/pressure/icp10100.c b/drivers/iio/pressure/icp10100.c index 48759fc4bf18..80cd66688731 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]; From patchwork Sun May 9 11:33:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 12246399 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 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 Reviewed-by: Mauro Carvalho Chehab --- 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);