From nobody Fri Oct 3 13:34:15 2025 Received: from mail-106111.protonmail.ch (mail-106111.protonmail.ch [79.135.106.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE7512ED84C; Mon, 1 Sep 2025 07:49:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.135.106.111 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756712980; cv=none; b=n2c2HTrrv0kWgZyxzeAooc0oRhaORgspXHanFK87IFaisnGWba5OpybLC5AG78B9xwVQpFEK5pBKs9Mq6hRv0F3cYJhy47z3SyV58dexiqG/VRiILK67hxTTN/XCglyDpwvr84W5kbFqwQBMybYgdWDWQRaJCc1qdnMCiH0Kiwg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756712980; c=relaxed/simple; bh=6oRmmzziaTgPC0bksMOkEHu7AoqHaS3P3gyUbOWU46A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AT6MeBxtUZ7Iek8oRLltLK9ur5ik/ebIdqHjmkE4R+7hCkmcVZcx5/jDYdSI6FocUmSsj68jDObRZNLb1JDGWsYX+Td9tXuopgCmzAhp4bfkJYYsH/f81w/aDu3DLgo9d+bk5n4ftnaa76bZaOsLQcUT3V+9WbvYYjfVog9obPI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=geanix.com; spf=pass smtp.mailfrom=geanix.com; dkim=pass (2048-bit key) header.d=geanix.com header.i=@geanix.com header.b=wJwT4E/h; arc=none smtp.client-ip=79.135.106.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=geanix.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=geanix.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=geanix.com header.i=@geanix.com header.b="wJwT4E/h" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=geanix.com; s=protonmail2; t=1756712970; x=1756972170; bh=vFveFwTnn7yrm9XsyVQ58MSODxhrcS6ozaHd9fgq5VU=; h=From:Date:Subject:Message-Id:References:In-Reply-To:To:Cc:From:To: Cc:Date:Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=wJwT4E/hWSXoWpD4U2xYwzaLLQhxo2Ao19MyqNDyDpajgy9AKtXwCyizEuNdl5flU uaIuyCWNOai7jeqwYWhWt9BYpNvs2LAND5GkH2jIyoHMRi+kpzxTihFVYX93Dj2TvN jddcnJVf7gm8tYJYJXvUL3LPbQwyhhxtZuMTvWD0LEoS9MfDnv4LlKyivTWy2fAMP1 NmPpgOUzct/lpF+gbD8UogmDpC6xrnvkdKbPQ5/VnCE473SnSwCUD5v8K67x5wvP+e WcRj/fNIuK0cb1uRgwOpNF2rg72AHc6XFmvS9FlThz79fumfHbL5ZYP73LgqZ1FRkK Ze7f+pnnIDlRg== X-Pm-Submission-Id: 4cFgxj00Ghz1DDC3 From: Sean Nyekjaer Date: Mon, 01 Sep 2025 09:49:13 +0200 Subject: [PATCH v3 1/5] iio: imu: inv_icm42600: Simplify pm_runtime setup Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250901-icm42pmreg-v3-1-ef1336246960@geanix.com> References: <20250901-icm42pmreg-v3-0-ef1336246960@geanix.com> In-Reply-To: <20250901-icm42pmreg-v3-0-ef1336246960@geanix.com> To: Jean-Baptiste Maneyrol , rafael@kernel.org, Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Jean-Baptiste Maneyrol , Jonathan Cameron , Sean Nyekjaer X-Mailer: b4 0.14.2 Rework the power management in inv_icm42600_core_probe() to use devm_pm_runtime_set_active_enabled(), which simplifies the runtime PM setup by handling activation and enabling in one step. Remove the separate inv_icm42600_disable_pm callback, as it's no longer needed with the devm-managed approach. Using devm_pm_runtime_enable() also fixes the missing disable of autosuspend. Update inv_icm42600_disable_vddio_reg() to only disable the regulator if the device is not suspended i.e. powered-down, preventing unbalanced disables. Also remove redundant error msg on regulator_disable(), the regulator framework already emits an error message when regulator_disable() fails. This simplifies the PM setup and avoids manipulating the usage counter unnecessarily. Fixes: 31c24c1e93c3 ("iio: imu: inv_icm42600: add core of new inv_icm42600 = driver") Signed-off-by: Sean Nyekjaer --- drivers/iio/imu/inv_icm42600/inv_icm42600_core.c | 24 +++++++-------------= ---- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c b/drivers/iio= /imu/inv_icm42600/inv_icm42600_core.c index a4d42e7e21807f7954def431e9cf03dffaa5bd5e..76d8e4f14d87a552a35d7a9e0cb= 3305781d85ca9 100644 --- a/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c +++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c @@ -711,20 +711,12 @@ static void inv_icm42600_disable_vdd_reg(void *_data) static void inv_icm42600_disable_vddio_reg(void *_data) { struct inv_icm42600_state *st =3D _data; - const struct device *dev =3D regmap_get_device(st->map); - int ret; - - ret =3D regulator_disable(st->vddio_supply); - if (ret) - dev_err(dev, "failed to disable vddio error %d\n", ret); -} + struct device *dev =3D regmap_get_device(st->map); =20 -static void inv_icm42600_disable_pm(void *_data) -{ - struct device *dev =3D _data; + if (pm_runtime_status_suspended(dev)) + return; =20 - pm_runtime_put_sync(dev); - pm_runtime_disable(dev); + regulator_disable(st->vddio_supply); } =20 int inv_icm42600_core_probe(struct regmap *regmap, int chip, @@ -824,16 +816,14 @@ int inv_icm42600_core_probe(struct regmap *regmap, in= t chip, return ret; =20 /* setup runtime power management */ - ret =3D pm_runtime_set_active(dev); + ret =3D devm_pm_runtime_set_active_enabled(dev); if (ret) return ret; - pm_runtime_get_noresume(dev); - pm_runtime_enable(dev); + pm_runtime_set_autosuspend_delay(dev, INV_ICM42600_SUSPEND_DELAY_MS); pm_runtime_use_autosuspend(dev); - pm_runtime_put(dev); =20 - return devm_add_action_or_reset(dev, inv_icm42600_disable_pm, dev); + return ret; } EXPORT_SYMBOL_NS_GPL(inv_icm42600_core_probe, "IIO_ICM42600"); =20 --=20 2.50.1