Skip to content

Commit

Permalink
hwrng: core - Use DEVICE_ATTR_<RW|RO> macro
Browse files Browse the repository at this point in the history
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: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
YueHaibing authored and Herbert Xu committed May 28, 2021
1 parent aa22cd7 commit 98f481f
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions drivers/char/hw_random/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,9 @@ static int enable_best_rng(void)
return ret;
}

static ssize_t hwrng_attr_current_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
static ssize_t rng_current_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t len)
{
int err;
struct hwrng *rng, *old_rng, *new_rng;
Expand Down Expand Up @@ -354,9 +354,9 @@ static ssize_t hwrng_attr_current_store(struct device *dev,
return err ? : len;
}

static ssize_t hwrng_attr_current_show(struct device *dev,
struct device_attribute *attr,
char *buf)
static ssize_t rng_current_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
ssize_t ret;
struct hwrng *rng;
Expand All @@ -371,9 +371,9 @@ static ssize_t hwrng_attr_current_show(struct device *dev,
return ret;
}

static ssize_t hwrng_attr_available_show(struct device *dev,
struct device_attribute *attr,
char *buf)
static ssize_t rng_available_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
int err;
struct hwrng *rng;
Expand All @@ -392,22 +392,16 @@ static ssize_t hwrng_attr_available_show(struct device *dev,
return strlen(buf);
}

static ssize_t hwrng_attr_selected_show(struct device *dev,
struct device_attribute *attr,
char *buf)
static ssize_t rng_selected_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
return sysfs_emit(buf, "%d\n", cur_rng_set_by_user);
}

static DEVICE_ATTR(rng_current, S_IRUGO | S_IWUSR,
hwrng_attr_current_show,
hwrng_attr_current_store);
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 DEVICE_ATTR_RW(rng_current);
static DEVICE_ATTR_RO(rng_available);
static DEVICE_ATTR_RO(rng_selected);

static struct attribute *rng_dev_attrs[] = {
&dev_attr_rng_current.attr,
Expand Down

0 comments on commit 98f481f

Please sign in to comment.