History

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input

Pull input layer updates from Dmitry Torokhov: "2nd round of updates for the input subsystem. With it input core no longer limits number of character devices per event handler (such as evdev) to 32, but switches to dynamic minors once legacy range is exhausted. This should get multi-seat installations that currently run our of event devices very quickly. You will also get an update for Wacom driver and a couple of driver fixes." * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: Input: extend the number of event (and other) devices Input: mousedev - mark mousedev interfaces as non-seekable Input: mousedev - rename mixdev_open to opened_by_mixdev Input: mousedev - reformat structure initializers Input: mousedev - factor out psaux code to reduce #ifdefery Input: samsung-keypad - add clk_prepare and clk_unprepare Input: atmel_mxt_ts - simplify mxt_dump_message Input: wacom - clean up wacom_query_tablet_data Input: wacom - introduce wacom_fix_phy_from_hid Input: wacom - allow any multi-input Intuos device to set prox Input: wacom - report correct touch contact size for I5/Bamboo

Linus Torvalds committed 14 years ago

Commit 8bbbfa72 parents bd81cce 0cc8d6a9 files · +382 −345Browse files

Unified · Split

9 files
  1. drivers/input/evdev.c +33 −66
  2. drivers/input/input.c +53 −61
  3. drivers/input/joydev.c +32 −56
  4. drivers/input/keyboard/samsung-keypad.c +10 −1
  5. drivers/input/mousedev.c +115 −109
  6. drivers/input/tablet/wacom_sys.c +106 −39
  7. drivers/input/tablet/wacom_wac.c +24 −6
  8. drivers/input/touchscreen/atmel_mxt_ts.c +2 −4
  9. include/linux/input.h +7 −3
