From patchwork Mon Jul 19 14:52: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: 479970 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4250586jao; Mon, 19 Jul 2021 08:48:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhNvVGNG84vQzUuYRZopcgjT0TxNaDDNcqEB6Z/edeY5GEvyEdwuGbVR6L2RSEyBZ3NgR6 X-Received: by 2002:aa7:d990:: with SMTP id u16mr34939471eds.263.1626709719046; Mon, 19 Jul 2021 08:48:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626709719; cv=none; d=google.com; s=arc-20160816; b=hdp0Q6a1piAK3Eug9xF7nSbvasQvQz+mt3s2JZC0XtsiD1P39ryMUY3P0P6+0xfpeY S4N94dSPC9e3udi0KsvVWW2cE338tU2GKg8f7250nyKE64+yURB1OHoitwdPhGdk2CjN aDFkfsqWLd+Y2gfKmnrN3ksTCDJe+GJrNUUZS0o/bUD5gFYCKtZSIC4nv1WcaSJFS9Me Zy6dQ6Lu4k66nqpEfirAEIpI1SeWRFgXldgaBHzQsAJdUDmflhoQtWRHz175cdZxLkaa vXPVHwrk5ETWLE7fAmxOLgNWbvX3HWJMT9pWSkffjFsSfTyLN+9wHy7YvKnCOB0bdMZN nDDg== 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=Zx7RyLpbeUUCfrhuMSml7W5Yfh+kk7H/GYTWZomke4k=; b=TiMzO2QQLwDB6kBmAoyj2gpno0ozDPYdwtpwWGJi6Eh+/RhLofme/4UtG3ATGvE9FN Ivss1VLm7OxmIRNRMRO55rVJr8iAoZNDqL0aj6YdY/DtnBNnZOe19EsXJvlZrWoTl5da Va1iJTJ8Rq5Hv7Dwd6Fm75YR9/Dj3Si7yIRcHklJOt+gQsWgpcqV6QRoUIBF+vhovGGP D66S/6ozDv7fOLmUmbGg2ZgT51L52/p5JheCbDJOVClu94Y3c9RIEsTQrcHSpmMyleKi s173KXqj0zYxMuJyZg/qodI/kiXTL+pvdfw4v2ztxmjG0KClYM843qOfGmyGtvX4mKvk NwLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LLR3kmeg; 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 x22si21782145edd.466.2021.07.19.08.48.38; Mon, 19 Jul 2021 08:48:39 -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=LLR3kmeg; 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 S1345094AbhGSPHy (ORCPT + 12 others); Mon, 19 Jul 2021 11:07:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:38540 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244648AbhGSPFe (ORCPT ); Mon, 19 Jul 2021 11:05:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 92E2260238; Mon, 19 Jul 2021 15:46:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626709573; bh=9um7bU0QSz8fHCjawR9fxW6X0ZJGhUEH7wCqU6luNOg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LLR3kmegB+JjKZtPdonERDXe/wh6YzPFITF9a5MV7pyoJSro5l8/zu35vm9PcnkI5 YRw4QM542t7t7HnJ4PfOqvyfDto/KsTVAMGPbMKcLcThb/fd7aI9nfi2hq55PmjMri l4jozDWlrFvkFnQDn+2rnvdgyzHv9xjZBi8JO/HE= 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.4 015/149] iio: magn: bmc150: Balance runtime pm + use pm_runtime_resume_and_get() Date: Mon, 19 Jul 2021 16:52:03 +0200 Message-Id: <20210719144905.056627130@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144901.370365147@linuxfoundation.org> References: <20210719144901.370365147@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 48685d785c1b..087dc16c2185 100644 --- a/drivers/iio/magnetometer/bmc150_magn.c +++ b/drivers/iio/magnetometer/bmc150_magn.c @@ -263,7 +263,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); @@ -272,9 +272,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 @@ -947,12 +944,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: @@ -976,7 +975,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);