Thread (3 messages) 3 messages, 3 authors, 2021-04-26

Re: [PATCH] Input: atkbd - simplify atkbd_show_force_release()

From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: 2021-04-25 02:27:43
Also in: lkml

Hi Rasmus,

On Wed, Apr 21, 2021 at 10:16:39PM +0200, Rasmus Villemoes wrote:
We can just include the newline in the format string, and scnprintf()
guarantees nul-termination. These days, sysfs_emit() is
preferred in sysfs ->show methods, so switch to that.
Technically speaking the conversion is not 100% equivalent - original
code ensured that there is always a newline in the output. I kind of
like this, so maybe we need sysfs_emit_nl() or similar?
quoted hunk ↗ jump to hunk
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 drivers/input/keyboard/atkbd.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index edc613efc158..b146a3ec631a 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -1492,13 +1492,8 @@ static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t coun
 
 static ssize_t atkbd_show_force_release(struct atkbd *atkbd, char *buf)
 {
-	size_t len = scnprintf(buf, PAGE_SIZE - 1, "%*pbl",
-			       ATKBD_KEYMAP_SIZE, atkbd->force_release_mask);
-
-	buf[len++] = '\n';
-	buf[len] = '\0';
-
-	return len;
+	return sysfs_emit(buf, "%*pbl\n",
+			  ATKBD_KEYMAP_SIZE, atkbd->force_release_mask);
 }
 
 static ssize_t atkbd_set_force_release(struct atkbd *atkbd,
-- 
2.29.2
Thanks.

-- 
Dmitry
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help