[PATCH 2/8] restart: do restart-priority OF parsing in restart_handler_register
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Oct 17 00:09:54 PDT 2022
The restart-priority OF property is parsed for a number of MFDs, but
there is no reason really not to parse it for every restart handler that
has a device tree node like we already do for watchdogs.
Add a new struct restart_handler::of_node field and look into it if
populated. With this of_get_restart_priority, is no longer used, so drop it.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
.../devicetree/bindings/power/restart.rst | 10 ++++++++++
common/restart.c | 20 +++++--------------
drivers/mfd/da9053.c | 2 +-
drivers/mfd/da9063.c | 2 +-
drivers/mfd/rn5t568.c | 2 +-
include/restart.h | 5 +++--
6 files changed, 21 insertions(+), 20 deletions(-)
create mode 100644 Documentation/devicetree/bindings/power/restart.rst
diff --git a/Documentation/devicetree/bindings/power/restart.rst b/Documentation/devicetree/bindings/power/restart.rst
new file mode 100644
index 000000000000..8c866f6e0ded
--- /dev/null
+++ b/Documentation/devicetree/bindings/power/restart.rst
@@ -0,0 +1,10 @@
+System Restart Controllers
+==========================
+
+In addition to upstream bindings, following properties are understood:
+
+Optional properties:
+
+- ``restart-priority`` : Overrides the priority set by the driver. Normally,
+ the device with the biggest reach should reset the system.
+ See :ref:`_system_reset` for more information.
diff --git a/common/restart.c b/common/restart.c
index b6f2bbf25b10..9e988838bc60 100644
--- a/common/restart.c
+++ b/common/restart.c
@@ -27,6 +27,11 @@ int restart_handler_register(struct restart_handler *rst)
if (!rst->priority)
rst->priority = RESTART_DEFAULT_PRIORITY;
+ if (rst->of_node) {
+ of_property_read_u32(rst->of_node, "restart-priority",
+ &rst->priority);
+ }
+
list_add_tail(&rst->list, &restart_handler_list);
pr_debug("registering restart handler \"%s\" with priority %d\n",
@@ -102,21 +107,6 @@ void __noreturn restart_machine(void)
hang();
}
-/**
- * of_get_restart_priority() - get the desired restart priority from device tree
- * @node: The device_node to read the property from
- *
- * return: The priority
- */
-unsigned int of_get_restart_priority(struct device_node *node)
-{
- unsigned int priority = RESTART_DEFAULT_PRIORITY;
-
- of_property_read_u32(node, "restart-priority", &priority);
-
- return priority;
-}
-
/*
* restart_handlers_print - print informations about all restart handlers
*/
diff --git a/drivers/mfd/da9053.c b/drivers/mfd/da9053.c
index 99827c968922..693c0ca606f7 100644
--- a/drivers/mfd/da9053.c
+++ b/drivers/mfd/da9053.c
@@ -272,7 +272,7 @@ static int da9053_probe(struct device_d *dev)
da9053_detect_reset_source(da9053);
- da9053->restart.priority = of_get_restart_priority(dev->device_node);
+ da9053->restart.of_node = dev->device_node;
da9053->restart.name = "da9063";
da9053->restart.restart = &da9053_force_system_reset;
diff --git a/drivers/mfd/da9063.c b/drivers/mfd/da9063.c
index a4e5226f3c98..4627dd1aa5a2 100644
--- a/drivers/mfd/da9063.c
+++ b/drivers/mfd/da9063.c
@@ -383,7 +383,7 @@ static int da9063_probe(struct device_d *dev)
da9063_detect_reset_source(priv);
- priv->restart.priority = of_get_restart_priority(dev->device_node);
+ priv->restart.of_node = dev->device_node;
priv->restart.name = "da9063";
priv->restart.restart = &da9063_restart;
diff --git a/drivers/mfd/rn5t568.c b/drivers/mfd/rn5t568.c
index c1c792cbecf0..4bbab54fe48b 100644
--- a/drivers/mfd/rn5t568.c
+++ b/drivers/mfd/rn5t568.c
@@ -138,7 +138,7 @@ static int __init rn5t568_i2c_probe(struct device_d *dev)
regmap_write(pmic_instance->regmap, RN5T568_REPCNT, RN5T568_REPCNT_OFF_RESETO_16MS |
RN5T568_REPCNT_OFF_REPWRTIM_1000MS | RN5T568_REPCNT_OFF_REPWRON);
- pmic_instance->restart.priority = of_get_restart_priority(dev->device_node);
+ pmic_instance->restart.of_node = dev->device_node;
pmic_instance->restart.name = "RN5T568";
pmic_instance->restart.restart = &rn5t568_restart;
restart_handler_register(&pmic_instance->restart);
diff --git a/include/restart.h b/include/restart.h
index 27fab1b80dfb..330b50a53ab2 100644
--- a/include/restart.h
+++ b/include/restart.h
@@ -11,9 +11,12 @@ void restart_handlers_print(void);
void __noreturn restart_machine(void);
struct restart_handler *restart_handler_get_by_name(const char *name);
+struct device_node;
+
struct restart_handler {
void (*restart)(struct restart_handler *);
int priority;
+ struct device_node *of_node;
const char *name;
struct list_head list;
};
@@ -24,6 +27,4 @@ int restart_handler_register_fn(const char *name,
#define RESTART_DEFAULT_PRIORITY 100
-unsigned int of_get_restart_priority(struct device_node *node);
-
#endif /* __INCLUDE_RESTART_H */
--
2.30.2
More information about the barebox
mailing list