Use ARRAY_SIZE(cal->ctx) to iterate over the cal->ctx array instead of using the numerical value from the CAL_NUM_CONTEXT macro (or, worse, hardcoding the value 2). This will allow reworking contexts with less changes in the code. Signed-off-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx> --- drivers/media/platform/ti-vpe/cal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c index af142b00ee0b..ca8aa630b9b3 100644 --- a/drivers/media/platform/ti-vpe/cal.c +++ b/drivers/media/platform/ti-vpe/cal.c @@ -1305,7 +1305,7 @@ static irqreturn_t cal_irq(int irq_cal, void *data) /* Clear Interrupt status */ reg_write(cal, CAL_HL_IRQSTATUS(1), status); - for (i = 0; i < 2; ++i) { + for (i = 0; i < ARRAY_SIZE(cal->ctx); ++i) { if (isportirqset(status, i)) { ctx = cal->ctx[i]; @@ -1326,7 +1326,7 @@ static irqreturn_t cal_irq(int irq_cal, void *data) /* Clear Interrupt status */ reg_write(cal, CAL_HL_IRQSTATUS(2), status); - for (i = 0; i < 2; ++i) { + for (i = 0; i < ARRAY_SIZE(cal->ctx); ++i) { if (isportirqset(status, i)) { ctx = cal->ctx[i]; dma_q = &ctx->vidq; @@ -2323,7 +2323,7 @@ static int cal_probe(struct platform_device *pdev) vb2_dma_contig_clear_max_seg_size(&pdev->dev); pm_runtime_disable(&pdev->dev); - for (i = 0; i < CAL_NUM_CONTEXT; i++) { + for (i = 0; i < ARRAY_SIZE(cal->ctx); i++) { ctx = cal->ctx[i]; if (ctx) { v4l2_async_notifier_unregister(&ctx->notifier); @@ -2352,7 +2352,7 @@ static int cal_remove(struct platform_device *pdev) pm_runtime_get_sync(&pdev->dev); - for (i = 0; i < CAL_NUM_CONTEXT; i++) { + for (i = 0; i < ARRAY_SIZE(cal->ctx); i++) { ctx = cal->ctx[i]; if (ctx) { ctx_dbg(1, ctx, "unregistering %s\n", -- Regards, Laurent Pinchart