Skip to contentSkip to conversation

drm/amd/pm: Use str_enabled_disabled in amdgpu_pm sysfs

PATCH In review Asad Kamal 2 participants 2 messages Mar 25

Subsystems (3)
lore
Share & tools
lore

Asad Kamal

author
#0 lore raw

PATCH 1/1 drm/amd/pm: Use str_enabled_disabled in amdgpu_pm sysfs

Coccinelle flags hand-rolled "enabled"/"disabled" strings; use the shared str_enabled_disabled() helper from string_choices.h for npm_status and thermal throttling logging sysfs text.

---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +3 -2
index 6565cc3e35f2..a4d8e667eafb 100644
@@ -33,6 +33,7 @@
 #include <linux/hwmon-sysfs.h>
 #include <linux/nospec.h>
 #include <linux/pm_runtime.h>
+#include <linux/string_choices.h>
 #include <asm/processor.h>
 
 #define MAX_NUM_OF_FEATURES_PER_SUBSET		8
@@ -1592,7 +1593,7 @@ static ssize_t amdgpu_get_thermal_throttling_logging(struct device *dev,
 
 	return sysfs_emit(buf, "%s: thermal throttling logging %s, with interval %d seconds\n",
 			  adev_to_drm(adev)->unique,
-			  atomic_read(&adev->throttling_logging_enabled) ? "enabled" : "disabled",
+			  str_enabled_disabled(atomic_read(&adev->throttling_logging_enabled)),
 			  adev->throttling_logging_rs.interval / HZ + 1);
 }
 
@@ -2235,7 +2236,7 @@ static ssize_t amdgpu_show_npm_status(struct device *dev,
 	if (r)
 		return r;
 
-	return sysfs_emit(buf, "%s\n", npower ? "enabled" : "disabled");
+	return sysfs_emit(buf, "%s\n", str_enabled_disabled(npower));
 }
 
 /**
Signature · 1 line
2.46.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Asad Kamal

Coccinelle flags hand-rolled "enabled"/"disabled" strings; use the shared str_enabled_disabled() helper from string_choices.h for npm_status and thermal throttling logging sysfs text.

Thanks,
Lijo

Quoted 34 lines
---
  drivers/gpu/drm/amd/pm/amdgpu_pm.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +3 -2
index 6565cc3e35f2..a4d8e667eafb 100644
@@ -33,6 +33,7 @@
  #include <linux/hwmon-sysfs.h>
  #include <linux/nospec.h>
  #include <linux/pm_runtime.h>
+#include <linux/string_choices.h>
  #include <asm/processor.h>
 
  #define MAX_NUM_OF_FEATURES_PER_SUBSET		8
@@ -1592,7 +1593,7 @@ static ssize_t amdgpu_get_thermal_throttling_logging(struct device *dev,
 
  	return sysfs_emit(buf, "%s: thermal throttling logging %s, with interval %d seconds\n",
  			  adev_to_drm(adev)->unique,
-			  atomic_read(&adev->throttling_logging_enabled) ? "enabled" : "disabled",
+			  str_enabled_disabled(atomic_read(&adev->throttling_logging_enabled)),
  			  adev->throttling_logging_rs.interval / HZ + 1);
  }
 
@@ -2235,7 +2236,7 @@ static ssize_t amdgpu_show_npm_status(struct device *dev,
  	if (r)
  		return r;
 
-	return sysfs_emit(buf, "%s\n", npower ? "enabled" : "disabled");
+	return sysfs_emit(buf, "%s\n", str_enabled_disabled(npower));
  }
 
  /**