Skip to contentSkip to conversation

drm/amd/pm: fix error flow in sensor fetching

PATCH In review Alex Deucher 2 participants 2 messages Aug 18, 2023 – Aug 22, 2023

Subsystems (3)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/1 drm/amd/pm: fix error flow in sensor fetching

Sensor fetching functions should return an signed int to handle errors properly.

---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +7 -7
index f03647fa3df6..a6697c266270 100644
@@ -1467,9 +1467,9 @@ static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev,
 	return -EINVAL;
 }
 
-static unsigned int amdgpu_hwmon_get_sensor_generic(struct amdgpu_device *adev,
-						    enum amd_pp_sensors sensor,
-						    void *query)
+static int amdgpu_hwmon_get_sensor_generic(struct amdgpu_device *adev,
+					   enum amd_pp_sensors sensor,
+					   void *query)
 {
 	int r, size = sizeof(uint32_t);
 
@@ -2772,8 +2772,8 @@ static ssize_t amdgpu_hwmon_show_vddnb_label(struct device *dev,
 	return sysfs_emit(buf, "vddnb\n");
 }
 
-static unsigned int amdgpu_hwmon_get_power(struct device *dev,
-					   enum amd_pp_sensors sensor)
+static int amdgpu_hwmon_get_power(struct device *dev,
+				  enum amd_pp_sensors sensor)
 {
 	struct amdgpu_device *adev = dev_get_drvdata(dev);
 	unsigned int uw;
@@ -2794,7 +2794,7 @@ static ssize_t amdgpu_hwmon_show_power_avg(struct device *dev,
 					   struct device_attribute *attr,
 					   char *buf)
 {
-	unsigned int val;
+	int val;
 
 	val = amdgpu_hwmon_get_power(dev, AMDGPU_PP_SENSOR_GPU_AVG_POWER);
 	if (val < 0)
@@ -2807,7 +2807,7 @@ static ssize_t amdgpu_hwmon_show_power_input(struct device *dev,
 					     struct device_attribute *attr,
 					     char *buf)
 {
-	unsigned int val;
+	int val;
 
 	val = amdgpu_hwmon_get_power(dev, AMDGPU_PP_SENSOR_GPU_INPUT_POWER);
 	if (val < 0)
Signature · 1 line
2.41.0
Reviewed-by on v1 1/1
#1 lore raw

[Public]

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Friday, August 18, 2023 9:55 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Jiapeng Chong <[email protected]>
Subject: [PATCH] drm/amd/pm: fix error flow in sensor fetching

Sensor fetching functions should return an signed int to handle errors properly.

---

 drivers/gpu/drm/amd/pm/amdgpu_pm.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +7 -7
index f03647fa3df6..a6697c266270 100644
@@ -1467,9 +1467,9 @@ static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev,
        return -EINVAL;
 }
 
-static unsigned int amdgpu_hwmon_get_sensor_generic(struct amdgpu_device *adev,
-                                                   enum amd_pp_sensors sensor,
-                                                   void *query)
+static int amdgpu_hwmon_get_sensor_generic(struct amdgpu_device *adev,
+                                          enum amd_pp_sensors sensor,
+                                          void *query)
 {
        int r, size = sizeof(uint32_t);
 
@@ -2772,8 +2772,8 @@ static ssize_t amdgpu_hwmon_show_vddnb_label(struct device *dev,
        return sysfs_emit(buf, "vddnb\n");
 }
 
-static unsigned int amdgpu_hwmon_get_power(struct device *dev,
-                                          enum amd_pp_sensors sensor)
+static int amdgpu_hwmon_get_power(struct device *dev,
+                                 enum amd_pp_sensors sensor)
 {
        struct amdgpu_device *adev = dev_get_drvdata(dev);
        unsigned int uw;
@@ -2794,7 +2794,7 @@ static ssize_t amdgpu_hwmon_show_power_avg(struct device *dev,
                                           struct device_attribute *attr,
                                           char *buf)
 {
-       unsigned int val;
+       int val;
 
        val = amdgpu_hwmon_get_power(dev, AMDGPU_PP_SENSOR_GPU_AVG_POWER);
        if (val < 0)
@@ -2807,7 +2807,7 @@ static ssize_t amdgpu_hwmon_show_power_input(struct device *dev,
                                             struct device_attribute *attr,
                                             char *buf)
 {
-       unsigned int val;
+       int val;
 
        val = amdgpu_hwmon_get_power(dev, AMDGPU_PP_SENSOR_GPU_INPUT_POWER);
        if (val < 0)

--
2.41.0