Commit 58edcace authored by Herve Codina's avatar Herve Codina Committed by Christophe Leroy

soc: fsl: cpm1: tsa: Use ARRAY_SIZE() instead of hardcoded integer values

Loops handling the tdm array use hardcoded size and the initialization
part uses hardcoded indexes to initialize the array.

Use ARRAY_SIZE() to avoid the hardcoded size and initialize the array
using a loop.
Signed-off-by: default avatarHerve Codina <herve.codina@bootlin.com>
Reviewed-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
Link: https://lore.kernel.org/r/20240808071132.149251-10-herve.codina@bootlin.comSigned-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
parent 442f3799
...@@ -448,8 +448,8 @@ static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np) ...@@ -448,8 +448,8 @@ static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np)
int i; int i;
tsa->tdms = 0; tsa->tdms = 0;
tsa->tdm[0].is_enable = false; for (i = 0; i < ARRAY_SIZE(tsa->tdm); i++)
tsa->tdm[1].is_enable = false; tsa->tdm[i].is_enable = false;
for_each_available_child_of_node(np, tdm_np) { for_each_available_child_of_node(np, tdm_np) {
ret = of_property_read_u32(tdm_np, "reg", &tdm_id); ret = of_property_read_u32(tdm_np, "reg", &tdm_id);
...@@ -609,7 +609,7 @@ static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np) ...@@ -609,7 +609,7 @@ static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np)
return 0; return 0;
err: err:
for (i = 0; i < 2; i++) { for (i = 0; i < ARRAY_SIZE(tsa->tdm); i++) {
if (tsa->tdm[i].l1rsync_clk) { if (tsa->tdm[i].l1rsync_clk) {
clk_disable_unprepare(tsa->tdm[i].l1rsync_clk); clk_disable_unprepare(tsa->tdm[i].l1rsync_clk);
clk_put(tsa->tdm[i].l1rsync_clk); clk_put(tsa->tdm[i].l1rsync_clk);
...@@ -710,7 +710,7 @@ static void tsa_remove(struct platform_device *pdev) ...@@ -710,7 +710,7 @@ static void tsa_remove(struct platform_device *pdev)
struct tsa *tsa = platform_get_drvdata(pdev); struct tsa *tsa = platform_get_drvdata(pdev);
int i; int i;
for (i = 0; i < 2; i++) { for (i = 0; i < ARRAY_SIZE(tsa->tdm); i++) {
if (tsa->tdm[i].l1rsync_clk) { if (tsa->tdm[i].l1rsync_clk) {
clk_disable_unprepare(tsa->tdm[i].l1rsync_clk); clk_disable_unprepare(tsa->tdm[i].l1rsync_clk);
clk_put(tsa->tdm[i].l1rsync_clk); clk_put(tsa->tdm[i].l1rsync_clk);
......
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