[<prev] [next>] [day] [month] [year] [list]
Message-ID: <Y0HOgd6DFkL8L3Oz@octinomon>
Date: Sat, 8 Oct 2022 20:24:49 +0100
From: Jules Irenge <jbi.octave@...il.com>
To: erazor_de@...rs.sourceforge.net
Cc: jikos@...nel.org, benjamin.tissoires@...hat.com,
linux-input@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 3/3] 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 <jules.irenge@...tgrad.manchester.ac.uk>
---
drivers/hid/hid-roccat-koneplus.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/hid/hid-roccat-koneplus.c b/drivers/hid/hid-roccat-koneplus.c
index 1896c69ea512..1635ddc7c3cf 100644
--- a/drivers/hid/hid-roccat-koneplus.c
+++ b/drivers/hid/hid-roccat-koneplus.c
@@ -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);
--
2.37.3
Powered by blists - more mailing lists