From nobody Fri Oct 3 01:10:48 2025 Received: from mail-244108.protonmail.ch (mail-244108.protonmail.ch [109.224.244.108]) (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 CB18C306B3D for ; Tue, 9 Sep 2025 07:11:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=109.224.244.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757401897; cv=none; b=D1vIalA3xQhGpljgFWNQgA0fr3g3jbnLK9dTega8ph0s5ZLIVSA09+TETrglNi0J0TsPPwmbxQl0THGGYRmk5y8V0Vasc+96UfmRMHfi1LeMAq/u8sIauWdPNP813z5v6FZ4tkbQwbab+z+fF/2tg+Pq8VsPntgXXRNU1Nbhu68= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757401897; c=relaxed/simple; bh=6oRmmzziaTgPC0bksMOkEHu7AoqHaS3P3gyUbOWU46A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MwTlq+Dbjmkrnb7qDVulZXZzvz3XDGZkTUk631IgMi7a8bXRmyTtq64iMHN5+mnAOnDWnLOtMqeyNyWfr5E8yn76UxwQwmZiQhq50svYn2vZSYZZiiGp8mJKx8GMO7giGVUYb+CeajB8XA4yb2MSeuNOsw9HZNJlt40IECeP1dg= 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=CJkMNrQP; arc=none smtp.client-ip=109.224.244.108 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="CJkMNrQP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=geanix.com; s=protonmail2; t=1757401887; x=1757661087; 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=CJkMNrQPRmqsxEv9QMxZ0du5R3y5BmhwKt1wcQsygRgrs6WlKeBSjdvwzglonSQG4 +JnNs84IC8JcLmQq/w4/Z0oU2J7UM5GIFAuFsfm8jjYvxjNn//kbnul45Acl0AIU9E 43Qkp+6KxtaJWxVbUclTPLFz01wd+vh8bfVx7ndF9/Mv73xgM6IP7KKfiGmcF5mWgU Q79MB88qlwAqY9dMc+R+/YzBzdcWb3QdW62QyNiOexiqopj+bgGlAicEAq8rdb0RsA 7s5GTdVdsfYaUovlhk2yVKJqhz8eS5p3iRg9AeWYyPbZNzQV51EHHQMXai3Kzofukx 3HCVgTBzz1fkg== X-Pm-Submission-Id: 4cLZk556T1z1DDs2 From: Sean Nyekjaer Date: Tue, 09 Sep 2025 09:11:07 +0200 Subject: [PATCH v4 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: <20250909-icm42pmreg-v4-1-2bf763662c5c@geanix.com> References: <20250909-icm42pmreg-v4-0-2bf763662c5c@geanix.com> In-Reply-To: <20250909-icm42pmreg-v4-0-2bf763662c5c@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