Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1144162pxv; Fri, 9 Jul 2021 19:24:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUl4PiX4/J7jH3KlavhjtGGfxloTTT8mRCTA51iuUdzEXrqRJfkq76+98Uu9jy0X/rLm/H X-Received: by 2002:a50:b2c5:: with SMTP id p63mr49598921edd.5.1625883875138; Fri, 09 Jul 2021 19:24:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625883875; cv=none; d=google.com; s=arc-20160816; b=BbSnyiJ8KpgpfbTra+TTPUrm+kykwXNmfktP3o3irEBwCGESu5n5G7bN8fEohgDITO d/u+IiAApU9WNfXGmXunFu9smXMuXSHltH3zRjqLV036HFSwZWqSIznykOnMuSFjD4pk iND/rP1wPuHMnWAQ9tQBevVNrZdBNysE+WMLJvqL+plNXfyyUuoxpYruNPuFurEzxQHh a67DpqQP1GjFQCK+/V6cb7Q8dbilW1Q9Rg8uJlVD97ffL3OMveL1BPbmz/xi9AtHzxXX OEwNrvP57B2LroXAdrAt6I3E7QxIK0yQHadggTsB6vhtEVCkx2tHTkg1URbiLyrV0jy7 tvBA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Bn3+7aiKApg/moZpCMq8U+ekUD1Kxz9L8UeP+IeXtAM=; b=mG32K/Km/sQvQlvB5fyOL9CBueDsYru8EyC5PL+U8eZp7YK2psWcSuT6ttzykHkmbl 5by/UcgbBT+oys3J/IUUjYfiaIbP1b1sbv2Iu7I7ZabgsIPUHXUZxDL1i+CY33Z1yJkI kU79omVdat2BYG/iP4jeSZ/iv7qCJ5qDwGARMCVOSJwhfo6nSdZ8BY302OiygktMBuCj k9LzVisRJJBLnrG7fw3plFZhgi4L+MfBQ1WdcJtPfnhG+JOPGzglh3IJJ8irMpuTuV97 Repqfe4woW1wXrOSgREqXMkFam379O6JgCS09S01iKekmHld9uUasOQm1myVaKIDXS0/ 5kDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="ZJ4xS/4R"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w18si9111492edd.302.2021.07.09.19.24.12; Fri, 09 Jul 2021 19:24:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@kernel.org header.s=k20201202 header.b="ZJ4xS/4R"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232935AbhGJCZ1 (ORCPT + 99 others); Fri, 9 Jul 2021 22:25:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:41958 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232556AbhGJCZE (ORCPT ); Fri, 9 Jul 2021 22:25:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 30BD8613E6; Sat, 10 Jul 2021 02:22:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625883740; bh=DEuIo/SM2yN2iFsTMZLONLo/aXpE2iz/5x1Fkni1Yms=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZJ4xS/4RH5LZJPuPZ2rBXvOPmg2JOVG8+yRjSC1WOgcrVBtSuo4YsTYcPpg23HGqx s/OhWhI8+9f7aNuYYoOuS2I+0hclCsYTvmITogEThtGWa2IbOOSbbK604AspMnnTgI cjCctPEqHmXWaq9uy/e3RnpeqguHZfY2c176+BP0vxBFlQ2w6hyeazeuj5cHU0I8pT Ow1LGTdmzCI1gFR1UUVJW7m9P3yoRJAlglHZpSmozfjND0DA9mV+UPaqd/yF/6Y2vW M1C0qc5rnxFfFvdb/2fgIH+Vphm3cJzmuY3GpNhBMH+Wv6JaAAJM9psNCiGbtu9n66 RHftNGezisBRA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jonathan Cameron , Linus Walleij , Mauro Carvalho Chehab , Sasha Levin , linux-iio@vger.kernel.org Subject: [PATCH AUTOSEL 5.12 018/104] iio: magn: bmc150: Balance runtime pm + use pm_runtime_resume_and_get() Date: Fri, 9 Jul 2021 22:20:30 -0400 Message-Id: <20210710022156.3168825-18-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710022156.3168825-1-sashal@kernel.org> References: <20210710022156.3168825-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) diff --git a/drivers/iio/magnetometer/bmc150_magn.c b/drivers/iio/magnetometer/bmc150_magn.c index b2f3129e1b4f..03d25c725533 100644 --- a/drivers/iio/magnetometer/bmc150_magn.c +++ b/drivers/iio/magnetometer/bmc150_magn.c @@ -262,7 +262,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); @@ -271,9 +271,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 @@ -964,12 +961,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: @@ -993,7 +992,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); -- 2.30.2