Subject: [PATCH] memory: mtk-smi: Use ARRAY_SIZE to define MTK_SMI_CLK_NR_MAX

This definition is tied to the number of SMI common clocks (the array
mtk_smi_common_clks): improve the definition by using the ARRAY_SIZE
macro instead. That will also reduce room for mistakes when updating
the aforementioned array in the future.

Signed-off-by: AngeloGioacchino Del Regno <[email protected]>
---
drivers/memory/mtk-smi.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c
index b883dcc0bbfa..6331422141e8 100644
--- a/drivers/memory/mtk-smi.c
+++ b/drivers/memory/mtk-smi.c
@@ -94,8 +94,6 @@ enum mtk_smi_type {
MTK_SMI_GEN2_SUB_COMM, /* gen2 smi sub common */
};

-#define MTK_SMI_CLK_NR_MAX 4
-
/* larbs: Require apb/smi clocks while gals is optional. */
static const char * const mtk_smi_larb_clks[] = {"apb", "smi", "gals"};
#define MTK_SMI_LARB_REQ_CLK_NR 2
@@ -106,6 +104,7 @@ static const char * const mtk_smi_larb_clks[] = {"apb", "smi", "gals"};
* sub common: Require apb/smi/gals0 clocks in has_gals case. Otherwise, only apb/smi are required.
*/
static const char * const mtk_smi_common_clks[] = {"apb", "smi", "gals0", "gals1"};
+#define MTK_SMI_CLK_NR_MAX ARRAY_SIZE(mtk_smi_common_clks)
#define MTK_SMI_COM_REQ_CLK_NR 2
#define MTK_SMI_COM_GALS_REQ_CLK_NR MTK_SMI_CLK_NR_MAX
#define MTK_SMI_SUB_COM_GALS_REQ_CLK_NR 3
--
2.33.0


2021-10-18 03:25:49

by Yong Wu (吴勇)

[permalink] [raw]
Subject: Re: [PATCH] memory: mtk-smi: Use ARRAY_SIZE to define MTK_SMI_CLK_NR_MAX

On Fri, 2021-10-15 at 17:15 +0200, AngeloGioacchino Del Regno wrote:
> This definition is tied to the number of SMI common clocks (the array
> mtk_smi_common_clks): improve the definition by using the ARRAY_SIZE
> macro instead. That will also reduce room for mistakes when updating
> the aforementioned array in the future.
>
> Signed-off-by: AngeloGioacchino Del Regno <
> [email protected]>

Reviewed-by: Yong Wu <[email protected]>

Thanks for this patch.

> ---
> drivers/memory/mtk-smi.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c
> index b883dcc0bbfa..6331422141e8 100644
> --- a/drivers/memory/mtk-smi.c
> +++ b/drivers/memory/mtk-smi.c
> @@ -94,8 +94,6 @@ enum mtk_smi_type {
> MTK_SMI_GEN2_SUB_COMM, /* gen2 smi sub common */
> };
>
> -#define MTK_SMI_CLK_NR_MAX 4
> -
> /* larbs: Require apb/smi clocks while gals is optional. */
> static const char * const mtk_smi_larb_clks[] = {"apb", "smi",
> "gals"};
> #define MTK_SMI_LARB_REQ_CLK_NR 2
> @@ -106,6 +104,7 @@ static const char * const mtk_smi_larb_clks[] =
> {"apb", "smi", "gals"};
> * sub common: Require apb/smi/gals0 clocks in has_gals case.
> Otherwise, only apb/smi are required.
> */
> static const char * const mtk_smi_common_clks[] = {"apb", "smi",
> "gals0", "gals1"};
> +#define MTK_SMI_CLK_NR_MAX ARRAY_SIZE(mtk_smi_common_clks)
> #define MTK_SMI_COM_REQ_CLK_NR 2
> #define MTK_SMI_COM_GALS_REQ_CLK_NR MTK_SMI_CLK_NR_MAX
> #define MTK_SMI_SUB_COM_GALS_REQ_CLK_NR 3

2021-10-21 09:24:21

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH] memory: mtk-smi: Use ARRAY_SIZE to define MTK_SMI_CLK_NR_MAX

On 15/10/2021 17:15, AngeloGioacchino Del Regno wrote:
> This definition is tied to the number of SMI common clocks (the array
> mtk_smi_common_clks): improve the definition by using the ARRAY_SIZE
> macro instead. That will also reduce room for mistakes when updating
> the aforementioned array in the future.
>
> Signed-off-by: AngeloGioacchino Del Regno <[email protected]>
> ---
> drivers/memory/mtk-smi.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>

Thanks for the patch. I sent mtk-smi pull request some time ago and it
is late in the cycle, so this might need to wait for next cycle. I'll
keep it in my queue.

Best regards,
Krzysztof

2021-11-15 14:11:44

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH] memory: mtk-smi: Use ARRAY_SIZE to define MTK_SMI_CLK_NR_MAX

On Fri, 15 Oct 2021 17:15:57 +0200, AngeloGioacchino Del Regno wrote:
> This definition is tied to the number of SMI common clocks (the array
> mtk_smi_common_clks): improve the definition by using the ARRAY_SIZE
> macro instead. That will also reduce room for mistakes when updating
> the aforementioned array in the future.
>
>

Applied, thanks!

[1/1] memory: mtk-smi: Use ARRAY_SIZE to define MTK_SMI_CLK_NR_MAX
commit: 3191e91ae15b60e69523578975bf5c6326ce1be4

Best regards,
--
Krzysztof Kozlowski <[email protected]>