Read the hardware revision and info right after allocating resources, as there's no need to delay doing so until all initialization is complete. Signed-off-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx> --- drivers/media/platform/ti-vpe/cal.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c index 6655c0051ccc..33a985300045 100644 --- a/drivers/media/platform/ti-vpe/cal.c +++ b/drivers/media/platform/ti-vpe/cal.c @@ -2401,6 +2401,15 @@ static int cal_probe(struct platform_device *pdev) if (ret) return ret; + /* Read the revision and hardware info to verify hardware access. */ + pm_runtime_enable(&pdev->dev); + ret = pm_runtime_get_sync(&pdev->dev); + if (ret) + goto error_pm_runtime; + + cal_get_hwinfo(cal); + pm_runtime_put_sync(&pdev->dev); + /* Create CAMERARX PHYs. */ for (i = 0; i < cal_data_get_num_csi2_phy(cal); ++i) { cal->phy[i] = cal_camerarx_create(cal, i); @@ -2425,24 +2434,14 @@ static int cal_probe(struct platform_device *pdev) goto error_media; } - /* Read the revision and hardware info to verify hardware access. */ - pm_runtime_enable(&pdev->dev); - ret = pm_runtime_get_sync(&pdev->dev); - if (ret) - goto error_pm_runtime; - - cal_get_hwinfo(cal); - pm_runtime_put_sync(&pdev->dev); - /* Register the media device. */ ret = cal_media_register(cal); if (ret) - goto error_pm_runtime; + goto error_context; return 0; -error_pm_runtime: - pm_runtime_disable(&pdev->dev); +error_context: for (i = 0; i < ARRAY_SIZE(cal->ctx); i++) { ctx = cal->ctx[i]; if (ctx) @@ -2456,6 +2455,9 @@ static int cal_probe(struct platform_device *pdev) for (i = 0; i < ARRAY_SIZE(cal->phy); i++) cal_camerarx_destroy(cal->phy[i]); +error_pm_runtime: + pm_runtime_disable(&pdev->dev); + return ret; } -- Regards, Laurent Pinchart