Commit 47acbd77 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Rafael J. Wysocki

PM / sysfs: Convert to use DEVICE_ATTR_RO / DEVICE_ATTR_RW

Use DEVICE_ATTR_RO() and DEVICE_ATTR_RW() macros instead of
open coding them.

No functional change intended.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: default avatarPavel Machek <pavel@ucw.cz>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent f0e6d9f1
...@@ -119,9 +119,9 @@ static ssize_t control_store(struct device * dev, struct device_attribute *attr, ...@@ -119,9 +119,9 @@ static ssize_t control_store(struct device * dev, struct device_attribute *attr,
return n; return n;
} }
static DEVICE_ATTR(control, 0644, control_show, control_store); static DEVICE_ATTR_RW(control);
static ssize_t rtpm_active_time_show(struct device *dev, static ssize_t runtime_active_time_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
int ret; int ret;
...@@ -132,9 +132,9 @@ static ssize_t rtpm_active_time_show(struct device *dev, ...@@ -132,9 +132,9 @@ static ssize_t rtpm_active_time_show(struct device *dev,
return ret; return ret;
} }
static DEVICE_ATTR(runtime_active_time, 0444, rtpm_active_time_show, NULL); static DEVICE_ATTR_RO(runtime_active_time);
static ssize_t rtpm_suspended_time_show(struct device *dev, static ssize_t runtime_suspended_time_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
int ret; int ret;
...@@ -146,9 +146,9 @@ static ssize_t rtpm_suspended_time_show(struct device *dev, ...@@ -146,9 +146,9 @@ static ssize_t rtpm_suspended_time_show(struct device *dev,
return ret; return ret;
} }
static DEVICE_ATTR(runtime_suspended_time, 0444, rtpm_suspended_time_show, NULL); static DEVICE_ATTR_RO(runtime_suspended_time);
static ssize_t rtpm_status_show(struct device *dev, static ssize_t runtime_status_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
const char *p; const char *p;
...@@ -178,7 +178,7 @@ static ssize_t rtpm_status_show(struct device *dev, ...@@ -178,7 +178,7 @@ static ssize_t rtpm_status_show(struct device *dev,
return sprintf(buf, p); return sprintf(buf, p);
} }
static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL); static DEVICE_ATTR_RO(runtime_status);
static ssize_t autosuspend_delay_ms_show(struct device *dev, static ssize_t autosuspend_delay_ms_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
...@@ -205,12 +205,11 @@ static ssize_t autosuspend_delay_ms_store(struct device *dev, ...@@ -205,12 +205,11 @@ static ssize_t autosuspend_delay_ms_store(struct device *dev,
return n; return n;
} }
static DEVICE_ATTR(autosuspend_delay_ms, 0644, autosuspend_delay_ms_show, static DEVICE_ATTR_RW(autosuspend_delay_ms);
autosuspend_delay_ms_store);
static ssize_t pm_qos_resume_latency_show(struct device *dev, static ssize_t pm_qos_resume_latency_us_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
s32 value = dev_pm_qos_requested_resume_latency(dev); s32 value = dev_pm_qos_requested_resume_latency(dev);
...@@ -222,9 +221,9 @@ static ssize_t pm_qos_resume_latency_show(struct device *dev, ...@@ -222,9 +221,9 @@ static ssize_t pm_qos_resume_latency_show(struct device *dev,
return sprintf(buf, "%d\n", value); return sprintf(buf, "%d\n", value);
} }
static ssize_t pm_qos_resume_latency_store(struct device *dev, static ssize_t pm_qos_resume_latency_us_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t n) const char *buf, size_t n)
{ {
s32 value; s32 value;
int ret; int ret;
...@@ -250,12 +249,11 @@ static ssize_t pm_qos_resume_latency_store(struct device *dev, ...@@ -250,12 +249,11 @@ static ssize_t pm_qos_resume_latency_store(struct device *dev,
return ret < 0 ? ret : n; return ret < 0 ? ret : n;
} }
static DEVICE_ATTR(pm_qos_resume_latency_us, 0644, static DEVICE_ATTR_RW(pm_qos_resume_latency_us);
pm_qos_resume_latency_show, pm_qos_resume_latency_store);
static ssize_t pm_qos_latency_tolerance_show(struct device *dev, static ssize_t pm_qos_latency_tolerance_us_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
s32 value = dev_pm_qos_get_user_latency_tolerance(dev); s32 value = dev_pm_qos_get_user_latency_tolerance(dev);
...@@ -267,9 +265,9 @@ static ssize_t pm_qos_latency_tolerance_show(struct device *dev, ...@@ -267,9 +265,9 @@ static ssize_t pm_qos_latency_tolerance_show(struct device *dev,
return sprintf(buf, "%d\n", value); return sprintf(buf, "%d\n", value);
} }
static ssize_t pm_qos_latency_tolerance_store(struct device *dev, static ssize_t pm_qos_latency_tolerance_us_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t n) const char *buf, size_t n)
{ {
s32 value; s32 value;
int ret; int ret;
...@@ -290,8 +288,7 @@ static ssize_t pm_qos_latency_tolerance_store(struct device *dev, ...@@ -290,8 +288,7 @@ static ssize_t pm_qos_latency_tolerance_store(struct device *dev,
return ret < 0 ? ret : n; return ret < 0 ? ret : n;
} }
static DEVICE_ATTR(pm_qos_latency_tolerance_us, 0644, static DEVICE_ATTR_RW(pm_qos_latency_tolerance_us);
pm_qos_latency_tolerance_show, pm_qos_latency_tolerance_store);
static ssize_t pm_qos_no_power_off_show(struct device *dev, static ssize_t pm_qos_no_power_off_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
...@@ -317,24 +314,22 @@ static ssize_t pm_qos_no_power_off_store(struct device *dev, ...@@ -317,24 +314,22 @@ static ssize_t pm_qos_no_power_off_store(struct device *dev,
return ret < 0 ? ret : n; return ret < 0 ? ret : n;
} }
static DEVICE_ATTR(pm_qos_no_power_off, 0644, static DEVICE_ATTR_RW(pm_qos_no_power_off);
pm_qos_no_power_off_show, pm_qos_no_power_off_store);
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static const char _enabled[] = "enabled"; static const char _enabled[] = "enabled";
static const char _disabled[] = "disabled"; static const char _disabled[] = "disabled";
static ssize_t static ssize_t wakeup_show(struct device *dev, struct device_attribute *attr,
wake_show(struct device * dev, struct device_attribute *attr, char * buf) char *buf)
{ {
return sprintf(buf, "%s\n", device_can_wakeup(dev) return sprintf(buf, "%s\n", device_can_wakeup(dev)
? (device_may_wakeup(dev) ? _enabled : _disabled) ? (device_may_wakeup(dev) ? _enabled : _disabled)
: ""); : "");
} }
static ssize_t static ssize_t wakeup_store(struct device *dev, struct device_attribute *attr,
wake_store(struct device * dev, struct device_attribute *attr, const char *buf, size_t n)
const char * buf, size_t n)
{ {
if (!device_can_wakeup(dev)) if (!device_can_wakeup(dev))
return -EINVAL; return -EINVAL;
...@@ -348,10 +343,10 @@ wake_store(struct device * dev, struct device_attribute *attr, ...@@ -348,10 +343,10 @@ wake_store(struct device * dev, struct device_attribute *attr,
return n; return n;
} }
static DEVICE_ATTR(wakeup, 0644, wake_show, wake_store); static DEVICE_ATTR_RW(wakeup);
static ssize_t wakeup_count_show(struct device *dev, static ssize_t wakeup_count_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
unsigned long count = 0; unsigned long count = 0;
bool enabled = false; bool enabled = false;
...@@ -365,10 +360,11 @@ static ssize_t wakeup_count_show(struct device *dev, ...@@ -365,10 +360,11 @@ static ssize_t wakeup_count_show(struct device *dev,
return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n"); return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n");
} }
static DEVICE_ATTR(wakeup_count, 0444, wakeup_count_show, NULL); static DEVICE_ATTR_RO(wakeup_count);
static ssize_t wakeup_active_count_show(struct device *dev, static ssize_t wakeup_active_count_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr,
char *buf)
{ {
unsigned long count = 0; unsigned long count = 0;
bool enabled = false; bool enabled = false;
...@@ -382,11 +378,11 @@ static ssize_t wakeup_active_count_show(struct device *dev, ...@@ -382,11 +378,11 @@ static ssize_t wakeup_active_count_show(struct device *dev,
return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n"); return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n");
} }
static DEVICE_ATTR(wakeup_active_count, 0444, wakeup_active_count_show, NULL); static DEVICE_ATTR_RO(wakeup_active_count);
static ssize_t wakeup_abort_count_show(struct device *dev, static ssize_t wakeup_abort_count_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
unsigned long count = 0; unsigned long count = 0;
bool enabled = false; bool enabled = false;
...@@ -400,7 +396,7 @@ static ssize_t wakeup_abort_count_show(struct device *dev, ...@@ -400,7 +396,7 @@ static ssize_t wakeup_abort_count_show(struct device *dev,
return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n"); return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n");
} }
static DEVICE_ATTR(wakeup_abort_count, 0444, wakeup_abort_count_show, NULL); static DEVICE_ATTR_RO(wakeup_abort_count);
static ssize_t wakeup_expire_count_show(struct device *dev, static ssize_t wakeup_expire_count_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
...@@ -418,10 +414,10 @@ static ssize_t wakeup_expire_count_show(struct device *dev, ...@@ -418,10 +414,10 @@ static ssize_t wakeup_expire_count_show(struct device *dev,
return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n"); return enabled ? sprintf(buf, "%lu\n", count) : sprintf(buf, "\n");
} }
static DEVICE_ATTR(wakeup_expire_count, 0444, wakeup_expire_count_show, NULL); static DEVICE_ATTR_RO(wakeup_expire_count);
static ssize_t wakeup_active_show(struct device *dev, static ssize_t wakeup_active_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
unsigned int active = 0; unsigned int active = 0;
bool enabled = false; bool enabled = false;
...@@ -435,10 +431,11 @@ static ssize_t wakeup_active_show(struct device *dev, ...@@ -435,10 +431,11 @@ static ssize_t wakeup_active_show(struct device *dev,
return enabled ? sprintf(buf, "%u\n", active) : sprintf(buf, "\n"); return enabled ? sprintf(buf, "%u\n", active) : sprintf(buf, "\n");
} }
static DEVICE_ATTR(wakeup_active, 0444, wakeup_active_show, NULL); static DEVICE_ATTR_RO(wakeup_active);
static ssize_t wakeup_total_time_show(struct device *dev, static ssize_t wakeup_total_time_ms_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr,
char *buf)
{ {
s64 msec = 0; s64 msec = 0;
bool enabled = false; bool enabled = false;
...@@ -452,10 +449,10 @@ static ssize_t wakeup_total_time_show(struct device *dev, ...@@ -452,10 +449,10 @@ static ssize_t wakeup_total_time_show(struct device *dev,
return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n"); return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n");
} }
static DEVICE_ATTR(wakeup_total_time_ms, 0444, wakeup_total_time_show, NULL); static DEVICE_ATTR_RO(wakeup_total_time_ms);
static ssize_t wakeup_max_time_show(struct device *dev, static ssize_t wakeup_max_time_ms_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
s64 msec = 0; s64 msec = 0;
bool enabled = false; bool enabled = false;
...@@ -469,10 +466,11 @@ static ssize_t wakeup_max_time_show(struct device *dev, ...@@ -469,10 +466,11 @@ static ssize_t wakeup_max_time_show(struct device *dev,
return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n"); return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n");
} }
static DEVICE_ATTR(wakeup_max_time_ms, 0444, wakeup_max_time_show, NULL); static DEVICE_ATTR_RO(wakeup_max_time_ms);
static ssize_t wakeup_last_time_show(struct device *dev, static ssize_t wakeup_last_time_ms_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr,
char *buf)
{ {
s64 msec = 0; s64 msec = 0;
bool enabled = false; bool enabled = false;
...@@ -486,12 +484,12 @@ static ssize_t wakeup_last_time_show(struct device *dev, ...@@ -486,12 +484,12 @@ static ssize_t wakeup_last_time_show(struct device *dev,
return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n"); return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n");
} }
static DEVICE_ATTR(wakeup_last_time_ms, 0444, wakeup_last_time_show, NULL); static DEVICE_ATTR_RO(wakeup_last_time_ms);
#ifdef CONFIG_PM_AUTOSLEEP #ifdef CONFIG_PM_AUTOSLEEP
static ssize_t wakeup_prevent_sleep_time_show(struct device *dev, static ssize_t wakeup_prevent_sleep_time_ms_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
s64 msec = 0; s64 msec = 0;
bool enabled = false; bool enabled = false;
...@@ -505,27 +503,29 @@ static ssize_t wakeup_prevent_sleep_time_show(struct device *dev, ...@@ -505,27 +503,29 @@ static ssize_t wakeup_prevent_sleep_time_show(struct device *dev,
return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n"); return enabled ? sprintf(buf, "%lld\n", msec) : sprintf(buf, "\n");
} }
static DEVICE_ATTR(wakeup_prevent_sleep_time_ms, 0444, static DEVICE_ATTR_RO(wakeup_prevent_sleep_time_ms);
wakeup_prevent_sleep_time_show, NULL);
#endif /* CONFIG_PM_AUTOSLEEP */ #endif /* CONFIG_PM_AUTOSLEEP */
#endif /* CONFIG_PM_SLEEP */ #endif /* CONFIG_PM_SLEEP */
#ifdef CONFIG_PM_ADVANCED_DEBUG #ifdef CONFIG_PM_ADVANCED_DEBUG
static ssize_t rtpm_usagecount_show(struct device *dev, static ssize_t runtime_usage_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
return sprintf(buf, "%d\n", atomic_read(&dev->power.usage_count)); return sprintf(buf, "%d\n", atomic_read(&dev->power.usage_count));
} }
static DEVICE_ATTR_RO(runtime_usage);
static ssize_t rtpm_children_show(struct device *dev, static ssize_t runtime_active_kids_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr,
char *buf)
{ {
return sprintf(buf, "%d\n", dev->power.ignore_children ? return sprintf(buf, "%d\n", dev->power.ignore_children ?
0 : atomic_read(&dev->power.child_count)); 0 : atomic_read(&dev->power.child_count));
} }
static DEVICE_ATTR_RO(runtime_active_kids);
static ssize_t rtpm_enabled_show(struct device *dev, static ssize_t runtime_enabled_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
if (dev->power.disable_depth && (dev->power.runtime_auto == false)) if (dev->power.disable_depth && (dev->power.runtime_auto == false))
return sprintf(buf, "disabled & forbidden\n"); return sprintf(buf, "disabled & forbidden\n");
...@@ -535,10 +535,7 @@ static ssize_t rtpm_enabled_show(struct device *dev, ...@@ -535,10 +535,7 @@ static ssize_t rtpm_enabled_show(struct device *dev,
return sprintf(buf, "forbidden\n"); return sprintf(buf, "forbidden\n");
return sprintf(buf, "enabled\n"); return sprintf(buf, "enabled\n");
} }
static DEVICE_ATTR_RO(runtime_enabled);
static DEVICE_ATTR(runtime_usage, 0444, rtpm_usagecount_show, NULL);
static DEVICE_ATTR(runtime_active_kids, 0444, rtpm_children_show, NULL);
static DEVICE_ATTR(runtime_enabled, 0444, rtpm_enabled_show, NULL);
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
static ssize_t async_show(struct device *dev, struct device_attribute *attr, static ssize_t async_show(struct device *dev, struct device_attribute *attr,
...@@ -561,7 +558,7 @@ static ssize_t async_store(struct device *dev, struct device_attribute *attr, ...@@ -561,7 +558,7 @@ static ssize_t async_store(struct device *dev, struct device_attribute *attr,
return n; return n;
} }
static DEVICE_ATTR(async, 0644, async_show, async_store); static DEVICE_ATTR_RW(async);
#endif /* CONFIG_PM_SLEEP */ #endif /* CONFIG_PM_SLEEP */
#endif /* CONFIG_PM_ADVANCED_DEBUG */ #endif /* CONFIG_PM_ADVANCED_DEBUG */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment