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) { /*