linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH led-next 1/1] leds: mlxreg: Allow multi-instantiation of same name LED for modular systems
@ 2020-10-06 16:58 Vadim Pasternak
  2020-10-06 23:15 ` Marek Behun
  2020-10-07 11:31 ` Pavel Machek
  0 siblings, 2 replies; 20+ messages in thread
From: Vadim Pasternak @ 2020-10-06 16:58 UTC (permalink / raw)
  To: jacek.anaszewski; +Cc: linux-leds, Vadim Pasternak

It could be more than one instance of LED with the same name in the
modular systems. For example, "status" or "uid" LED can be located
on chassis and on each line card of modular system.
In order to avoid conflicts with duplicated names, append platform
device Id, which is unquie, to LED name after driver name.
Thus, for example, "status" LED on chassis is to be called, like it is
called now on non modular systems, on which platform device Id is not
specified: "mlxreg:status:green". While for the line cards LEDs it will
be called like: "mlxreg48:status:green", "mlxreg66:status:green",
etcetera.

Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
---
 drivers/leds/leds-mlxreg.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/leds/leds-mlxreg.c b/drivers/leds/leds-mlxreg.c
index 82aea1cd0c12..53130a8656b1 100644
--- a/drivers/leds/leds-mlxreg.c
+++ b/drivers/leds/leds-mlxreg.c
@@ -228,8 +228,12 @@ static int mlxreg_led_config(struct mlxreg_led_priv_data *priv)
 			brightness = LED_OFF;
 			led_data->base_color = MLXREG_LED_GREEN_SOLID;
 		}
-		snprintf(led_data->led_cdev_name, sizeof(led_data->led_cdev_name),
-			 "mlxreg:%s", data->label);
+		if (priv->pdev->id > 0)
+			sprintf(led_data->led_cdev_name, "%s%d:%s", "mlxreg",
+				priv->pdev->id, data->label);
+		else
+			sprintf(led_data->led_cdev_name, "%s:%s", "mlxreg",
+				data->label);
 		led_cdev->name = led_data->led_cdev_name;
 		led_cdev->brightness = brightness;
 		led_cdev->max_brightness = LED_ON;
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2020-12-30 18:49 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-06 16:58 [PATCH led-next 1/1] leds: mlxreg: Allow multi-instantiation of same name LED for modular systems Vadim Pasternak
2020-10-06 23:15 ` Marek Behun
2020-10-07  6:07   ` Vadim Pasternak
2020-10-07 12:17     ` Marek Behun
2020-10-07 11:31 ` Pavel Machek
2020-10-07 12:20   ` Marek Behun
2020-10-08  6:16     ` Vadim Pasternak
2020-10-08  7:56       ` Pavel Machek
2020-10-08  8:47         ` Vadim Pasternak
2020-10-08  8:55           ` Marek Behun
2020-10-08  9:30             ` Vadim Pasternak
2020-10-08 10:05               ` Pavel Machek
2020-10-08 10:32                 ` Vadim Pasternak
2020-11-25 11:20                   ` Pavel Machek
2020-11-25 12:01                     ` Vadim Pasternak
2020-12-30 18:48                       ` Pavel Machek
2020-10-08 10:32               ` Marek Behun
2020-10-12 10:14                 ` Vadim Pasternak
2020-10-21  8:33                   ` Pavel Machek
2020-10-21 12:29                     ` Vadim Pasternak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).