Commit 65cdc691 authored by Olliver Schinagl's avatar Olliver Schinagl Committed by Thierry Reding

pwm: sysfs: Make use of the DEVICE_ATTR_[RW][WO] macro's

For the npwm property the PWM sysfs interface already made use of the
DEVICE_ATTR_RO macro. This patch expands this to the other sysfs
properties so that the code base is concise and makes use of this
helpful macro.

This has the advantage of slightly reducing the code size, improving
readability and no longer using magic values for permissions.
Signed-off-by: default avatarOlliver Schinagl <oliver@schinagl.nl>
Signed-off-by: default avatarThierry Reding <thierry.reding@gmail.com>
parent 0344d0d6
......@@ -40,7 +40,7 @@ static struct pwm_device *child_to_pwm_device(struct device *child)
return export->pwm;
}
static ssize_t pwm_period_show(struct device *child,
static ssize_t period_show(struct device *child,
struct device_attribute *attr,
char *buf)
{
......@@ -49,7 +49,7 @@ static ssize_t pwm_period_show(struct device *child,
return sprintf(buf, "%u\n", pwm_get_period(pwm));
}
static ssize_t pwm_period_store(struct device *child,
static ssize_t period_store(struct device *child,
struct device_attribute *attr,
const char *buf, size_t size)
{
......@@ -66,7 +66,7 @@ static ssize_t pwm_period_store(struct device *child,
return ret ? : size;
}
static ssize_t pwm_duty_cycle_show(struct device *child,
static ssize_t duty_cycle_show(struct device *child,
struct device_attribute *attr,
char *buf)
{
......@@ -75,7 +75,7 @@ static ssize_t pwm_duty_cycle_show(struct device *child,
return sprintf(buf, "%u\n", pwm_get_duty_cycle(pwm));
}
static ssize_t pwm_duty_cycle_store(struct device *child,
static ssize_t duty_cycle_store(struct device *child,
struct device_attribute *attr,
const char *buf, size_t size)
{
......@@ -92,7 +92,7 @@ static ssize_t pwm_duty_cycle_store(struct device *child,
return ret ? : size;
}
static ssize_t pwm_enable_show(struct device *child,
static ssize_t enable_show(struct device *child,
struct device_attribute *attr,
char *buf)
{
......@@ -101,7 +101,7 @@ static ssize_t pwm_enable_show(struct device *child,
return sprintf(buf, "%d\n", pwm_is_enabled(pwm));
}
static ssize_t pwm_enable_store(struct device *child,
static ssize_t enable_store(struct device *child,
struct device_attribute *attr,
const char *buf, size_t size)
{
......@@ -127,7 +127,7 @@ static ssize_t pwm_enable_store(struct device *child,
return ret ? : size;
}
static ssize_t pwm_polarity_show(struct device *child,
static ssize_t polarity_show(struct device *child,
struct device_attribute *attr,
char *buf)
{
......@@ -147,7 +147,7 @@ static ssize_t pwm_polarity_show(struct device *child,
return sprintf(buf, "%s\n", polarity);
}
static ssize_t pwm_polarity_store(struct device *child,
static ssize_t polarity_store(struct device *child,
struct device_attribute *attr,
const char *buf, size_t size)
{
......@@ -167,10 +167,10 @@ static ssize_t pwm_polarity_store(struct device *child,
return ret ? : size;
}
static DEVICE_ATTR(period, 0644, pwm_period_show, pwm_period_store);
static DEVICE_ATTR(duty_cycle, 0644, pwm_duty_cycle_show, pwm_duty_cycle_store);
static DEVICE_ATTR(enable, 0644, pwm_enable_show, pwm_enable_store);
static DEVICE_ATTR(polarity, 0644, pwm_polarity_show, pwm_polarity_store);
static DEVICE_ATTR_RW(period);
static DEVICE_ATTR_RW(duty_cycle);
static DEVICE_ATTR_RW(enable);
static DEVICE_ATTR_RW(polarity);
static struct attribute *pwm_attrs[] = {
&dev_attr_period.attr,
......@@ -244,7 +244,7 @@ static int pwm_unexport_child(struct device *parent, struct pwm_device *pwm)
return 0;
}
static ssize_t pwm_export_store(struct device *parent,
static ssize_t export_store(struct device *parent,
struct device_attribute *attr,
const char *buf, size_t len)
{
......@@ -270,9 +270,9 @@ static ssize_t pwm_export_store(struct device *parent,
return ret ? : len;
}
static DEVICE_ATTR(export, 0200, NULL, pwm_export_store);
static DEVICE_ATTR_WO(export);
static ssize_t pwm_unexport_store(struct device *parent,
static ssize_t unexport_store(struct device *parent,
struct device_attribute *attr,
const char *buf, size_t len)
{
......@@ -291,7 +291,7 @@ static ssize_t pwm_unexport_store(struct device *parent,
return ret ? : len;
}
static DEVICE_ATTR(unexport, 0200, NULL, pwm_unexport_store);
static DEVICE_ATTR_WO(unexport);
static ssize_t npwm_show(struct device *parent, struct device_attribute *attr,
char *buf)
......
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