Commit 2167c0b2 authored by Jiasheng Jiang's avatar Jiasheng Jiang Committed by Mark Brown

ASoC: rt5663: Handle device_property_read_u32_array error codes

The return value of device_property_read_u32_array() is not always 0.
To catch the exception in case that devm_kzalloc failed and the
rt5663->imp_table was NULL, which caused the failure of
device_property_read_u32_array.

Fixes: 450f0f6a ("ASoC: rt5663: Add the manual offset field to compensate the DC offset")
Signed-off-by: default avatarJiasheng Jiang <jiasheng@iscas.ac.cn>
Link: https://lore.kernel.org/r/20211215031550.70702-1-jiasheng@iscas.ac.cnSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 28084f4a
...@@ -3461,6 +3461,7 @@ static void rt5663_calibrate(struct rt5663_priv *rt5663) ...@@ -3461,6 +3461,7 @@ static void rt5663_calibrate(struct rt5663_priv *rt5663)
static int rt5663_parse_dp(struct rt5663_priv *rt5663, struct device *dev) static int rt5663_parse_dp(struct rt5663_priv *rt5663, struct device *dev)
{ {
int table_size; int table_size;
int ret;
device_property_read_u32(dev, "realtek,dc_offset_l_manual", device_property_read_u32(dev, "realtek,dc_offset_l_manual",
&rt5663->pdata.dc_offset_l_manual); &rt5663->pdata.dc_offset_l_manual);
...@@ -3477,9 +3478,11 @@ static int rt5663_parse_dp(struct rt5663_priv *rt5663, struct device *dev) ...@@ -3477,9 +3478,11 @@ static int rt5663_parse_dp(struct rt5663_priv *rt5663, struct device *dev)
table_size = sizeof(struct impedance_mapping_table) * table_size = sizeof(struct impedance_mapping_table) *
rt5663->pdata.impedance_sensing_num; rt5663->pdata.impedance_sensing_num;
rt5663->imp_table = devm_kzalloc(dev, table_size, GFP_KERNEL); rt5663->imp_table = devm_kzalloc(dev, table_size, GFP_KERNEL);
device_property_read_u32_array(dev, ret = device_property_read_u32_array(dev,
"realtek,impedance_sensing_table", "realtek,impedance_sensing_table",
(u32 *)rt5663->imp_table, table_size); (u32 *)rt5663->imp_table, table_size);
if (ret)
return ret;
} }
return 0; return 0;
...@@ -3504,8 +3507,11 @@ static int rt5663_i2c_probe(struct i2c_client *i2c, ...@@ -3504,8 +3507,11 @@ static int rt5663_i2c_probe(struct i2c_client *i2c,
if (pdata) if (pdata)
rt5663->pdata = *pdata; rt5663->pdata = *pdata;
else else {
rt5663_parse_dp(rt5663, &i2c->dev); ret = rt5663_parse_dp(rt5663, &i2c->dev);
if (ret)
return ret;
}
for (i = 0; i < ARRAY_SIZE(rt5663->supplies); i++) for (i = 0; i < ARRAY_SIZE(rt5663->supplies); i++)
rt5663->supplies[i].supply = rt5663_supply_names[i]; rt5663->supplies[i].supply = rt5663_supply_names[i];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment