The helper cal_data_get_num_csi2_phy() is defined late in the module, leaving 3 instances of open-coded access to the num_csi2_phy value. Move the helper function directly after the 'struct cal_data' definitions and utilise the helper consistently throughout. Signed-off-by: Kieran Bingham <kieran.bingham@xxxxxxxxxxxxxxxx> --- drivers/media/platform/ti-vpe/cal.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c index d00dc241804b..8e99e7e58188 100644 --- a/drivers/media/platform/ti-vpe/cal.c +++ b/drivers/media/platform/ti-vpe/cal.c @@ -253,6 +253,11 @@ static const struct cal_data am654_cal_data = { .num_csi2_phy = ARRAY_SIZE(am654_cal_csi_phy), }; +static u32 cal_data_get_num_csi2_phy(struct cal_dev *cal) +{ + return cal->data->num_csi2_phy; +} + /* ------------------------------------------------------------------ * I/O Register Accessors * ------------------------------------------------------------------ @@ -267,7 +272,7 @@ void cal_quickdump_regs(struct cal_dev *cal) (__force const void *)cal->base, resource_size(cal->res), false); - for (i = 0; i < cal->data->num_csi2_phy; ++i) { + for (i = 0; i < cal_data_get_num_csi2_phy(cal); ++i) { struct cal_camerarx *phy = cal->phy[i]; cal_info(cal, "CSI2 Core %u Registers @ %pa:\n", i, @@ -559,7 +564,7 @@ static irqreturn_t cal_irq(int irq_cal, void *data) if (status & CAL_HL_IRQ_OCPO_ERR_MASK) dev_err_ratelimited(cal->dev, "OCPO ERROR\n"); - for (i = 0; i < cal->data->num_csi2_phy; ++i) { + for (i = 0; i < cal_data_get_num_csi2_phy(cal); ++i) { if (status & CAL_HL_IRQ_CIO_MASK(i)) { u32 cio_stat = cal_read(cal, CAL_CSI2_COMPLEXIO_IRQSTATUS(i)); @@ -685,7 +690,7 @@ static int cal_async_notifier_register(struct cal_dev *cal) v4l2_async_notifier_init(&cal->notifier); cal->notifier.ops = &cal_async_notifier_ops; - for (i = 0; i < cal->data->num_csi2_phy; ++i) { + for (i = 0; i < cal_data_get_num_csi2_phy(cal); ++i) { struct cal_camerarx *phy = cal->phy[i]; struct cal_v4l2_async_subdev *casd; struct v4l2_async_subdev *asd; @@ -904,11 +909,6 @@ static void cal_get_hwinfo(struct cal_dev *cal) hwinfo, CAL_HL_HWINFO_VALUE); } -static u32 cal_data_get_num_csi2_phy(struct cal_dev *cal) -{ - return cal->data->num_csi2_phy; -} - static int cal_init_camerarx_regmap(struct cal_dev *cal) { struct platform_device *pdev = to_platform_device(cal->dev); @@ -1063,7 +1063,7 @@ static int cal_probe(struct platform_device *pdev) error_media: cal_media_cleanup(cal); - for (i = 0; i < cal->data->num_csi2_phy; i++) + for (i = 0; i < cal_data_get_num_csi2_phy(cal); i++) cal_camerarx_destroy(cal->phy[i]); error_pm_runtime: @@ -1090,7 +1090,7 @@ static int cal_remove(struct platform_device *pdev) cal_media_cleanup(cal); - for (i = 0; i < cal->data->num_csi2_phy; i++) + for (i = 0; i < cal_data_get_num_csi2_phy(cal); i++) cal_camerarx_destroy(cal->phy[i]); pm_runtime_put_sync(&pdev->dev); @@ -1109,7 +1109,7 @@ static int cal_runtime_resume(struct device *dev) * Apply errata on both port everytime we (re-)enable * the clock */ - for (i = 0; i < cal->data->num_csi2_phy; i++) + for (i = 0; i < cal_data_get_num_csi2_phy(cal); i++) cal_camerarx_i913_errata(cal->phy[i]); } -- 2.25.1