From nobody Wed Sep 10 09:18:12 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86D08EE499B for ; Fri, 18 Aug 2023 20:42:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380041AbjHRUly (ORCPT ); Fri, 18 Aug 2023 16:41:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380018AbjHRUlU (ORCPT ); Fri, 18 Aug 2023 16:41:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B2FC3C3D; Fri, 18 Aug 2023 13:41:19 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 360E76117F; Fri, 18 Aug 2023 20:41:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA842C433C8; Fri, 18 Aug 2023 20:41:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692391278; bh=H9GV+tg3g3GPDELoA8+aiKstqj5atxl9FDzEGMxPjA0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=s+N6KeRcSBoxKu4UhD0zZ8apA+v9Xqj3O0vBd+lAeU5HsELHKG5jr3WyzCwUZNDZX rLmZMCF64bgF4qIZtScxGmHYyGULe8TfAC75cpoI36MYApyNoq6sZXAvUyaOQQYc/V XynpZuO9ZUR3wS9v3hmWbtyBFSOtbgG+MDSGXp/Ga8e/1Qx6NO6hmMWYMbUY7cI3+C EN+cjJL2MNH3ncSKvozQvFgADzY7lSwDoNvC9gYImVw45zSl1tMJchK8TX1a8qWEzv /fYPz2OxmN7icBFGNSDlFjhuE1GLA6ommUawBNo8soOkMXNlGuonM1GmzRJP74qrXk AAelAlr0uYVJQ== Received: (nullmailer pid 545142 invoked by uid 1000); Fri, 18 Aug 2023 20:41:06 -0000 From: Rob Herring Date: Fri, 18 Aug 2023 15:40:58 -0500 Subject: [PATCH v3 3/6] of: dynamic: Refactor changeset action printing to common helpers MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230801-dt-changeset-fixes-v3-3-5f0410e007dd@kernel.org> References: <20230801-dt-changeset-fixes-v3-0-5f0410e007dd@kernel.org> In-Reply-To: <20230801-dt-changeset-fixes-v3-0-5f0410e007dd@kernel.org> To: Frank Rowand , "Enrico Weigelt, metux IT consult" , "Rafael J. Wysocki" , Sakari Ailus , Petr Mladek , Andy Shevchenko , Geert Uytterhoeven Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.13-dev Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Reviewed-by: Geert Uytterhoeven --- 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[] =3D { [OF_RECONFIG_UPDATE_PROPERTY] =3D "UPDATE_PROPERTY", }; =20 +#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 =3D p; =20 - 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); =20 - } -#endif rc =3D 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_cha= ngeset_entry *ce) kfree(ce); } =20 -#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_changes= et_entry *ce) unsigned long flags; int ret =3D 0; =20 - __of_changeset_entry_dump(ce); + of_changeset_action_debug("applying: ", ce->action, ce->np, ce->prop); =20 raw_spin_lock_irqsave(&devtree_lock, flags); switch (ce->action) { @@ -642,8 +612,7 @@ static int __of_changeset_entry_apply(struct of_changes= et_entry *ce) raw_spin_unlock_irqrestore(&devtree_lock, flags); =20 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; } =20 --=20 2.40.1