Replace a manually unrolled loop with an explicit for loop to increase readability when creating the CAMERARX and context instances. The explicit NULL initialization of cal->phy[] and cal->ctx[] is removed, as the cal structure is zeroed when allocated. Signed-off-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx> --- drivers/media/platform/ti-vpe/cal.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c index e353b1b0f6f9..681e846eb236 100644 --- a/drivers/media/platform/ti-vpe/cal.c +++ b/drivers/media/platform/ti-vpe/cal.c @@ -2347,24 +2347,15 @@ static int cal_probe(struct platform_device *pdev) platform_set_drvdata(pdev, cal); - cal->phy[0] = cal_camerarx_create(cal, 0); - if (IS_ERR(cal->phy[0])) - return PTR_ERR(cal->phy[0]); - - if (cal_data_get_num_csi2_phy(cal) > 1) { - cal->phy[1] = cal_camerarx_create(cal, 1); - if (IS_ERR(cal->phy[1])) - return PTR_ERR(cal->phy[1]); - } else { - cal->phy[1] = NULL; + for (i = 0; i < cal_data_get_num_csi2_phy(cal); ++i) { + cal->phy[i] = cal_camerarx_create(cal, i); + if (IS_ERR(cal->phy[i])) + return PTR_ERR(cal->phy[i]); } - cal->ctx[0] = NULL; - cal->ctx[1] = NULL; + for (i = 0; i < cal_data_get_num_csi2_phy(cal); ++i) + cal->ctx[i] = cal_create_instance(cal, i); - cal->ctx[0] = cal_create_instance(cal, 0); - if (cal_data_get_num_csi2_phy(cal) > 1) - cal->ctx[1] = cal_create_instance(cal, 1); if (!cal->ctx[0] && !cal->ctx[1]) { cal_err(cal, "Neither port is configured, no point in staying up\n"); return -ENODEV; -- Regards, Laurent Pinchart