Skip to content

Commit a4e8c38

Browse files
JordanYatesbjarki-andreasen
authored andcommitted
[nrf fromtree] spi: nrfx_spim: fix incorrect clock control logic
To determine whether device runtime PM is enabled on a device, use `pm_device_runtime_is_enabled`. This results in the same behaviour when `CONFIG_PM_DEVICE_RUNTIME=n`, but properly controls the clocks on a per-instance basis when `CONFIG_PM_DEVICE_RUNTIME=y`. Signed-off-by: Jordan Yates <[email protected]> (cherry picked from commit 6e0d0f5)
1 parent 4829c71 commit a4e8c38

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/spi/spi_nrfx_spim.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static inline void finalize_spi_transaction(const struct device *dev, bool deact
161161
nrfy_spim_disable(reg);
162162
}
163163

164-
if (!IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) {
164+
if (!pm_device_runtime_is_enabled(dev)) {
165165
release_clock(dev);
166166
}
167167

@@ -550,7 +550,7 @@ static int transceive(const struct device *dev,
550550

551551
error = configure(dev, spi_cfg);
552552

553-
if (error == 0 && !IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) {
553+
if (error == 0 && !pm_device_runtime_is_enabled(dev)) {
554554
error = request_clock(dev);
555555
}
556556

@@ -686,7 +686,7 @@ static int spim_resume(const struct device *dev)
686686
nrf_gpd_retain_pins_set(dev_config->pcfg, false);
687687
#endif
688688

689-
return IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME) ? request_clock(dev) : 0;
689+
return pm_device_runtime_is_enabled(dev) ? request_clock(dev) : 0;
690690
}
691691

692692
static void spim_suspend(const struct device *dev)
@@ -699,7 +699,7 @@ static void spim_suspend(const struct device *dev)
699699
dev_data->initialized = false;
700700
}
701701

702-
if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) {
702+
if (pm_device_runtime_is_enabled(dev)) {
703703
release_clock(dev);
704704
}
705705

0 commit comments

Comments
 (0)