hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/input/joydev.c
....@@ -1,13 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Joystick device driver for the input driver suite.
34 *
45 * Copyright (c) 1999-2002 Vojtech Pavlik
56 * Copyright (c) 1999 Colin Van Dyke
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published by
9
- * the Free Software Foundation; either version 2 of the License, or
10
- * (at your option) any later version.
117 */
128
139 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
....@@ -279,7 +275,7 @@
279275 goto err_free_client;
280276
281277 file->private_data = client;
282
- nonseekable_open(inode, file);
278
+ stream_open(inode, file);
283279
284280 return 0;
285281
....@@ -815,6 +811,7 @@
815811 static bool joydev_dev_is_absolute_mouse(struct input_dev *dev)
816812 {
817813 DECLARE_BITMAP(jd_scratch, KEY_CNT);
814
+ bool ev_match = false;
818815
819816 BUILD_BUG_ON(ABS_CNT > KEY_CNT || EV_CNT > KEY_CNT);
820817
....@@ -833,17 +830,36 @@
833830 * considered to be an absolute mouse if the following is
834831 * true:
835832 *
836
- * 1) Event types are exactly EV_ABS, EV_KEY and EV_SYN.
833
+ * 1) Event types are exactly
834
+ * EV_ABS, EV_KEY and EV_SYN
835
+ * or
836
+ * EV_ABS, EV_KEY, EV_SYN and EV_MSC
837
+ * or
838
+ * EV_ABS, EV_KEY, EV_SYN, EV_MSC and EV_REL.
837839 * 2) Absolute events are exactly ABS_X and ABS_Y.
838840 * 3) Keys are exactly BTN_LEFT, BTN_RIGHT and BTN_MIDDLE.
839841 * 4) Device is not on "Amiga" bus.
840842 */
841843
842844 bitmap_zero(jd_scratch, EV_CNT);
845
+ /* VMware VMMouse, HP ILO2 */
843846 __set_bit(EV_ABS, jd_scratch);
844847 __set_bit(EV_KEY, jd_scratch);
845848 __set_bit(EV_SYN, jd_scratch);
846
- if (!bitmap_equal(jd_scratch, dev->evbit, EV_CNT))
849
+ if (bitmap_equal(jd_scratch, dev->evbit, EV_CNT))
850
+ ev_match = true;
851
+
852
+ /* HP ILO2, AMI BMC firmware */
853
+ __set_bit(EV_MSC, jd_scratch);
854
+ if (bitmap_equal(jd_scratch, dev->evbit, EV_CNT))
855
+ ev_match = true;
856
+
857
+ /* VMware Virtual USB Mouse, QEMU USB Tablet, ATEN BMC firmware */
858
+ __set_bit(EV_REL, jd_scratch);
859
+ if (bitmap_equal(jd_scratch, dev->evbit, EV_CNT))
860
+ ev_match = true;
861
+
862
+ if (!ev_match)
847863 return false;
848864
849865 bitmap_zero(jd_scratch, ABS_CNT);