]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
Input: move input_bits_to_string() to input-compat.c
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Wed, 2 Jul 2025 04:29:15 +0000 (21:29 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Thu, 21 Aug 2025 19:00:58 +0000 (12:00 -0700)
The input_bits_to_string() function has special handling for compat
tasks, formatting the output as a sequence of 32-bit hex values. To
better isolate compatibility-related code, move it from
drivers/input/input.c to drivers/input/input-compat.c.

No functional change intended.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/input-compat.c
drivers/input/input-compat.h
drivers/input/input.c

index 2ccd3eedbd6733116de09113e417cbe7e8de8888..a5043193ead85abafe5e0f7739d587ad5f1174da 100644 (file)
@@ -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);
index 3b7bb12b023bc60fc11520d9c98fcc567724afaa..99c87ceb923d52221f8c05ea19e0c37055dd1fe7 100644 (file)
@@ -75,4 +75,7 @@ int input_event_to_user(char __user *buffer,
 int input_ff_effect_from_user(const char __user *buffer, size_t size,
                              struct ff_effect *effect);
 
+int input_bits_to_string(char *buf, int buf_size, unsigned long bits,
+                         bool skip_empty);
+
 #endif /* _INPUT_COMPAT_H */
index 1da41324362b5d5fefd3d189f782ca8434501336..9ec817acfeb14468d5b1f3746b2a0fd561436eff 100644 (file)
@@ -998,41 +998,6 @@ static int input_attach_handler(struct input_dev *dev, struct input_handler *han
        return error;
 }
 
-#ifdef CONFIG_COMPAT
-
-static 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 /* !CONFIG_COMPAT */
-
-static 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
-
 #ifdef CONFIG_PROC_FS
 
 static struct proc_dir_entry *proc_bus_input_dir;