From patchwork Mon Jul 19 14:50:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 480002 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4271356jao; Mon, 19 Jul 2021 09:11:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZRMj9k4ImMfgNahQPFT299fT3fU/CRDbLMLwmfeOkn0Ueasaq9lty5y5lQsO956qfKEsE X-Received: by 2002:a05:6402:752:: with SMTP id p18mr35676471edy.281.1626711119713; Mon, 19 Jul 2021 09:11:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626711119; cv=none; d=google.com; s=arc-20160816; b=EZO8aG1N3sA7hadFgjtMokRZZ/QRnW03bXOKiAVIMEx80lwT7Rp7hMc1JU3YRK8BtT T2jzvy3m9g/7iAEajyYKPvXQQSInPk6KCg2Rf+vnSJwqq5S+CDLvmPXJmFR8QLlrew81 pd8V2LwcKqzhVxw25TOLbxK0YxznE4scNzdHttwIPBz009iFYa1OybWEltNyTLcvUKb7 mHg/L3KkiKjho4XjGMDwnWAbNoIOWuyS9cgMGgN4KnXvNhX5vA9C/CwlMF6ZUQJnJcJS Qmp7Khsw1yWNMvhyELC5tmVzwMu9qgLr0J7cpxBCtE4RtAMQFLulEZPpicppTxDdDOI5 7RYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5gUsHTi6axajI7pBrfhURq0jtZXwJHxh6aRiwwJ+l5g=; b=BnT8y4FR4Q8xS9MH5RQgbEO8Q1HmpwNIo1X3PkR5W6G5D+rMJNQU8MIgrDvszwRoYY 220cFoWu5JroBPRIsGroI4TmEqzZtKHHkfPZ82lt1vIiMHKmpNlXabzgJVCrAsU1isTO LfeCl5A5RuSN9lvUpJZG909BXi7YXxHx62Wl3tb6wEKJSOGTyMw6NLTrExPTNF1gaZK4 n180jUL89ycsPNrM0yKcPpkC28fIVPzqJ3SeKzdhzO6kfBlER/zsha1/0RdIQ+dKS5N7 NmOHJ3vWTmJSUCrIkAnwFhFVWTP0PCyQL5Jy5rv3fJwaJxuTxrFGvBvuOiZBRpKM37LD /9nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bWLOWkLN; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id la14si22045543ejc.142.2021.07.19.09.11.59; Mon, 19 Jul 2021 09:11:59 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bWLOWkLN; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237580AbhGSP3D (ORCPT + 12 others); Mon, 19 Jul 2021 11:29:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:41026 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348376AbhGSPYp (ORCPT ); Mon, 19 Jul 2021 11:24:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 64CE1610FB; Mon, 19 Jul 2021 16:04:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626710696; bh=5FjZSUZGZWfbmcrxb9cYHAm8FGJ6RzwlOdGyCzz77ZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bWLOWkLNj4Nav9ZzJD7g0MeycYoUxTDHfznwxp6HIRVqMnSmzIdsgFU8nKM2oon2s 6sQjfH/KSFwp/zRIbwT89kIXSkyGiEEdBA6gQ7QfjZNEYSTLMeYTVrJpY+HDiqiGZo Yx8YoMwdSH59QZQomBuJ9JzCSKfWR4Qopc5eP3A8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathan Cameron , Linus Walleij , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.13 057/351] iio: magn: bmc150: Balance runtime pm + use pm_runtime_resume_and_get() Date: Mon, 19 Jul 2021 16:50:03 +0200 Message-Id: <20210719144946.416691600@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144944.537151528@linuxfoundation.org> References: <20210719144944.537151528@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jonathan Cameron [ Upstream commit 264da512431495e542fcaf56ffe75e7df0e7db74 ] 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 Link: https://lore.kernel.org/r/20210509113354.660190-12-jic23@kernel.org Signed-off-by: Sasha Levin --- drivers/iio/magnetometer/bmc150_magn.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) -- 2.30.2 diff --git a/drivers/iio/magnetometer/bmc150_magn.c b/drivers/iio/magnetometer/bmc150_magn.c index d534f4f3909e..6cf3eceaf2d9 100644 --- a/drivers/iio/magnetometer/bmc150_magn.c +++ b/drivers/iio/magnetometer/bmc150_magn.c @@ -265,7 +265,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); @@ -274,9 +274,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 @@ -966,12 +963,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: @@ -995,7 +994,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);