From nobody Sun Oct 5 07:26:04 2025 Received: from mail-0201.mail-europe.com (mail-0201.mail-europe.com [51.77.79.158]) (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 66BE9285C8D for ; Fri, 8 Aug 2025 15:57:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=51.77.79.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754668681; cv=none; b=Ik81CzHQPJW8QRt2zCpwbZcSlB10d2y8DTQdP6UMgJ5XgBt2bTxTxVmafCeE5KuDkHqOy2KHY+dCgASUMf2qEARHZafyTW0wBW33nhA90GfuDrXq4rQ2rGITAi+P2s+Fp+3jYPMlZvFvO3z+4M39wDi7gQD3BuEHgtEfofkgStE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754668681; c=relaxed/simple; bh=rvt6rM4Vqo/82nMtBHiRIxI6C70kbBNbWpNvi6u01aY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UjHKC4ZKaOsvD9MX1LCnYgTRHOjA77p7zx0zotmitUFMknZdWgIw5ImEmDUbgtAQb8ELyfK95O1ev6gnNuQHBf7ha/aaLVW/siCzj4RLkO1Lnal9Uy/85SwIh3frEQR7CdTlu+H7Q1GpUTHA4LFfpF/1t7k8bzV/pbecpkiRAqo= 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=RKQPyx6f; arc=none smtp.client-ip=51.77.79.158 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="RKQPyx6f" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=geanix.com; s=protonmail; t=1754668668; x=1754927868; bh=NsrBLr1O+psgUK8h5GJ977rYQy+ePA4Gy8v6K3B17og=; 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=RKQPyx6ffw3/KYUp2cAvczvyyjTrnjd8W/CmtxhrIg6H8sQp9waW7bfStLftEtOx2 z1IUgU5zwQl/GnlqmB5q2F7qcKpeQW+XYyQTWpqOUmOn2JhK7DyQornRaXhrLxf4Xe /z3RPhtCVrDWJ03DfPngPQD+sOuzKFlEBkX1haWR6uTZkvHd6TFntyZpanosuGeaTi ra6U+hv6z/hxbfeUXLYRaAS8jj1km5mhtjVtEBFvVYOsJpc6jmRQY7koFnlDZaBVmn XdeSPXM8c+ec4HqLeATPuByx7Pj0b6+66NoEI7JjoX74LCUFDppdfZX0FRbFoiqE48 Ewlm3ceFMfmcw== X-Pm-Submission-Id: 4bz7wB4jN3z1DDBp From: Sean Nyekjaer Date: Fri, 08 Aug 2025 17:57:41 +0200 Subject: [PATCH v2 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: <20250808-icm42pmreg-v2-1-a480279e7721@geanix.com> References: <20250808-icm42pmreg-v2-0-a480279e7721@geanix.com> In-Reply-To: <20250808-icm42pmreg-v2-0-a480279e7721@geanix.com> To: Jean-Baptiste Maneyrol , Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: linux-iio@vger.kernel.org, linux-kernel@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, 6 insertions(+), 18 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..c19615750c717101312f358a916= 0dd2c455cfb14 100644 --- a/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c +++ b/drivers/iio/imu/inv_icm42600/inv_icm42600_core.c @@ -711,20 +711,10 @@ 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); -} - -static void inv_icm42600_disable_pm(void *_data) -{ - struct device *dev =3D _data; + struct device *dev =3D regmap_get_device(st->map); =20 - pm_runtime_put_sync(dev); - pm_runtime_disable(dev); + if (!pm_runtime_status_suspended(dev)) + regulator_disable(st->vddio_supply); } =20 int inv_icm42600_core_probe(struct regmap *regmap, int chip, @@ -824,16 +814,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