mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 2/3] mfd: rn5t568: refactor to call reset_source_set_device only once
Date: Mon, 25 Nov 2024 09:20:31 +0100	[thread overview]
Message-ID: <Z0QzT1LZ6Lo2kxtr@pengutronix.de> (raw)
In-Reply-To: <20241120130640.3866362-2-a.fatoum@pengutronix.de>

On Wed, Nov 20, 2024 at 02:06:39PM +0100, Ahmad Fatoum wrote:
> ---
>  drivers/mfd/rn5t568.c | 59 +++++++++++++++++++++----------------------
>  1 file changed, 29 insertions(+), 30 deletions(-)
> 

No S-o-b?

Sascha

> diff --git a/drivers/mfd/rn5t568.c b/drivers/mfd/rn5t568.c
> index f1e2eeb0c88b..7468338a2d53 100644
> --- a/drivers/mfd/rn5t568.c
> +++ b/drivers/mfd/rn5t568.c
> @@ -33,6 +33,7 @@ static void rn5t568_restart(struct restart_handler *rst)
>  static int rn5t568_reset_reason_detect(struct device *dev,
>  				       struct regmap *regmap)
>  {
> +	enum reset_src_type type;
>  	unsigned int reg;
>  	int ret;
>  
> @@ -47,40 +48,38 @@ static int rn5t568_reset_reason_detect(struct device *dev,
>  		return 0;
>  	}
>  
> -	if (reg & RN5T568_PONHIS_ON_EXTINPON) {
> -		reset_source_set_device(dev, RESET_POR);
> -		return 0;
> -	} else if (reg & RN5T568_PONHIS_ON_PWRONPON) {
> -		reset_source_set_device(dev, RESET_POR);
> -		return 0;
> -	} else if (!(reg & RN5T568_PONHIS_ON_REPWRPON))
> +	if (reg & (RN5T568_PONHIS_ON_EXTINPON | RN5T568_PONHIS_ON_PWRONPON)) {
> +		type = RESET_POR;
> +	} else if (!(reg & RN5T568_PONHIS_ON_REPWRPON)) {
>  		return -EINVAL;
> +	} else {
> +		ret = regmap_read(regmap, RN5T568_POFFHIS, &reg);
> +		if (ret)
> +			return ret;
>  
> -	ret = regmap_read(regmap, RN5T568_POFFHIS, &reg);
> -	if (ret)
> -		return ret;
> +		dev_dbg(dev, "Power-off history: %x\n", reg);
>  
> -	dev_dbg(dev, "Power-off history: %x\n", reg);
> -
> -	if (reg & RN5T568_POFFHIS_PWRONPOFF)
> -		reset_source_set_device(dev, RESET_POR);
> -	else if (reg & RN5T568_POFFHIS_TSHUTPOFF)
> -		reset_source_set_device(dev, RESET_THERM);
> -	else if (reg & RN5T568_POFFHIS_VINDETPOFF)
> -		reset_source_set_device(dev, RESET_BROWNOUT);
> -	else if (reg & RN5T568_POFFHIS_IODETPOFF)
> -		reset_source_set_device(dev, RESET_UKWN);
> -	else if (reg & RN5T568_POFFHIS_CPUPOFF)
> -		reset_source_set_device(dev, RESET_RST);
> -	else if (reg & RN5T568_POFFHIS_WDGPOFF)
> -		reset_source_set_device(dev, RESET_WDG);
> -	else if (reg & RN5T568_POFFHIS_DCLIMPOFF)
> -		reset_source_set_device(dev, RESET_BROWNOUT);
> -	else if (reg & RN5T568_POFFHIS_N_OEPOFF)
> -		reset_source_set_device(dev, RESET_EXT);
> -	else
> -		return -EINVAL;
> +		if (reg & RN5T568_POFFHIS_PWRONPOFF)
> +			type = RESET_POR;
> +		else if (reg & RN5T568_POFFHIS_TSHUTPOFF)
> +			type = RESET_THERM;
> +		else if (reg & RN5T568_POFFHIS_VINDETPOFF)
> +			type = RESET_BROWNOUT;
> +		else if (reg & RN5T568_POFFHIS_IODETPOFF)
> +			type = RESET_UKWN;
> +		else if (reg & RN5T568_POFFHIS_CPUPOFF)
> +			type = RESET_RST;
> +		else if (reg & RN5T568_POFFHIS_WDGPOFF)
> +			type = RESET_WDG;
> +		else if (reg & RN5T568_POFFHIS_DCLIMPOFF)
> +			type = RESET_BROWNOUT;
> +		else if (reg & RN5T568_POFFHIS_N_OEPOFF)
> +			type = RESET_EXT;
> +		else
> +			return -EINVAL;
> +	}
>  
> +	reset_source_set_device(dev, type);
>  	return 0;
>  }
>  
> -- 
> 2.39.5
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



  reply	other threads:[~2024-11-25  8:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-20 13:06 [PATCH 1/3] reset_source: have reset_source_set_device actually set device Ahmad Fatoum
2024-11-20 13:06 ` [PATCH 2/3] mfd: rn5t568: refactor to call reset_source_set_device only once Ahmad Fatoum
2024-11-25  8:20   ` Sascha Hauer [this message]
2024-11-20 13:06 ` [PATCH 3/3] reset_source: give reset_source_set_device a priority parameter Ahmad Fatoum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z0QzT1LZ6Lo2kxtr@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox