Commit 98f481f2 authored by YueHaibing's avatar YueHaibing Committed by Herbert Xu

hwrng: core - Use DEVICE_ATTR_<RW|RO> macro

Use DEVICE_ATTR_RW()/DEVICE_ATTR_RO() helper instead of
plain DEVICE_ATTR, which makes the code a bit shorter and
easier to read.
Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent aa22cd7f
...@@ -319,9 +319,9 @@ static int enable_best_rng(void) ...@@ -319,9 +319,9 @@ static int enable_best_rng(void)
return ret; return ret;
} }
static ssize_t hwrng_attr_current_store(struct device *dev, static ssize_t rng_current_store(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t len) const char *buf, size_t len)
{ {
int err; int err;
struct hwrng *rng, *old_rng, *new_rng; struct hwrng *rng, *old_rng, *new_rng;
...@@ -354,9 +354,9 @@ static ssize_t hwrng_attr_current_store(struct device *dev, ...@@ -354,9 +354,9 @@ static ssize_t hwrng_attr_current_store(struct device *dev,
return err ? : len; return err ? : len;
} }
static ssize_t hwrng_attr_current_show(struct device *dev, static ssize_t rng_current_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
ssize_t ret; ssize_t ret;
struct hwrng *rng; struct hwrng *rng;
...@@ -371,9 +371,9 @@ static ssize_t hwrng_attr_current_show(struct device *dev, ...@@ -371,9 +371,9 @@ static ssize_t hwrng_attr_current_show(struct device *dev,
return ret; return ret;
} }
static ssize_t hwrng_attr_available_show(struct device *dev, static ssize_t rng_available_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
int err; int err;
struct hwrng *rng; struct hwrng *rng;
...@@ -392,22 +392,16 @@ static ssize_t hwrng_attr_available_show(struct device *dev, ...@@ -392,22 +392,16 @@ static ssize_t hwrng_attr_available_show(struct device *dev,
return strlen(buf); return strlen(buf);
} }
static ssize_t hwrng_attr_selected_show(struct device *dev, static ssize_t rng_selected_show(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
char *buf) char *buf)
{ {
return sysfs_emit(buf, "%d\n", cur_rng_set_by_user); return sysfs_emit(buf, "%d\n", cur_rng_set_by_user);
} }
static DEVICE_ATTR(rng_current, S_IRUGO | S_IWUSR, static DEVICE_ATTR_RW(rng_current);
hwrng_attr_current_show, static DEVICE_ATTR_RO(rng_available);
hwrng_attr_current_store); static DEVICE_ATTR_RO(rng_selected);
static DEVICE_ATTR(rng_available, S_IRUGO,
hwrng_attr_available_show,
NULL);
static DEVICE_ATTR(rng_selected, S_IRUGO,
hwrng_attr_selected_show,
NULL);
static struct attribute *rng_dev_attrs[] = { static struct attribute *rng_dev_attrs[] = {
&dev_attr_rng_current.attr, &dev_attr_rng_current.attr,
......
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