mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/7] sandbox: watchdog: handle missing stickypage gracefully
@ 2023-04-24 12:17 Ahmad Fatoum
  2023-04-24 12:18 ` [PATCH 2/7] sandbox: power: " Ahmad Fatoum
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Ahmad Fatoum @ 2023-04-24 12:17 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

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

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




^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/7] sandbox: power: handle missing stickypage gracefully
  2023-04-24 12:17 [PATCH 1/7] sandbox: watchdog: handle missing stickypage gracefully Ahmad Fatoum
@ 2023-04-24 12:18 ` Ahmad Fatoum
  2023-04-24 12:18 ` [PATCH 3/7] sandbox: hostfile: don't warn on failed hostfile fixup Ahmad Fatoum
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Ahmad Fatoum @ 2023-04-24 12:18 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

To enable simulation of $global.system.reset in sandbox, the power
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/power.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/sandbox/board/power.c b/arch/sandbox/board/power.c
index 51f0968447c4..4adc8d7455fc 100644
--- a/arch/sandbox/board/power.c
+++ b/arch/sandbox/board/power.c
@@ -5,7 +5,7 @@
 #include <poweroff.h>
 #include <restart.h>
 #include <mach/linux.h>
-#include <reset_source.h>
+#include <asm/reset_source.h>
 #include <linux/nvmem-consumer.h>
 
 struct sandbox_power {
@@ -18,7 +18,8 @@ static void sandbox_poweroff(struct poweroff_handler *poweroff)
 {
 	struct sandbox_power *power = container_of(poweroff, struct sandbox_power, poweroff);
 
-	nvmem_cell_write(power->reset_source_cell, &(u8) { RESET_POR }, 1);
+	sandbox_save_reset_source(power->reset_source_cell, RESET_POR);
+
 	linux_exit();
 }
 
@@ -29,11 +30,9 @@ static void sandbox_rst_hang(struct restart_handler *rst)
 
 static void sandbox_rst_reexec(struct restart_handler *rst)
 {
-	u8 reason = RESET_RST;
 	struct sandbox_power *power = container_of(rst, struct sandbox_power, rst_reexec);
 
-	if (!IS_ERR(power->reset_source_cell))
-		WARN_ON(nvmem_cell_write(power->reset_source_cell, &reason, 1) <= 0);
+	sandbox_save_reset_source(power->reset_source_cell, RESET_RST);
 
 	linux_reexec();
 }
@@ -69,7 +68,10 @@ static int sandbox_power_probe(struct device *dev)
 	power->reset_source_cell = of_nvmem_cell_get(dev->of_node,
 						     "reset-source");
 	if (IS_ERR(power->reset_source_cell)) {
-		dev_warn(dev, "No reset source info available: %pe\n", power->reset_source_cell);
+		if (PTR_ERR(power->reset_source_cell) != -EPROBE_DEFER)
+			dev_warn(dev, "No reset source info available: %pe\n",
+				 power->reset_source_cell);
+		power->reset_source_cell = NULL;
 		return 0;
 	}
 
-- 
2.38.4




^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 3/7] sandbox: hostfile: don't warn on failed hostfile fixup
  2023-04-24 12:17 [PATCH 1/7] sandbox: watchdog: handle missing stickypage gracefully Ahmad Fatoum
  2023-04-24 12:18 ` [PATCH 2/7] sandbox: power: " Ahmad Fatoum
@ 2023-04-24 12:18 ` Ahmad Fatoum
  2023-04-24 12:18 ` [PATCH 4/7] treewide: drop trailing space Ahmad Fatoum
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Ahmad Fatoum @ 2023-04-24 12:18 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

The node is not deleted, so the hostfile driver will probe the node in
any case and error will just be printed twice. Thus drop the checks from
the fixup.

Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
 arch/sandbox/board/hostfile.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c
index 436a7503befa..424f16acd5fc 100644
--- a/arch/sandbox/board/hostfile.c
+++ b/arch/sandbox/board/hostfile.c
@@ -257,23 +257,14 @@ static int of_hostfile_map_fixup(struct device_node *root, void *ctx)
 
 		ret = linux_open_hostfile(&hf);
 		if (ret)
-			goto out;
+			continue;
 
 		reg[0] = hf.base;
 		reg[1] = hf.size;
 
-		ret = of_property_write_u64_array(node, "reg", reg, ARRAY_SIZE(reg));
-		if (ret)
-			goto out;
-
-		ret = of_property_write_bool(node, "barebox,blockdev", hf.is_blockdev);
-		if (ret)
-			goto out;
-
-		ret = of_property_write_u32(node, "barebox,fd", hf.fd);
-out:
-		if (ret)
-			pr_err("error fixing up %s: %pe\n", hf.devname, ERR_PTR(ret));
+		of_property_write_u64_array(node, "reg", reg, ARRAY_SIZE(reg));
+		of_property_write_bool(node, "barebox,blockdev", hf.is_blockdev);
+		of_property_write_u32(node, "barebox,fd", hf.fd);
 	}
 
 	return 0;
-- 
2.38.4




^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 4/7] treewide: drop trailing space
  2023-04-24 12:17 [PATCH 1/7] sandbox: watchdog: handle missing stickypage gracefully 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 ` Ahmad Fatoum
  2023-04-24 12:18 ` [PATCH 5/7] driver: be explicit about supported #feature-cells Ahmad Fatoum
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Ahmad Fatoum @ 2023-04-24 12:18 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Found by manual inspection of the output of:

  rg '\s+$' | rg -v dts/

Patch can be verified by observing that no diff results from:

  git show --ignore-space-at-eol

Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
 Documentation/boards/ibase-mi991af.rst                    | 2 +-
 Documentation/user/state.rst                              | 2 +-
 arch/arm/boards/boundarydevices-nitrogen6/Makefile        | 2 +-
 arch/arm/boards/ls1046ardb/board.c                        | 2 +-
 arch/arm/boards/protonic-imx6/flash-header-lanmcu.imxcfg  | 2 +-
 arch/arm/boards/protonic-imx6/flash-header-plybas.imxcfg  | 2 +-
 arch/arm/boards/protonic-imx6/flash-header-plym2m.imxcfg  | 2 +-
 arch/arm/boards/protonic-imx6/flash-header-prti6q.imxcfg  | 2 +-
 arch/arm/boards/protonic-imx6/flash-header-prtmvt.imxcfg  | 2 +-
 arch/arm/boards/protonic-imx6/flash-header-prtrvt.imxcfg  | 2 +-
 arch/arm/boards/protonic-imx6/flash-header-prtvt7.imxcfg  | 2 +-
 arch/arm/boards/protonic-imx6/flash-header-vicut1.imxcfg  | 2 +-
 arch/arm/boards/protonic-imx6/flash-header-vicut1q.imxcfg | 2 +-
 arch/arm/boards/protonic-imx6/flash-header-vicutp.imxcfg  | 2 +-
 arch/arm/boards/zii-imx8mq-dev/ddr_init.c                 | 2 +-
 arch/arm/dts/imx6qdl-nitrogen6_max.dtsi                   | 2 +-
 arch/arm/dts/vf610.dtsi                                   | 2 +-
 arch/arm/dts/zynq-7000.dtsi                               | 2 +-
 arch/arm/mach-at91/sam9263_ll.c                           | 4 ++--
 arch/arm/mach-omap/am33xx_bbu_nand.c                      | 2 +-
 commands/of_overlay.c                                     | 2 +-
 drivers/clk/clk-qoric.c                                   | 2 +-
 drivers/ddr/fsl/ctrl_regs.c                               | 2 +-
 drivers/mtd/nand/Kconfig                                  | 2 +-
 drivers/mtd/nand/nand_omap_gpmc.c                         | 2 +-
 drivers/net/usb/ax88179_178a.c                            | 2 +-
 drivers/regulator/core.c                                  | 2 +-
 drivers/serial/serial_omap4_usbboot.c                     | 2 +-
 include/crypto/des.h                                      | 2 +-
 include/linux/idr.h                                       | 2 +-
 include/tlsf.h                                            | 6 +++---
 scripts/socfpga_import_preloader                          | 2 +-
 32 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/Documentation/boards/ibase-mi991af.rst b/Documentation/boards/ibase-mi991af.rst
index a22e5fcf795b..8e40a0d657b0 100644
--- a/Documentation/boards/ibase-mi991af.rst
+++ b/Documentation/boards/ibase-mi991af.rst
@@ -40,4 +40,4 @@ To continue please proceed with barebox :ref:`barebox_on_uefi` documentation.
 Links
 -----
 
-  * https://www.ibase.com.tw/english/ProductDetail/EmbeddedComputing/MI991 
+  * https://www.ibase.com.tw/english/ProductDetail/EmbeddedComputing/MI991
diff --git a/Documentation/user/state.rst b/Documentation/user/state.rst
index a0e27d4fe847..594c2c15945b 100644
--- a/Documentation/user/state.rst
+++ b/Documentation/user/state.rst
@@ -24,7 +24,7 @@ barebox itself uses a *state* driver to access the variables in the
 persistent memory.
 
 Currently there is only one implementation, enabled by
-``CONFIG_STATE_DRV=y``. Without driver, the state framework will silently 
+``CONFIG_STATE_DRV=y``. Without driver, the state framework will silently
 fail and be non-functional.
 
 For the Linux run-time there is a userspace tool_ to do
diff --git a/arch/arm/boards/boundarydevices-nitrogen6/Makefile b/arch/arm/boards/boundarydevices-nitrogen6/Makefile
index b365c8eab067..da63d2625f7a 100644
--- a/arch/arm/boards/boundarydevices-nitrogen6/Makefile
+++ b/arch/arm/boards/boundarydevices-nitrogen6/Makefile
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
-obj-y += board.o 
+obj-y += board.o
 lwl-y += lowlevel.o
