Commit 325c4b3b authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Rafael J. Wysocki

PM / sysfs: Convert to use sysfs_streq()

...instead of custom approach.
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 db68daff
...@@ -108,16 +108,10 @@ static ssize_t control_show(struct device *dev, struct device_attribute *attr, ...@@ -108,16 +108,10 @@ static ssize_t control_show(struct device *dev, struct device_attribute *attr,
static ssize_t control_store(struct device * dev, struct device_attribute *attr, static ssize_t control_store(struct device * dev, struct device_attribute *attr,
const char * buf, size_t n) const char * buf, size_t n)
{ {
char *cp;
int len = n;
cp = memchr(buf, '\n', n);
if (cp)
len = cp - buf;
device_lock(dev); device_lock(dev);
if (len == sizeof ctrl_auto - 1 && strncmp(buf, ctrl_auto, len) == 0) if (sysfs_streq(buf, ctrl_auto))
pm_runtime_allow(dev); pm_runtime_allow(dev);
else if (len == sizeof ctrl_on - 1 && strncmp(buf, ctrl_on, len) == 0) else if (sysfs_streq(buf, ctrl_on))
pm_runtime_forbid(dev); pm_runtime_forbid(dev);
else else
n = -EINVAL; n = -EINVAL;
...@@ -245,7 +239,7 @@ static ssize_t pm_qos_resume_latency_store(struct device *dev, ...@@ -245,7 +239,7 @@ static ssize_t pm_qos_resume_latency_store(struct device *dev,
if (value == 0) if (value == 0)
value = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT; value = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT;
} else if (!strcmp(buf, "n/a") || !strcmp(buf, "n/a\n")) { } else if (sysfs_streq(buf, "n/a")) {
value = 0; value = 0;
} else { } else {
return -EINVAL; return -EINVAL;
...@@ -285,9 +279,9 @@ static ssize_t pm_qos_latency_tolerance_store(struct device *dev, ...@@ -285,9 +279,9 @@ static ssize_t pm_qos_latency_tolerance_store(struct device *dev,
if (value < 0) if (value < 0)
return -EINVAL; return -EINVAL;
} else { } else {
if (!strcmp(buf, "auto") || !strcmp(buf, "auto\n")) if (sysfs_streq(buf, "auto"))
value = PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT; value = PM_QOS_LATENCY_TOLERANCE_NO_CONSTRAINT;
else if (!strcmp(buf, "any") || !strcmp(buf, "any\n")) else if (sysfs_streq(buf, "any"))
value = PM_QOS_LATENCY_ANY; value = PM_QOS_LATENCY_ANY;
else else
return -EINVAL; return -EINVAL;
...@@ -342,20 +336,12 @@ static ssize_t ...@@ -342,20 +336,12 @@ static ssize_t
wake_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)
{ {
char *cp;
int len = n;
if (!device_can_wakeup(dev)) if (!device_can_wakeup(dev))
return -EINVAL; return -EINVAL;
cp = memchr(buf, '\n', n); if (sysfs_streq(buf, _enabled))
if (cp)
len = cp - buf;
if (len == sizeof _enabled - 1
&& strncmp(buf, _enabled, sizeof _enabled - 1) == 0)
device_set_wakeup_enable(dev, 1); device_set_wakeup_enable(dev, 1);
else if (len == sizeof _disabled - 1 else if (sysfs_streq(buf, _disabled))
&& strncmp(buf, _disabled, sizeof _disabled - 1) == 0)
device_set_wakeup_enable(dev, 0); device_set_wakeup_enable(dev, 0);
else else
return -EINVAL; return -EINVAL;
...@@ -566,16 +552,9 @@ static ssize_t async_show(struct device *dev, struct device_attribute *attr, ...@@ -566,16 +552,9 @@ static ssize_t async_show(struct device *dev, struct device_attribute *attr,
static ssize_t async_store(struct device *dev, struct device_attribute *attr, static ssize_t async_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t n) const char *buf, size_t n)
{ {
char *cp; if (sysfs_streq(buf, _enabled))
int len = n;
cp = memchr(buf, '\n', n);
if (cp)
len = cp - buf;
if (len == sizeof _enabled - 1 && strncmp(buf, _enabled, len) == 0)
device_enable_async_suspend(dev); device_enable_async_suspend(dev);
else if (len == sizeof _disabled - 1 && else if (sysfs_streq(buf, _disabled))
strncmp(buf, _disabled, len) == 0)
device_disable_async_suspend(dev); device_disable_async_suspend(dev);
else else
return -EINVAL; return -EINVAL;
......
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