Commit 3d5cb60e authored by Thadeu Lima de Souza Cascardo's avatar Thadeu Lima de Souza Cascardo Committed by Dmitry Torokhov

Input: simplify name handling for certain input handles

For evdev, joydev and mousedev, instead of having a separate character array
holding name of the handle, use struct devce's name which is the same.
Signed-off-by: default avatarThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent 7e044e05
...@@ -25,7 +25,6 @@ struct evdev { ...@@ -25,7 +25,6 @@ struct evdev {
int exist; int exist;
int open; int open;
int minor; int minor;
char name[16];
struct input_handle handle; struct input_handle handle;
wait_queue_head_t wait; wait_queue_head_t wait;
struct evdev_client *grab; struct evdev_client *grab;
...@@ -609,7 +608,8 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd, ...@@ -609,7 +608,8 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
p, compat_mode); p, compat_mode);
if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0))) if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0)))
return str_to_user(dev->name, _IOC_SIZE(cmd), p); return str_to_user(dev_name(&evdev->dev),
_IOC_SIZE(cmd), p);
if (_IOC_NR(cmd) == _IOC_NR(EVIOCGPHYS(0))) if (_IOC_NR(cmd) == _IOC_NR(EVIOCGPHYS(0)))
return str_to_user(dev->phys, _IOC_SIZE(cmd), p); return str_to_user(dev->phys, _IOC_SIZE(cmd), p);
...@@ -807,16 +807,15 @@ static int evdev_connect(struct input_handler *handler, struct input_dev *dev, ...@@ -807,16 +807,15 @@ static int evdev_connect(struct input_handler *handler, struct input_dev *dev,
mutex_init(&evdev->mutex); mutex_init(&evdev->mutex);
init_waitqueue_head(&evdev->wait); init_waitqueue_head(&evdev->wait);
snprintf(evdev->name, sizeof(evdev->name), "event%d", minor); dev_set_name(&evdev->dev, "event%d", minor);
evdev->exist = 1; evdev->exist = 1;
evdev->minor = minor; evdev->minor = minor;
evdev->handle.dev = input_get_device(dev); evdev->handle.dev = input_get_device(dev);
evdev->handle.name = evdev->name; evdev->handle.name = dev_name(&evdev->dev);
evdev->handle.handler = handler; evdev->handle.handler = handler;
evdev->handle.private = evdev; evdev->handle.private = evdev;
dev_set_name(&evdev->dev, evdev->name);
evdev->dev.devt = MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor); evdev->dev.devt = MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor);
evdev->dev.class = &input_class; evdev->dev.class = &input_class;
evdev->dev.parent = &dev->dev; evdev->dev.parent = &dev->dev;
......
...@@ -39,7 +39,6 @@ struct joydev { ...@@ -39,7 +39,6 @@ struct joydev {
int exist; int exist;
int open; int open;
int minor; int minor;
char name[16];
struct input_handle handle; struct input_handle handle;
wait_queue_head_t wait; wait_queue_head_t wait;
struct list_head client_list; struct list_head client_list;
...@@ -537,12 +536,14 @@ static int joydev_ioctl_common(struct joydev *joydev, ...@@ -537,12 +536,14 @@ static int joydev_ioctl_common(struct joydev *joydev,
default: default:
if ((cmd & ~IOCSIZE_MASK) == JSIOCGNAME(0)) { if ((cmd & ~IOCSIZE_MASK) == JSIOCGNAME(0)) {
int len; int len;
if (!dev->name) const char *name = dev_name(&dev->dev);
if (!name)
return 0; return 0;
len = strlen(dev->name) + 1; len = strlen(name) + 1;
if (len > _IOC_SIZE(cmd)) if (len > _IOC_SIZE(cmd))
len = _IOC_SIZE(cmd); len = _IOC_SIZE(cmd);
if (copy_to_user(argp, dev->name, len)) if (copy_to_user(argp, name, len))
return -EFAULT; return -EFAULT;
return len; return len;
} }
...@@ -742,13 +743,13 @@ static int joydev_connect(struct input_handler *handler, struct input_dev *dev, ...@@ -742,13 +743,13 @@ static int joydev_connect(struct input_handler *handler, struct input_dev *dev,
mutex_init(&joydev->mutex); mutex_init(&joydev->mutex);
init_waitqueue_head(&joydev->wait); init_waitqueue_head(&joydev->wait);
snprintf(joydev->name, sizeof(joydev->name), "js%d", minor); dev_set_name(&joydev->dev, "js%d", minor);
joydev->exist = 1; joydev->exist = 1;
joydev->minor = minor; joydev->minor = minor;
joydev->exist = 1; joydev->exist = 1;
joydev->handle.dev = input_get_device(dev); joydev->handle.dev = input_get_device(dev);
joydev->handle.name = joydev->name; joydev->handle.name = dev_name(&joydev->dev);
joydev->handle.handler = handler; joydev->handle.handler = handler;
joydev->handle.private = joydev; joydev->handle.private = joydev;
...@@ -797,7 +798,6 @@ static int joydev_connect(struct input_handler *handler, struct input_dev *dev, ...@@ -797,7 +798,6 @@ static int joydev_connect(struct input_handler *handler, struct input_dev *dev,
} }
} }
dev_set_name(&joydev->dev, joydev->name);
joydev->dev.devt = MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor); joydev->dev.devt = MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor);
joydev->dev.class = &input_class; joydev->dev.class = &input_class;
joydev->dev.parent = &dev->dev; joydev->dev.parent = &dev->dev;
......
...@@ -60,7 +60,6 @@ struct mousedev { ...@@ -60,7 +60,6 @@ struct mousedev {
int exist; int exist;
int open; int open;
int minor; int minor;
char name[16];
struct input_handle handle; struct input_handle handle;
wait_queue_head_t wait; wait_queue_head_t wait;
struct list_head client_list; struct list_head client_list;
...@@ -863,19 +862,17 @@ static struct mousedev *mousedev_create(struct input_dev *dev, ...@@ -863,19 +862,17 @@ static struct mousedev *mousedev_create(struct input_dev *dev,
init_waitqueue_head(&mousedev->wait); init_waitqueue_head(&mousedev->wait);
if (minor == MOUSEDEV_MIX) if (minor == MOUSEDEV_MIX)
strlcpy(mousedev->name, "mice", sizeof(mousedev->name)); dev_set_name(&mousedev->dev, "mice");
else else
snprintf(mousedev->name, sizeof(mousedev->name), dev_set_name(&mousedev->dev, "mouse%d", minor);
"mouse%d", minor);
mousedev->minor = minor; mousedev->minor = minor;
mousedev->exist = 1; mousedev->exist = 1;
mousedev->handle.dev = input_get_device(dev); mousedev->handle.dev = input_get_device(dev);
mousedev->handle.name = mousedev->name; mousedev->handle.name = dev_name(&mousedev->dev);
mousedev->handle.handler = handler; mousedev->handle.handler = handler;
mousedev->handle.private = mousedev; mousedev->handle.private = mousedev;
dev_set_name(&mousedev->dev, mousedev->name);
mousedev->dev.class = &input_class; mousedev->dev.class = &input_class;
if (dev) if (dev)
mousedev->dev.parent = &dev->dev; mousedev->dev.parent = &dev->dev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment