Skip to contentSkip to conversation

ASoC: Match DT helper types

PATCH In review Rob Herring (Arm) 2 participants 2 messages Jun 12 – Jun 14

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: Match DT helper types

The affected ASoC drivers read properties whose bindings use boolean flags, normal uint32 cells, or phandle-style arrays. Using helpers for a different encoding makes those accesses disagree with the binding.

Use helpers that match the documented encoding and keep the existing driver storage by copying through temporary values where needed.

Assisted-by Codex:gpt-5-5
---
 sound/soc/codecs/ak4642.c         | 2 +-
 sound/soc/codecs/sta32x.c         | 6 +++---
 sound/soc/codecs/sta350.c         | 6 +++---
 sound/soc/codecs/twl4030.c        | 6 ++----
 sound/soc/rockchip/rockchip_pdm.c | 3 +--
 5 files changed, 10 insertions(+), 13 deletions(-)
sound/soc/codecs/ak4642.c +1 -1
index fe035d2fc913..b68555c8fbaf 100644
@@ -613,7 +613,7 @@ static struct clk *ak4642_of_parse_mcko(struct device *dev)
 	if (of_property_read_u32(np, "clock-frequency", &rate))
 		return NULL;
 
-	if (of_property_read_bool(np, "clocks"))
+	if (of_property_present(np, "clocks"))
 		parent_clk_name = of_clk_get_parent_name(np, 0);
 
 	of_property_read_string(np, "clock-output-names", &clk_name);
sound/soc/codecs/sta32x.c +3 -3
index b9f9784f5164..857b729e6978 100644
@@ -1038,7 +1038,7 @@ static int sta32x_probe_dt(struct device *dev, struct sta32x_priv *sta32x)
 {
 	struct device_node *np = dev->of_node;
 	struct sta32x_platform_data *pdata;
-	u16 tmp;
+	u32 tmp;
 
 	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
 	if (!pdata)
@@ -1063,8 +1063,8 @@ static int sta32x_probe_dt(struct device *dev, struct sta32x_priv *sta32x)
 		of_property_read_bool(np, "st,needs_esd_watchdog");
 
 	tmp = 140;
-	of_property_read_u16(np, "st,drop-compensation-ns", &tmp);
-	pdata->drop_compensation_ns = clamp_t(u16, tmp, 0, 300) / 20;
+	of_property_read_u32(np, "st,drop-compensation-ns", &tmp);
+	pdata->drop_compensation_ns = clamp_t(u32, tmp, 0, 300) / 20;
 
 	/* CONFE */
 	pdata->max_power_use_mpcc =
sound/soc/codecs/sta350.c +3 -3
index 71af82b099c0..367d60577906 100644
@@ -1091,7 +1091,7 @@ static int sta350_probe_dt(struct device *dev, struct sta350_priv *sta350)
 	struct device_node *np = dev->of_node;
 	struct sta350_platform_data *pdata;
 	const char *ffx_power_mode;
-	u16 tmp;
+	u32 tmp;
 	u8 tmp8;
 
 	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
@@ -1131,8 +1131,8 @@ static int sta350_probe_dt(struct device *dev, struct sta350_priv *sta350)
 	}
 
 	tmp = 140;
-	of_property_read_u16(np, "st,drop-compensation-ns", &tmp);
-	pdata->drop_compensation_ns = clamp_t(u16, tmp, 0, 300) / 20;
+	of_property_read_u32(np, "st,drop-compensation-ns", &tmp);
+	pdata->drop_compensation_ns = clamp_t(u32, tmp, 0, 300) / 20;
 
 	pdata->oc_warning_adjustment =
 		of_property_read_bool(np, "st,overcurrent-warning-adjustment");
sound/soc/codecs/twl4030.c +2 -4
index 9476cdfd4dde..91f5f907951a 100644
@@ -202,13 +202,11 @@ static void
 twl4030_get_board_param_values(struct twl4030_board_params *board_params,
 			       struct device_node *node)
 {
-	int value;
-
 	of_property_read_u32(node, "ti,digimic_delay", &board_params->digimic_delay);
 	of_property_read_u32(node, "ti,ramp_delay_value", &board_params->ramp_delay_value);
 	of_property_read_u32(node, "ti,offset_cncl_path", &board_params->offset_cncl_path);
-	if (!of_property_read_u32(node, "ti,hs_extmute", &value))
-		board_params->hs_extmute = value;
+	if (of_property_read_bool(node, "ti,hs_extmute"))
+		board_params->hs_extmute = 1;
 
 	if (of_property_present(node, "ti,hs_extmute_gpio"))
 		board_params->hs_extmute = 1;
sound/soc/rockchip/rockchip_pdm.c +1 -2
index c69cdd6f2499..966105a544f5 100644
@@ -546,8 +546,7 @@ static int rockchip_pdm_path_parse(struct rk_pdm_dev *pdm, struct device_node *n
 	unsigned int path[PDM_PATH_MAX];
 	int cnt = 0, ret = 0, i = 0, val = 0, msk = 0;
 
-	cnt = of_count_phandle_with_args(node, "rockchip,path-map",
-					 NULL);
+	cnt = of_property_count_u32_elems(node, "rockchip,path-map");
 	if (cnt != PDM_PATH_MAX)
 		return cnt;
 
Signature · 1 line
2.53.0
maintainer
#1 lore raw
Quoted 6 lines · Rob Herring (Arm)

The affected ASoC drivers read properties whose bindings use boolean flags, normal uint32 cells, or phandle-style arrays. Using helpers for a different encoding makes those accesses disagree with the binding.

Use helpers that match the documented encoding and keep the existing driver storage by copying through temporary values where needed.

This feels like it would be easier to deal with as separate commits for each issue...

sound/soc/rockchip/rockchip_pdm.c static int rockchip_pdm_path_parse(struct rk_pdm_dev *pdm, struct device_node *n · line 551

Quoted 11 lines
sound/soc/rockchip/rockchip_pdm.c +1 -2
@@ -546,8 +546,7 @@ static int rockchip_pdm_path_parse(struct rk_pdm_dev *pdm, struct device_node *n
 	unsigned int path[PDM_PATH_MAX];
 	int cnt = 0, ret = 0, i = 0, val = 0, msk = 0;
 
-	cnt = of_count_phandle_with_args(node, "rockchip,path-map",
-					 NULL);
+	cnt = of_property_count_u32_elems(node, "rockchip,path-map");
 	if (cnt != PDM_PATH_MAX)
 		return cnt;

The error codes reported by these two functions for missing properties differ (-ENOENT vs -EINVAL) and the caller of this function has a specific check for -ENOENT which allows it.