Compact some very long and repetitive lines of code by caching the
respective object in local variables. This is a concept which is already
used at places, but not consistently so.

add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-45 (-45)
Function                                     old     new   delta
amdgpu_jpeg_dec_ring_test_ring               382     337     -45
Total: Before=8977332, After=8977287, chg -0.00%

Signed-off-by: Tvrtko Ursulin <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c
index 620dc338e0a6..fc43e8668b6a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c
@@ -153,6 +153,8 @@ void amdgpu_jpeg_ring_end_use(struct amdgpu_ring *ring)
 int amdgpu_jpeg_dec_ring_test_ring(struct amdgpu_ring *ring)
 {
        struct amdgpu_device *adev = ring->adev;
+       struct amdgpu_jpeg_reg *external = &adev->jpeg.inst[ring->me].external;
+       unsigned int pipe = ring->pipe;
        uint32_t tmp = 0;
        unsigned i;
        int r;
@@ -165,16 +167,16 @@ int amdgpu_jpeg_dec_ring_test_ring(struct amdgpu_ring 
*ring)
        if (r)
                return r;
 
-       WREG32(adev->jpeg.inst[ring->me].external.jpeg_pitch[ring->pipe], 
0xCAFEDEAD);
+       WREG32(external->jpeg_pitch[pipe], 0xCAFEDEAD);
        /* Add a read register to make sure the write register is executed. */
-       RREG32(adev->jpeg.inst[ring->me].external.jpeg_pitch[ring->pipe]);
+       RREG32(external->jpeg_pitch[pipe]);
 
-       amdgpu_ring_write(ring, 
PACKET0(adev->jpeg.internal.jpeg_pitch[ring->pipe], 0));
+       amdgpu_ring_write(ring, PACKET0(adev->jpeg.internal.jpeg_pitch[pipe], 
0));
        amdgpu_ring_write(ring, 0xABADCAFE);
        amdgpu_ring_commit(ring);
 
        for (i = 0; i < adev->usec_timeout; i++) {
-               tmp = 
RREG32(adev->jpeg.inst[ring->me].external.jpeg_pitch[ring->pipe]);
+               tmp = RREG32(external->jpeg_pitch[pipe]);
                if (tmp == 0xABADCAFE)
                        break;
                udelay(1);
-- 
2.48.0

Reply via email to