From: Daniel Golle <daniel@makrotopia.org>
To: "Rob Herring (Arm)" <robh@kernel.org>
Cc: "Lee Jones" <lee@kernel.org>, "Arnd Bergmann" <arnd@arndb.de>,
"Krzysztof Kozlowski" <krzysztof.kozlowski@linaro.org>,
"Pankaj Dubey" <pankaj.dubey@samsung.com>,
"Will McVicker" <willmcvicker@google.com>,
"John Madieu" <john.madieu.xa@bp.renesas.com>,
"Nishanth Menon" <nm@ti.com>,
"Vaishnav Achath" <vaishnav.a@ti.com>,
"Frank Wunderlich" <frank-w@public-files.de>,
"Rafał Miłecki" <rafal@milecki.pl>,
"John Crispin" <john@phrozen.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mfd: syscon: Restore device_node_to_regmap() for non-syscon nodes
Date: Sun, 2 Feb 2025 22:57:42 +0000 [thread overview]
Message-ID: <Z5_4Zh7vbB2ku5so@makrotopia.org> (raw)
In-Reply-To: <20250124191644.2309790-1-robh@kernel.org>
On Fri, Jan 24, 2025 at 01:16:44PM -0600, Rob Herring (Arm) wrote:
> Commit ba5095ebbc7a ("mfd: syscon: Allow syscon nodes without a
> "syscon" compatible") broke drivers which call device_node_to_regmap()
> on nodes without a "syscon" compatible. Restore the prior behavior for
> device_node_to_regmap().
>
> This also makes using device_node_to_regmap() incompatible with
> of_syscon_register_regmap() again, so add kerneldoc for
> device_node_to_regmap() and syscon_node_to_regmap() to make it clear
> how and when each one should be used.
>
> Fixes: ba5095ebbc7a ("mfd: syscon: Allow syscon nodes without a "syscon" compatible")
> Cc: Will McVicker <willmcvicker@google.com>
> Cc: John Madieu <john.madieu.xa@bp.renesas.com>
> Cc: Nishanth Menon <nm@ti.com>
> Reported-by: Vaishnav Achath <vaishnav.a@ti.com>
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> ---
Reviewed-by: Daniel Golle <daniel@makrotopia.org>
Texted-by: Daniel Golle <daniel@makrotopia.org>
This fix is required to un-break various Mediatek clock drivers as
device_node_to_regmap() is used all over the place there (in
reset.c, clk-gate.c, clk-cpumux.c, clk-mux.c) and commit
3ba5a6159434 ("arm64: dts: mediatek: mt7622: fix clock controllers")
has droped all those unneeded "syscon"s.
> drivers/mfd/syscon.c | 29 ++++++++++++++++++++++++++---
> 1 file changed, 26 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
> index 226915ca3c93..aa4a9940b569 100644
> --- a/drivers/mfd/syscon.c
> +++ b/drivers/mfd/syscon.c
> @@ -159,6 +159,7 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_res)
> }
>
> static struct regmap *device_node_get_regmap(struct device_node *np,
> + bool create_regmap,
> bool check_res)
> {
> struct syscon *entry, *syscon = NULL;
> @@ -172,7 +173,7 @@ static struct regmap *device_node_get_regmap(struct device_node *np,
> }
>
> if (!syscon) {
> - if (of_device_is_compatible(np, "syscon"))
> + if (create_regmap)
> syscon = of_syscon_register(np, check_res);
> else
> syscon = ERR_PTR(-EINVAL);
> @@ -233,15 +234,37 @@ int of_syscon_register_regmap(struct device_node *np, struct regmap *regmap)
> }
> EXPORT_SYMBOL_GPL(of_syscon_register_regmap);
>
> +/**
> + * device_node_to_regmap() - Get or create a regmap for specified device node
> + * @np: Device tree node
> + *
> + * Get a regmap for the specified device node. If there's not an existing
> + * regmap, then one is instantiated. This function should not be used if the
> + * device node has a custom regmap driver or has resources (clocks, resets) to
> + * be managed. Use syscon_node_to_regmap() instead for those cases.
> + *
> + * Return: regmap ptr on success, negative error code on failure.
> + */
> struct regmap *device_node_to_regmap(struct device_node *np)
> {
> - return device_node_get_regmap(np, false);
> + return device_node_get_regmap(np, true, false);
> }
> EXPORT_SYMBOL_GPL(device_node_to_regmap);
>
> +/**
> + * syscon_node_to_regmap() - Get or create a regmap for specified syscon device node
> + * @np: Device tree node
> + *
> + * Get a regmap for the specified device node. If there's not an existing
> + * regmap, then one is instantiated if the node is a generic "syscon". This
> + * function is safe to use for a syscon registered with
> + * of_syscon_register_regmap().
> + *
> + * Return: regmap ptr on success, negative error code on failure.
> + */
> struct regmap *syscon_node_to_regmap(struct device_node *np)
> {
> - return device_node_get_regmap(np, true);
> + return device_node_get_regmap(np, of_device_is_compatible(np, "syscon"), true);
> }
> EXPORT_SYMBOL_GPL(syscon_node_to_regmap);
>
> --
> 2.45.2
>
next prev parent reply other threads:[~2025-02-02 22:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-24 19:16 [PATCH] mfd: syscon: Restore device_node_to_regmap() for non-syscon nodes Rob Herring (Arm)
2025-01-24 22:08 ` Nishanth Menon
2025-01-28 22:53 ` Nícolas F. R. A. Prado
2025-02-02 22:57 ` Daniel Golle [this message]
2025-02-03 13:16 ` Aw: " Frank Wunderlich
2025-02-04 9:21 ` Dhruva Gole
2025-02-07 9:00 ` Lee Jones
2025-02-10 6:17 ` Chen-Yu Tsai
2025-02-11 14:50 ` AngeloGioacchino Del Regno
2025-02-11 14:54 ` (subset) " Lee Jones
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=Z5_4Zh7vbB2ku5so@makrotopia.org \
--to=daniel@makrotopia.org \
--cc=arnd@arndb.de \
--cc=frank-w@public-files.de \
--cc=john.madieu.xa@bp.renesas.com \
--cc=john@phrozen.org \
--cc=krzysztof.kozlowski@linaro.org \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nm@ti.com \
--cc=pankaj.dubey@samsung.com \
--cc=rafal@milecki.pl \
--cc=robh@kernel.org \
--cc=vaishnav.a@ti.com \
--cc=willmcvicker@google.com \
/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