Split the GPU_ID register read into its own helper function. The GPU_ID
value will be used to enable architecture-specific behaviours, which may
also affect how other registers (such as those used for gpu_info) are
read.

This change separates the read operation so that subsequent code can
depend on the intermediate result of processing the GPU_ID.

Signed-off-by: Karunika Choo <[email protected]>
---
 drivers/gpu/drm/panthor/panthor_hw.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/panthor/panthor_hw.c 
b/drivers/gpu/drm/panthor/panthor_hw.c
index 4f2858114e5e..326a9db0b5c2 100644
--- a/drivers/gpu/drm/panthor/panthor_hw.c
+++ b/drivers/gpu/drm/panthor/panthor_hw.c
@@ -62,7 +62,6 @@ static void panthor_gpu_info_init(struct panthor_device 
*ptdev)
 {
        unsigned int i;
 
-       ptdev->gpu_info.gpu_id = gpu_read(ptdev, GPU_ID);
        ptdev->gpu_info.csf_id = gpu_read(ptdev, GPU_CSF_ID);
        ptdev->gpu_info.gpu_rev = gpu_read(ptdev, GPU_REVID);
        ptdev->gpu_info.core_features = gpu_read(ptdev, GPU_CORE_FEATURES);
@@ -117,8 +116,23 @@ static void panthor_hw_info_init(struct panthor_device 
*ptdev)
                 ptdev->gpu_info.tiler_present);
 }
 
+static int panthor_hw_gpu_id_init(struct panthor_device *ptdev)
+{
+       ptdev->gpu_info.gpu_id = gpu_read(ptdev, GPU_ID);
+       if (!ptdev->gpu_info.gpu_id)
+               return -ENXIO;
+
+       return 0;
+}
+
 int panthor_hw_init(struct panthor_device *ptdev)
 {
+       int ret = 0;
+
+       ret = panthor_hw_gpu_id_init(ptdev);
+       if (ret)
+               return ret;
+
        panthor_hw_info_init(ptdev);
 
        return 0;
-- 
2.49.0

Reply via email to