diff mbox series

[RESEND,2/5] leds: leds-st1202: initialize hardware before DT node child operations

Message ID CWLP123MB54732954D59EFDB0D344A6DAC5EB2@CWLP123MB5473.GBRP123.PROD.OUTLOOK.COM
State New
Headers show
Series LED1202 / leds-st1202 fixes and improvements | expand

Commit Message

Manuel Fombuena Feb. 1, 2025, 1:04 p.m. UTC
Arguably, there are more chances of errors occurring during the
initialization of the hardware, so this should complete successfully
before the DT node childreen are initialized.

Signed-off-by: Manuel Fombuena <fombuena@outlook.com>
---
 drivers/leds/leds-st1202.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Lee Jones Feb. 11, 2025, 1:32 p.m. UTC | #1
On Sat, 01 Feb 2025, Manuel Fombuena wrote:

> Arguably, there are more chances of errors occurring during the
> initialization of the hardware, so this should complete successfully
> before the DT node childreen are initialized.

Okay.  And you're sure nothing in Setup needs the DT info?

> Signed-off-by: Manuel Fombuena <fombuena@outlook.com>
> ---
>  drivers/leds/leds-st1202.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/leds/leds-st1202.c b/drivers/leds/leds-st1202.c
> index e894b3f9a0f4..927874f20839 100644
> --- a/drivers/leds/leds-st1202.c
> +++ b/drivers/leds/leds-st1202.c
> @@ -348,11 +348,11 @@ static int st1202_probe(struct i2c_client *client)
>  	devm_mutex_init(&client->dev, &chip->lock);
>  	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;
>  
> -- 
> 2.48.1
>
Manuel Fombuena Feb. 12, 2025, 3:15 p.m. UTC | #2
On Tue, 11 Feb 2025, Lee Jones wrote:

> On Sat, 01 Feb 2025, Manuel Fombuena wrote:
> 
> > Arguably, there are more chances of errors occurring during the
> > initialization of the hardware, so this should complete successfully
> > before the DT node childreen are initialized.
> 
> Okay.  And you're sure nothing in Setup needs the DT info?

Yes, st1202_setup() doesn't require anything previously done in  
st1202_dt_init() to do its thing.

Additionally, I am not just relying on reviewing the code. I am also 
carrying out real-world testing on a device I use daily and it works 
either way.

--
Manuel Fombuena
diff mbox series

Patch

diff --git a/drivers/leds/leds-st1202.c b/drivers/leds/leds-st1202.c
index e894b3f9a0f4..927874f20839 100644
--- a/drivers/leds/leds-st1202.c
+++ b/drivers/leds/leds-st1202.c
@@ -348,11 +348,11 @@  static int st1202_probe(struct i2c_client *client)
 	devm_mutex_init(&client->dev, &chip->lock);
 	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;