diff --git a/arch/arm/boards/ls1046ardb/board.c b/arch/arm/boards/ls1046ardb/board.c
index 921629d2a840..ee70171ca3d3 100644
--- a/arch/arm/boards/ls1046ardb/board.c
+++ b/arch/arm/boards/ls1046ardb/board.c
@@ -33,7 +33,7 @@ struct nxid {
 	u8 mac_count;     /* 0x40        Number of MAC addresses */
 	u8 mac_flag;      /* 0x41        MAC table flags */
 	u8 mac[MAX_NUM_PORTS][6];     /* 0x42 - 0xa1 MAC addresses */
-	u8 res_2[90];     /* 0xa2 - 0xfb Reserved */	
+	u8 res_2[90];     /* 0xa2 - 0xfb Reserved */
 	u32 crc;          /* 0xfc - 0xff CRC32 checksum */
 } __packed;
 
diff --git a/arch/arm/boards/protonic-imx6/flash-header-lanmcu.imxcfg b/arch/arm/boards/protonic-imx6/flash-header-lanmcu.imxcfg
index e6e37672aa3e..7deaaa9b7b34 100644
--- a/arch/arm/boards/protonic-imx6/flash-header-lanmcu.imxcfg
+++ b/arch/arm/boards/protonic-imx6/flash-header-lanmcu.imxcfg
@@ -61,7 +61,7 @@ wm 32 0x021b001c 0x04008040
 
 /* MPZQHWCTRL */
 wm 32 0x021b0800 0xa1390003 /* ZQ mode = 3  force calibration */
-wm 32 0x021b4800 0xa1390003 
+wm 32 0x021b4800 0xa1390003
 
 wm 32 0x021b0020 MDREF_64KHZ
 
diff --git a/arch/arm/boards/protonic-imx6/flash-header-plybas.imxcfg b/arch/arm/boards/protonic-imx6/flash-header-plybas.imxcfg
index 16f2f596c773..c9c9d076f587 100644
--- a/arch/arm/boards/protonic-imx6/flash-header-plybas.imxcfg
+++ b/arch/arm/boards/protonic-imx6/flash-header-plybas.imxcfg
@@ -63,7 +63,7 @@ wm 32 0x021b001c 0x04008040
 
 /* MPZQHWCTRL */
 wm 32 0x021b0800 0xa1390003 /* ZQ mode = 3  force calibration */
-wm 32 0x021b4800 0xa1390003 
+wm 32 0x021b4800 0xa1390003
 
 wm 32 0x021b0020 MDREF_64KHZ
 
diff --git a/arch/arm/boards/protonic-imx6/flash-header-plym2m.imxcfg b/arch/arm/boards/protonic-imx6/flash-header-plym2m.imxcfg
index 1692c1e08771..71df95b96853 100644
--- a/arch/arm/boards/protonic-imx6/flash-header-plym2m.imxcfg
+++ b/arch/arm/boards/protonic-imx6/flash-header-plym2m.imxcfg
@@ -63,7 +63,7 @@ wm 32 0x021b001c 0x04008040
 
 /* MPZQHWCTRL */
 wm 32 0x021b0800 0xa1390003 /* ZQ mode = 3  force calibration */
-wm 32 0x021b4800 0xa1390003 
+wm 32 0x021b4800 0xa1390003
 
 wm 32 0x021b0020 MDREF_64KHZ
 
diff --git a/arch/arm/boards/protonic-imx6/flash-header-prti6q.imxcfg b/arch/arm/boards/protonic-imx6/flash-header-prti6q.imxcfg
index 2d0064e8c1cb..deced6901bc7 100644
--- a/arch/arm/boards/protonic-imx6/flash-header-prti6q.imxcfg
+++ b/arch/arm/boards/protonic-imx6/flash-header-prti6q.imxcfg
@@ -65,7 +65,7 @@ wm 32 0x021b001c 0x04008040
 
 /* MPZQHWCTRL */
 wm 32 0x021b0800 0xa1390003 /* ZQ mode = 3  force calibration */
-wm 32 0x021b4800 0xa1390003 
+wm 32 0x021b4800 0xa1390003
 
 wm 32 0x021b0020 MDREF_64KHZ
 
diff --git a/arch/arm/boards/protonic-imx6/flash-header-prtmvt.imxcfg b/arch/arm/boards/protonic-imx6/flash-header-prtmvt.imxcfg
index 887811fa4240..58530910fc63 100644
--- a/arch/arm/boards/protonic-imx6/flash-header-prtmvt.imxcfg
+++ b/arch/arm/boards/protonic-imx6/flash-header-prtmvt.imxcfg
@@ -63,7 +63,7 @@ wm 32 0x021b001c 0x04008040
 
 /* MPZQHWCTRL */
 wm 32 0x021b0800 0xa1390003 /* ZQ mode = 3  force calibration */
-wm 32 0x021b4800 0xa1390003 
+wm 32 0x021b4800 0xa1390003
 
 wm 32 0x021b0020 MDREF_64KHZ
 
