Commit fb7d5ebe authored by Deepak R Varma's avatar Deepak R Varma Committed by Greg Kroah-Hartman

staging: fieldbus: use sysfs_emit() in show functions

The show() methods should only use sysfs_emit() when formatting values
to be returned to the user space.
Ref: Documentation/filesystems/sysfs.rst
Issue identified by coccicheck.
Signed-off-by: default avatarDeepak R Varma <drv@mailo.com>
Link: https://lore.kernel.org/r/Y2uEIzebbM/Fs5Jz@qemulionSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8ce25654
......@@ -28,7 +28,7 @@ static ssize_t online_show(struct device *dev, struct device_attribute *attr,
{
struct fieldbus_dev *fb = dev_get_drvdata(dev);
return sprintf(buf, "%d\n", !!fb->online);
return sysfs_emit(buf, "%d\n", !!fb->online);
}
static DEVICE_ATTR_RO(online);
......@@ -39,7 +39,7 @@ static ssize_t enabled_show(struct device *dev, struct device_attribute *attr,
if (!fb->enable_get)
return -EINVAL;
return sprintf(buf, "%d\n", !!fb->enable_get(fb));
return sysfs_emit(buf, "%d\n", !!fb->enable_get(fb));
}
static ssize_t enabled_store(struct device *dev, struct device_attribute *attr,
......@@ -66,11 +66,8 @@ static ssize_t card_name_show(struct device *dev, struct device_attribute *attr,
{
struct fieldbus_dev *fb = dev_get_drvdata(dev);
/*
* card_name was provided by child driver, could potentially be long.
* protect against buffer overrun.
*/
return snprintf(buf, PAGE_SIZE, "%s\n", fb->card_name);
/* card_name was provided by child driver. */
return sysfs_emit(buf, "%s\n", fb->card_name);
}
static DEVICE_ATTR_RO(card_name);
......@@ -79,7 +76,7 @@ static ssize_t read_area_size_show(struct device *dev,
{
struct fieldbus_dev *fb = dev_get_drvdata(dev);
return sprintf(buf, "%zu\n", fb->read_area_sz);
return sysfs_emit(buf, "%zu\n", fb->read_area_sz);
}
static DEVICE_ATTR_RO(read_area_size);
......@@ -88,7 +85,7 @@ static ssize_t write_area_size_show(struct device *dev,
{
struct fieldbus_dev *fb = dev_get_drvdata(dev);
return sprintf(buf, "%zu\n", fb->write_area_sz);
return sysfs_emit(buf, "%zu\n", fb->write_area_sz);
}
static DEVICE_ATTR_RO(write_area_size);
......@@ -116,7 +113,7 @@ static ssize_t fieldbus_type_show(struct device *dev,
break;
}
return sprintf(buf, "%s\n", t);
return sysfs_emit(buf, "%s\n", t);
}
static DEVICE_ATTR_RO(fieldbus_type);
......
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