lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <bd1704a5-5504-4bb9-af6a-37c2849508a8@collabora.com>
Date: Tue, 11 Feb 2025 15:50:06 +0100
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
To: "Rob Herring (Arm)" <robh@...nel.org>, Lee Jones <lee@...nel.org>,
 Arnd Bergmann <arnd@...db.de>,
 Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>,
 Pankaj Dubey <pankaj.dubey@...sung.com>
Cc: Will McVicker <willmcvicker@...gle.com>,
 John Madieu <john.madieu.xa@...renesas.com>, Nishanth Menon <nm@...com>,
 Vaishnav Achath <vaishnav.a@...com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mfd: syscon: Restore device_node_to_regmap() for
 non-syscon nodes

Il 24/01/25 20:16, Rob Herring (Arm) ha scritto:
> 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@...gle.com>
> Cc: John Madieu <john.madieu.xa@...renesas.com>
> Cc: Nishanth Menon <nm@...com>
> Reported-by: Vaishnav Achath <vaishnav.a@...com>
> Signed-off-by: Rob Herring (Arm) <robh@...nel.org>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>

...and tested on

Radxa NIO 12L (MT8395/8195), MediaTek Genio 700 EVK (MT8390/MT8188), and on
MT8195 Tomato Chromebook

Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>

> ---
>   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);
>   


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