mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <ahmad@a3f.at>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/7] sandbox: watchdog: handle missing stickypage gracefully
Date: Tue, 2 May 2023 11:34:20 +0200	[thread overview]
Message-ID: <20230502093420.GX13543@pengutronix.de> (raw)
In-Reply-To: <20230424121805.150434-1-ahmad@a3f.at>

On Mon, Apr 24, 2023 at 02:17:59PM +0200, Ahmad Fatoum wrote:
> To enable simulation of $global.system.reset in sandbox, the watchdog
> driver writes the reset-source into the stickypage for readout during
> subsequent barebox startup. This is an optional feature, so it should
> happen before watchdog registration, but not break watchdog operation if
> not available.
> 
> Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
> ---
>  arch/sandbox/board/watchdog.c           | 28 +++++++++----------------
>  arch/sandbox/include/asm/reset_source.h | 16 ++++++++++++++
>  2 files changed, 26 insertions(+), 18 deletions(-)
>  create mode 100644 arch/sandbox/include/asm/reset_source.h

Applied, thanks

Sascha

> 
> diff --git a/arch/sandbox/board/watchdog.c b/arch/sandbox/board/watchdog.c
> index 54e87cdde4ab..5bffad81195e 100644
> --- a/arch/sandbox/board/watchdog.c
> +++ b/arch/sandbox/board/watchdog.c
> @@ -7,7 +7,7 @@
>  #include <of.h>
>  #include <watchdog.h>
>  #include <linux/nvmem-consumer.h>
> -#include <reset_source.h>
> +#include <asm/reset_source.h>
>  
>  struct sandbox_watchdog {
>  	struct watchdog wdd;
> @@ -30,7 +30,7 @@ static int sandbox_watchdog_set_timeout(struct watchdog *wdd, unsigned int timeo
>  	if (timeout > wdd->timeout_max)
>  		return -EINVAL;
>  
> -	nvmem_cell_write(wd->reset_source_cell, &(u8) { RESET_WDG }, 1);
> +	sandbox_save_reset_source(wd->reset_source_cell, RESET_WDG);
>  
>  	linux_watchdog_set_timeout(timeout);
>  	return 0;
> @@ -41,7 +41,6 @@ static int sandbox_watchdog_probe(struct device *dev)
>  	struct device_node *np = dev->of_node;
>  	struct sandbox_watchdog *wd;
>  	struct watchdog *wdd;
> -	int ret;
>  
>  	wd = xzalloc(sizeof(*wd));
>  
> @@ -50,24 +49,17 @@ static int sandbox_watchdog_probe(struct device *dev)
>  	wdd->set_timeout = sandbox_watchdog_set_timeout;
>  	wdd->timeout_max = 1000;
>  
> -	wd->cant_disable = of_property_read_bool(np, "barebox,cant-disable");
> -
> -	ret = watchdog_register(wdd);
> -	if (ret) {
> -		dev_err(dev, "Failed to register watchdog device\n");
> -		return ret;
> -	}
> -
> -	wd->reset_source_cell = of_nvmem_cell_get(dev->of_node,
> -						  "reset-source");
> +	wd->reset_source_cell = of_nvmem_cell_get(np, "reset-source");
>  	if (IS_ERR(wd->reset_source_cell)) {
> -		dev_warn(dev, "No reset source info available: %pe\n", wd->reset_source_cell);
> -		goto out;
> +		if (PTR_ERR(wd->reset_source_cell) != -EPROBE_DEFER)
> +			dev_warn(dev, "No reset source info available: %pe\n",
> +				 wd->reset_source_cell);
> +		wd->reset_source_cell = NULL;
>  	}
>  
> -out:
> -	dev_info(dev, "probed\n");
> -	return 0;
> +	wd->cant_disable = of_property_read_bool(np, "barebox,cant-disable");
> +
> +	return watchdog_register(wdd);
>  }
>  
>  
> diff --git a/arch/sandbox/include/asm/reset_source.h b/arch/sandbox/include/asm/reset_source.h
> new file mode 100644
> index 000000000000..1690299c4718
> --- /dev/null
> +++ b/arch/sandbox/include/asm/reset_source.h
> @@ -0,0 +1,16 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +
> +#ifndef __SANDBOX_RESET_SOURCE_H
> +#define __SANDBOX_RESET_SOURCE_H
> +
> +#include <reset_source.h>
> +#include <linux/nvmem-consumer.h>
> +
> +static inline void sandbox_save_reset_source(struct nvmem_cell *reset_source_cell,
> +					     enum reset_src_type src)
> +{
> +	if (reset_source_cell)
> +		WARN_ON(nvmem_cell_write(reset_source_cell, &(u8) { src }, 1) <= 0);
> +}
> +
> +#endif
> -- 
> 2.38.4
> 
> 
> 

-- 
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 |



      parent reply	other threads:[~2023-05-02  9:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-24 12:17 Ahmad Fatoum
2023-04-24 12:18 ` [PATCH 2/7] sandbox: power: " Ahmad Fatoum
2023-04-24 12:18 ` [PATCH 3/7] sandbox: hostfile: don't warn on failed hostfile fixup Ahmad Fatoum
2023-04-24 12:18 ` [PATCH 4/7] treewide: drop trailing space Ahmad Fatoum
2023-04-24 12:18 ` [PATCH 5/7] driver: be explicit about supported #feature-cells Ahmad Fatoum
2023-04-24 12:18 ` [PATCH 6/7] featctrl: drop useless NULL check Ahmad Fatoum
2023-04-24 12:18 ` [PATCH 7/7] sandbox: hostfile: add feature controller support Ahmad Fatoum
2023-05-02  9:34 ` Sascha Hauer [this message]

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=20230502093420.GX13543@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=ahmad@a3f.at \
    --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