diff --git a/arch/arm/boards/protonic-imx6/flash-header-prtrvt.imxcfg b/arch/arm/boards/protonic-imx6/flash-header-prtrvt.imxcfg
index 16f2f596c773..c9c9d076f587 100644
--- a/arch/arm/boards/protonic-imx6/flash-header-prtrvt.imxcfg
+++ b/arch/arm/boards/protonic-imx6/flash-header-prtrvt.imxcfg
@@ -63,7 +63,7 @@ wm 32 0x021b001c 0x04008040
 
 /* MPZQHWCTRL */
 wm 32 0x021b0800 0xa1390003 /* ZQ mode = 3  force calibration */
-wm 32 0x021b4800 0xa1390003 
+wm 32 0x021b4800 0xa1390003
 
 wm 32 0x021b0020 MDREF_64KHZ
 
diff --git a/arch/arm/boards/protonic-imx6/flash-header-prtvt7.imxcfg b/arch/arm/boards/protonic-imx6/flash-header-prtvt7.imxcfg
index 7f2662567e6b..5073458a0302 100644
--- a/arch/arm/boards/protonic-imx6/flash-header-prtvt7.imxcfg
+++ b/arch/arm/boards/protonic-imx6/flash-header-prtvt7.imxcfg
@@ -61,7 +61,7 @@ wm 32 0x021b001c 0x04008040
 
 /* MPZQHWCTRL */
 wm 32 0x021b0800 0xa1390003 /* ZQ mode = 3  force calibration */
-wm 32 0x021b4800 0xa1390003 
+wm 32 0x021b4800 0xa1390003
 
 wm 32 0x021b0020 MDREF_64KHZ
 
diff --git a/arch/arm/boards/protonic-imx6/flash-header-vicut1.imxcfg b/arch/arm/boards/protonic-imx6/flash-header-vicut1.imxcfg
index b86a32be0c2c..a879229923bb 100644
--- a/arch/arm/boards/protonic-imx6/flash-header-vicut1.imxcfg
+++ b/arch/arm/boards/protonic-imx6/flash-header-vicut1.imxcfg
@@ -63,7 +63,7 @@ wm 32 0x021b001c 0x04008040
 
 /* MPZQHWCTRL */
 wm 32 0x021b0800 0xa1390003 /* ZQ mode = 3  force calibration */
-wm 32 0x021b4800 0xa1390003 
+wm 32 0x021b4800 0xa1390003
 
 wm 32 0x021b0020 MDREF_64KHZ
 
diff --git a/arch/arm/boards/protonic-imx6/flash-header-vicut1q.imxcfg b/arch/arm/boards/protonic-imx6/flash-header-vicut1q.imxcfg
index 3abb21b70e32..8e41a410df5b 100644
--- a/arch/arm/boards/protonic-imx6/flash-header-vicut1q.imxcfg
+++ b/arch/arm/boards/protonic-imx6/flash-header-vicut1q.imxcfg
@@ -66,7 +66,7 @@ wm 32 0x021b001c 0x04008040
 
 /* MPZQHWCTRL */
 wm 32 0x021b0800 0xa1390003 /* ZQ mode = 3  force calibration */
-wm 32 0x021b4800 0xa1390003 
+wm 32 0x021b4800 0xa1390003
 
 wm 32 0x021b0020 MDREF_64KHZ
 
diff --git a/arch/arm/boards/protonic-imx6/flash-header-vicutp.imxcfg b/arch/arm/boards/protonic-imx6/flash-header-vicutp.imxcfg
index a8178fe2580b..54a86a0008a6 100644
--- a/arch/arm/boards/protonic-imx6/flash-header-vicutp.imxcfg
+++ b/arch/arm/boards/protonic-imx6/flash-header-vicutp.imxcfg
@@ -126,7 +126,7 @@ wm 32 0x021b001c 0x04008040
 
 /* MPZQHWCTRL */
 wm 32 0x021b0800 0xa1390003 /* ZQ mode = 3  force calibration */
-wm 32 0x021b4800 0xa1390003 
+wm 32 0x021b4800 0xa1390003
 
 wm 32 0x021b0020 MDREF_64KHZ
 
diff --git a/arch/arm/boards/zii-imx8mq-dev/ddr_init.c b/arch/arm/boards/zii-imx8mq-dev/ddr_init.c
index 902d0ee3cd6e..2d4133fb1375 100644
--- a/arch/arm/boards/zii-imx8mq-dev/ddr_init.c
+++ b/arch/arm/boards/zii-imx8mq-dev/ddr_init.c
@@ -178,7 +178,7 @@ void ddr_init(void)
 	reg32_write(DDRC_SWCTL(0), 0x0000);
 	/*
 	 * ------------------- 9 -------------------
-	 * Set DFIMISC.dfi_init_start to 1 
+	 * Set DFIMISC.dfi_init_start to 1
 	 *  -----------------------------------------
 	 */
 	reg32_write(DDRC_DFIMISC(0), 0x00000030);
diff --git a/arch/arm/dts/imx6qdl-nitrogen6_max.dtsi b/arch/arm/dts/imx6qdl-nitrogen6_max.dtsi
index 5d301289f3ed..0f6d17ad6ce5 100644
--- a/arch/arm/dts/imx6qdl-nitrogen6_max.dtsi
+++ b/arch/arm/dts/imx6qdl-nitrogen6_max.dtsi
@@ -39,7 +39,7 @@
  *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  *     OTHER DEALINGS IN THE SOFTWARE.
  */
- 
+
 / {
 	chosen {
 		environment {
diff --git a/arch/arm/dts/vf610.dtsi b/arch/arm/dts/vf610.dtsi
index 3060031b8aaf..d1297e952c00 100644
--- a/arch/arm/dts/vf610.dtsi
+++ b/arch/arm/dts/vf610.dtsi
@@ -9,4 +9,4 @@
 		mmc0 = &esdhc0;
 		mmc1 = &esdhc1;
 	};
-};	
+};
diff --git a/arch/arm/dts/zynq-7000.dtsi b/arch/arm/dts/zynq-7000.dtsi
index 3791f743a47d..f7a0d70babef 100644
--- a/arch/arm/dts/zynq-7000.dtsi
+++ b/arch/arm/dts/zynq-7000.dtsi
@@ -8,7 +8,7 @@
 		clocks = <&clkc 10>, <&clkc 43>;
 		clock-names = "ref_clk", "pclk";
 		status = "disabled";
-		
+
 		#address-cells = <1>;
 		#size-cells = <0>;
 	};
diff --git a/arch/arm/mach-at91/sam9263_ll.c b/arch/arm/mach-at91/sam9263_ll.c
index 2beeaccd618e..8855a679fdf2 100644
--- a/arch/arm/mach-at91/sam9263_ll.c
+++ b/arch/arm/mach-at91/sam9263_ll.c
@@ -17,12 +17,12 @@ static void sam9263_pmc_init(const struct sam92_pmc_config *config)
 	/* Setting PLL A and divider A */
 	at91_pmc_cfg_plla(IOMEM(AT91SAM926X_BASE_PMC),
 			  AT91_PMC_MUL_(config->mula) |
-			  AT91_PMC_OUT_2 |		// 190 to 240 MHz		
+			  AT91_PMC_OUT_2 |		// 190 to 240 MHz
 			  config->diva,			// Divider
 			  0);
 
 	/* Selection of Master Clock and Processor Clock */
