diff mbox series

[v2,09/36] soc: fsl: cpm1: tsa: Use ARRAY_SIZE() instead of hardcoded integer values

Message ID 20240808071132.149251-10-herve.codina@bootlin.com (mailing list archive)
State New, archived
Headers show
Series soc: fsl: Add support for QUICC Engine TSA and QMC | expand

Commit Message

Herve Codina Aug. 8, 2024, 7:11 a.m. UTC
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: Herve Codina <herve.codina@bootlin.com>
---
 drivers/soc/fsl/qe/tsa.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Christophe Leroy Aug. 23, 2024, 8:05 a.m. UTC | #1
Le 08/08/2024 à 09:11, Herve Codina a écrit :
> 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: Herve Codina <herve.codina@bootlin.com>

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>


> ---
>   drivers/soc/fsl/qe/tsa.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/soc/fsl/qe/tsa.c b/drivers/soc/fsl/qe/tsa.c
> index 244d521d8780..3d0c31a62dbb 100644
> --- a/drivers/soc/fsl/qe/tsa.c
> +++ b/drivers/soc/fsl/qe/tsa.c
> @@ -448,8 +448,8 @@ static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np)
>   	int i;
>   
>   	tsa->tdms = 0;
> -	tsa->tdm[0].is_enable = false;
> -	tsa->tdm[1].is_enable = false;
> +	for (i = 0; i < ARRAY_SIZE(tsa->tdm); i++)
> +		tsa->tdm[i].is_enable = false;
>   
>   	for_each_available_child_of_node(np, tdm_np) {
>   		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)
>   	return 0;
>   
>   err:
> -	for (i = 0; i < 2; i++) {
> +	for (i = 0; i < ARRAY_SIZE(tsa->tdm); i++) {
>   		if (tsa->tdm[i].l1rsync_clk) {
>   			clk_disable_unprepare(tsa->tdm[i].l1rsync_clk);
>   			clk_put(tsa->tdm[i].l1rsync_clk);
> @@ -710,7 +710,7 @@ static void tsa_remove(struct platform_device *pdev)
>   	struct tsa *tsa = platform_get_drvdata(pdev);
>   	int i;
>   
> -	for (i = 0; i < 2; i++) {
> +	for (i = 0; i < ARRAY_SIZE(tsa->tdm); i++) {
>   		if (tsa->tdm[i].l1rsync_clk) {
>   			clk_disable_unprepare(tsa->tdm[i].l1rsync_clk);
>   			clk_put(tsa->tdm[i].l1rsync_clk);
diff mbox series

Patch

diff --git a/drivers/soc/fsl/qe/tsa.c b/drivers/soc/fsl/qe/tsa.c
index 244d521d8780..3d0c31a62dbb 100644
--- a/drivers/soc/fsl/qe/tsa.c
+++ b/drivers/soc/fsl/qe/tsa.c
@@ -448,8 +448,8 @@  static int tsa_of_parse_tdms(struct tsa *tsa, struct device_node *np)
 	int i;
 
 	tsa->tdms = 0;
-	tsa->tdm[0].is_enable = false;
-	tsa->tdm[1].is_enable = false;
+	for (i = 0; i < ARRAY_SIZE(tsa->tdm); i++)
+		tsa->tdm[i].is_enable = false;
 
 	for_each_available_child_of_node(np, tdm_np) {
 		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)
 	return 0;
 
 err:
-	for (i = 0; i < 2; i++) {
+	for (i = 0; i < ARRAY_SIZE(tsa->tdm); i++) {
 		if (tsa->tdm[i].l1rsync_clk) {
 			clk_disable_unprepare(tsa->tdm[i].l1rsync_clk);
 			clk_put(tsa->tdm[i].l1rsync_clk);
@@ -710,7 +710,7 @@  static void tsa_remove(struct platform_device *pdev)
 	struct tsa *tsa = platform_get_drvdata(pdev);
 	int i;
 
-	for (i = 0; i < 2; i++) {
+	for (i = 0; i < ARRAY_SIZE(tsa->tdm); i++) {
 		if (tsa->tdm[i].l1rsync_clk) {
 			clk_disable_unprepare(tsa->tdm[i].l1rsync_clk);
 			clk_put(tsa->tdm[i].l1rsync_clk);