mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-22 07:27:12 +08:00
Input: move input_bits_to_string() to input-compat.c
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>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user