-	 
+
 	/* PCK = PLLA = 2 * MCK */
 	at91_pmc_cfg_mck(IOMEM(AT91SAM926X_BASE_PMC),
 			 AT91_PMC_CSS_SLOW
diff --git a/arch/arm/mach-omap/am33xx_bbu_nand.c b/arch/arm/mach-omap/am33xx_bbu_nand.c
index 2041cf3c0b46..40e382780a9c 100644
--- a/arch/arm/mach-omap/am33xx_bbu_nand.c
+++ b/arch/arm/mach-omap/am33xx_bbu_nand.c
@@ -213,7 +213,7 @@ static int nand_update_handler_complete(struct bbu_handler *handler,
 
 		buf = xzalloc(mtd->erasesize);
 		memcpy(buf, data->image, data->len);
-	
+
 		for (i = 0; i < 4; i++) {
 			if (mtd_peb_is_bad(mtd, i)) {
 				pr_info("PEB%d is bad, skipping\n", i);
diff --git a/commands/of_overlay.c b/commands/of_overlay.c
index b80f371c5c93..b0ca57749bf6 100644
--- a/commands/of_overlay.c
+++ b/commands/of_overlay.c
@@ -36,7 +36,7 @@ static int do_of_overlay(int argc, char *argv[])
 		printf("Support for live tree overlays is disabled. Enable CONFIG_OF_OVERLAY_LIVE\n");
 		return 1;
 	}
-		
+
 	fdt = read_file(argv[optind], &size);
 	if (!fdt) {
 		printf("cannot read %s\n", argv[optind]);
diff --git a/drivers/clk/clk-qoric.c b/drivers/clk/clk-qoric.c
index f7dbf7230d9f..667ce6df298b 100644
--- a/drivers/clk/clk-qoric.c
+++ b/drivers/clk/clk-qoric.c
@@ -592,7 +592,7 @@ static void __init clockgen_init(struct device_node *np,
 		pr_err("sysclk not found: %pe\n", clockgen.sysclk);
 		return;
 	}
-	
+
 	clockgen.coreclk = of_clk_get(clockgen.node, 1);
 	if (IS_ERR(clockgen.coreclk))
 		clockgen.coreclk = NULL;
diff --git a/drivers/ddr/fsl/ctrl_regs.c b/drivers/ddr/fsl/ctrl_regs.c
index b0d98a929c5d..7c882946b9df 100644
--- a/drivers/ddr/fsl/ctrl_regs.c
+++ b/drivers/ddr/fsl/ctrl_regs.c
@@ -284,7 +284,7 @@ static void set_timing_cfg_0(struct fsl_ddr_controller *c)
 		/*
 		 * for single quad-rank DIMM and two-slot DIMMs
 		 * to avoid ODT overlap
-		 */ 
+		 */
 		switch (avoid_odt_overlap(c, dimm_params)) {
 		case 2:
 			twrt_mclk = 2;
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 1cfd65f40816..f50b860c45c3 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -40,7 +40,7 @@ config NAND_IMX
 	  "MXC" series:  i.MX21/25/27/31/35/51/53.
 
 	  This is not for the "MXS" series i.MX processors (23 & 28), or i.MX6
-	  and later, which use the GPMI NAND controller from the MXS series. 
+	  and later, which use the GPMI NAND controller from the MXS series.
 	  See the i.MX 'mxs' driver for those chips.
 
 config NAND_FSL_IFC
diff --git a/drivers/mtd/nand/nand_omap_gpmc.c b/drivers/mtd/nand/nand_omap_gpmc.c
index c5e50d27c862..ab3618300511 100644
--- a/drivers/mtd/nand/nand_omap_gpmc.c
+++ b/drivers/mtd/nand/nand_omap_gpmc.c
@@ -54,7 +54,7 @@
  * Copyright (c) 2004 Micron Technology Inc.
  * Copyright (c) 2004 David Brownell
  *
- * 
+ *
  */
 
 #include <common.h>
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
index 318eb9be026c..c6108c488be6 100644
--- a/drivers/net/usb/ax88179_178a.c
+++ b/drivers/net/usb/ax88179_178a.c
@@ -469,7 +469,7 @@ static int ax88179_rx_fixup(struct usbnet *dev, void *buf, int len)
 			__func__, frame_pos, pkt_len);
 
 		net_receive(&dev->edev, buf + frame_pos, pkt_len);
-		
+
 		pkt_hdr++;
 		frame_pos += ((pkt_len + 7) & 0xfff8) - 2;
 	}
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 97f359d6d29f..f914641c8777 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -287,7 +287,7 @@ static struct regulator_internal *of_regulator_get(struct device *dev,
 
 	ret = of_device_ensure_probed(node);
 	if (ret) {
-		/* 
+		/*
 		 * If "barebox,allow-dummy-supply" property is set for regulator
 		 * provider allow use of dummy regulator (NULL is returned).
 		 * Check regulator node and its parent if this setting is set
diff --git a/drivers/serial/serial_omap4_usbboot.c b/drivers/serial/serial_omap4_usbboot.c
index 709398966ff2..6592be4f353b 100644
--- a/drivers/serial/serial_omap4_usbboot.c
+++ b/drivers/serial/serial_omap4_usbboot.c
@@ -54,7 +54,7 @@ static int serial_omap4_usbboot_probe(struct device *dev)
 	ret = omap4_usbboot_open();
 	if (ret)
 		return ret;
-	
+
 	priv = xzalloc(sizeof(*priv));
 
 	priv->cdev.dev = dev;
diff --git a/include/crypto/des.h b/include/crypto/des.h
index abc3d9c59d01..645a9c9969eb 100644
--- a/include/crypto/des.h
+++ b/include/crypto/des.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 
-/* 
+/*
  * DES & Triple DES EDE Cipher Algorithms.
  */
 
diff --git a/include/linux/idr.h b/include/linux/idr.h
index 8a0f452d766d..50c9e3f81ade 100644
--- a/include/linux/idr.h
+++ b/include/linux/idr.h
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
  * include/linux/idr.h
- * 
+ *
  * 2002-10-18  written by Jim Houston jim.houston@ccur.com
  *	Copyright (C) 2002 by Concurrent Computer Corporation
  *
diff --git a/include/tlsf.h b/include/tlsf.h
index 161176d5ac84..3fa220371577 100644
--- a/include/tlsf.h
+++ b/include/tlsf.h
@@ -11,10 +11,10 @@
 **
 ** This implementation was written to the specification
 ** of the document, therefore no GPL restrictions apply.
-** 
+**
 ** Copyright (c) 2006-2016, Matthew Conte
 ** All rights reserved.
-** 
+**
 ** Redistribution and use in source and binary forms, with or without
 ** modification, are permitted provided that the following conditions are met:
 **     * Redistributions of source code must retain the above copyright
@@ -25,7 +25,7 @@
 **     * Neither the name of the copyright holder nor the
 **       names of its contributors may be used to endorse or promote products
 **       derived from this software without specific prior written permission.
-** 
+**
 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
diff --git a/scripts/socfpga_import_preloader b/scripts/socfpga_import_preloader
index 2bec9f2d2173..bd54e1b913ba 100755
--- a/scripts/socfpga_import_preloader
+++ b/scripts/socfpga_import_preloader
@@ -8,7 +8,7 @@ usage() {
 	  -b|--board <BOARD_DIRECTORY>
 	optional:
 	  -e|--embedded-sdk <ALTERA_EMBEDDED_SDK>"
-	echo "EXAMPLE: $0 -i ~/cv_soc_devkit_ghrd/hps_isw_handoff/soc_system_hps_0/ -b arch/arm/boards/altera-socdk -e ~/altera-embedded-sdk/" 
+	echo "EXAMPLE: $0 -i ~/cv_soc_devkit_ghrd/hps_isw_handoff/soc_system_hps_0/ -b arch/arm/boards/altera-socdk -e ~/altera-embedded-sdk/"
 	exit 1
 }
 
-- 
2.38.4




^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 5/7] driver: be explicit about supported #feature-cells
  2023-04-24 12:17 [PATCH 1/7] sandbox: watchdog: handle missing stickypage gracefully Ahmad Fatoum
                   ` (2 preceding siblings ...)
  2023-04-24 12:18 ` [PATCH 4/7] treewide: drop trailing space Ahmad Fatoum
@ 2023-04-24 12:18 ` Ahmad Fatoum
  2023-04-24 12:18 ` [PATCH 6/7] featctrl: drop useless NULL check Ahmad Fatoum
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Ahmad Fatoum @ 2023-04-24 12:18 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

A feature controller may control the activation of multiple devices.
This is represented by a single index argument in the API. Thus any
value higher than #feature-cells = <1>; is unsupported, so let's be
explicit about that. #feature-cells = <0>; specs will just be
interpreted as if the argument was a 0.

Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
 drivers/base/featctrl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/base/featctrl.c b/drivers/base/featctrl.c
index abe21698ede7..f40b1f04bc1f 100644
--- a/drivers/base/featctrl.c
+++ b/drivers/base/featctrl.c
@@ -53,10 +53,13 @@ static struct feature_controller *featctrl_get_from_provider(struct of_phandle_a
 	if (ret < 0)
 		return ERR_PTR(ret);
 
+	if (spec->args_count > 1)
+		return ERR_PTR(-EINVAL);
+
 	/* Check if we have such a controller in our array */
 	list_for_each_entry(featctrl, &of_feature_controllers, list) {
 		if (dev_of_node(featctrl->dev) == spec->np) {
-			*gateid = spec->args[0];
+			*gateid = spec->args_count ? spec->args[0] : 0;
 			return featctrl;
 		}
 	}
-- 
2.38.4




^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 6/7] featctrl: drop useless NULL check
  2023-04-24 12:17 [PATCH 1/7] sandbox: watchdog: handle missing stickypage gracefully Ahmad Fatoum
                   ` (3 preceding siblings ...)
  2023-04-24 12:18 ` [PATCH 5/7] driver: be explicit about supported #feature-cells Ahmad Fatoum
@ 2023-04-24 12:18 ` Ahmad Fatoum
  2023-04-24 12:18 ` [PATCH 7/7] sandbox: hostfile: add feature controller support Ahmad Fatoum
  2023-05-02  9:34 ` [PATCH 1/7] sandbox: watchdog: handle missing stickypage gracefully Sascha Hauer
  6 siblings, 0 replies; 8+ messages in thread
From: Ahmad Fatoum @ 2023-04-24 12:18 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

The only instance of calling featctrl_get_from_provider looks like this:

  featctrl = featctrl_get_from_provider(&featctrl_args, &gateid);

Given that the function is static, there's no need to protect against
either argument being NULL, so drop the check.

Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
 drivers/base/featctrl.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/base/featctrl.c b/drivers/base/featctrl.c
index f40b1f04bc1f..0b81f801058d 100644
--- a/drivers/base/featctrl.c
+++ b/drivers/base/featctrl.c
@@ -46,9 +46,6 @@ static struct feature_controller *featctrl_get_from_provider(struct of_phandle_a
 	struct feature_controller *featctrl;
 	int ret;
 
-	if (!spec)
-		return ERR_PTR(-EINVAL);
-
 	ret = of_device_ensure_probed(spec->np);
 	if (ret < 0)
 		return ERR_PTR(ret);
-- 
2.38.4




^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 7/7] sandbox: hostfile: add feature controller support
  2023-04-24 12:17 [PATCH 1/7] sandbox: watchdog: handle missing stickypage gracefully Ahmad Fatoum
                   ` (4 preceding siblings ...)
  2023-04-24 12:18 ` [PATCH 6/7] featctrl: drop useless NULL check Ahmad Fatoum
@ 2023-04-24 12:18 ` Ahmad Fatoum
  2023-05-02  9:34 ` [PATCH 1/7] sandbox: watchdog: handle missing stickypage gracefully Sascha Hauer
  6 siblings, 0 replies; 8+ messages in thread
From: Ahmad Fatoum @ 2023-04-24 12:18 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Keeping the tradition of making the sandbox more complex than it needs
to in order to exercise more parts of barebox, let's allow hostfiles to
be feature controllers: This allows specifying optional hostfiles in the
DT: If the hostfile is unavailable, the nodes pointing at the hostfile
can be gated by it, so they behaves as if they were disabled.

This is useful for the stickypage, which results in a number of ugly
errors whenever it's unavailable.

Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
 arch/sandbox/board/hostfile.c          | 30 +++++++++++++++++++++++---
 arch/sandbox/configs/sandbox_defconfig |  2 ++
 arch/sandbox/dts/sandbox.dts           |  4 ++++
 drivers/base/Kconfig                   |  2 +-
 4 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c
index 424f16acd5fc..d0f400787d7a 100644
--- a/arch/sandbox/board/hostfile.c
+++ b/arch/sandbox/board/hostfile.c
@@ -24,6 +24,7 @@
 #include <errno.h>
 #include <linux/err.h>
 #include <mach/hostfile.h>
+#include <featctrl.h>
 #include <xfuncs.h>
 
 struct hf_priv {
@@ -33,6 +34,7 @@ struct hf_priv {
 	};
 	const char *filename;
 	int fd;
+	struct feature_controller feat;
 };
 
 static ssize_t hf_read(struct hf_priv *priv, void *buf, size_t count, loff_t offset, ulong flags)
@@ -96,18 +98,41 @@ static void hf_info(struct device *dev)
 	printf("file: %s\n", priv->filename);
 }
 
+static int hostfile_feat_check(struct feature_controller *feat, int idx)
+{
+	struct hf_priv *priv = container_of(feat, struct hf_priv, feat);
+
+	return priv->fd >= 0 ? FEATCTRL_OKAY : FEATCTRL_GATED;
+}
+
 static int hf_probe(struct device *dev)
 {
 	struct device_node *np = dev->of_node;
 	struct hf_priv *priv = xzalloc(sizeof(*priv));
 	struct cdev *cdev;
-	bool is_blockdev;
+	bool is_featctrl = false, is_blockdev;
 	u64 reg[2];
 	int err;
 
 	if (!np)
 		return -ENODEV;
 
+	dev->priv = priv;
+	priv->fd = -1;
+
+	if (IS_ENABLED(CONFIG_FEATURE_CONTROLLER) &&
+	    of_property_read_bool(np, "barebox,feature-controller")) {
+		priv->feat.dev = dev;
+		priv->feat.check = hostfile_feat_check;
+
+		err = feature_controller_register(&priv->feat);
+		if (err)
+			return err;
+
+		is_featctrl = true;
+	}
+
+
 	err = of_property_read_u64_array(np, "reg", reg, ARRAY_SIZE(reg));
 	if (err)
 		return err;
@@ -120,10 +145,9 @@ static int hf_probe(struct device *dev)
 		return err;
 
 	if (priv->fd < 0)
-		return priv->fd;
+		return is_featctrl ? 0 : priv->fd;
 
 	dev->info = hf_info;
-	dev->priv = priv;
 
 	is_blockdev = of_property_read_bool(np, "barebox,blockdev");
 
diff --git a/arch/sandbox/configs/sandbox_defconfig b/arch/sandbox/configs/sandbox_defconfig
index 16138d9274c4..1bb98c550c43 100644
--- a/arch/sandbox/configs/sandbox_defconfig
+++ b/arch/sandbox/configs/sandbox_defconfig
@@ -96,7 +96,9 @@ CONFIG_NET_NFS=y
 CONFIG_NET_NETCONSOLE=y
 CONFIG_NET_SNTP=y
 CONFIG_NET_FASTBOOT=y
+CONFIG_FEATURE_CONTROLLER=y
 CONFIG_OFDEVICE=y
+# CONFIG_FEATURE_CONTROLLER_FIXUP is not set
 CONFIG_OF_BAREBOX_DRIVERS=y
 CONFIG_OF_BAREBOX_ENV_IN_FS=y
 CONFIG_OF_OVERLAY_LIVE=y
diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts
index 5b2cab219e2a..75c633c5909f 100644
--- a/arch/sandbox/dts/sandbox.dts
+++ b/arch/sandbox/dts/sandbox.dts
@@ -31,6 +31,8 @@
 		backend = <&part_state>;
 		backend-storage-type = "direct";
 		backend-stridesize = <64>;
+		/* suppres sandbox warnings when stickypage is missing */
+		barebox,feature-gates = <&stickypage>;
 
 		#address-cells = <1>;
 		#size-cells = <1>;
@@ -58,6 +60,8 @@
 		barebox,filename = "$build/stickypage.bin";
 		reg = <0 0 0 4096>;
 		barebox,cdev; /* no caching allowed */
+		barebox,feature-controller;
+		#feature-cells = <0>;
 
 		bmode: reboot-mode {
 			compatible = "nvmem-reboot-mode";
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 3788231b6e82..612a84be33e7 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -4,6 +4,6 @@ config PM_GENERIC_DOMAINS
 	bool
 
 config FEATURE_CONTROLLER
-	bool "Feature controller support" if COMPILE_TEST
+	bool "Feature controller support" if COMPILE_TEST || SANDBOX
 
 source "drivers/base/regmap/Kconfig"
-- 
2.38.4




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/7] sandbox: watchdog: handle missing stickypage gracefully
  2023-04-24 12:17 [PATCH 1/7] sandbox: watchdog: handle missing stickypage gracefully Ahmad Fatoum
                   ` (5 preceding siblings ...)
  2023-04-24 12:18 ` [PATCH 7/7] sandbox: hostfile: add feature controller support Ahmad Fatoum
@ 2023-05-02  9:34 ` Sascha Hauer
  6 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2023-05-02  9:34 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

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 |



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-05-02  9:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-24 12:17 [PATCH 1/7] sandbox: watchdog: handle missing stickypage gracefully 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 ` [PATCH 1/7] sandbox: watchdog: handle missing stickypage gracefully Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox