Skip to content

Commit 6d8b18a

Browse files
committed
memory: stm32_omm: Use syscon_regmap_lookup_by_phandle_args
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. Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com> Link: https://lore.kernel.org/r/20250525191300.50873-2-krzysztof.kozlowski@linaro.org Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
1 parent 43f9c5c commit 6d8b18a

1 file changed

Lines changed: 6 additions & 15 deletions

File tree

drivers/memory/stm32_omm.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static int stm32_omm_set_amcr(struct device *dev, bool set)
4646
struct regmap *syscfg_regmap;
4747
struct device_node *node;
4848
struct resource res, res1;
49-
u32 amcr_base, amcr_mask;
49+
unsigned int syscon_args[2];
5050
int ret, idx;
5151
unsigned int i, amcr, read_amcr;
5252

@@ -98,29 +98,20 @@ static int stm32_omm_set_amcr(struct device *dev, bool set)
9898
of_node_put(node);
9999
}
100100

101-
syscfg_regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "st,syscfg-amcr");
101+
syscfg_regmap = syscon_regmap_lookup_by_phandle_args(dev->of_node, "st,syscfg-amcr",
102+
2, syscon_args);
102103
if (IS_ERR(syscfg_regmap))
103104
return dev_err_probe(dev, PTR_ERR(syscfg_regmap),
104105
"Failed to get st,syscfg-amcr property\n");
105106

106-
ret = of_property_read_u32_index(dev->of_node, "st,syscfg-amcr", 1,
107-
&amcr_base);
108-
if (ret)
109-
return ret;
110-
111-
ret = of_property_read_u32_index(dev->of_node, "st,syscfg-amcr", 2,
112-
&amcr_mask);
113-
if (ret)
114-
return ret;
115-
116107
amcr = mm_ospi2_size / SZ_64M;
117108

118109
if (set)
119-
regmap_update_bits(syscfg_regmap, amcr_base, amcr_mask, amcr);
110+
regmap_update_bits(syscfg_regmap, syscon_args[0], syscon_args[1], amcr);
120111

121112
/* read AMCR and check coherency with memory-map areas defined in DT */
122-
regmap_read(syscfg_regmap, amcr_base, &read_amcr);
123-
read_amcr = read_amcr >> (ffs(amcr_mask) - 1);
113+
regmap_read(syscfg_regmap, syscon_args[0], &read_amcr);
114+
read_amcr = read_amcr >> (ffs(syscon_args[1]) - 1);
124115

125116
if (amcr != read_amcr) {
126117
dev_err(dev, "AMCR value not coherent with DT memory-map areas\n");

0 commit comments

Comments
 (0)