drm/amd/display: Fix unused-but-set-variable warning
Subsystems (3)
PATCH v2 1/1 drm/amd/display: Fix unused-but-set-variable warning
Fix the kernel test robot warning below:
drivers/gpu/drm/amd/amdgpu/../display/dmub/inc/dmub_cmd.h:2893:12:
warning: variable 'temp' set but not used [-Wunused-but-set-variable]
Replaced the assignment to the unused temp variable with READ_ONCE() macro to flush the writes. READ_ONCE() helps avoid the use of volatile and makes it obvious from the code that the read here is intentional. Also verified on x86 that the generated code is exactly the same as before.
---
v2: Removed unnecessary volatile qualifier in the typecast and an unnecessary comment. Also reworded the commit message.
--- drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h +2 -4
@@ -2913,13 +2913,11 @@ static inline void dmub_rb_flush_pending(const struct dmub_rb *rb)uint32_t wptr = rb->wrpt;while (rptr != wptr) { -uint64_t volatile *data = (uint64_t volatile *)((uint8_t *)(rb->base_address) + rptr); -//uint64_t volatile *p = (uint64_t volatile *)data; -uint64_t temp; +uint64_t *data = (uint64_t *)((uint8_t *)(rb->base_address) + rptr);uint8_t i;for (i =0 ; i <DMUB_RB_CMD_SIZE /sizeof (uint64_t ); i++) - temp = *data++; + (void )READ_ONCE (*data++); rptr +=DMUB_RB_CMD_SIZE ;if (rptr >= rb->capacity)
Signature · 1 line
2.35.1.894.gb6a874cedc-goog
Alex Deucher
AppliedApplied. Thanks!
Alex
Quoted 43 lines · Aashish Sharma
Fix the kernel test robot warning below:
drivers/gpu/drm/amd/amdgpu/../display/dmub/inc/dmub_cmd.h:2893:12:
warning: variable 'temp' set but not used [-Wunused-but-set-variable]Replaced the assignment to the unused temp variable with
READ_ONCE()macro to flush the writes.READ_ONCE()helps avoid the use of volatile and makes it obvious from the code that the read here is intentional. Also verified on x86 that the generated code is exactly the same as before.Reported-by kernel test robot <[email protected]>Signed-off-by Aashish Sharma <[email protected]>---
v2: Removed unnecessary volatile qualifier in the typecast and an unnecessary comment. Also reworded the commit message.--- drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h +2
-5@@ -2913,13 +2913,11 @@ static inline void dmub_rb_flush_pending(const struct dmub_rb *rb)uint32_t wptr = rb->wrpt;while (rptr != wptr) { -uint64_t volatile *data = (uint64_t volatile *)((uint8_t *)(rb->base_address) + rptr); -//uint64_t volatile *p = (uint64_t volatile *)data; -uint64_t temp; +uint64_t *data = (uint64_t *)((uint8_t *)(rb->base_address) + rptr);uint8_t i;for (i =0 ; i <DMUB_RB_CMD_SIZE /sizeof (uint64_t ); i++) - temp = *data++; + (void )READ_ONCE (*data++); rptr +=DMUB_RB_CMD_SIZE ;if (rptr >= rb->capacity) --2.35.1.894.gb6a874cedc-goog