linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] memory: stm32_omm: Use syscon_regmap_lookup_by_phandle_args
@ 2025-05-25 19:13 Krzysztof Kozlowski
  2025-05-26  6:41 ` Patrice CHOTARD
  2025-06-10  8:23 ` Krzysztof Kozlowski
  0 siblings, 2 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2025-05-25 19:13 UTC (permalink / raw)
  To: Patrice Chotard, Krzysztof Kozlowski, Maxime Coquelin,
	Alexandre Torgue, linux-kernel, linux-stm32, linux-arm-kernel
  Cc: Krzysztof Kozlowski

Use syscon_regmap_lookup_by_phandle_args() which is a wrapper over
syscon_regmap_lookup_by_phandle() combined with getting the syscon
argument.  Except simpler code this annotates within one line that given
phandle has arguments, so grepping for code would be easier.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

---

Not tested on hardware.
---
 drivers/memory/stm32_omm.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/memory/stm32_omm.c b/drivers/memory/stm32_omm.c
index 79ceb1635698..bee2ecc8c2b9 100644
--- a/drivers/memory/stm32_omm.c
+++ b/drivers/memory/stm32_omm.c
@@ -46,7 +46,7 @@ static int stm32_omm_set_amcr(struct device *dev, bool set)
 	struct regmap *syscfg_regmap;
 	struct device_node *node;
 	struct resource res, res1;
-	u32 amcr_base, amcr_mask;
+	unsigned int syscon_args[2];
 	int ret, idx;
 	unsigned int i, amcr, read_amcr;
 
@@ -98,29 +98,20 @@ static int stm32_omm_set_amcr(struct device *dev, bool set)
 		of_node_put(node);
 	}
 
-	syscfg_regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "st,syscfg-amcr");
+	syscfg_regmap = syscon_regmap_lookup_by_phandle_args(dev->of_node, "st,syscfg-amcr",
+							     2, syscon_args);
 	if (IS_ERR(syscfg_regmap))
 		return dev_err_probe(dev, PTR_ERR(syscfg_regmap),
 				     "Failed to get st,syscfg-amcr property\n");
 
-	ret = of_property_read_u32_index(dev->of_node, "st,syscfg-amcr", 1,
-					 &amcr_base);
-	if (ret)
-		return ret;
-
-	ret = of_property_read_u32_index(dev->of_node, "st,syscfg-amcr", 2,
-					 &amcr_mask);
-	if (ret)
-		return ret;
-
 	amcr = mm_ospi2_size / SZ_64M;
 
 	if (set)
-		regmap_update_bits(syscfg_regmap, amcr_base, amcr_mask, amcr);
+		regmap_update_bits(syscfg_regmap, syscon_args[0], syscon_args[1], amcr);
 
 	/* read AMCR and check coherency with memory-map areas defined in DT */
-	regmap_read(syscfg_regmap, amcr_base, &read_amcr);
-	read_amcr = read_amcr >> (ffs(amcr_mask) - 1);
+	regmap_read(syscfg_regmap, syscon_args[0], &read_amcr);
+	read_amcr = read_amcr >> (ffs(syscon_args[1]) - 1);
 
 	if (amcr != read_amcr) {
 		dev_err(dev, "AMCR value not coherent with DT memory-map areas\n");
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] memory: stm32_omm: Use syscon_regmap_lookup_by_phandle_args
  2025-05-25 19:13 [PATCH] memory: stm32_omm: Use syscon_regmap_lookup_by_phandle_args Krzysztof Kozlowski
@ 2025-05-26  6:41 ` Patrice CHOTARD
  2025-06-10  8:23 ` Krzysztof Kozlowski
  1 sibling, 0 replies; 3+ messages in thread
From: Patrice CHOTARD @ 2025-05-26  6:41 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Krzysztof Kozlowski, Maxime Coquelin,
	Alexandre Torgue, linux-kernel, linux-stm32, linux-arm-kernel



On 5/25/25 21:13, Krzysztof Kozlowski wrote:
> Use syscon_regmap_lookup_by_phandle_args() which is a wrapper over
> syscon_regmap_lookup_by_phandle() combined with getting the syscon
> argument.  Except simpler code this annotates within one line that given
> phandle has arguments, so grepping for code would be easier.
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> 
> ---
> 
> Not tested on hardware.
> ---
>  drivers/memory/stm32_omm.c | 21 ++++++---------------
>  1 file changed, 6 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/memory/stm32_omm.c b/drivers/memory/stm32_omm.c
> index 79ceb1635698..bee2ecc8c2b9 100644
> --- a/drivers/memory/stm32_omm.c
> +++ b/drivers/memory/stm32_omm.c
> @@ -46,7 +46,7 @@ static int stm32_omm_set_amcr(struct device *dev, bool set)
>  	struct regmap *syscfg_regmap;
>  	struct device_node *node;
>  	struct resource res, res1;
> -	u32 amcr_base, amcr_mask;
> +	unsigned int syscon_args[2];
>  	int ret, idx;
>  	unsigned int i, amcr, read_amcr;
>  
> @@ -98,29 +98,20 @@ static int stm32_omm_set_amcr(struct device *dev, bool set)
>  		of_node_put(node);
>  	}
>  
> -	syscfg_regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "st,syscfg-amcr");
> +	syscfg_regmap = syscon_regmap_lookup_by_phandle_args(dev->of_node, "st,syscfg-amcr",
> +							     2, syscon_args);
>  	if (IS_ERR(syscfg_regmap))
>  		return dev_err_probe(dev, PTR_ERR(syscfg_regmap),
>  				     "Failed to get st,syscfg-amcr property\n");
>  
> -	ret = of_property_read_u32_index(dev->of_node, "st,syscfg-amcr", 1,
> -					 &amcr_base);
> -	if (ret)
> -		return ret;
> -
> -	ret = of_property_read_u32_index(dev->of_node, "st,syscfg-amcr", 2,
> -					 &amcr_mask);
> -	if (ret)
> -		return ret;
> -
>  	amcr = mm_ospi2_size / SZ_64M;
>  
>  	if (set)
> -		regmap_update_bits(syscfg_regmap, amcr_base, amcr_mask, amcr);
> +		regmap_update_bits(syscfg_regmap, syscon_args[0], syscon_args[1], amcr);
>  
>  	/* read AMCR and check coherency with memory-map areas defined in DT */
> -	regmap_read(syscfg_regmap, amcr_base, &read_amcr);
> -	read_amcr = read_amcr >> (ffs(amcr_mask) - 1);
> +	regmap_read(syscfg_regmap, syscon_args[0], &read_amcr);
> +	read_amcr = read_amcr >> (ffs(syscon_args[1]) - 1);
>  
>  	if (amcr != read_amcr) {
>  		dev_err(dev, "AMCR value not coherent with DT memory-map areas\n");

Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>

Thanks
Patrice

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] memory: stm32_omm: Use syscon_regmap_lookup_by_phandle_args
  2025-05-25 19:13 [PATCH] memory: stm32_omm: Use syscon_regmap_lookup_by_phandle_args Krzysztof Kozlowski
  2025-05-26  6:41 ` Patrice CHOTARD
@ 2025-06-10  8:23 ` Krzysztof Kozlowski
  1 sibling, 0 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2025-06-10  8:23 UTC (permalink / raw)
  To: Patrice Chotard, Krzysztof Kozlowski, Maxime Coquelin,
	Alexandre Torgue, linux-kernel, linux-stm32, linux-arm-kernel,
	Krzysztof Kozlowski


On Sun, 25 May 2025 21:13:00 +0200, Krzysztof Kozlowski wrote:
> Use syscon_regmap_lookup_by_phandle_args() which is a wrapper over
> syscon_regmap_lookup_by_phandle() combined with getting the syscon
> argument.  Except simpler code this annotates within one line that given
> phandle has arguments, so grepping for code would be easier.
> 
> 

Applied, thanks!

[1/1] memory: stm32_omm: Use syscon_regmap_lookup_by_phandle_args
      https://git.kernel.org/krzk/linux-mem-ctrl/c/6d8b18ae647bb456d2a2dac9771d007f243537cf

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-06-10  8:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-25 19:13 [PATCH] memory: stm32_omm: Use syscon_regmap_lookup_by_phandle_args Krzysztof Kozlowski
2025-05-26  6:41 ` Patrice CHOTARD
2025-06-10  8:23 ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).