Skip to content

Commit a8fd392

Browse files
committed
ASoC: sti: regmap_field usage improvements
Merge series from Sander Vanheule <sander@svanheule.net>: uni_player_parse_dt_audio_glue() allocates two regmap_field objects on the device's regmap. However, error codes from these allocations are not propagated correctly and the resources will leak on device removal. These issues were found while looking for users of regmap_field_alloc(), to assess the impact of adding a cleanup helper for regmap_field. It appears this driver is the only (remaining) in-tree user of this allocator. Since the resources are long-lived, it may as well switch to devm_regmap_field_alloc(). As I don't have access to this hardware, these patches were only compile tested on a UM build.
2 parents ca5355d + 1696fad commit a8fd392

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

sound/soc/sti/uniperif_player.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,8 +1028,13 @@ static int uni_player_parse_dt_audio_glue(struct platform_device *pdev,
10281028
return PTR_ERR(regmap);
10291029
}
10301030

1031-
player->clk_sel = regmap_field_alloc(regmap, regfield[0]);
1032-
player->valid_sel = regmap_field_alloc(regmap, regfield[1]);
1031+
player->clk_sel = devm_regmap_field_alloc(&pdev->dev, regmap, regfield[0]);
1032+
if (IS_ERR(player->clk_sel))
1033+
return PTR_ERR(player->clk_sel);
1034+
1035+
player->valid_sel = devm_regmap_field_alloc(&pdev->dev, regmap, regfield[1]);
1036+
if (IS_ERR(player->valid_sel))
1037+
return PTR_ERR(player->valid_sel);
10331038

10341039
return 0;
10351040
}

0 commit comments

Comments
 (0)