Rework dc_ed_pec_src_sel() to drop ARRAY_SIZE() use and use new sentinel
trailing entry LINK_ID_LAST to stop iterating over src_sels array instead.
This allows passing of this array around as OF match data, which will be
useful when using this pipeline on i.MX95, which has different src_sels
array.

Signed-off-by: Marek Vasut <[email protected]>
---
Cc: Abel Vesa <[email protected]>
Cc: Conor Dooley <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Liu Ying <[email protected]>
Cc: Lucas Stach <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Pengutronix Kernel Team <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Shawn Guo <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
 drivers/gpu/drm/imx/dc/dc-ed.c | 7 ++++---
 drivers/gpu/drm/imx/dc/dc-pe.h | 1 +
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/imx/dc/dc-ed.c b/drivers/gpu/drm/imx/dc/dc-ed.c
index 9a141c6aa0812..2fdd22a903dec 100644
--- a/drivers/gpu/drm/imx/dc/dc-ed.c
+++ b/drivers/gpu/drm/imx/dc/dc-ed.c
@@ -116,6 +116,7 @@ static const enum dc_link_id src_sels[] = {
        LINK_ID_LAYERBLEND2_MX8QXP,
        LINK_ID_LAYERBLEND1_MX8QXP,
        LINK_ID_LAYERBLEND0_MX8QXP,
+       LINK_ID_LAST    /* sentinel */
 };
 
 static inline void dc_ed_pec_enable_shden(struct dc_ed *ed)
@@ -141,10 +142,10 @@ static inline void dc_ed_pec_div_reset(struct dc_ed *ed)
 
 void dc_ed_pec_src_sel(struct dc_ed *ed, enum dc_link_id src)
 {
-       int i;
+       int i = 0;
 
-       for (i = 0; i < ARRAY_SIZE(src_sels); i++) {
-               if (src_sels[i] == src) {
+       while (src_sels[i] != LINK_ID_LAST) {
+               if (src_sels[i++] == src) {
                        regmap_write(ed->reg_pec, PIXENGCFG_DYNAMIC, src);
                        return;
                }
diff --git a/drivers/gpu/drm/imx/dc/dc-pe.h b/drivers/gpu/drm/imx/dc/dc-pe.h
index 866859403a79d..1e1e04cc39d4b 100644
--- a/drivers/gpu/drm/imx/dc/dc-pe.h
+++ b/drivers/gpu/drm/imx/dc/dc-pe.h
@@ -33,6 +33,7 @@ enum dc_link_id {
        LINK_ID_LAYERBLEND1_MX8QXP      = 0x22,
        LINK_ID_LAYERBLEND2_MX8QXP      = 0x23,
        LINK_ID_LAYERBLEND3_MX8QXP      = 0x24,
+       LINK_ID_LAST                    = 0xffffffff, /* sentinel */
 };
 
 enum dc_lb_mode {
-- 
2.51.0

Reply via email to