]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
leds: leds-st1202: Initialize hardware before DT node child operations
authorManuel Fombuena <fombuena@outlook.com>
Wed, 26 Feb 2025 17:06:40 +0000 (17:06 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 May 2025 09:12:43 +0000 (11:12 +0200)
[ Upstream commit a17d9e736ddd78323e77d3066c1e86371a99023c ]

Arguably, there are more chances of errors occurring during the
initialization of the hardware, so this should complete successfully
before the devicetree node's children are initialized.

st1202_dt_init() fills the led_classdev struct.

st1202_setup() initializes the hardware. Specifically, resets the chip,
enables its phase-shift delay feature, enables the device and disables all
the LEDs channels. All that writing to registers, with no input from
st1202_dt_init().

Real-world testing corroborates that calling st1202_setup() before
st1202_dt_init() doesn't cause any issue during initialization.

Switch the order of st1202_dt_init() and st1202_setup() to ensure the
hardware is correctly initialized before the led_classdev struct is
filled.

Signed-off-by: Manuel Fombuena <fombuena@outlook.com>
Link: https://lore.kernel.org/r/CWLP123MB54731877A8DC54EDD33F0229C5C22@CWLP123MB5473.GBRP123.PROD.OUTLOOK.COM
Signed-off-by: Lee Jones <lee@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/leds/leds-st1202.c

index 4cebc0203c227a47a1391c431c875c6fa41db82c..ccea216c11f9b6cda888b2d9b189c96c5ce5583b 100644 (file)
@@ -350,11 +350,11 @@ static int st1202_probe(struct i2c_client *client)
                return ret;
        chip->client = client;
 
-       ret = st1202_dt_init(chip);
+       ret = st1202_setup(chip);
        if (ret < 0)
                return ret;
 
-       ret = st1202_setup(chip);
+       ret = st1202_dt_init(chip);
        if (ret < 0)
                return ret;