From 46c4b0cdf2a3abe321e137bcb87e5639c39fd655 Mon Sep 17 00:00:00 2001 From: Vadim Pasternak Date: Thu, 20 Jul 2023 11:01:56 +0000 Subject: [PATCH backport 6.1.42 44/85] leds: mlxreg: Add support for new flavour of capability register LED platform data is common across the various systems, while LED driver should be able to apply only the LED instances relevant to specific system. For example, platform data might contain descriptions for fan1, fan2, ..., fan{n} LEDs, while some systems equipped with all 'n' fan LEDs, others with less. For detection of the real number of equipped LEDs special capability register is used. This register used to indicate presence of LED through the bitmap. For some new big modular systems this register will provide presence data by counter. Use slot parameter to distinct whether capability register contains bitmask or counter. Signed-off-by: Vadim Pasternak --- drivers/leds/leds-mlxreg.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/leds/leds-mlxreg.c b/drivers/leds/leds-mlxreg.c index b7855c93bd72..063a9cb50a2b 100644 --- a/drivers/leds/leds-mlxreg.c +++ b/drivers/leds/leds-mlxreg.c @@ -206,16 +206,22 @@ static int mlxreg_led_config(struct mlxreg_led_priv_data *priv) dev_err(&priv->pdev->dev, "Failed to query capability register\n"); return err; } - if (!(regval & data->bit)) + /* + * If slot is specified - validate if slot is equipped on system. + * In case slot is specified in platform data, capability register + * comtains the counter of untits. + */ + if (data->slot && data->slot > regval) + continue; + else if (!(regval & data->bit)) continue; /* * Field "bit" can contain one capability bit in 0 byte * and offset bit in 1-3 bytes. Clear capability bit and - * keep only offset bit. + * contains the counter of units. */ data->bit &= MLXREG_LED_CAPABILITY_CLEAR; } - led_cdev = &led_data->led_cdev; led_data->data_parent = priv; if (strstr(data->label, "red") || -- 2.20.1