From 829666710cee80ee942b3ecc8b6ef5d1606b89e7 Mon Sep 17 00:00:00 2001 From: Nikodem Kastelik Date: Mon, 1 Dec 2025 15:22:48 +0100 Subject: [PATCH] drivers: pwm: nrf: fix nrfx instance being zeroed on suspend PWM driver clears its runtime state on each suspend event. However, since nrfx 4.0 integration nrfx driver instance is part of the runtime state structure, so clear action must be limited. Signed-off-by: Nikodem Kastelik --- drivers/pwm/pwm_nrfx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/pwm/pwm_nrfx.c b/drivers/pwm/pwm_nrfx.c index 2a97aa47dfdc2..ef3c2c030ff80 100644 --- a/drivers/pwm/pwm_nrfx.c +++ b/drivers/pwm/pwm_nrfx.c @@ -354,7 +354,11 @@ static int pwm_suspend(const struct device *dev) while (!nrfx_pwm_stopped_check(&data->pwm)) { } - memset(dev->data, 0, sizeof(struct pwm_nrfx_data)); + /* Explicitly clear driver state that might be invalid after subsequent resume. */ + data->period_cycles = 0; + data->pwm_needed = 0; + data->prescaler = 0; + data->stop_requested = 0; (void)pinctrl_apply_state(config->pcfg, PINCTRL_STATE_SLEEP); return 0;