From patchwork Mon Jul 19 14:51:05 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: 479987 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp4258304jao; Mon, 19 Jul 2021 08:58:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwT+USGVIpgKr3mD98FuxSc31s+NLURcVbnH9kjGiTut+vb5j0KmkvL8l8jc31tM8c0nVk/ X-Received: by 2002:a50:8a89:: with SMTP id j9mr34786146edj.226.1626710308089; Mon, 19 Jul 2021 08:58:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626710308; cv=none; d=google.com; s=arc-20160816; b=CgZxF5iz2LRo7M8Sc4tF4k/cSxN/2yjehxFVmUBO5bPWdfFkDMa0zMo8DMCZi1GLIM N1TMYwmhqcV+It3C10HL7nLKmzI+QCFTn8jBtVf/PxwuP0zq4cSauoh9nKbh+JdTjkza YohZ4JxunJdK2+juG2J4qydoJXokdOGW/dGIrncmLGpgj0MHyzHFbbp16HiR2s9x5SXx ai9fwPBERvjd+azVyakOR8/ILnKTBL3X2OkMV9huWZleoe+sM84XJluTDMD+4nQfj/WB EsarzPbroS+JVvcIwEp45WMLQ/d8b9IscZRRQSTt09oD6mDJtUSqoGETFDiMtetEhIy2 3HGg== 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=rZlfkr/YsA634YWcM+1f9ziPMOQhHm9HIzMllqxUL0A=; b=E/AH2uHmUd1LDku1vfExkQwMnnaJDCH7NwsywfYmb8icKSwWoBe7IhHfO8V/SSWGVK xnXmVau/5abtOeeSp4sQV+GtW7c2dLnwU0+gIushVODUPTAJEycjOGKpw/deLIqEEs0C WHao8xqJgMZ3x6O2JWxum2PuIq3CVNu4ca5WITAhcsqjgpRSiiHMLb9qo1igS/rCEy/6 LM4w0740URJGMY6nYy9lkwtoAZ3YOBQrFK52M6OSbEJACB3uUp8eEiKeHKGGsCp4vQpW TIioJ3lYCWIhlve6DmNBYkKH40yroK33QyU3AkreJum1+VcXiAkGm8IRWtH6NMeR7LPv xlZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=b9W1qrZC; 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.08.58.27; Mon, 19 Jul 2021 08:58:28 -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=b9W1qrZC; 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 S244573AbhGSPRk (ORCPT + 12 others); Mon, 19 Jul 2021 11:17:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:48156 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346335AbhGSPOi (ORCPT ); Mon, 19 Jul 2021 11:14:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 71FC261405; Mon, 19 Jul 2021 15:54:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626710046; bh=ojZPvMZ9QED8uhrQc+lGq2D7813RXrFHkCZoCprd4eQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b9W1qrZCnYa2kGuRLJmueNdjT9tn8rTrikPB4ctrDtcdojLA7qdxfyZKzWRp1FUWC eImZwojeF8uSSvUpxj03/b5W6Hrs1p1a8XAhMdla1ZW0GH79J3OGOQSJMLgDN0URi5 TExq7CsRsHZvsFghWAppggpXI64U9/WZEAczHy6A= 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.10 036/243] iio: magn: bmc150: Balance runtime pm + use pm_runtime_resume_and_get() Date: Mon, 19 Jul 2021 16:51:05 +0200 Message-Id: <20210719144942.095179176@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.904087935@linuxfoundation.org> References: <20210719144940.904087935@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 8042175275d0..8eacfaf584cf 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 @@ -944,12 +941,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: @@ -973,7 +972,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);