From patchwork Mon Jul 19 14:51:51 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: 480024 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4284282jao; Mon, 19 Jul 2021 09:27:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKSre0ioS3RPm/pubYBumW0REwMQsFgCqrNhJVMji9Kv3ZawvJk/QJLHNTEfwsYPpbacg4 X-Received: by 2002:a17:906:63ca:: with SMTP id u10mr18212564ejk.411.1626712030155; Mon, 19 Jul 2021 09:27:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626712030; cv=none; d=google.com; s=arc-20160816; b=qD3LhgZKICREqy8riLmZAoV3MFHJkLaTvLPKimq5+mo00fNJZ+wcpYrA+dHHVtwNYS oGxLRFXqkU+qvo9sbFlZDUxM1vpdyTecD2FwXBv6tbnCzcMokrK03mqJZ7XSTvF9YdHk cnqeoGqRU7Dyanz3P8oujf2gCUcnMI1NALAJNCWyAGjf+J6XrXuU8C/A3p3RlFmv3gDl k4FEXeBNnhabyLWYzhK1+MjeEA2X3uylc5AUK5oWazQJ6s0MGZJOXfKGY6qOm0oHp+WR UHCI1Lw0Ak0dB1BEWIZ28xD/8pZd715JvejD7xvjfreOLnkq6t6TWDFXiQDzLixEcBXS 2tvw== 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=jjq9ZGWt0JL5ojr3KL2rRPtm0dfdw8CJIIGpXcHR/6s=; b=AdTVWcLPlQb3LQkiLVWvck6+z5QDdDmmHjpV+fnot4lR1L25NfuypFpFsnCyyJpii5 qG4iYsVdyRcOEkIMQ9OqOSu3NV4tZ6sMSAVFBBtsRkbiV4ZcEwh0mXLycxyXvnVIyq38 ePPIjKbqKDOlkEB17+g5CLB7exYKNfgH29HYgvh2RYifultGMRQ+r2Xiky8JQfIxsUyl P5+VVD9cVvcwe2v0a++/FdcnF5G0VuOsMKx3LC7L4ss3/20gJSkWnS/LKWC1LMm1gjVw R6QDLjpnCsMb1wYbJa5giCICMUHvfIYpml2EQvU8RFt4MgkB7PNMvneEkLDjN7OUmTXy hfyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ma1ynCN7; 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.27.09; Mon, 19 Jul 2021 09:27:10 -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=Ma1ynCN7; 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 S1348532AbhGSPoK (ORCPT + 12 others); Mon, 19 Jul 2021 11:44:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:37058 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235235AbhGSPkm (ORCPT ); Mon, 19 Jul 2021 11:40:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 066C961380; Mon, 19 Jul 2021 16:20:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626711655; bh=ROI89Oip2jR67RT8yJVn6b9Pa50pCCGVtr7XrH1qn1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ma1ynCN7Xv+dUwH/zcGWkCwg2zAfHYHe5E0vQCzwkT+khB2lVZo6KyiyuItoQNjEP xlsoNBBRbna5JxZeMEpJyjDAqyALZ+GUKeEuU36fuXGpSogZZ9W9OoRB+dAl8G7Cd5 BnhGak79+dJXAUEBqFP9pqJxJKNl74czhVk5UztA= 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.12 049/292] iio: magn: bmc150: Balance runtime pm + use pm_runtime_resume_and_get() Date: Mon, 19 Jul 2021 16:51:51 +0200 Message-Id: <20210719144944.121515533@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144942.514164272@linuxfoundation.org> References: <20210719144942.514164272@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 20a0842f0e3a..26c6400cb08c 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 @@ -967,12 +964,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: @@ -996,7 +995,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);