From nobody Wed Dec 17 16:13:15 2025 Received: from mail.hypatia.paranoidlabs.org (hypatia.paranoidlabs.org [45.11.248.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 491B71E501C; Fri, 13 Dec 2024 19:20:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.11.248.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734117614; cv=none; b=Ef1+JKOtpzx0Sx/QdxqWSle8fgdJl0GWWwttMlwlAwSEqodRnHN4vChtBh7NbyIdcbY1ZImVgVWDwY7kHdQwgw8mvieVYvyY/0feKJEjmdlgb7MFDnPmnMA7TM8uLOy5IbcdAxouJeVq1icI2IbTxSfH0HS/Kzw4fHqbK/65qY4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734117614; c=relaxed/simple; bh=9OoqmauZQxohnJFZN4P+wamIlR3i4wpOOCK/m7yVa1g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qOb3YNRRKztQbASFravCa/Fo7W2ouRQ21tjispCafsSdoZcr5Cwq4h9nf1YkNrTy/E7zLxSwuorZJyypcd4oySAQeHAjHcuCHqt1E2kKk8s+qmOjy4KTENHHUWLAZT0kTfxTAxwopL3xb+XLV2cs5T77cIJDhJmu5OqqToyI5b0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paranoidlabs.org; spf=pass smtp.mailfrom=paranoidlabs.org; dkim=permerror (0-bit key) header.d=paranoidlabs.org header.i=@paranoidlabs.org header.b=Z+6zO/ak; dkim=pass (2048-bit key) header.d=paranoidlabs.org header.i=@paranoidlabs.org header.b=JcwlwK3z; arc=none smtp.client-ip=45.11.248.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paranoidlabs.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paranoidlabs.org Authentication-Results: smtp.subspace.kernel.org; dkim=permerror (0-bit key) header.d=paranoidlabs.org header.i=@paranoidlabs.org header.b="Z+6zO/ak"; dkim=pass (2048-bit key) header.d=paranoidlabs.org header.i=@paranoidlabs.org header.b="JcwlwK3z" Received: from caph.lan (unknown [IPv6:2a02:1748:dd4e:ded0::3ab]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.hypatia.paranoidlabs.org (PlabsMail) with ESMTPSA id C2F621DB80; Fri, 13 Dec 2024 19:13:10 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=paranoidlabs.org; s=ed25519-20210101; t=1734117191; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yQ8n5rTevTsEagDkA9CThrufiGSWMm/mG2qZW+/pzSQ=; b=Z+6zO/ak+dNkVat4nDjkQYeN5w9UZrge2k44A1oF5xuLUhqTJu2ybLMp6O5LSOwM9JoUwr 8ObkavOgfgMOUqAA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paranoidlabs.org; s=rsa-20210101; t=1734117191; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yQ8n5rTevTsEagDkA9CThrufiGSWMm/mG2qZW+/pzSQ=; b=JcwlwK3z7+TjYCQwVsn6bMMZPrYZAq/gd7D49TkqWNGarXxSfHMCeahfkhqfZ0JEzLNBNL BD8xXppPnNiyyy0FLxQQOuh9SBU4/2rh0TQXy/TthEZVb74KH3cP8RlPlnQflFZZXNZUBd DA80P/FWaaNGLZ4HLVxPcViqSSaj6QBhds78Ju/nRD06t3F4gEy9jmcn/+3ugxjiAvE881 03is+8bP34LHLsoqsvioePvTHgask0Wpy62vG/5psd0qKoYtT9Tp1uhwWRElMC2hMhEQql YGLSDd2sAB/LOWdoQjqhd6b8WAE3AOED8BfUL+oggA9plmP0ARqoLIfxE0duXg== From: Jakob Riepler To: Pavel Machek , Lee Jones Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Jakob Riepler , Jakob Riepler Subject: [PATCH v3] leds: pwm-multicolor: Disable PWM when going to suspend Date: Fri, 13 Dec 2024 20:10:41 +0100 Message-ID: <20241213191039.181169-3-jakob+lkml@paranoidlabs.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241213163445.GA2418536@google.com> References: <50bbd767-b0e0-4788-975b-f5d9598208e5@chaosfield.at> <20241212174356.GJ7139@google.com> <20241213163445.GA2418536@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This fixes suspend on platforms like stm32mp1xx, where the PWM consumer has to be disabled for the PWM to enter suspend. Another positive side effect is that active-low LEDs now properly turn off instead of going back to full brightness when they are set to 0. Link: https://lore.kernel.org/all/20240417153846.271751-2-u.kleine-koenig@p= engutronix.de/ Signed-off-by: Jakob Riepler Acked-by: Uwe Kleine-K=C3=B6nig --- Changes in v2: - fix wrong line-breaks in patch Changes in v3: - use git send-email Sorry for the issues. I'm using git send-email with a different mailserver now so the patch formatting should now be correct - at least in my tests git am was happy now. Best regards Jakob drivers/leds/rgb/leds-pwm-multicolor.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/leds/rgb/leds-pwm-multicolor.c b/drivers/leds/rgb/leds= -pwm-multicolor.c index e1a81e0109e8..f80a06cc31f8 100644 --- a/drivers/leds/rgb/leds-pwm-multicolor.c +++ b/drivers/leds/rgb/leds-pwm-multicolor.c @@ -50,7 +50,13 @@ static int led_pwm_mc_set(struct led_classdev *cdev, duty =3D priv->leds[i].state.period - duty; =20 priv->leds[i].state.duty_cycle =3D duty; - priv->leds[i].state.enabled =3D duty > 0; + /* + * Disabling a PWM doesn't guarantee that it emits the inactive level. + * So keep it on. Only for suspending the PWM should be disabled because + * otherwise it refuses to suspend. The possible downside is that the + * LED might stay (or even go) on. + */ + priv->leds[i].state.enabled =3D !(cdev->flags & LED_SUSPENDED); ret =3D pwm_apply_might_sleep(priv->leds[i].pwm, &priv->leds[i].state); if (ret) --=20 2.47.1