amdgpu/pm: remove code duplication in show_power_cap calls
authorDarren Powell <darren.powell@amd.com>
Fri, 25 Jun 2021 02:54:35 +0000 (22:54 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 30 Jun 2021 04:18:56 +0000 (00:18 -0400)
commit91161b06be5729050a11e36366d2db8a679f35b6
tree03f0623e0944b762d133c70fbf5051114356c964
parented50995514d319ff27dafe3747f04abab9e87bdf
amdgpu/pm: remove code duplication in show_power_cap calls

 v3: updated patch to apply to latest code
 v2: reorder to check pointers before calling pm_runtime_* functions

 created generic function and call with enum from
 * amdgpu_hwmon_show_power_cap_max
 * amdgpu_hwmon_show_power_cap
 * amdgpu_hwmon_show_power_cap_default

=== Test ===
AMDGPU_PCI_ADDR=`lspci -nn | grep "VGA\|Display" | cut -d " " -f 1`
AMDGPU_HWMON=`ls -la /sys/class/hwmon | grep $AMDGPU_PCI_ADDR | cut -d " " -f 10`
HWMON_DIR=/sys/class/hwmon/${AMDGPU_HWMON}

cp pp_show_power_cap.txt{,.old}
lspci -nn | grep "VGA\|Display" > pp_show_power_cap.test.log
FILES="
power1_cap
power1_cap_max
power1_cap_default "

for f in $FILES
do
  echo  $f = `cat $HWMON_DIR/$f` >> pp_show_power_cap.test.log
done

Signed-off-by: Darren Powell <darren.powell@amd.com>
Reviewed-by: Kevin Wang <kevin1.wang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/amdgpu_pm.c