Commit 796703ba authored by Bo Liu's avatar Bo Liu Committed by Johannes Berg

rfkill: Use sysfs_emit() to instead of sprintf()

Follow the advice of the Documentation/filesystems/sysfs.rst and show()
should only use sysfs_emit() or sysfs_emit_at() when formatting the
value to be returned to user space.
Signed-off-by: default avatarBo Liu <liubo03@inspur.com>
Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
Link: https://lore.kernel.org/r/20230206081641.3193-1-liubo03@inspur.comSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 19085ef3
...@@ -685,7 +685,7 @@ static ssize_t name_show(struct device *dev, struct device_attribute *attr, ...@@ -685,7 +685,7 @@ static ssize_t name_show(struct device *dev, struct device_attribute *attr,
{ {
struct rfkill *rfkill = to_rfkill(dev); struct rfkill *rfkill = to_rfkill(dev);
return sprintf(buf, "%s\n", rfkill->name); return sysfs_emit(buf, "%s\n", rfkill->name);
} }
static DEVICE_ATTR_RO(name); static DEVICE_ATTR_RO(name);
...@@ -694,7 +694,7 @@ static ssize_t type_show(struct device *dev, struct device_attribute *attr, ...@@ -694,7 +694,7 @@ static ssize_t type_show(struct device *dev, struct device_attribute *attr,
{ {
struct rfkill *rfkill = to_rfkill(dev); struct rfkill *rfkill = to_rfkill(dev);
return sprintf(buf, "%s\n", rfkill_types[rfkill->type]); return sysfs_emit(buf, "%s\n", rfkill_types[rfkill->type]);
} }
static DEVICE_ATTR_RO(type); static DEVICE_ATTR_RO(type);
...@@ -703,7 +703,7 @@ static ssize_t index_show(struct device *dev, struct device_attribute *attr, ...@@ -703,7 +703,7 @@ static ssize_t index_show(struct device *dev, struct device_attribute *attr,
{ {
struct rfkill *rfkill = to_rfkill(dev); struct rfkill *rfkill = to_rfkill(dev);
return sprintf(buf, "%d\n", rfkill->idx); return sysfs_emit(buf, "%d\n", rfkill->idx);
} }
static DEVICE_ATTR_RO(index); static DEVICE_ATTR_RO(index);
...@@ -712,7 +712,7 @@ static ssize_t persistent_show(struct device *dev, ...@@ -712,7 +712,7 @@ static ssize_t persistent_show(struct device *dev,
{ {
struct rfkill *rfkill = to_rfkill(dev); struct rfkill *rfkill = to_rfkill(dev);
return sprintf(buf, "%d\n", rfkill->persistent); return sysfs_emit(buf, "%d\n", rfkill->persistent);
} }
static DEVICE_ATTR_RO(persistent); static DEVICE_ATTR_RO(persistent);
...@@ -721,7 +721,7 @@ static ssize_t hard_show(struct device *dev, struct device_attribute *attr, ...@@ -721,7 +721,7 @@ static ssize_t hard_show(struct device *dev, struct device_attribute *attr,
{ {
struct rfkill *rfkill = to_rfkill(dev); struct rfkill *rfkill = to_rfkill(dev);
return sprintf(buf, "%d\n", (rfkill->state & RFKILL_BLOCK_HW) ? 1 : 0 ); return sysfs_emit(buf, "%d\n", (rfkill->state & RFKILL_BLOCK_HW) ? 1 : 0);
} }
static DEVICE_ATTR_RO(hard); static DEVICE_ATTR_RO(hard);
...@@ -730,7 +730,7 @@ static ssize_t soft_show(struct device *dev, struct device_attribute *attr, ...@@ -730,7 +730,7 @@ static ssize_t soft_show(struct device *dev, struct device_attribute *attr,
{ {
struct rfkill *rfkill = to_rfkill(dev); struct rfkill *rfkill = to_rfkill(dev);
return sprintf(buf, "%d\n", (rfkill->state & RFKILL_BLOCK_SW) ? 1 : 0 ); return sysfs_emit(buf, "%d\n", (rfkill->state & RFKILL_BLOCK_SW) ? 1 : 0);
} }
static ssize_t soft_store(struct device *dev, struct device_attribute *attr, static ssize_t soft_store(struct device *dev, struct device_attribute *attr,
...@@ -764,7 +764,7 @@ static ssize_t hard_block_reasons_show(struct device *dev, ...@@ -764,7 +764,7 @@ static ssize_t hard_block_reasons_show(struct device *dev,
{ {
struct rfkill *rfkill = to_rfkill(dev); struct rfkill *rfkill = to_rfkill(dev);
return sprintf(buf, "0x%lx\n", rfkill->hard_block_reasons); return sysfs_emit(buf, "0x%lx\n", rfkill->hard_block_reasons);
} }
static DEVICE_ATTR_RO(hard_block_reasons); static DEVICE_ATTR_RO(hard_block_reasons);
...@@ -783,7 +783,7 @@ static ssize_t state_show(struct device *dev, struct device_attribute *attr, ...@@ -783,7 +783,7 @@ static ssize_t state_show(struct device *dev, struct device_attribute *attr,
{ {
struct rfkill *rfkill = to_rfkill(dev); struct rfkill *rfkill = to_rfkill(dev);
return sprintf(buf, "%d\n", user_state_from_blocked(rfkill->state)); return sysfs_emit(buf, "%d\n", user_state_from_blocked(rfkill->state));
} }
static ssize_t state_store(struct device *dev, struct device_attribute *attr, static ssize_t state_store(struct device *dev, struct device_attribute *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