diff options
| author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2025-10-07 21:53:13 -0700 |
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2025-10-07 21:53:13 -0700 |
| commit | 8b87f67b4c87452e21721887fa8dec1f4c6b2b7c (patch) | |
| tree | 2c163f512e5d7f8400b42a7a8439e2b06492a870 /drivers/input/input-compat.c | |
| parent | 30989f67650cbf8dc763f7c22e3a210f70a8d7d0 (diff) | |
| parent | c7866ee0a9ddd9789faadf58cdac6abd7aabf045 (diff) | |
| download | lwn-8b87f67b4c87452e21721887fa8dec1f4c6b2b7c.tar.gz lwn-8b87f67b4c87452e21721887fa8dec1f4c6b2b7c.zip | |
Merge branch 'next' into for-linus
Prepare input updates for 6.18 merge window.
Diffstat (limited to 'drivers/input/input-compat.c')
| -rw-r--r-- | drivers/input/input-compat.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/input/input-compat.c b/drivers/input/input-compat.c index 2ccd3eedbd67..a5043193ead8 100644 --- a/drivers/input/input-compat.c +++ b/drivers/input/input-compat.c @@ -6,6 +6,7 @@ */ #include <linux/export.h> +#include <linux/sprintf.h> #include <linux/uaccess.h> #include "input-compat.h" @@ -94,6 +95,28 @@ int input_ff_effect_from_user(const char __user *buffer, size_t size, return 0; } +int input_bits_to_string(char *buf, int buf_size, unsigned long bits, + bool skip_empty) +{ + int len = 0; + + if (in_compat_syscall()) { + u32 dword = bits >> 32; + if (dword || !skip_empty) + len += snprintf(buf, buf_size, "%x ", dword); + + dword = bits & 0xffffffffUL; + if (dword || !skip_empty || len) + len += snprintf(buf + len, max(buf_size - len, 0), + "%x", dword); + } else { + if (bits || !skip_empty) + len += snprintf(buf, buf_size, "%lx", bits); + } + + return len; +} + #else int input_event_from_user(const char __user *buffer, @@ -126,6 +149,13 @@ int input_ff_effect_from_user(const char __user *buffer, size_t size, return 0; } +int input_bits_to_string(char *buf, int buf_size, unsigned long bits, + bool skip_empty) +{ + return bits || !skip_empty ? + snprintf(buf, buf_size, "%lx", bits) : 0; +} + #endif /* CONFIG_COMPAT */ EXPORT_SYMBOL_GPL(input_event_from_user); |
