From: YueHaibing <yuehaibing@huawei.com>
To: <alexander.deucher@amd.com>, <christian.koenig@amd.com>,
<Xinhui.Pan@amd.com>, <airlied@linux.ie>, <daniel@ffwll.ch>
Cc: <amd-gfx@lists.freedesktop.org>,
<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>,
YueHaibing <yuehaibing@huawei.com>
Subject: [PATCH -next] drm/radeon/radeon_pm: use DEVICE_ATTR_RW macro
Date: Fri, 28 May 2021 15:02:17 +0800 [thread overview]
Message-ID: <20210528070217.9204-1-yuehaibing@huawei.com> (raw)
Use DEVICE_ATTR_RW() helper instead of plain DEVICE_ATTR(),
which makes the code a bit shorter and easier to read.
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
drivers/gpu/drm/radeon/radeon_pm.c | 56 ++++++++++++------------------
1 file changed, 23 insertions(+), 33 deletions(-)
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
index 3861c0b98fcf..edf10cc3947e 100644
--- a/drivers/gpu/drm/radeon/radeon_pm.c
+++ b/drivers/gpu/drm/radeon/radeon_pm.c
@@ -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
next reply other threads:[~2021-05-28 7:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-28 7:02 YueHaibing [this message]
2021-06-02 1:53 ` Alex Deucher
2021-06-02 6:41 ` Christian König
2021-06-02 6:41 ` Christian König
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210528070217.9204-1-yuehaibing@huawei.com \
--to=yuehaibing@huawei.com \
--cc=Xinhui.Pan@amd.com \
--cc=airlied@linux.ie \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®