From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_2 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 3A5E2C49361 for ; Wed, 16 Jun 2021 12:45:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 21DBB6135C for ; Wed, 16 Jun 2021 12:45:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230269AbhFPMry (ORCPT ); Wed, 16 Jun 2021 08:47:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:53466 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232854AbhFPMrv (ORCPT ); Wed, 16 Jun 2021 08:47:51 -0400 Received: from jic23-huawei (cpc108967-cmbg20-2-0-cust86.5-4.cable.virginm.net [81.101.6.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B603260FDB; Wed, 16 Jun 2021 12:45:43 +0000 (UTC) Date: Wed, 16 Jun 2021 13:47:46 +0100 From: Jonathan Cameron To: Mauro Carvalho Chehab Cc: linux-iio@vger.kernel.org, Jonathan Cameron , Matt Ranostay Subject: Re: [PATCH v2 3/6] iio: chemical: atlas-sensor: Balance runtime pm + pm_runtime_resume_and_get() Message-ID: <20210616134746.7e747dea@jic23-huawei> In-Reply-To: <20210616091620.5f689adb@coco.lan> References: <20210516162103.1332291-1-jic23@kernel.org> <20210516162103.1332291-4-jic23@kernel.org> <20210616091620.5f689adb@coco.lan> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org On Wed, 16 Jun 2021 09:16:20 +0200 Mauro Carvalho Chehab wrote: > Em Sun, 16 May 2021 17:21:00 +0100 > Jonathan Cameron escreveu: > > > From: Jonathan Cameron > > > > The pm_runtime_put_noidle() call in remove isn't balanced with any get, so > > drop it. Note this isn't a bug as the runtime pm core will not allow the > > reference count to go negative, making this a noop. However, it is > > confusing to the reader so let's drop it. > > > > pm_runtime_resume_and_get() replacement found using the coccicheck script > > under review at: > > https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@inria.fr/ > > > > As pm_runtime_resume_and_get() returns <= 0 take advantage of that to > > change the error checking to if (ret) which is more in keeping with the > > rest of this driver. > > > > This is a prequel to taking a closer look at the runtime pm in IIO drivers > > in general. > > > > Signed-off-by: Jonathan Cameron > > Cc: Matt Ranostay > > LGTM. > > Reviewed-by: Mauro Carvalho Chehab Applied > > > --- > > drivers/iio/chemical/atlas-sensor.c | 13 ++++--------- > > 1 file changed, 4 insertions(+), 9 deletions(-) > > > > diff --git a/drivers/iio/chemical/atlas-sensor.c b/drivers/iio/chemical/atlas-sensor.c > > index 0fdb3b29c5eb..9cb99585b6ff 100644 > > --- a/drivers/iio/chemical/atlas-sensor.c > > +++ b/drivers/iio/chemical/atlas-sensor.c > > @@ -410,11 +410,9 @@ static int atlas_buffer_postenable(struct iio_dev *indio_dev) > > struct atlas_data *data = iio_priv(indio_dev); > > int ret; > > > > - ret = pm_runtime_get_sync(&data->client->dev); > > - if (ret < 0) { > > - pm_runtime_put_noidle(&data->client->dev); > > + ret = pm_runtime_resume_and_get(&data->client->dev); > > + if (ret) > > return ret; > > - } > > > > return atlas_set_interrupt(data, true); > > } > > @@ -487,11 +485,9 @@ static int atlas_read_measurement(struct atlas_data *data, int reg, __be32 *val) > > int suspended = pm_runtime_suspended(dev); > > int ret; > > > > - ret = pm_runtime_get_sync(dev); > > - if (ret < 0) { > > - pm_runtime_put_noidle(dev); > > + ret = pm_runtime_resume_and_get(dev); > > + if (ret) > > return ret; > > - } > > > > if (suspended) > > msleep(data->chip->delay); > > @@ -741,7 +737,6 @@ static int atlas_remove(struct i2c_client *client) > > > > pm_runtime_disable(&client->dev); > > pm_runtime_set_suspended(&client->dev); > > - pm_runtime_put_noidle(&client->dev); > > > > return atlas_set_powermode(data, 0); > > } > > > > Thanks, > Mauro