未验证 提交 ba499a50 编写于 作者: Z Zhen Lei 提交者: Mark Brown

regulator: userspace-consumer: use DEVICE_ATTR_RO/RW macro

Use DEVICE_ATTR_RO/RW macro helper instead of plain DEVICE_ATTR, which
makes the code a bit shorter and easier to read.
Signed-off-by: NZhen Lei <thunder.leizhen@huawei.com>
Link: https://lore.kernel.org/r/20210602080526.11117-1-thunder.leizhen@huawei.comSigned-off-by: NMark Brown <broonie@kernel.org>
上级 de20b747
...@@ -29,15 +29,15 @@ struct userspace_consumer_data { ...@@ -29,15 +29,15 @@ struct userspace_consumer_data {
struct regulator_bulk_data *supplies; struct regulator_bulk_data *supplies;
}; };
static ssize_t reg_show_name(struct device *dev, static ssize_t name_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct userspace_consumer_data *data = dev_get_drvdata(dev); struct userspace_consumer_data *data = dev_get_drvdata(dev);
return sprintf(buf, "%s\n", data->name); return sprintf(buf, "%s\n", data->name);
} }
static ssize_t reg_show_state(struct device *dev, static ssize_t state_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct userspace_consumer_data *data = dev_get_drvdata(dev); struct userspace_consumer_data *data = dev_get_drvdata(dev);
...@@ -48,8 +48,8 @@ static ssize_t reg_show_state(struct device *dev, ...@@ -48,8 +48,8 @@ static ssize_t reg_show_state(struct device *dev,
return sprintf(buf, "disabled\n"); return sprintf(buf, "disabled\n");
} }
static ssize_t reg_set_state(struct device *dev, struct device_attribute *attr, static ssize_t state_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct userspace_consumer_data *data = dev_get_drvdata(dev); struct userspace_consumer_data *data = dev_get_drvdata(dev);
bool enabled; bool enabled;
...@@ -87,8 +87,8 @@ static ssize_t reg_set_state(struct device *dev, struct device_attribute *attr, ...@@ -87,8 +87,8 @@ static ssize_t reg_set_state(struct device *dev, struct device_attribute *attr,
return count; return count;
} }
static DEVICE_ATTR(name, 0444, reg_show_name, NULL); static DEVICE_ATTR_RO(name);
static DEVICE_ATTR(state, 0644, reg_show_state, reg_set_state); static DEVICE_ATTR_RW(state);
static struct attribute *attributes[] = { static struct attribute *attributes[] = {
&dev_attr_name.attr, &dev_attr_name.attr,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册