drivers/input/evdev.c+33−66
@@ -23,11 +23,11 @@ · 22 unmodified lines
2323 #include <linux/input/mt.h>
2424 #include <linux/major.h>
2525 #include <linux/device.h>
26+#include <linux/cdev.h>
2627 #include "input-compat.h"
2728
2829 struct evdev {
2930 int open;
30− int minor;
3131 struct input_handle handle;
3232 wait_queue_head_t wait;
3333 struct evdev_client __rcu *grab;
@@ -35,6 +35,7 @@ struct evdev { · 1 unmodified line
3535 spinlock_t client_lock; /* protects client_list */
3636 struct mutex mutex;
3737 struct device dev;
38+ struct cdev cdev;
3839 bool exist;
3940 };
4041
@@ -51,9 +52,6 @@ struct evdev_client { · 10 unmodified lines
5152 struct input_event buffer[];
5253 };
5354
54−static struct evdev *evdev_table[EVDEV_MINORS];
55−static DEFINE_MUTEX(evdev_table_mutex);
56−
5755 static void __pass_event(struct evdev_client *client,
5856 const struct input_event *event)
5957 {
@@ -310,35 +308,16 @@ static unsigned int evdev_compute_buffer_size(struct input_dev *dev) · 250 unmodified lines
310308
311309 static int evdev_open(struct inode *inode, struct file *file)
312310 {
313− struct evdev *evdev;
311+ struct evdev *evdev = container_of(inode->i_cdev, struct evdev, cdev);
312+ unsigned int bufsize = evdev_compute_buffer_size(evdev->handle.dev);
314313 struct evdev_client *client;
315− int i = iminor(inode) - EVDEV_MINOR_BASE;
316− unsigned int bufsize;
317314 int error;
318315
319− if (i >= EVDEV_MINORS)
320− return -ENODEV;
321−
322− error = mutex_lock_interruptible(&evdev_table_mutex);
323− if (error)
324− return error;
325− evdev = evdev_table[i];
326− if (evdev)
327− get_device(&evdev->dev);
328− mutex_unlock(&evdev_table_mutex);
329−
330− if (!evdev)
331− return -ENODEV;
332−
333− bufsize = evdev_compute_buffer_size(evdev->handle.dev);
334−
335316 client = kzalloc(sizeof(struct evdev_client) +
336317 bufsize * sizeof(struct input_event),
337318 GFP_KERNEL);
338− if (!client) {
339− error = -ENOMEM;
340− goto err_put_evdev;
341− }
319+ if (!client)
320+ return -ENOMEM;
342321
343322 client->bufsize = bufsize;
344323 spin_lock_init(&client->buffer_lock);
@@ -352,13 +331,12 @@ static int evdev_open(struct inode *inode, struct file *file) · 7 unmodified lines
352331 file->private_data = client;
353332 nonseekable_open(inode, file);
354333
334+ get_device(&evdev->dev);
355335 return 0;
356336
357337 err_free_client:
358338 evdev_detach_client(evdev, client);
359339 kfree(client);
360− err_put_evdev:
361− put_device(&evdev->dev);
362340 return error;
363341 }
364342
@@ -942,26 +920,6 @@ static const struct file_operations evdev_fops = { · 577 unmodified lines
942920 .llseek = no_llseek,
943921 };
944922
945−static int evdev_install_chrdev(struct evdev *evdev)
946−{
947− /*
948− * No need to do any locking here as calls to connect and
949− * disconnect are serialized by the input core
950− */
951− evdev_table[evdev->minor] = evdev;
952− return 0;
953−}
954−
955−static void evdev_remove_chrdev(struct evdev *evdev)
956−{
957− /*
958− * Lock evdev table to prevent race with evdev_open()
959− */
960− mutex_lock(&evdev_table_mutex);
961− evdev_table[evdev->minor] = NULL;
962− mutex_unlock(&evdev_table_mutex);
963−}
964−
965923 /*
966924 * Mark device non-existent. This disables writes, ioctls and
967925 * prevents new users from opening the device. Already posted
@@ -980,7 +938,8 @@ static void evdev_cleanup(struct evdev *evdev) · 12 unmodified lines
980938
981939 evdev_mark_dead(evdev);
982940 evdev_hangup(evdev);
983− evdev_remove_chrdev(evdev);
941+
942+ cdev_del(&evdev->cdev);
984943
985944 /* evdev is marked dead so no one else accesses evdev->open */
986945 if (evdev->open) {
@@ -991,43 +950,47 @@ static void evdev_cleanup(struct evdev *evdev) · 4 unmodified lines
991950
992951 /*
993952 * Create new evdev device. Note that input core serializes calls
994− * to connect and disconnect so we don't need to lock evdev_table here.
953+ * to connect and disconnect.
995954 */
996955 static int evdev_connect(struct input_handler *handler, struct input_dev *dev,
997956 const struct input_device_id *id)
998957 {
999958 struct evdev *evdev;
1000959 int minor;
960+ int dev_no;
1001961 int error;
1002962
1003− for (minor = 0; minor < EVDEV_MINORS; minor++)
1004− if (!evdev_table[minor])
1005− break;
1006−
1007− if (minor == EVDEV_MINORS) {
1008− pr_err("no more free evdev devices\n");
1009− return -ENFILE;
963+ minor = input_get_new_minor(EVDEV_MINOR_BASE, EVDEV_MINORS, true);
964+ if (minor < 0) {
965+ error = minor;
966+ pr_err("failed to reserve new minor: %d\n", error);
967+ return error;
1010968 }
1011969
1012970 evdev = kzalloc(sizeof(struct evdev), GFP_KERNEL);
1013− if (!evdev)
1014− return -ENOMEM;
971+ if (!evdev) {
972+ error = -ENOMEM;
973+ goto err_free_minor;
974+ }
1015975
1016976 INIT_LIST_HEAD(&evdev->client_list);
1017977 spin_lock_init(&evdev->client_lock);
1018978 mutex_init(&evdev->mutex);
1019979 init_waitqueue_head(&evdev->wait);
1020−
1021− dev_set_name(&evdev->dev, "event%d", minor);
1022980 evdev->exist = true;
1023− evdev->minor = minor;
981+
982+ dev_no = minor;
983+ /* Normalize device number if it falls into legacy range */
984+ if (dev_no < EVDEV_MINOR_BASE + EVDEV_MINORS)
985+ dev_no -= EVDEV_MINOR_BASE;
986+ dev_set_name(&evdev->dev, "event%d", dev_no);
1024987
1025988 evdev->handle.dev = input_get_device(dev);
1026989 evdev->handle.name = dev_name(&evdev->dev);
1027990 evdev->handle.handler = handler;
1028991 evdev->handle.private = evdev;
1029992
1030− evdev->dev.devt = MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor);
993+ evdev->dev.devt = MKDEV(INPUT_MAJOR, minor);
1031994 evdev->dev.class = &input_class;
1032995 evdev->dev.parent = &dev->dev;
1033996 evdev->dev.release = evdev_free;
@@ -1037,7 +1000,8 @@ static int evdev_connect(struct input_handler *handler, struct input_dev *dev, · 3 unmodified lines
10371000 if (error)
10381001 goto err_free_evdev;
10391002
1040− error = evdev_install_chrdev(evdev);
1003+ cdev_init(&evdev->cdev, &evdev_fops);
1004+ error = cdev_add(&evdev->cdev, evdev->dev.devt, 1);
10411005 if (error)
10421006 goto err_unregister_handle;
10431007
@@ -1053,6 +1017,8 @@ static int evdev_connect(struct input_handler *handler, struct input_dev *dev, · 9 unmodified lines
10531017 input_unregister_handle(&evdev->handle);
10541018 err_free_evdev:
10551019 put_device(&evdev->dev);
1020+ err_free_minor:
1021+ input_free_minor(minor);
10561022 return error;
10571023 }
10581024
@@ -1062,6 +1028,7 @@ static void evdev_disconnect(struct input_handle *handle) · 3 unmodified lines
10621028
10631029 device_del(&evdev->dev);
10641030 evdev_cleanup(evdev);
1031+ input_free_minor(MINOR(evdev->dev.devt));
10651032 input_unregister_handle(handle);
10661033 put_device(&evdev->dev);
10671034 }
@@ -1078,7 +1045,7 @@ static struct input_handler evdev_handler = { · 10 unmodified lines
10781045 .events = evdev_events,
10791046 .connect = evdev_connect,
10801047 .disconnect = evdev_disconnect,
1081− .fops = &evdev_fops,
1048+ .legacy_minors = true,
10821049 .minor = EVDEV_MINOR_BASE,
10831050 .name = "evdev",
10841051 .id_table = evdev_ids,
drivers/input/input.c+53−61
@@ -14,6 +14,7 @@ · 13 unmodified lines
1414
1515 #include <linux/init.h>
1616 #include <linux/types.h>
17+#include <linux/idr.h>
1718 #include <linux/input/mt.h>
1819 #include <linux/module.h>
1920 #include <linux/slab.h>
@@ -32,7 +33,9 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>"); · 12 unmodified lines
3233 MODULE_DESCRIPTION("Input core");
3334 MODULE_LICENSE("GPL");
3435
35−#define INPUT_DEVICES 256
36+#define INPUT_MAX_CHAR_DEVICES 1024
37+#define INPUT_FIRST_DYNAMIC_DEV 256
38+static DEFINE_IDA(input_ida);
3639
3740 static LIST_HEAD(input_dev_list);
3841 static LIST_HEAD(input_handler_list);
@@ -45,8 +48,6 @@ static LIST_HEAD(input_handler_list); · 6 unmodified lines
4548 */
4649 static DEFINE_MUTEX(input_mutex);
4750
48−static struct input_handler *input_table[8];
49−
5051 static const struct input_value input_value_sync = { EV_SYN, SYN_REPORT, 1 };
5152
5253 static inline int is_event_supported(unsigned int code,
@@ -1218,7 +1219,7 @@ static int input_handlers_seq_show(struct seq_file *seq, void *v) · 1165 unmodified lines
12181219 seq_printf(seq, "N: Number=%u Name=%s", state->pos, handler->name);
12191220 if (handler->filter)
12201221 seq_puts(seq, " (filter)");
1221− if (handler->fops)
1222+ if (handler->legacy_minors)
12221223 seq_printf(seq, " Minor=%d", handler->minor);
12231224 seq_putc(seq, '\n');
12241225
@@ -2016,22 +2017,14 @@ EXPORT_SYMBOL(input_unregister_device); · 791 unmodified lines
20162017 int input_register_handler(struct input_handler *handler)
20172018 {
20182019 struct input_dev *dev;
2019− int retval;
2020+ int error;
20202021
2021− retval = mutex_lock_interruptible(&input_mutex);
2022− if (retval)
2023− return retval;
2022+ error = mutex_lock_interruptible(&input_mutex);
2023+ if (error)
2024+ return error;
20242025
20252026 INIT_LIST_HEAD(&handler->h_list);
20262027
2027− if (handler->fops != NULL) {
2028− if (input_table[handler->minor >> 5]) {
2029− retval = -EBUSY;
2030− goto out;
2031− }
2032− input_table[handler->minor >> 5] = handler;
2033− }
2034−
20352028 list_add_tail(&handler->node, &input_handler_list);
20362029
20372030 list_for_each_entry(dev, &input_dev_list, node)
@@ -2039,9 +2032,8 @@ int input_register_handler(struct input_handler *handler) · 1 unmodified line
20392032
20402033 input_wakeup_procfs_readers();
20412034
2042− out:
20432035 mutex_unlock(&input_mutex);
2044− return retval;
2036+ return 0;
20452037 }
20462038 EXPORT_SYMBOL(input_register_handler);
20472039
@@ -2064,9 +2056,6 @@ void input_unregister_handler(struct input_handler *handler) · 16 unmodified lines
20642056
20652057 list_del_init(&handler->node);
20662058
2067− if (handler->fops != NULL)
2068− input_table[handler->minor >> 5] = NULL;
2069−
20702059 input_wakeup_procfs_readers();
20712060
20722061 mutex_unlock(&input_mutex);
@@ -2183,51 +2172,52 @@ void input_unregister_handle(struct input_handle *handle) · 110 unmodified lines
21832172 }
21842173 EXPORT_SYMBOL(input_unregister_handle);
21852174
2186−static int input_open_file(struct inode *inode, struct file *file)
2175+/**
2176+ * input_get_new_minor - allocates a new input minor number
2177+ * @legacy_base: beginning or the legacy range to be searched
2178+ * @legacy_num: size of legacy range
2179+ * @allow_dynamic: whether we can also take ID from the dynamic range
2180+ *
2181+ * This function allocates a new device minor for from input major namespace.
2182+ * Caller can request legacy minor by specifying @legacy_base and @legacy_num
2183+ * parameters and whether ID can be allocated from dynamic range if there are
2184+ * no free IDs in legacy range.
2185+ */
2186+int input_get_new_minor(int legacy_base, unsigned int legacy_num,
2187+ bool allow_dynamic)
21872188 {
2188− struct input_handler *handler;
2189− const struct file_operations *old_fops, *new_fops = NULL;
2190− int err;
2191−
2192− err = mutex_lock_interruptible(&input_mutex);
2193− if (err)
2194− return err;
2195−
2196− /* No load-on-demand here? */
2197− handler = input_table[iminor(inode) >> 5];
2198− if (handler)
2199− new_fops = fops_get(handler->fops);
2200−
2201− mutex_unlock(&input_mutex);
2202−
22032189 /*
2204− * That's _really_ odd. Usually NULL ->open means "nothing special",
2205− * not "no device". Oh, well...
2190+ * This function should be called from input handler's ->connect()
2191+ * methods, which are serialized with input_mutex, so no additional
2192+ * locking is needed here.
22062193 */
2207− if (!new_fops || !new_fops->open) {
2208− fops_put(new_fops);
2209− err = -ENODEV;
2210− goto out;
2194+ if (legacy_base >= 0) {
2195+ int minor = ida_simple_get(&input_ida,
2196+ legacy_base,
2197+ legacy_base + legacy_num,
2198+ GFP_KERNEL);
2199+ if (minor >= 0 || !allow_dynamic)
2200+ return minor;
22112201 }
22122202
2213− old_fops = file->f_op;
2214− file->f_op = new_fops;
2215−
2216− err = new_fops->open(inode, file);
2217− if (err) {
2218− fops_put(file->f_op);
2219− file->f_op = fops_get(old_fops);
2220− }
2221− fops_put(old_fops);
2222−out:
2223− return err;
2203+ return ida_simple_get(&input_ida,
2204+ INPUT_FIRST_DYNAMIC_DEV, INPUT_MAX_CHAR_DEVICES,
2205+ GFP_KERNEL);
22242206 }
2207+EXPORT_SYMBOL(input_get_new_minor);
22252208
2226−static const struct file_operations input_fops = {
2227− .owner = THIS_MODULE,
2228− .open = input_open_file,
2229− .llseek = noop_llseek,
2230−};
2209+/**
2210+ * input_free_minor - release previously allocated minor
2211+ * @minor: minor to be released
2212+ *
2213+ * This function releases previously allocated input minor so that it can be
2214+ * reused later.
2215+ */
2216+void input_free_minor(unsigned int minor)
2217+{
2218+ ida_simple_remove(&input_ida, minor);
2219+}
2220+EXPORT_SYMBOL(input_free_minor);
22312221
22322222 static int __init input_init(void)
22332223 {
@@ -2243,7 +2233,8 @@ static int __init input_init(void) · 9 unmodified lines
22432233 if (err)
22442234 goto fail1;
22452235
2246− err = register_chrdev(INPUT_MAJOR, "input", &input_fops);
2236+ err = register_chrdev_region(MKDEV(INPUT_MAJOR, 0),
2237+ INPUT_MAX_CHAR_DEVICES, "input");
22472238 if (err) {
22482239 pr_err("unable to register char major %d", INPUT_MAJOR);
22492240 goto fail2;
@@ -2259,7 +2250,8 @@ static int __init input_init(void) · 9 unmodified lines
22592250 static void __exit input_exit(void)
22602251 {
22612252 input_proc_exit();
2262− unregister_chrdev(INPUT_MAJOR, "input");
2253+ unregister_chrdev_region(MKDEV(INPUT_MAJOR, 0),
2254+ INPUT_MAX_CHAR_DEVICES);
22632255 class_unregister(&input_class);
22642256 }
22652257
drivers/input/joydev.c+32−56
@@ -27,6 +27,7 @@ · 26 unmodified lines
2727 #include <linux/poll.h>
2828 #include <linux/init.h>
2929 #include <linux/device.h>
30+#include <linux/cdev.h>
3031
3132 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
3233 MODULE_DESCRIPTION("Joystick device interfaces");
@@ -39,13 +40,13 @@ MODULE_LICENSE("GPL"); · 6 unmodified lines
3940
4041 struct joydev {
4142 int open;
42− int minor;
4343 struct input_handle handle;
4444 wait_queue_head_t wait;
4545 struct list_head client_list;
4646 spinlock_t client_lock; /* protects client_list */
4747 struct mutex mutex;
4848 struct device dev;
49+ struct cdev cdev;
4950 bool exist;
5051
5152 struct js_corr corr[ABS_CNT];
@@ -70,9 +71,6 @@ struct joydev_client { · 18 unmodified lines
7071 struct list_head node;
7172 };
7273
73−static struct joydev *joydev_table[JOYDEV_MINORS];
74−static DEFINE_MUTEX(joydev_table_mutex);
75−
7674 static int joydev_correct(int value, struct js_corr *corr)
7775 {
7876 switch (corr->type) {
@@ -252,30 +250,14 @@ static int joydev_release(struct inode *inode, struct file *file) · 173 unmodified lines
252250
253251 static int joydev_open(struct inode *inode, struct file *file)
254252 {
253+ struct joydev *joydev =
254+ container_of(inode->i_cdev, struct joydev, cdev);
255255 struct joydev_client *client;
256− struct joydev *joydev;
257− int i = iminor(inode) - JOYDEV_MINOR_BASE;
258256 int error;
259257
260− if (i >= JOYDEV_MINORS)
261− return -ENODEV;
262−
263− error = mutex_lock_interruptible(&joydev_table_mutex);
264− if (error)
265− return error;
266− joydev = joydev_table[i];
267− if (joydev)
268− get_device(&joydev->dev);
269− mutex_unlock(&joydev_table_mutex);
270−
271− if (!joydev)
272− return -ENODEV;
273−
274258 client = kzalloc(sizeof(struct joydev_client), GFP_KERNEL);
275− if (!client) {
276− error = -ENOMEM;
277− goto err_put_joydev;
278− }
259+ if (!client)
260+ return -ENOMEM;
279261
280262 spin_lock_init(&client->buffer_lock);
281263 client->joydev = joydev;
@@ -288,13 +270,12 @@ static int joydev_open(struct inode *inode, struct file *file) · 6 unmodified lines
288270 file->private_data = client;
289271 nonseekable_open(inode, file);
290272
273+ get_device(&joydev->dev);
291274 return 0;
292275
293276 err_free_client:
294277 joydev_detach_client(joydev, client);
295278 kfree(client);
296− err_put_joydev:
297− put_device(&joydev->dev);
298279 return error;
299280 }
300281
@@ -742,19 +723,6 @@ static const struct file_operations joydev_fops = { · 441 unmodified lines
742723 .llseek = no_llseek,
743724 };
744725
745−static int joydev_install_chrdev(struct joydev *joydev)
746−{
747− joydev_table[joydev->minor] = joydev;
748− return 0;
749−}
750−
751−static void joydev_remove_chrdev(struct joydev *joydev)
752−{
753− mutex_lock(&joydev_table_mutex);
754− joydev_table[joydev->minor] = NULL;
755− mutex_unlock(&joydev_table_mutex);
756−}
757−
758726 /*
759727 * Mark device non-existent. This disables writes, ioctls and
760728 * prevents new users from opening the device. Already posted
@@ -773,7 +741,8 @@ static void joydev_cleanup(struct joydev *joydev) · 12 unmodified lines
773741
774742 joydev_mark_dead(joydev);
775743 joydev_hangup(joydev);
776− joydev_remove_chrdev(joydev);
744+
745+ cdev_del(&joydev->cdev);
777746
778747 /* joydev is marked dead so no one else accesses joydev->open */
779748 if (joydev->open)
@@ -798,30 +767,33 @@ static int joydev_connect(struct input_handler *handler, struct input_dev *dev, · 18 unmodified lines
798767 const struct input_device_id *id)
799768 {
800769 struct joydev *joydev;
801− int i, j, t, minor;
770+ int i, j, t, minor, dev_no;
802771 int error;
803772
804− for (minor = 0; minor < JOYDEV_MINORS; minor++)
805− if (!joydev_table[minor])
806− break;
807−
808− if (minor == JOYDEV_MINORS) {
809− pr_err("no more free joydev devices\n");
810− return -ENFILE;
773+ minor = input_get_new_minor(JOYDEV_MINOR_BASE, JOYDEV_MINORS, true);
774+ if (minor < 0) {
775+ error = minor;
776+ pr_err("failed to reserve new minor: %d\n", error);
777+ return error;
811778 }
812779
813780 joydev = kzalloc(sizeof(struct joydev), GFP_KERNEL);
814− if (!joydev)
815− return -ENOMEM;
781+ if (!joydev) {
782+ error = -ENOMEM;
783+ goto err_free_minor;
784+ }
816785
817786 INIT_LIST_HEAD(&joydev->client_list);
818787 spin_lock_init(&joydev->client_lock);
819788 mutex_init(&joydev->mutex);
820789 init_waitqueue_head(&joydev->wait);
821−
822− dev_set_name(&joydev->dev, "js%d", minor);
823790 joydev->exist = true;
824− joydev->minor = minor;
791+
792+ dev_no = minor;
793+ /* Normalize device number if it falls into legacy range */
794+ if (dev_no < JOYDEV_MINOR_BASE + JOYDEV_MINORS)
795+ dev_no -= JOYDEV_MINOR_BASE;
796+ dev_set_name(&joydev->dev, "js%d", dev_no);
825797
826798 joydev->handle.dev = input_get_device(dev);
827799 joydev->handle.name = dev_name(&joydev->dev);
@@ -875,7 +847,7 @@ static int joydev_connect(struct input_handler *handler, struct input_dev *dev, · 47 unmodified lines
875847 }
876848 }
877849
878− joydev->dev.devt = MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor);
850+ joydev->dev.devt = MKDEV(INPUT_MAJOR, minor);
879851 joydev->dev.class = &input_class;
880852 joydev->dev.parent = &dev->dev;
881853 joydev->dev.release = joydev_free;
@@ -885,7 +857,8 @@ static int joydev_connect(struct input_handler *handler, struct input_dev *dev, · 3 unmodified lines
885857 if (error)
886858 goto err_free_joydev;
887859
888− error = joydev_install_chrdev(joydev);
860+ cdev_init(&joydev->cdev, &joydev_fops);
861+ error = cdev_add(&joydev->cdev, joydev->dev.devt, 1);
889862 if (error)
890863 goto err_unregister_handle;
891864
@@ -901,6 +874,8 @@ static int joydev_connect(struct input_handler *handler, struct input_dev *dev, · 9 unmodified lines
901874 input_unregister_handle(&joydev->handle);
902875 err_free_joydev:
903876 put_device(&joydev->dev);
877+ err_free_minor:
878+ input_free_minor(minor);
904879 return error;
905880 }
906881
@@ -910,6 +885,7 @@ static void joydev_disconnect(struct input_handle *handle) · 3 unmodified lines
910885
911886 device_del(&joydev->dev);
912887 joydev_cleanup(joydev);
888+ input_free_minor(MINOR(joydev->dev.devt));
913889 input_unregister_handle(handle);
914890 put_device(&joydev->dev);
915891 }
@@ -961,7 +937,7 @@ static struct input_handler joydev_handler = { · 45 unmodified lines
961937 .match = joydev_match,
962938 .connect = joydev_connect,
963939 .disconnect = joydev_disconnect,
964− .fops = &joydev_fops,
940+ .legacy_minors = true,
965941 .minor = JOYDEV_MINOR_BASE,
966942 .name = "joydev",
967943 .id_table = joydev_ids,
drivers/input/keyboard/samsung-keypad.c+10−1
@@ -431,6 +431,12 @@ static int __devinit samsung_keypad_probe(struct platform_device *pdev) · 430 unmodified lines
431431 goto err_unmap_base;
432432 }
433433
434+ error = clk_prepare(keypad->clk);
435+ if (error) {
436+ dev_err(&pdev->dev, "keypad clock prepare failed\n");
437+ goto err_put_clk;
438+ }
439+
434440 keypad->input_dev = input_dev;
435441 keypad->pdev = pdev;
436442 keypad->row_shift = row_shift;
@@ -461,7 +467,7 @@ static int __devinit samsung_keypad_probe(struct platform_device *pdev) · 24 unmodified lines
461467 keypad->keycodes, input_dev);
462468 if (error) {
463469 dev_err(&pdev->dev, "failed to build keymap\n");
464− goto err_put_clk;
470+ goto err_unprepare_clk;
465471 }
466472
467473 input_set_capability(input_dev, EV_MSC, MSC_SCAN);
@@ -503,6 +509,8 @@ err_free_irq: · 35 unmodified lines
503509 pm_runtime_disable(&pdev->dev);
504510 device_init_wakeup(&pdev->dev, 0);
505511 platform_set_drvdata(pdev, NULL);
512+err_unprepare_clk:
513+ clk_unprepare(keypad->clk);
506514 err_put_clk:
507515 clk_put(keypad->clk);
508516 samsung_keypad_dt_gpio_free(keypad);
@@ -531,6 +539,7 @@ static int __devexit samsung_keypad_remove(struct platform_device *pdev) · 22 unmodified lines
531539 */
532540 free_irq(keypad->irq, keypad);
533541
542+ clk_unprepare(keypad->clk);
534543 clk_put(keypad->clk);
535544 samsung_keypad_dt_gpio_free(keypad);
536545
drivers/input/mousedev.c+115−109
@@ -24,10 +24,8 @@ · 23 unmodified lines
2424 #include <linux/random.h>
2525 #include <linux/major.h>
2626 #include <linux/device.h>
27+#include <linux/cdev.h>
2728 #include <linux/kernel.h>
28−#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
29−#include <linux/miscdevice.h>
30−#endif
3129
3230 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
3331 MODULE_DESCRIPTION("Mouse (ExplorerPS/2) device interfaces");
@@ -61,17 +59,18 @@ struct mousedev_hw_data { · 27 unmodified lines
6159
6260 struct mousedev {
6361 int open;
64− int minor;
6562 struct input_handle handle;
6663 wait_queue_head_t wait;
6764 struct list_head client_list;
6865 spinlock_t client_lock; /* protects client_list */
6966 struct mutex mutex;
7067 struct device dev;
68+ struct cdev cdev;
7169 bool exist;
70+ bool is_mixdev;
7271
7372 struct list_head mixdev_node;
74− int mixdev_open;
73+ bool opened_by_mixdev;
7574
7675 struct mousedev_hw_data packet;
7776 unsigned int pkt_count;
@@ -114,10 +113,6 @@ struct mousedev_client { · 36 unmodified lines
114113 static unsigned char mousedev_imps_seq[] = { 0xf3, 200, 0xf3, 100, 0xf3, 80 };
115114 static unsigned char mousedev_imex_seq[] = { 0xf3, 200, 0xf3, 200, 0xf3, 80 };
116115
117−static struct input_handler mousedev_handler;
118−
119−static struct mousedev *mousedev_table[MOUSEDEV_MINORS];
120−static DEFINE_MUTEX(mousedev_table_mutex);
121116 static struct mousedev *mousedev_mix;
122117 static LIST_HEAD(mousedev_mix_list);
123118
@@ -433,7 +428,7 @@ static int mousedev_open_device(struct mousedev *mousedev) · 309 unmodified lines
433428 if (retval)
434429 return retval;
435430
436− if (mousedev->minor == MOUSEDEV_MIX)
431+ if (mousedev->is_mixdev)
437432 mixdev_open_devices();
438433 else if (!mousedev->exist)
439434 retval = -ENODEV;
@@ -451,7 +446,7 @@ static void mousedev_close_device(struct mousedev *mousedev) · 11 unmodified lines
451446 {
452447 mutex_lock(&mousedev->mutex);
453448
454− if (mousedev->minor == MOUSEDEV_MIX)
449+ if (mousedev->is_mixdev)
455450 mixdev_close_devices();
456451 else if (mousedev->exist && !--mousedev->open)
457452 input_close_device(&mousedev->handle);
@@ -472,11 +467,11 @@ static void mixdev_open_devices(void) · 14 unmodified lines
472467 return;
473468
474469 list_for_each_entry(mousedev, &mousedev_mix_list, mixdev_node) {
475− if (!mousedev->mixdev_open) {
470+ if (!mousedev->opened_by_mixdev) {
476471 if (mousedev_open_device(mousedev))
477472 continue;
478473
479− mousedev->mixdev_open = 1;
474+ mousedev->opened_by_mixdev = true;
480475 }
481476 }
482477 }
@@ -494,8 +489,8 @@ static void mixdev_close_devices(void) · 11 unmodified lines
494489 return;
495490
496491 list_for_each_entry(mousedev, &mousedev_mix_list, mixdev_node) {
497− if (mousedev->mixdev_open) {
498− mousedev->mixdev_open = 0;
492+ if (mousedev->opened_by_mixdev) {
493+ mousedev->opened_by_mixdev = false;
499494 mousedev_close_device(mousedev);
500495 }
501496 }
@@ -538,35 +533,17 @@ static int mousedev_open(struct inode *inode, struct file *file) · 36 unmodified lines
538533 struct mousedev_client *client;
539534 struct mousedev *mousedev;
540535 int error;
541− int i;
542536
543537 #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
544538 if (imajor(inode) == MISC_MAJOR)
545− i = MOUSEDEV_MIX;
539+ mousedev = mousedev_mix;
546540 else
547541 #endif
548− i = iminor(inode) - MOUSEDEV_MINOR_BASE;
549−
550− if (i >= MOUSEDEV_MINORS)
551− return -ENODEV;
552−
553− error = mutex_lock_interruptible(&mousedev_table_mutex);
554− if (error)
555− return error;
556−
557− mousedev = mousedev_table[i];
558− if (mousedev)
559− get_device(&mousedev->dev);
560− mutex_unlock(&mousedev_table_mutex);
561−
562− if (!mousedev)
563− return -ENODEV;
542+ mousedev = container_of(inode->i_cdev, struct mousedev, cdev);
564543
565544 client = kzalloc(sizeof(struct mousedev_client), GFP_KERNEL);
566− if (!client) {
567− error = -ENOMEM;
568− goto err_put_mousedev;
569− }
545+ if (!client)
546+ return -ENOMEM;
570547
571548 spin_lock_init(&client->packet_lock);
572549 client->pos_x = xres / 2;
@@ -579,13 +556,14 @@ static int mousedev_open(struct inode *inode, struct file *file) · 6 unmodified lines
579556 goto err_free_client;
580557
581558 file->private_data = client;
559+ nonseekable_open(inode, file);
560+
561+ get_device(&mousedev->dev);
582562 return 0;
583563
584564 err_free_client:
585565 mousedev_detach_client(mousedev, client);
586566 kfree(client);
587− err_put_mousedev:
588− put_device(&mousedev->dev);
589567 return error;
590568 }
591569
@@ -785,29 +763,16 @@ static unsigned int mousedev_poll(struct file *file, poll_table *wait) · 193 unmodified lines
785763 }
786764
787765 static const struct file_operations mousedev_fops = {
788− .owner = THIS_MODULE,
789− .read = mousedev_read,
790− .write = mousedev_write,
791− .poll = mousedev_poll,
792− .open = mousedev_open,
793− .release = mousedev_release,
794− .fasync = mousedev_fasync,
795− .llseek = noop_llseek,
766+ .owner = THIS_MODULE,
767+ .read = mousedev_read,
768+ .write = mousedev_write,
769+ .poll = mousedev_poll,
770+ .open = mousedev_open,
771+ .release = mousedev_release,
772+ .fasync = mousedev_fasync,
773+ .llseek = noop_llseek,
796774 };
797775
798−static int mousedev_install_chrdev(struct mousedev *mousedev)
799−{
800− mousedev_table[mousedev->minor] = mousedev;
801− return 0;
802−}
803−
804−static void mousedev_remove_chrdev(struct mousedev *mousedev)
805−{
806− mutex_lock(&mousedev_table_mutex);
807− mousedev_table[mousedev->minor] = NULL;
808− mutex_unlock(&mousedev_table_mutex);
809−}
810−
811776 /*
812777 * Mark device non-existent. This disables writes, ioctls and
813778 * prevents new users from opening the device. Already posted
@@ -842,24 +807,50 @@ static void mousedev_cleanup(struct mousedev *mousedev) · 28 unmodified lines
842807
843808 mousedev_mark_dead(mousedev);
844809 mousedev_hangup(mousedev);
845− mousedev_remove_chrdev(mousedev);
810+
811+ cdev_del(&mousedev->cdev);
846812
847813 /* mousedev is marked dead so no one else accesses mousedev->open */
848814 if (mousedev->open)
849815 input_close_device(handle);
850816 }
851817
818+static int mousedev_reserve_minor(bool mixdev)
819+{
820+ int minor;
821+
822+ if (mixdev) {
823+ minor = input_get_new_minor(MOUSEDEV_MIX, 1, false);
824+ if (minor < 0)
825+ pr_err("failed to reserve mixdev minor: %d\n", minor);
826+ } else {
827+ minor = input_get_new_minor(MOUSEDEV_MINOR_BASE,
828+ MOUSEDEV_MINORS, true);
829+ if (minor < 0)
830+ pr_err("failed to reserve new minor: %d\n", minor);
831+ }
832+
833+ return minor;
834+}
835+
852836 static struct mousedev *mousedev_create(struct input_dev *dev,
853837 struct input_handler *handler,
854− int minor)
838+ bool mixdev)
855839 {
856840 struct mousedev *mousedev;
841+ int minor;
857842 int error;
858843
844+ minor = mousedev_reserve_minor(mixdev);
845+ if (minor < 0) {
846+ error = minor;
847+ goto err_out;
848+ }
849+
859850 mousedev = kzalloc(sizeof(struct mousedev), GFP_KERNEL);
860851 if (!mousedev) {
861852 error = -ENOMEM;
862− goto err_out;
853+ goto err_free_minor;
863854 }
864855
865856 INIT_LIST_HEAD(&mousedev->client_list);
@@ -867,16 +858,21 @@ static struct mousedev *mousedev_create(struct input_dev *dev, · 1 unmodified line
867858 spin_lock_init(&mousedev->client_lock);
868859 mutex_init(&mousedev->mutex);
869860 lockdep_set_subclass(&mousedev->mutex,
870− minor == MOUSEDEV_MIX ? SINGLE_DEPTH_NESTING : 0);
861+ mixdev ? SINGLE_DEPTH_NESTING : 0);
871862 init_waitqueue_head(&mousedev->wait);
872863
873− if (minor == MOUSEDEV_MIX)
864+ if (mixdev) {
874865 dev_set_name(&mousedev->dev, "mice");
875− else
876− dev_set_name(&mousedev->dev, "mouse%d", minor);
866+ } else {
867+ int dev_no = minor;
868+ /* Normalize device number if it falls into legacy range */
869+ if (dev_no < MOUSEDEV_MINOR_BASE + MOUSEDEV_MINORS)
870+ dev_no -= MOUSEDEV_MINOR_BASE;
871+ dev_set_name(&mousedev->dev, "mouse%d", dev_no);
872+ }
877873
878− mousedev->minor = minor;
879874 mousedev->exist = true;
875+ mousedev->is_mixdev = mixdev;
880876 mousedev->handle.dev = input_get_device(dev);
881877 mousedev->handle.name = dev_name(&mousedev->dev);
882878 mousedev->handle.handler = handler;
@@ -885,17 +881,18 @@ static struct mousedev *mousedev_create(struct input_dev *dev, · 2 unmodified lines
885881 mousedev->dev.class = &input_class;
886882 if (dev)
887883 mousedev->dev.parent = &dev->dev;
888− mousedev->dev.devt = MKDEV(INPUT_MAJOR, MOUSEDEV_MINOR_BASE + minor);
884+ mousedev->dev.devt = MKDEV(INPUT_MAJOR, minor);
889885 mousedev->dev.release = mousedev_free;
890886 device_initialize(&mousedev->dev);
891887
892− if (minor != MOUSEDEV_MIX) {
888+ if (!mixdev) {
893889 error = input_register_handle(&mousedev->handle);
894890 if (error)
895891 goto err_free_mousedev;
896892 }
897893
898− error = mousedev_install_chrdev(mousedev);
894+ cdev_init(&mousedev->cdev, &mousedev_fops);
895+ error = cdev_add(&mousedev->cdev, mousedev->dev.devt, 1);
899896 if (error)
900897 goto err_unregister_handle;
901898
@@ -908,10 +905,12 @@ static struct mousedev *mousedev_create(struct input_dev *dev, · 6 unmodified lines
908905 err_cleanup_mousedev:
909906 mousedev_cleanup(mousedev);
910907 err_unregister_handle:
911− if (minor != MOUSEDEV_MIX)
908+ if (!mixdev)
912909 input_unregister_handle(&mousedev->handle);
913910 err_free_mousedev:
914911 put_device(&mousedev->dev);
912+ err_free_minor:
913+ input_free_minor(minor);
915914 err_out:
916915 return ERR_PTR(error);
917916 }
@@ -920,7 +919,8 @@ static void mousedev_destroy(struct mousedev *mousedev) · 2 unmodified lines
920919 {
921920 device_del(&mousedev->dev);
922921 mousedev_cleanup(mousedev);
923− if (mousedev->minor != MOUSEDEV_MIX)
922+ input_free_minor(MINOR(mousedev->dev.devt));
923+ if (!mousedev->is_mixdev)
924924 input_unregister_handle(&mousedev->handle);
925925 put_device(&mousedev->dev);
926926 }
@@ -938,7 +938,7 @@ static int mixdev_add_device(struct mousedev *mousedev) · 11 unmodified lines
938938 if (retval)
939939 goto out;
940940
941− mousedev->mixdev_open = 1;
941+ mousedev->opened_by_mixdev = true;
942942 }
943943
944944 get_device(&mousedev->dev);
@@ -953,8 +953,8 @@ static void mixdev_remove_device(struct mousedev *mousedev) · 8 unmodified lines
953953 {
954954 mutex_lock(&mousedev_mix->mutex);
955955
956− if (mousedev->mixdev_open) {
957− mousedev->mixdev_open = 0;
956+ if (mousedev->opened_by_mixdev) {
957+ mousedev->opened_by_mixdev = false;
958958 mousedev_close_device(mousedev);
959959 }
960960
@@ -969,19 +969,9 @@ static int mousedev_connect(struct input_handler *handler, · 8 unmodified lines
969969 const struct input_device_id *id)
970970 {
971971 struct mousedev *mousedev;
972− int minor;
973972 int error;
974973
975− for (minor = 0; minor < MOUSEDEV_MINORS; minor++)
976− if (!mousedev_table[minor])
977− break;
978−
979− if (minor == MOUSEDEV_MINORS) {
980− pr_err("no more free mousedev devices\n");
981− return -ENFILE;
982− }
983−
984− mousedev = mousedev_create(dev, handler, minor);
974+ mousedev = mousedev_create(dev, handler, false);
985975 if (IS_ERR(mousedev))
986976 return PTR_ERR(mousedev);
987977
@@ -1054,27 +1044,53 @@ static const struct input_device_id mousedev_ids[] = { · 66 unmodified lines
10541044 MODULE_DEVICE_TABLE(input, mousedev_ids);
10551045
10561046 static struct input_handler mousedev_handler = {
1057− .event = mousedev_event,
1058− .connect = mousedev_connect,
1059− .disconnect = mousedev_disconnect,
1060− .fops = &mousedev_fops,
1061− .minor = MOUSEDEV_MINOR_BASE,
1062− .name = "mousedev",
1063− .id_table = mousedev_ids,
1047+ .event = mousedev_event,
1048+ .connect = mousedev_connect,
1049+ .disconnect = mousedev_disconnect,
1050+ .legacy_minors = true,
1051+ .minor = MOUSEDEV_MINOR_BASE,
1052+ .name = "mousedev",
1053+ .id_table = mousedev_ids,
10641054 };
10651055
10661056 #ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
1057+#include <linux/miscdevice.h>
1058+
10671059 static struct miscdevice psaux_mouse = {
1068− PSMOUSE_MINOR, "psaux", &mousedev_fops
1060+ .minor = PSMOUSE_MINOR,
1061+ .name = "psaux",
1062+ .fops = &mousedev_fops,
10691063 };
1070−static int psaux_registered;
1064+
1065+static bool psaux_registered;
1066+
1067+static void __init mousedev_psaux_register(void)
1068+{
1069+ int error;
1070+
1071+ error = misc_register(&psaux_mouse);
1072+ if (error)
1073+ pr_warn("could not register psaux device, error: %d\n",
1074+ error);
1075+ else
1076+ psaux_registered = true;
1077+}
1078+
1079+static void __exit mousedev_psaux_unregister(void)
1080+{
1081+ if (psaux_registered)
1082+ misc_deregister(&psaux_mouse);
1083+}
1084+#else
1085+static inline void mousedev_psaux_register(void) { }
1086+static inline void mousedev_psaux_unregister(void) { }
10711087 #endif
10721088
10731089 static int __init mousedev_init(void)
10741090 {
10751091 int error;
10761092
1077− mousedev_mix = mousedev_create(NULL, &mousedev_handler, MOUSEDEV_MIX);
1093+ mousedev_mix = mousedev_create(NULL, &mousedev_handler, true);
10781094 if (IS_ERR(mousedev_mix))
10791095 return PTR_ERR(mousedev_mix);
10801096
@@ -1084,14 +1100,7 @@ static int __init mousedev_init(void) · 3 unmodified lines
10841100 return error;
10851101 }
10861102
1087−#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
1088− error = misc_register(&psaux_mouse);
1089− if (error)
1090− pr_warn("could not register psaux device, error: %d\n",
1091− error);
1092− else
1093− psaux_registered = 1;
1094−#endif
1103+ mousedev_psaux_register();
10951104
10961105 pr_info("PS/2 mouse device common for all mice\n");
10971106
@@ -1100,10 +1109,7 @@ static int __init mousedev_init(void) · 2 unmodified lines
11001109
11011110 static void __exit mousedev_exit(void)
11021111 {
1103−#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
1104− if (psaux_registered)
1105− misc_deregister(&psaux_mouse);
1106−#endif
1112+ mousedev_psaux_unregister();
11071113 input_unregister_handler(&mousedev_handler);
11081114 mousedev_destroy(mousedev_mix);
11091115 }
drivers/input/tablet/wacom_sys.c+106−39
@@ -171,6 +171,76 @@ static void wacom_close(struct input_dev *dev) · 170 unmodified lines
171171 usb_autopm_put_interface(wacom->intf);
172172 }
173173
174+/*
175+ * Calculate the resolution of the X or Y axis, given appropriate HID data.
176+ * This function is little more than hidinput_calc_abs_res stripped down.
177+ */
178+static int wacom_calc_hid_res(int logical_extents, int physical_extents,
179+ unsigned char unit, unsigned char exponent)
180+{
181+ int prev, unit_exponent;
182+
183+ /* Check if the extents are sane */
184+ if (logical_extents <= 0 || physical_extents <= 0)
185+ return 0;
186+
187+ /* Get signed value of nybble-sized twos-compliment exponent */
188+ unit_exponent = exponent;
189+ if (unit_exponent > 7)
190+ unit_exponent -= 16;
191+
192+ /* Convert physical_extents to millimeters */
193+ if (unit == 0x11) { /* If centimeters */
194+ unit_exponent += 1;
195+ } else if (unit == 0x13) { /* If inches */
196+ prev = physical_extents;
197+ physical_extents *= 254;
198+ if (physical_extents < prev)
199+ return 0;
200+ unit_exponent -= 1;
201+ } else {
202+ return 0;
203+ }
204+
205+ /* Apply negative unit exponent */
206+ for (; unit_exponent < 0; unit_exponent++) {
207+ prev = logical_extents;
208+ logical_extents *= 10;
209+ if (logical_extents < prev)
210+ return 0;
211+ }
212+ /* Apply positive unit exponent */
213+ for (; unit_exponent > 0; unit_exponent--) {
214+ prev = physical_extents;
215+ physical_extents *= 10;
216+ if (physical_extents < prev)
217+ return 0;
218+ }
219+
220+ /* Calculate resolution */
221+ return logical_extents / physical_extents;
222+}
223+
224+/*
225+ * The physical dimension specified by the HID descriptor is likely not in
226+ * the "100th of a mm" units expected by wacom_calculate_touch_res. This
227+ * function adjusts the value of [xy]_phy based on the unit and exponent
228+ * provided by the HID descriptor. If an error occurs durring conversion
229+ * (e.g. from the unit being left unspecified) [xy]_phy is not modified.
230+ */
231+static void wacom_fix_phy_from_hid(struct wacom_features *features)
232+{
233+ int xres = wacom_calc_hid_res(features->x_max, features->x_phy,
234+ features->unit, features->unitExpo);
235+ int yres = wacom_calc_hid_res(features->y_max, features->y_phy,
236+ features->unit, features->unitExpo);
237+
238+ if (xres > 0 && yres > 0) {
239+ features->x_phy = (100 * features->x_max) / xres;
240+ features->y_phy = (100 * features->y_max) / yres;
241+ }
242+}
243+
174244 /*
175245 * Static values for max X/Y and resolution of Pen interface is stored in
176246 * features. This mean physical size of active area can be computed.
@@ -432,56 +502,52 @@ static int wacom_parse_hid(struct usb_interface *intf, · 255 unmodified lines
432502 return result;
433503 }
434504
435−static int wacom_query_tablet_data(struct usb_interface *intf, struct wacom_features *features)
505+static int wacom_set_device_mode(struct usb_interface *intf, int report_id, int length, int mode)
436506 {
437507 unsigned char *rep_data;
438− int limit = 0, report_id = 2;
439− int error = -ENOMEM;
508+ int error = -ENOMEM, limit = 0;
440509
441− rep_data = kmalloc(4, GFP_KERNEL);
510+ rep_data = kzalloc(length, GFP_KERNEL);
442511 if (!rep_data)
443512 return error;
444513
445− /* ask to report Wacom data */
514+ rep_data[0] = report_id;
515+ rep_data[1] = mode;
516+
517+ do {
518+ error = wacom_set_report(intf, WAC_HID_FEATURE_REPORT,
519+ report_id, rep_data, length, 1);
520+ if (error >= 0)
521+ error = wacom_get_report(intf, WAC_HID_FEATURE_REPORT,
522+ report_id, rep_data, length, 1);
523+ } while ((error < 0 || rep_data[1] != mode) && limit++ < WAC_MSG_RETRIES);
524+
525+ kfree(rep_data);
526+
527+ return error < 0 ? error : 0;
528+}
529+
530+/*
531+ * Switch the tablet into its most-capable mode. Wacom tablets are
532+ * typically configured to power-up in a mode which sends mouse-like
533+ * reports to the OS. To get absolute position, pressure data, etc.
534+ * from the tablet, it is necessary to switch the tablet out of this
535+ * mode and into one which sends the full range of tablet data.
536+ */
537+static int wacom_query_tablet_data(struct usb_interface *intf, struct wacom_features *features)
538+{
446539 if (features->device_type == BTN_TOOL_FINGER) {
447− /* if it is an MT Tablet PC touch */
448540 if (features->type > TABLETPC) {
449− do {
450− rep_data[0] = 3;
451− rep_data[1] = 4;
452− rep_data[2] = 0;
453− rep_data[3] = 0;
454− report_id = 3;
455− error = wacom_set_report(intf,
456− WAC_HID_FEATURE_REPORT,
457− report_id,
458− rep_data, 4, 1);
459− if (error >= 0)
460− error = wacom_get_report(intf,
461− WAC_HID_FEATURE_REPORT,
462− report_id,
463− rep_data, 4, 1);
464− } while ((error < 0 || rep_data[1] != 4) &&
465− limit++ < WAC_MSG_RETRIES);
541+ /* MT Tablet PC touch */
542+ return wacom_set_device_mode(intf, 3, 4, 4);
543+ }
544+ } else if (features->device_type == BTN_TOOL_PEN) {
545+ if (features->type <= BAMBOO_PT && features->type != WIRELESS) {
546+ return wacom_set_device_mode(intf, 2, 2, 2);
466547 }
467− } else if (features->type <= BAMBOO_PT &&
468− features->type != WIRELESS &&
469− features->device_type == BTN_TOOL_PEN) {
470− do {
471− rep_data[0] = 2;
472− rep_data[1] = 2;
473− error = wacom_set_report(intf, WAC_HID_FEATURE_REPORT,
474− report_id, rep_data, 2, 1);
475− if (error >= 0)
476− error = wacom_get_report(intf,
477− WAC_HID_FEATURE_REPORT,
478− report_id, rep_data, 2, 1);
479− } while ((error < 0 || rep_data[1] != 2) && limit++ < WAC_MSG_RETRIES);
480548 }
481549
482− kfree(rep_data);
483−
484− return error < 0 ? error : 0;
550+ return 0;
485551 }
486552
487553 static int wacom_retrieve_hid_descriptor(struct usb_interface *intf,
@@ -531,6 +597,7 @@ static int wacom_retrieve_hid_descriptor(struct usb_interface *intf, · 43 unmodified lines
531597 error = wacom_parse_hid(intf, hid_desc, features);
532598 if (error)
533599 goto out;
600+ wacom_fix_phy_from_hid(features);
534601
535602 out:
536603 return error;
drivers/input/tablet/wacom_wac.c+24−6
@@ -25,6 +25,11 @@ · 24 unmodified lines
2525 #define WACOM_INTUOS_RES 100
2626 #define WACOM_INTUOS3_RES 200
2727
28+/* Scale factor relating reported contact size to logical contact area.
29+ * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo
30+ */
31+#define WACOM_CONTACT_AREA_SCALE 2607
32+
2833 static int wacom_penpartner_irq(struct wacom_wac *wacom)
2934 {
3035 unsigned char *data = wacom->data;
@@ -326,7 +331,7 @@ static int wacom_intuos_inout(struct wacom_wac *wacom) · 295 unmodified lines
326331
327332 /* Enter report */
328333 if ((data[1] & 0xfc) == 0xc0) {
329− if (features->type >= INTUOS5S && features->type <= INTUOS5L)
334+ if (features->quirks == WACOM_QUIRK_MULTI_INPUT)
330335 wacom->shared->stylus_in_proximity = true;
331336
332337 /* serial number of the tool */
@@ -414,7 +419,7 @@ static int wacom_intuos_inout(struct wacom_wac *wacom) · 81 unmodified lines
414419
415420 /* Exit report */
416421 if ((data[1] & 0xfe) == 0x80) {
417− if (features->type >= INTUOS5S && features->type <= INTUOS5L)
422+ if (features->quirks == WACOM_QUIRK_MULTI_INPUT)
418423 wacom->shared->stylus_in_proximity = false;
419424
420425 /*
@@ -1043,11 +1048,19 @@ static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data) · 622 unmodified lines
10431048 if (touch) {
10441049 int x = (data[2] << 4) | (data[4] >> 4);
10451050 int y = (data[3] << 4) | (data[4] & 0x0f);
1046− int w = data[6];
1051+ int a = data[5];
1052+
1053+ // "a" is a scaled-down area which we assume is roughly
1054+ // circular and which can be described as: a=(pi*r^2)/C.
1055+ int x_res = input_abs_get_res(input, ABS_X);
1056+ int y_res = input_abs_get_res(input, ABS_Y);
1057+ int width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE);
1058+ int height = width * y_res / x_res;
10471059
10481060 input_report_abs(input, ABS_MT_POSITION_X, x);
10491061 input_report_abs(input, ABS_MT_POSITION_Y, y);
1050− input_report_abs(input, ABS_MT_TOUCH_MAJOR, w);
1062+ input_report_abs(input, ABS_MT_TOUCH_MAJOR, width);
1063+ input_report_abs(input, ABS_MT_TOUCH_MINOR, height);
10511064 }
10521065 }
10531066
@@ -1533,7 +1546,9 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev, · 479 unmodified lines
15331546 input_mt_init_slots(input_dev, features->touch_max, 0);
15341547
15351548 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
1536− 0, 255, 0, 0);
1549+ 0, features->x_max, 0, 0);
1550+ input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR,
1551+ 0, features->y_max, 0, 0);
15371552
15381553 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
15391554 0, features->x_max,
@@ -1641,7 +1656,10 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev, · 101 unmodified lines
16411656
16421657 input_set_abs_params(input_dev,
16431658 ABS_MT_TOUCH_MAJOR,
1644− 0, 255, 0, 0);
1659+ 0, features->x_max, 0, 0);
1660+ input_set_abs_params(input_dev,
1661+ ABS_MT_TOUCH_MINOR,
1662+ 0, features->y_max, 0, 0);
16451663 }
16461664
16471665 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
drivers/input/touchscreen/atmel_mxt_ts.c+2−4
@@ -320,10 +320,8 @@ static bool mxt_object_writable(unsigned int type) · 319 unmodified lines
320320 static void mxt_dump_message(struct device *dev,
321321 struct mxt_message *message)
322322 {
323− dev_dbg(dev, "reportid: %u\tmessage: %02x %02x %02x %02x %02x %02x %02x\n",
324− message->reportid, message->message[0], message->message[1],
325− message->message[2], message->message[3], message->message[4],
326− message->message[5], message->message[6]);
323+ dev_dbg(dev, "reportid: %u\tmessage: %*ph\n",
324+ message->reportid, 7, message->message);
327325 }
328326
329327 static int mxt_check_bootloader(struct i2c_client *client,
include/linux/input.h+7−3
@@ -1396,8 +1396,8 @@ struct input_handle; · 1395 unmodified lines
13961396 * @start: starts handler for given handle. This function is called by
13971397 * input core right after connect() method and also when a process
13981398 * that "grabbed" a device releases it
1399− * @fops: file operations this driver implements
1400− * @minor: beginning of range of 32 minors for devices this driver
1399+ * @legacy_minors: set to %true by drivers using legacy minor ranges
1400+ * @minor: beginning of range of 32 legacy minors for devices this driver
14011401 * can provide
14021402 * @name: name of the handler, to be shown in /proc/bus/input/handlers
14031403 * @id_table: pointer to a table of input_device_ids this driver can
@@ -1431,7 +1431,7 @@ struct input_handler { · 27 unmodified lines
14311431 void (*disconnect)(struct input_handle *handle);
14321432 void (*start)(struct input_handle *handle);
14331433
1434− const struct file_operations *fops;
1434+ bool legacy_minors;
14351435 int minor;
14361436 const char *name;
14371437
@@ -1499,6 +1499,10 @@ void input_reset_device(struct input_dev *); · 61 unmodified lines
14991499 int __must_check input_register_handler(struct input_handler *);
15001500 void input_unregister_handler(struct input_handler *);
15011501
1502+int __must_check input_get_new_minor(int legacy_base, unsigned int legacy_num,
1503+ bool allow_dynamic);
1504+void input_free_minor(unsigned int minor);
1505+
15021506 int input_handler_for_each_handle(struct input_handler *, void *data,
15031507 int (*fn)(struct input_handle *, void *));
15041508