[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230801-dt-changeset-fixes-v3-3-5f0410e007dd@kernel.org>
Date: Fri, 18 Aug 2023 15:40:58 -0500
From: Rob Herring <robh@...nel.org>
To: Frank Rowand <frowand.list@...il.com>,
"Enrico Weigelt, metux IT consult" <info@...ux.net>,
"Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
Sakari Ailus <sakari.ailus@...ux.intel.com>,
Petr Mladek <pmladek@...e.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Geert Uytterhoeven <geert+renesas@...der.be>
Cc: devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH v3 3/6] of: dynamic: Refactor changeset action printing to
common helpers
Several places print the changeset action with node and property
details. Refactor these into a common printing helper. The complicating
factor is some prints are debug and some are errors. Solve this with a
bit of preprocessor magic.
Signed-off-by: Rob Herring <robh@...nel.org>
---
v3:
- Drop printing changeset entry pointers
v2:
- Split out refactoring from fix in prior patch
- Avoid pr_cont and relying on pr_debug return value which dynamic
debug doesn't have
---
drivers/of/dynamic.c | 53 +++++++++++-----------------------------------------
1 file changed, 11 insertions(+), 42 deletions(-)
diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
index 4999636eaa92..17a0727d3f9b 100644
--- a/drivers/of/dynamic.c
+++ b/drivers/of/dynamic.c
@@ -72,27 +72,21 @@ static const char *action_names[] = {
[OF_RECONFIG_UPDATE_PROPERTY] = "UPDATE_PROPERTY",
};
+#define _do_print(func, prefix, action, node, prop, ...) ({ \
+ func("changeset: " prefix "%-15s %pOF%s%s\n", \
+ ##__VA_ARGS__, action_names[action], node, \
+ prop ? ":" : "", prop ? prop->name : ""); \
+})
+#define of_changeset_action_err(...) _do_print(pr_err, __VA_ARGS__)
+#define of_changeset_action_debug(...) _do_print(pr_debug, __VA_ARGS__)
+
int of_reconfig_notify(unsigned long action, struct of_reconfig_data *p)
{
int rc;
-#ifdef DEBUG
struct of_reconfig_data *pr = p;
- switch (action) {
- case OF_RECONFIG_ATTACH_NODE:
- case OF_RECONFIG_DETACH_NODE:
- pr_debug("notify %-15s %pOF\n", action_names[action],
- pr->dn);
- break;
- case OF_RECONFIG_ADD_PROPERTY:
- case OF_RECONFIG_REMOVE_PROPERTY:
- case OF_RECONFIG_UPDATE_PROPERTY:
- pr_debug("notify %-15s %pOF:%s\n", action_names[action],
- pr->dn, pr->prop->name);
- break;
+ of_changeset_action_debug("notify: ", action, pr->dn, pr->prop);
- }
-#endif
rc = blocking_notifier_call_chain(&of_reconfig_chain, action, p);
return notifier_to_errno(rc);
}
@@ -503,30 +497,6 @@ static void __of_changeset_entry_destroy(struct of_changeset_entry *ce)
kfree(ce);
}
-#ifdef DEBUG
-static void __of_changeset_entry_dump(struct of_changeset_entry *ce)
-{
- switch (ce->action) {
- case OF_RECONFIG_ADD_PROPERTY:
- case OF_RECONFIG_REMOVE_PROPERTY:
- case OF_RECONFIG_UPDATE_PROPERTY:
- pr_debug("cset<%p> %-15s %pOF/%s\n", ce, action_names[ce->action],
- ce->np, ce->prop->name);
- break;
- case OF_RECONFIG_ATTACH_NODE:
- case OF_RECONFIG_DETACH_NODE:
- pr_debug("cset<%p> %-15s %pOF\n", ce, action_names[ce->action],
- ce->np);
- break;
- }
-}
-#else
-static inline void __of_changeset_entry_dump(struct of_changeset_entry *ce)
-{
- /* empty */
-}
-#endif
-
static void __of_changeset_entry_invert(struct of_changeset_entry *ce,
struct of_changeset_entry *rce)
{
@@ -598,7 +568,7 @@ static int __of_changeset_entry_apply(struct of_changeset_entry *ce)
unsigned long flags;
int ret = 0;
- __of_changeset_entry_dump(ce);
+ of_changeset_action_debug("applying: ", ce->action, ce->np, ce->prop);
raw_spin_lock_irqsave(&devtree_lock, flags);
switch (ce->action) {
@@ -642,8 +612,7 @@ static int __of_changeset_entry_apply(struct of_changeset_entry *ce)
raw_spin_unlock_irqrestore(&devtree_lock, flags);
if (ret) {
- pr_err("changeset: apply failed: %-15s %pOF:%s\n",
- action_names[ce->action], ce->np, ce->prop->name);
+ of_changeset_action_err("apply failed: ", ce->action, ce->np, ce->prop);
return ret;
}
--
2.40.1
Powered by blists - more mailing lists