drm/radeon/radeon_pm: use DEVICE_ATTR_RW macro
Subsystems (2)
PATCH 1/1 drm/radeon/radeon_pm: use DEVICE_ATTR_RW macro
Use DEVICE_ATTR_RW() helper instead of plain DEVICE_ATTR(), which makes the code a bit shorter and easier to read.
--- drivers/gpu/drm/radeon/radeon_pm.c | 56 ++++++++++++------------------ 1 file changed, 23 insertions(+), 33 deletions(-)
drivers/gpu/drm/radeon/radeon_pm.c +23 -33
@@ -352,9 +352,8 @@ static void radeon_pm_print_states(struct radeon_device *rdev) } } -static ssize_t radeon_get_pm_profile (struct device *dev, -struct device_attribute *attr, -char *buf) +static ssize_t power_profile_show (struct device *dev, +struct device_attribute *attr,char *buf) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;
@@ -366,10 +365,8 @@ static ssize_t radeon_get_pm_profile(struct device *dev, (cp == PM_PROFILE_HIGH) ? "high" : "default"); } -static ssize_t radeon_set_pm_profile (struct device *dev, -struct device_attribute *attr, -const char *buf, -size_t count) +static ssize_t power_profile_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;
@@ -406,9 +403,8 @@ static ssize_t radeon_set_pm_profile(struct device *dev,return count; } -static ssize_t radeon_get_pm_method (struct device *dev, -struct device_attribute *attr, -char *buf) +static ssize_t power_method_show (struct device *dev, +struct device_attribute *attr,char *buf) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;
@@ -418,10 +414,9 @@ static ssize_t radeon_get_pm_method(struct device *dev, (pm == PM_METHOD_PROFILE) ? "profile" : "dpm"); } -static ssize_t radeon_set_pm_method (struct device *dev, -struct device_attribute *attr, -const char *buf, -size_t count) +static ssize_t power_method_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;
@@ -462,9 +457,8 @@ static ssize_t radeon_set_pm_method(struct device *dev,return count; } -static ssize_t radeon_get_dpm_state (struct device *dev, -struct device_attribute *attr, -char *buf) +static ssize_t power_dpm_state_show (struct device *dev, +struct device_attribute *attr,char *buf) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;
@@ -475,10 +469,9 @@ static ssize_t radeon_get_dpm_state(struct device *dev, (pm == POWER_STATE_TYPE_BALANCED) ? "balanced" : "performance"); } -static ssize_t radeon_set_dpm_state (struct device *dev, -struct device_attribute *attr, -const char *buf, -size_t count) +static ssize_t power_dpm_state_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;
@@ -506,9 +499,9 @@ static ssize_t radeon_set_dpm_state(struct device *dev,return count; } -static ssize_t radeon_get_dpm_forced_performance_level (struct device *dev, -struct device_attribute *attr, -char *buf) +static ssize_t power_dpm_force_performance_level_show (struct device *dev, +struct device_attribute *attr, +char *buf) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;
@@ -523,10 +516,9 @@ static ssize_t radeon_get_dpm_forced_performance_level(struct device *dev, (level == RADEON_DPM_FORCED_LEVEL_LOW) ? "low" : "high"); } -static ssize_t radeon_set_dpm_forced_performance_level (struct device *dev, +static ssize_t power_dpm_force_performance_level_store (struct device *dev,struct device_attribute *attr, -const char *buf, -size_t count) +const char *buf,size_t count) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;
@@ -658,12 +650,10 @@ static ssize_t radeon_hwmon_get_pwm1(struct device *dev,return sprintf (buf,"%i\n" , speed); } -static DEVICE_ATTR(power_profile, S_IRUGO | S_IWUSR, radeon_get_pm_profile, radeon_set_pm_profile); -static DEVICE_ATTR(power_method, S_IRUGO | S_IWUSR, radeon_get_pm_method, radeon_set_pm_method); -static DEVICE_ATTR(power_dpm_state, S_IRUGO | S_IWUSR, radeon_get_dpm_state, radeon_set_dpm_state); -static DEVICE_ATTR(power_dpm_force_performance_level, S_IRUGO | S_IWUSR, - radeon_get_dpm_forced_performance_level, - radeon_set_dpm_forced_performance_level); +static DEVICE_ATTR_RW (power_profile); +static DEVICE_ATTR_RW (power_method); +static DEVICE_ATTR_RW (power_dpm_state); +static DEVICE_ATTR_RW (power_dpm_force_performance_level); static ssize_t radeon_hwmon_show_temp(struct device *dev, struct device_attribute *attr,
Signature · 1 line
2.17.1
Quoted 5 lines · YueHaibing
Use
DEVICE_ATTR_RW()helper instead of plainDEVICE_ATTR(), which makes the code a bit shorter and easier to read.Signed-off-by YueHaibing <[email protected]>
I'm not convinced this really buys us anything other than code churn, but I don't have a particularly strong opinion of others feel differently.
Alex
Quoted 131 lines
--- drivers/gpu/drm/radeon/radeon_pm.c | 56 ++++++++++++------------------ 1 file changed, 23 insertions(+), 33 deletions(-)drivers/gpu/drm/radeon/radeon_pm.c +23
-34@@ -352,9 +352,8 @@ static void radeon_pm_print_states(struct radeon_device *rdev) } } -static ssize_t radeon_get_pm_profile (struct device *dev, -struct device_attribute *attr, -char *buf) +static ssize_t power_profile_show (struct device *dev, +struct device_attribute *attr,char *buf) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;@@ -366,10 +365,8 @@ static ssize_t radeon_get_pm_profile(struct device *dev, (cp == PM_PROFILE_HIGH) ? "high" : "default"); } -static ssize_t radeon_set_pm_profile (struct device *dev, -struct device_attribute *attr, -const char *buf, -size_t count) +static ssize_t power_profile_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;@@ -406,9 +403,8 @@ static ssize_t radeon_set_pm_profile(struct device *dev,return count; } -static ssize_t radeon_get_pm_method (struct device *dev, -struct device_attribute *attr, -char *buf) +static ssize_t power_method_show (struct device *dev, +struct device_attribute *attr,char *buf) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;@@ -418,10 +414,9 @@ static ssize_t radeon_get_pm_method(struct device *dev, (pm == PM_METHOD_PROFILE) ? "profile" : "dpm"); } -static ssize_t radeon_set_pm_method (struct device *dev, -struct device_attribute *attr, -const char *buf, -size_t count) +static ssize_t power_method_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;@@ -462,9 +457,8 @@ static ssize_t radeon_set_pm_method(struct device *dev,return count; } -static ssize_t radeon_get_dpm_state (struct device *dev, -struct device_attribute *attr, -char *buf) +static ssize_t power_dpm_state_show (struct device *dev, +struct device_attribute *attr,char *buf) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;@@ -475,10 +469,9 @@ static ssize_t radeon_get_dpm_state(struct device *dev, (pm == POWER_STATE_TYPE_BALANCED) ? "balanced" : "performance"); } -static ssize_t radeon_set_dpm_state (struct device *dev, -struct device_attribute *attr, -const char *buf, -size_t count) +static ssize_t power_dpm_state_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;@@ -506,9 +499,9 @@ static ssize_t radeon_set_dpm_state(struct device *dev,return count; } -static ssize_t radeon_get_dpm_forced_performance_level (struct device *dev, -struct device_attribute *attr, -char *buf) +static ssize_t power_dpm_force_performance_level_show (struct device *dev, +struct device_attribute *attr, +char *buf) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;@@ -523,10 +516,9 @@ static ssize_t radeon_get_dpm_forced_performance_level(struct device *dev, (level == RADEON_DPM_FORCED_LEVEL_LOW) ? "low" : "high"); } -static ssize_t radeon_set_dpm_forced_performance_level (struct device *dev, +static ssize_t power_dpm_force_performance_level_store (struct device *dev,struct device_attribute *attr, -const char *buf, -size_t count) +const char *buf,size_t count) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;@@ -658,12 +650,10 @@ static ssize_t radeon_hwmon_get_pwm1(struct device *dev,return sprintf (buf,"%i\n" , speed); } -static DEVICE_ATTR(power_profile, S_IRUGO | S_IWUSR, radeon_get_pm_profile, radeon_set_pm_profile); -static DEVICE_ATTR(power_method, S_IRUGO | S_IWUSR, radeon_get_pm_method, radeon_set_pm_method); -static DEVICE_ATTR(power_dpm_state, S_IRUGO | S_IWUSR, radeon_get_dpm_state, radeon_set_dpm_state); -static DEVICE_ATTR(power_dpm_force_performance_level, S_IRUGO | S_IWUSR, - radeon_get_dpm_forced_performance_level, - radeon_set_dpm_forced_performance_level); +static DEVICE_ATTR_RW (power_profile); +static DEVICE_ATTR_RW (power_method); +static DEVICE_ATTR_RW (power_dpm_state); +static DEVICE_ATTR_RW (power_dpm_force_performance_level); static ssize_t radeon_hwmon_show_temp(struct device *dev, struct device_attribute *attr, --2.17.1
Am 02.06.21 um 03:53 schrieb Alex Deucher:
Quoted 8 lines · YueHaibing
Quoted 4 lines
Use
DEVICE_ATTR_RW()helper instead of plainDEVICE_ATTR(), which makes the code a bit shorter and easier to read.Signed-off-by YueHaibing <[email protected]>I'm not convinced this really buys us anything other than code churn, but I don't have a particularly strong opinion of others feel differently.
I agree, especially dropping the amdgpu prefix from the functions doesn't sound like something we want.
Christian.
Quoted 139 lines
Alex
Quoted 129 lines
--- drivers/gpu/drm/radeon/radeon_pm.c | 56 ++++++++++++------------------ 1 file changed, 23 insertions(+), 33 deletions(-)drivers/gpu/drm/radeon/radeon_pm.c +23
-34@@ -352,9 +352,8 @@ static void radeon_pm_print_states(struct radeon_device *rdev) } } -static ssize_t radeon_get_pm_profile (struct device *dev, -struct device_attribute *attr, -char *buf) +static ssize_t power_profile_show (struct device *dev, +struct device_attribute *attr,char *buf) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;@@ -366,10 +365,8 @@ static ssize_t radeon_get_pm_profile(struct device *dev, (cp == PM_PROFILE_HIGH) ? "high" : "default"); } -static ssize_t radeon_set_pm_profile (struct device *dev, -struct device_attribute *attr, -const char *buf, -size_t count) +static ssize_t power_profile_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;@@ -406,9 +403,8 @@ static ssize_t radeon_set_pm_profile(struct device *dev,return count; } -static ssize_t radeon_get_pm_method (struct device *dev, -struct device_attribute *attr, -char *buf) +static ssize_t power_method_show (struct device *dev, +struct device_attribute *attr,char *buf) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;@@ -418,10 +414,9 @@ static ssize_t radeon_get_pm_method(struct device *dev, (pm == PM_METHOD_PROFILE) ? "profile" : "dpm"); } -static ssize_t radeon_set_pm_method (struct device *dev, -struct device_attribute *attr, -const char *buf, -size_t count) +static ssize_t power_method_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;@@ -462,9 +457,8 @@ static ssize_t radeon_set_pm_method(struct device *dev,return count; } -static ssize_t radeon_get_dpm_state (struct device *dev, -struct device_attribute *attr, -char *buf) +static ssize_t power_dpm_state_show (struct device *dev, +struct device_attribute *attr,char *buf) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;@@ -475,10 +469,9 @@ static ssize_t radeon_get_dpm_state(struct device *dev, (pm == POWER_STATE_TYPE_BALANCED) ? "balanced" : "performance"); } -static ssize_t radeon_set_dpm_state (struct device *dev, -struct device_attribute *attr, -const char *buf, -size_t count) +static ssize_t power_dpm_state_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;@@ -506,9 +499,9 @@ static ssize_t radeon_set_dpm_state(struct device *dev,return count; } -static ssize_t radeon_get_dpm_forced_performance_level (struct device *dev, -struct device_attribute *attr, -char *buf) +static ssize_t power_dpm_force_performance_level_show (struct device *dev, +struct device_attribute *attr, +char *buf) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;@@ -523,10 +516,9 @@ static ssize_t radeon_get_dpm_forced_performance_level(struct device *dev, (level == RADEON_DPM_FORCED_LEVEL_LOW) ? "low" : "high"); } -static ssize_t radeon_set_dpm_forced_performance_level (struct device *dev, +static ssize_t power_dpm_force_performance_level_store (struct device *dev,struct device_attribute *attr, -const char *buf, -size_t count) +const char *buf,size_t count) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;@@ -658,12 +650,10 @@ static ssize_t radeon_hwmon_get_pwm1(struct device *dev,return sprintf (buf,"%i\n" , speed); } -static DEVICE_ATTR(power_profile, S_IRUGO | S_IWUSR, radeon_get_pm_profile, radeon_set_pm_profile); -static DEVICE_ATTR(power_method, S_IRUGO | S_IWUSR, radeon_get_pm_method, radeon_set_pm_method); -static DEVICE_ATTR(power_dpm_state, S_IRUGO | S_IWUSR, radeon_get_dpm_state, radeon_set_dpm_state); -static DEVICE_ATTR(power_dpm_force_performance_level, S_IRUGO | S_IWUSR, - radeon_get_dpm_forced_performance_level, - radeon_set_dpm_forced_performance_level); +static DEVICE_ATTR_RW (power_profile); +static DEVICE_ATTR_RW (power_method); +static DEVICE_ATTR_RW (power_dpm_state); +static DEVICE_ATTR_RW (power_dpm_force_performance_level); static ssize_t radeon_hwmon_show_temp(struct device *dev, struct device_attribute *attr, --Quoted 2 lines
2.17.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 02.06.21 um 03:53 schrieb Alex Deucher:
Quoted 8 lines · YueHaibing
Quoted 4 lines
Use
DEVICE_ATTR_RW()helper instead of plainDEVICE_ATTR(), which makes the code a bit shorter and easier to read.Signed-off-by YueHaibing <[email protected]>I'm not convinced this really buys us anything other than code churn, but I don't have a particularly strong opinion of others feel differently.
I agree, especially dropping the amdgpu/radeon prefix from the functions doesn't sound like something we want.
Christian.
Quoted 139 lines
Alex
Quoted 129 lines
--- drivers/gpu/drm/radeon/radeon_pm.c | 56 ++++++++++++------------------ 1 file changed, 23 insertions(+), 33 deletions(-)drivers/gpu/drm/radeon/radeon_pm.c +23
-34@@ -352,9 +352,8 @@ static void radeon_pm_print_states(struct radeon_device *rdev) } } -static ssize_t radeon_get_pm_profile (struct device *dev, -struct device_attribute *attr, -char *buf) +static ssize_t power_profile_show (struct device *dev, +struct device_attribute *attr,char *buf) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;@@ -366,10 +365,8 @@ static ssize_t radeon_get_pm_profile(struct device *dev, (cp == PM_PROFILE_HIGH) ? "high" : "default"); } -static ssize_t radeon_set_pm_profile (struct device *dev, -struct device_attribute *attr, -const char *buf, -size_t count) +static ssize_t power_profile_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;@@ -406,9 +403,8 @@ static ssize_t radeon_set_pm_profile(struct device *dev,return count; } -static ssize_t radeon_get_pm_method (struct device *dev, -struct device_attribute *attr, -char *buf) +static ssize_t power_method_show (struct device *dev, +struct device_attribute *attr,char *buf) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;@@ -418,10 +414,9 @@ static ssize_t radeon_get_pm_method(struct device *dev, (pm == PM_METHOD_PROFILE) ? "profile" : "dpm"); } -static ssize_t radeon_set_pm_method (struct device *dev, -struct device_attribute *attr, -const char *buf, -size_t count) +static ssize_t power_method_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;@@ -462,9 +457,8 @@ static ssize_t radeon_set_pm_method(struct device *dev,return count; } -static ssize_t radeon_get_dpm_state (struct device *dev, -struct device_attribute *attr, -char *buf) +static ssize_t power_dpm_state_show (struct device *dev, +struct device_attribute *attr,char *buf) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;@@ -475,10 +469,9 @@ static ssize_t radeon_get_dpm_state(struct device *dev, (pm == POWER_STATE_TYPE_BALANCED) ? "balanced" : "performance"); } -static ssize_t radeon_set_dpm_state (struct device *dev, -struct device_attribute *attr, -const char *buf, -size_t count) +static ssize_t power_dpm_state_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;@@ -506,9 +499,9 @@ static ssize_t radeon_set_dpm_state(struct device *dev,return count; } -static ssize_t radeon_get_dpm_forced_performance_level (struct device *dev, -struct device_attribute *attr, -char *buf) +static ssize_t power_dpm_force_performance_level_show (struct device *dev, +struct device_attribute *attr, +char *buf) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;@@ -523,10 +516,9 @@ static ssize_t radeon_get_dpm_forced_performance_level(struct device *dev, (level == RADEON_DPM_FORCED_LEVEL_LOW) ? "low" : "high"); } -static ssize_t radeon_set_dpm_forced_performance_level (struct device *dev, +static ssize_t power_dpm_force_performance_level_store (struct device *dev,struct device_attribute *attr, -const char *buf, -size_t count) +const char *buf,size_t count) {struct drm_device *ddev =dev_get_drvdata (dev);struct radeon_device *rdev = ddev->dev_private;@@ -658,12 +650,10 @@ static ssize_t radeon_hwmon_get_pwm1(struct device *dev,return sprintf (buf,"%i\n" , speed); } -static DEVICE_ATTR(power_profile, S_IRUGO | S_IWUSR, radeon_get_pm_profile, radeon_set_pm_profile); -static DEVICE_ATTR(power_method, S_IRUGO | S_IWUSR, radeon_get_pm_method, radeon_set_pm_method); -static DEVICE_ATTR(power_dpm_state, S_IRUGO | S_IWUSR, radeon_get_dpm_state, radeon_set_dpm_state); -static DEVICE_ATTR(power_dpm_force_performance_level, S_IRUGO | S_IWUSR, - radeon_get_dpm_forced_performance_level, - radeon_set_dpm_forced_performance_level); +static DEVICE_ATTR_RW (power_profile); +static DEVICE_ATTR_RW (power_method); +static DEVICE_ATTR_RW (power_dpm_state); +static DEVICE_ATTR_RW (power_dpm_force_performance_level); static ssize_t radeon_hwmon_show_temp(struct device *dev, struct device_attribute *attr, --Quoted 2 lines
2.17.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx