HID: roccat-*: Convert snprintf() to sysfs_emit()
Subsystems (2)
PATCH v2 1/1 HID: roccat-*: Convert snprintf() to sysfs_emit()
Coccinnelle reports a warning
Warning: Use scnprintf or sprintf
Following the advice on kernel documentation
https://www.kernel.org/doc/html/latest/filesystems/sysfs.html
For show(device *...) functions we should only use sysfs_emit() or sysfs_emit_at() especially when formatting the value to be returned to user space. Convert snprintf() to sysfs_emit()
Signed-off-by Jules Irenge <[email protected]>
---
v2 - Combines the 4 previous patches into one
drivers/hid/hid-roccat-kone.c | 12 ++++++------ drivers/hid/hid-roccat-koneplus.c | 4 ++-- drivers/hid/hid-roccat-kovaplus.c | 10 +++++----- drivers/hid/hid-roccat-pyra.c | 6 +++--- 4 files changed, 16 insertions(+), 16 deletions(-)
drivers/hid/hid-roccat-kone.c +6 -6
@@ -403,7 +403,7 @@ static ssize_t kone_sysfs_show_actual_profile(struct device *dev, {struct kone_device *kone =hid_get_drvdata (dev_get_drvdata (dev->parent->parent)); -return snprintf (buf,PAGE_SIZE ,"%d\n" , kone->actual_profile); +return sysfs_emit (buf,"%d\n" , kone->actual_profile); } static DEVICE_ATTR(actual_profile, 0440, kone_sysfs_show_actual_profile, NULL);
@@ -412,7 +412,7 @@ static ssize_t kone_sysfs_show_actual_dpi(struct device *dev, {struct kone_device *kone =hid_get_drvdata (dev_get_drvdata (dev->parent->parent)); -return snprintf (buf,PAGE_SIZE ,"%d\n" , kone->actual_dpi); +return sysfs_emit (buf,"%d\n" , kone->actual_dpi); } static DEVICE_ATTR(actual_dpi, 0440, kone_sysfs_show_actual_dpi, NULL);
@@ -435,7 +435,7 @@ static ssize_t kone_sysfs_show_weight(struct device *dev,if (retval)return retval; -return snprintf (buf,PAGE_SIZE ,"%d\n" , weight); +return sysfs_emit (buf,"%d\n" , weight); } static DEVICE_ATTR(weight, 0440, kone_sysfs_show_weight, NULL);
@@ -444,7 +444,7 @@ static ssize_t kone_sysfs_show_firmware_version(struct device *dev, {struct kone_device *kone =hid_get_drvdata (dev_get_drvdata (dev->parent->parent)); -return snprintf (buf,PAGE_SIZE ,"%d\n" , kone->firmware_version); +return sysfs_emit (buf,"%d\n" , kone->firmware_version); } static DEVICE_ATTR(firmware_version, 0440, kone_sysfs_show_firmware_version, NULL);
@@ -454,7 +454,7 @@ static ssize_t kone_sysfs_show_tcu(struct device *dev, {struct kone_device *kone =hid_get_drvdata (dev_get_drvdata (dev->parent->parent)); -return snprintf (buf,PAGE_SIZE ,"%d\n" , kone->settings.tcu); +return sysfs_emit (buf,"%d\n" , kone->settings.tcu); }static int kone_tcu_command (struct usb_device *usb_dev,int number)
@@ -556,7 +556,7 @@ static ssize_t kone_sysfs_show_startup_profile(struct device *dev, {struct kone_device *kone =hid_get_drvdata (dev_get_drvdata (dev->parent->parent)); -return snprintf (buf,PAGE_SIZE ,"%d\n" , kone->settings.startup_profile); +return sysfs_emit (buf,"%d\n" , kone->settings.startup_profile); } static ssize_t kone_sysfs_set_startup_profile(struct device *dev,
drivers/hid/hid-roccat-koneplus.c +2 -2
@@ -244,7 +244,7 @@ static ssize_t koneplus_sysfs_show_actual_profile(struct device *dev, {struct koneplus_device *koneplus =hid_get_drvdata (dev_get_drvdata (dev->parent->parent)); -return snprintf (buf,PAGE_SIZE ,"%d\n" , koneplus->actual_profile); +return sysfs_emit (buf,"%d\n" , koneplus->actual_profile); } static ssize_t koneplus_sysfs_set_actual_profile(struct device *dev,
@@ -311,7 +311,7 @@ static ssize_t koneplus_sysfs_show_firmware_version(struct device *dev, &info, KONEPLUS_SIZE_INFO);mutex_unlock (&koneplus->koneplus_lock); -return snprintf (buf,PAGE_SIZE ,"%d\n" , info.firmware_version); +return sysfs_emit (buf,"%d\n" , info.firmware_version); } static DEVICE_ATTR(firmware_version, 0440, koneplus_sysfs_show_firmware_version, NULL);
drivers/hid/hid-roccat-kovaplus.c +5 -5
@@ -274,7 +274,7 @@ static ssize_t kovaplus_sysfs_show_actual_profile(struct device *dev, {struct kovaplus_device *kovaplus =hid_get_drvdata (dev_get_drvdata (dev->parent->parent)); -return snprintf (buf,PAGE_SIZE ,"%d\n" , kovaplus->actual_profile); +return sysfs_emit (buf,"%d\n" , kovaplus->actual_profile); } static ssize_t kovaplus_sysfs_set_actual_profile(struct device *dev,
@@ -327,7 +327,7 @@ static ssize_t kovaplus_sysfs_show_actual_cpi(struct device *dev, {struct kovaplus_device *kovaplus =hid_get_drvdata (dev_get_drvdata (dev->parent->parent)); -return snprintf (buf,PAGE_SIZE ,"%d\n" , kovaplus->actual_cpi); +return sysfs_emit (buf,"%d\n" , kovaplus->actual_cpi); } static DEVICE_ATTR(actual_cpi, 0440, kovaplus_sysfs_show_actual_cpi, NULL);
@@ -336,7 +336,7 @@ static ssize_t kovaplus_sysfs_show_actual_sensitivity_x(struct device *dev, {struct kovaplus_device *kovaplus =hid_get_drvdata (dev_get_drvdata (dev->parent->parent)); -return snprintf (buf,PAGE_SIZE ,"%d\n" , kovaplus->actual_x_sensitivity); +return sysfs_emit (buf,"%d\n" , kovaplus->actual_x_sensitivity); } static DEVICE_ATTR(actual_sensitivity_x, 0440, kovaplus_sysfs_show_actual_sensitivity_x, NULL);
@@ -346,7 +346,7 @@ static ssize_t kovaplus_sysfs_show_actual_sensitivity_y(struct device *dev, {struct kovaplus_device *kovaplus =hid_get_drvdata (dev_get_drvdata (dev->parent->parent)); -return snprintf (buf,PAGE_SIZE ,"%d\n" , kovaplus->actual_y_sensitivity); +return sysfs_emit (buf,"%d\n" , kovaplus->actual_y_sensitivity); } static DEVICE_ATTR(actual_sensitivity_y, 0440, kovaplus_sysfs_show_actual_sensitivity_y, NULL);
@@ -367,7 +367,7 @@ static ssize_t kovaplus_sysfs_show_firmware_version(struct device *dev, &info, KOVAPLUS_SIZE_INFO);mutex_unlock (&kovaplus->kovaplus_lock); -return snprintf (buf,PAGE_SIZE ,"%d\n" , info.firmware_version); +return sysfs_emit (buf,"%d\n" , info.firmware_version); } static DEVICE_ATTR(firmware_version, 0440, kovaplus_sysfs_show_firmware_version, NULL);
drivers/hid/hid-roccat-pyra.c +3 -3
@@ -286,7 +286,7 @@ static ssize_t pyra_sysfs_show_actual_cpi(struct device *dev, {struct pyra_device *pyra =hid_get_drvdata (dev_get_drvdata (dev->parent->parent)); -return snprintf (buf,PAGE_SIZE ,"%d\n" , pyra->actual_cpi); +return sysfs_emit (buf,"%d\n" , pyra->actual_cpi); } static DEVICE_ATTR(actual_cpi, 0440, pyra_sysfs_show_actual_cpi, NULL);
@@ -303,7 +303,7 @@ static ssize_t pyra_sysfs_show_actual_profile(struct device *dev, &settings, PYRA_SIZE_SETTINGS);mutex_unlock (&pyra->pyra_lock); -return snprintf (buf,PAGE_SIZE ,"%d\n" , settings.startup_profile); +return sysfs_emit (buf,"%d\n" , settings.startup_profile); } static DEVICE_ATTR(actual_profile, 0440, pyra_sysfs_show_actual_profile, NULL); static DEVICE_ATTR(startup_profile, 0440, pyra_sysfs_show_actual_profile, NULL);
@@ -324,7 +324,7 @@ static ssize_t pyra_sysfs_show_firmware_version(struct device *dev, &info, PYRA_SIZE_INFO);mutex_unlock (&pyra->pyra_lock); -return snprintf (buf,PAGE_SIZE ,"%d\n" , info.firmware_version); +return sysfs_emit (buf,"%d\n" , info.firmware_version); } static DEVICE_ATTR(firmware_version, 0440, pyra_sysfs_show_firmware_version, NULL);
Signature · 1 line
2.37.3