Commit cc3db79b authored by Bo Liu's avatar Bo Liu Committed by Greg Kroah-Hartman

misc: isl29003: 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>
Link: https://lore.kernel.org/r/20230129092357.3143-1-liubo03@inspur.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent dd08ebe7
...@@ -186,7 +186,7 @@ static ssize_t isl29003_show_range(struct device *dev, ...@@ -186,7 +186,7 @@ static ssize_t isl29003_show_range(struct device *dev,
{ {
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
return sprintf(buf, "%i\n", isl29003_get_range(client)); return sysfs_emit(buf, "%i\n", isl29003_get_range(client));
} }
static ssize_t isl29003_store_range(struct device *dev, static ssize_t isl29003_store_range(struct device *dev,
...@@ -222,7 +222,7 @@ static ssize_t isl29003_show_resolution(struct device *dev, ...@@ -222,7 +222,7 @@ static ssize_t isl29003_show_resolution(struct device *dev,
{ {
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
return sprintf(buf, "%d\n", isl29003_get_resolution(client)); return sysfs_emit(buf, "%d\n", isl29003_get_resolution(client));
} }
static ssize_t isl29003_store_resolution(struct device *dev, static ssize_t isl29003_store_resolution(struct device *dev,
...@@ -256,7 +256,7 @@ static ssize_t isl29003_show_mode(struct device *dev, ...@@ -256,7 +256,7 @@ static ssize_t isl29003_show_mode(struct device *dev,
{ {
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
return sprintf(buf, "%d\n", isl29003_get_mode(client)); return sysfs_emit(buf, "%d\n", isl29003_get_mode(client));
} }
static ssize_t isl29003_store_mode(struct device *dev, static ssize_t isl29003_store_mode(struct device *dev,
...@@ -291,7 +291,7 @@ static ssize_t isl29003_show_power_state(struct device *dev, ...@@ -291,7 +291,7 @@ static ssize_t isl29003_show_power_state(struct device *dev,
{ {
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
return sprintf(buf, "%d\n", isl29003_get_power_state(client)); return sysfs_emit(buf, "%d\n", isl29003_get_power_state(client));
} }
static ssize_t isl29003_store_power_state(struct device *dev, static ssize_t isl29003_store_power_state(struct device *dev,
...@@ -327,7 +327,7 @@ static ssize_t isl29003_show_lux(struct device *dev, ...@@ -327,7 +327,7 @@ static ssize_t isl29003_show_lux(struct device *dev,
if (!isl29003_get_power_state(client)) if (!isl29003_get_power_state(client))
return -EBUSY; return -EBUSY;
return sprintf(buf, "%d\n", isl29003_get_adc_value(client)); return sysfs_emit(buf, "%d\n", isl29003_get_adc_value(client));
} }
static DEVICE_ATTR(lux, S_IRUGO, isl29003_show_lux, NULL); static DEVICE_ATTR(lux, S_IRUGO, isl29003_show_lux, NULL);
......
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