From nobody Tue Dec 2 00:26:11 2025 Received: from mail.prodrive-technologies.com (mail.prodrive-technologies.com [212.61.153.67]) (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 514082586C8; Mon, 24 Nov 2025 21:05:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.61.153.67 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764018338; cv=none; b=padzhhOCYjgAU7ikDJAIR4su90N/DB5YIYjowyAJENXtAoEKo1OWoisA6BvY82aWMQoxlGcHHdTF9Os8j34Fkj4Bp5GNd67oxVGf7258BdFRqS6pdoNLG4WmwJksk2vDORks5Wayk6Du8h6UCgKwW9tbvjsGXmg8LS+4xT+6On4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764018338; c=relaxed/simple; bh=qAY9uWjo2On3Knsq1B9cc5A7xmd2SMVecubLhi5DZs4=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=j5U/S3Js4K577lDy74JTG3AQdjU6UtiP7kC633oGOndrJfq1IY0fbhXOHmKozqrVg0mQ/UO6RwsD/70quEQGKddjzN4ybWo/De6GYvzL9r6Fh/M1p49VBUxi6L2DpZQosKuPuOoGrX/OSJRJesbwLahHCvmufKKWuUm5B4QJkH4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=prodrive-technologies.com; spf=pass smtp.mailfrom=prodrive-technologies.com; arc=none smtp.client-ip=212.61.153.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=prodrive-technologies.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=prodrive-technologies.com Received: from EXCOP01.bk.prodrive.nl (10.1.0.22) by EXCOP01.bk.prodrive.nl (10.1.0.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 24 Nov 2025 22:05:27 +0100 Received: from lnxdevrm02.prodrive.nl (10.1.1.121) by EXCOP01.bk.prodrive.nl (10.1.0.22) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Mon, 24 Nov 2025 22:05:27 +0100 From: Martijn de Gouw To: Lee Jones , Pavel Machek CC: Martijn de Gouw , , Subject: [PATCH v2] leds: group-multicolor: Add support for initial value. Date: Mon, 24 Nov 2025 22:05:20 +0100 Message-ID: <20251124210521.2064660-1-martijn.de.gouw@prodrive-technologies.com> X-Mailer: git-send-email 2.39.2 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" When the driver is loaded, it turned off all LEDs in the group. This patch changes the driver to take over existing LED states and set the brighness and intensity in the group accordingly. Signed-off-by: Martijn de Gouw --- drivers/leds/rgb/leds-group-multicolor.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/leds/rgb/leds-group-multicolor.c b/drivers/leds/rgb/le= ds-group-multicolor.c index 548c7dd63ba1e..a12720d73f188 100644 --- a/drivers/leds/rgb/leds-group-multicolor.c +++ b/drivers/leds/rgb/leds-group-multicolor.c @@ -69,6 +69,7 @@ static int leds_gmc_probe(struct platform_device *pdev) struct mc_subled *subled; struct leds_multicolor *priv; unsigned int max_brightness =3D 0; + unsigned int default_brightness =3D 0; int i, ret, count =3D 0, common_flags =3D 0; =20 priv =3D devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); @@ -96,6 +97,13 @@ static int leds_gmc_probe(struct platform_device *pdev) =20 max_brightness =3D max(max_brightness, led_cdev->max_brightness); =20 + /* + * If any LED is on, set brightness to the max brightness. + * The actual brightness of the LED is set as intensity value. + */ + if (led_cdev->brightness) + default_brightness =3D max_brightness; + count++; } =20 @@ -109,14 +117,16 @@ static int leds_gmc_probe(struct platform_device *pde= v) =20 subled[i].color_index =3D led_cdev->color; =20 - /* Configure the LED intensity to its maximum */ - subled[i].intensity =3D max_brightness; + /* Configure the LED intensity to its current brightness */ + subled[i].intensity =3D DIV_ROUND_CLOSEST(led_cdev->brightness * max_bri= ghtness, + led_cdev->max_brightness); } =20 /* Initialise the multicolor's LED class device */ cdev =3D &priv->mc_cdev.led_cdev; cdev->brightness_set_blocking =3D leds_gmc_set; cdev->max_brightness =3D max_brightness; + cdev->brightness =3D default_brightness; cdev->color =3D LED_COLOR_ID_MULTI; priv->mc_cdev.num_colors =3D count; =20 --=20 2.39.2