diff options
69 files changed, 2464 insertions, 1210 deletions
diff --git a/Documentation/ABI/testing/sysfs-driver-hid-roccat-kone b/Documentation/ABI/testing/sysfs-driver-hid-roccat-kone index 063bda7fe707..698b8081c473 100644 --- a/Documentation/ABI/testing/sysfs-driver-hid-roccat-kone +++ b/Documentation/ABI/testing/sysfs-driver-hid-roccat-kone | |||
@@ -1,4 +1,4 @@ | |||
1 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/actual_dpi | 1 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kone/roccatkone<minor>/actual_dpi |
2 | Date: March 2010 | 2 | Date: March 2010 |
3 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | 3 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> |
4 | Description: It is possible to switch the dpi setting of the mouse with the | 4 | Description: It is possible to switch the dpi setting of the mouse with the |
@@ -17,13 +17,13 @@ Description: It is possible to switch the dpi setting of the mouse with the | |||
17 | 17 | ||
18 | This file is readonly. | 18 | This file is readonly. |
19 | 19 | ||
20 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/actual_profile | 20 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kone/roccatkone<minor>/actual_profile |
21 | Date: March 2010 | 21 | Date: March 2010 |
22 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | 22 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> |
23 | Description: When read, this file returns the number of the actual profile. | 23 | Description: When read, this file returns the number of the actual profile. |
24 | This file is readonly. | 24 | This file is readonly. |
25 | 25 | ||
26 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/firmware_version | 26 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kone/roccatkone<minor>/firmware_version |
27 | Date: March 2010 | 27 | Date: March 2010 |
28 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | 28 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> |
29 | Description: When read, this file returns the raw integer version number of the | 29 | Description: When read, this file returns the raw integer version number of the |
@@ -33,7 +33,7 @@ Description: When read, this file returns the raw integer version number of the | |||
33 | left. E.g. a returned value of 138 means 1.38 | 33 | left. E.g. a returned value of 138 means 1.38 |
34 | This file is readonly. | 34 | This file is readonly. |
35 | 35 | ||
36 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/profile[1-5] | 36 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kone/roccatkone<minor>/profile[1-5] |
37 | Date: March 2010 | 37 | Date: March 2010 |
38 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | 38 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> |
39 | Description: The mouse can store 5 profiles which can be switched by the | 39 | Description: The mouse can store 5 profiles which can be switched by the |
@@ -48,7 +48,7 @@ Description: The mouse can store 5 profiles which can be switched by the | |||
48 | stored in the profile doesn't need to fit the number of the | 48 | stored in the profile doesn't need to fit the number of the |
49 | store. | 49 | store. |
50 | 50 | ||
51 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/settings | 51 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kone/roccatkone<minor>/settings |
52 | Date: March 2010 | 52 | Date: March 2010 |
53 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | 53 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> |
54 | Description: When read, this file returns the settings stored in the mouse. | 54 | Description: When read, this file returns the settings stored in the mouse. |
@@ -58,7 +58,7 @@ Description: When read, this file returns the settings stored in the mouse. | |||
58 | The data has to be 36 bytes long. The mouse will reject invalid | 58 | The data has to be 36 bytes long. The mouse will reject invalid |
59 | data. | 59 | data. |
60 | 60 | ||
61 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/startup_profile | 61 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kone/roccatkone<minor>/startup_profile |
62 | Date: March 2010 | 62 | Date: March 2010 |
63 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | 63 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> |
64 | Description: The integer value of this attribute ranges from 1 to 5. | 64 | Description: The integer value of this attribute ranges from 1 to 5. |
@@ -67,7 +67,7 @@ Description: The integer value of this attribute ranges from 1 to 5. | |||
67 | When written, this file sets the number of the startup profile | 67 | When written, this file sets the number of the startup profile |
68 | and the mouse activates this profile immediately. | 68 | and the mouse activates this profile immediately. |
69 | 69 | ||
70 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/tcu | 70 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kone/roccatkone<minor>/tcu |
71 | Date: March 2010 | 71 | Date: March 2010 |
72 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | 72 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> |
73 | Description: The mouse has a "Tracking Control Unit" which lets the user | 73 | Description: The mouse has a "Tracking Control Unit" which lets the user |
@@ -78,7 +78,7 @@ Description: The mouse has a "Tracking Control Unit" which lets the user | |||
78 | Writing 1 in this file will start the calibration which takes | 78 | Writing 1 in this file will start the calibration which takes |
79 | around 6 seconds to complete and activates the TCU. | 79 | around 6 seconds to complete and activates the TCU. |
80 | 80 | ||
81 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/weight | 81 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/kone/roccatkone<minor>/weight |
82 | Date: March 2010 | 82 | Date: March 2010 |
83 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | 83 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> |
84 | Description: The mouse can be equipped with one of four supplied weights | 84 | Description: The mouse can be equipped with one of four supplied weights |
diff --git a/Documentation/ABI/testing/sysfs-driver-hid-roccat-koneplus b/Documentation/ABI/testing/sysfs-driver-hid-roccat-koneplus new file mode 100644 index 000000000000..0f9f30eb1742 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-driver-hid-roccat-koneplus | |||
@@ -0,0 +1,108 @@ | |||
1 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/actual_profile | ||
2 | Date: October 2010 | ||
3 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
4 | Description: When read, this file returns the number of the actual profile in | ||
5 | range 0-4. | ||
6 | This file is readonly. | ||
7 | |||
8 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/firmware_version | ||
9 | Date: October 2010 | ||
10 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
11 | Description: When read, this file returns the raw integer version number of the | ||
12 | firmware reported by the mouse. Using the integer value eases | ||
13 | further usage in other programs. To receive the real version | ||
14 | number the decimal point has to be shifted 2 positions to the | ||
15 | left. E.g. a returned value of 121 means 1.21 | ||
16 | This file is readonly. | ||
17 | |||
18 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/macro | ||
19 | Date: October 2010 | ||
20 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
21 | Description: The mouse can store a macro with max 500 key/button strokes | ||
22 | internally. | ||
23 | When written, this file lets one set the sequence for a specific | ||
24 | button for a specific profile. Button and profile numbers are | ||
25 | included in written data. The data has to be 2082 bytes long. | ||
26 | This file is writeonly. | ||
27 | |||
28 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/profile_buttons | ||
29 | Date: August 2010 | ||
30 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
31 | Description: The mouse can store 5 profiles which can be switched by the | ||
32 | press of a button. A profile is split in settings and buttons. | ||
33 | profile_buttons holds informations about button layout. | ||
34 | When written, this file lets one write the respective profile | ||
35 | buttons back to the mouse. The data has to be 77 bytes long. | ||
36 | The mouse will reject invalid data. | ||
37 | Which profile to write is determined by the profile number | ||
38 | contained in the data. | ||
39 | This file is writeonly. | ||
40 | |||
41 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/profile[1-5]_buttons | ||
42 | Date: August 2010 | ||
43 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
44 | Description: The mouse can store 5 profiles which can be switched by the | ||
45 | press of a button. A profile is split in settings and buttons. | ||
46 | profile_buttons holds informations about button layout. | ||
47 | When read, these files return the respective profile buttons. | ||
48 | The returned data is 77 bytes in size. | ||
49 | This file is readonly. | ||
50 | |||
51 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/profile_settings | ||
52 | Date: October 2010 | ||
53 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
54 | Description: The mouse can store 5 profiles which can be switched by the | ||
55 | press of a button. A profile is split in settings and buttons. | ||
56 | profile_settings holds informations like resolution, sensitivity | ||
57 | and light effects. | ||
58 | When written, this file lets one write the respective profile | ||
59 | settings back to the mouse. The data has to be 43 bytes long. | ||
60 | The mouse will reject invalid data. | ||
61 | Which profile to write is determined by the profile number | ||
62 | contained in the data. | ||
63 | This file is writeonly. | ||
64 | |||
65 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/profile[1-5]_settings | ||
66 | Date: August 2010 | ||
67 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
68 | Description: The mouse can store 5 profiles which can be switched by the | ||
69 | press of a button. A profile is split in settings and buttons. | ||
70 | profile_settings holds informations like resolution, sensitivity | ||
71 | and light effects. | ||
72 | When read, these files return the respective profile settings. | ||
73 | The returned data is 43 bytes in size. | ||
74 | This file is readonly. | ||
75 | |||
76 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/sensor | ||
77 | Date: October 2010 | ||
78 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
79 | Description: The mouse has a tracking- and a distance-control-unit. These | ||
80 | can be activated/deactivated and the lift-off distance can be | ||
81 | set. The data has to be 6 bytes long. | ||
82 | This file is writeonly. | ||
83 | |||
84 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/startup_profile | ||
85 | Date: October 2010 | ||
86 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
87 | Description: The integer value of this attribute ranges from 0-4. | ||
88 | When read, this attribute returns the number of the profile | ||
89 | that's active when the mouse is powered on. | ||
90 | When written, this file sets the number of the startup profile | ||
91 | and the mouse activates this profile immediately. | ||
92 | |||
93 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/tcu | ||
94 | Date: October 2010 | ||
95 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
96 | Description: When written a calibration process for the tracking control unit | ||
97 | can be initiated/cancelled. | ||
98 | The data has to be 3 bytes long. | ||
99 | This file is writeonly. | ||
100 | |||
101 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/koneplus/roccatkoneplus<minor>/tcu_image | ||
102 | Date: October 2010 | ||
103 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | ||
104 | Description: When read the mouse returns a 30x30 pixel image of the | ||
105 | sampled underground. This works only in the course of a | ||
106 | calibration process initiated with tcu. | ||
107 | The returned data is 1028 bytes in size. | ||
108 | This file is readonly. | ||
diff --git a/Documentation/ABI/testing/sysfs-driver-hid-roccat-pyra b/Documentation/ABI/testing/sysfs-driver-hid-roccat-pyra index ad1125b02ff4..1c37b823f142 100644 --- a/Documentation/ABI/testing/sysfs-driver-hid-roccat-pyra +++ b/Documentation/ABI/testing/sysfs-driver-hid-roccat-pyra | |||
@@ -1,4 +1,4 @@ | |||
1 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/actual_cpi | 1 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/actual_cpi |
2 | Date: August 2010 | 2 | Date: August 2010 |
3 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | 3 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> |
4 | Description: It is possible to switch the cpi setting of the mouse with the | 4 | Description: It is possible to switch the cpi setting of the mouse with the |
@@ -14,14 +14,14 @@ Description: It is possible to switch the cpi setting of the mouse with the | |||
14 | 14 | ||
15 | This file is readonly. | 15 | This file is readonly. |
16 | 16 | ||
17 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/actual_profile | 17 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/actual_profile |
18 | Date: August 2010 | 18 | Date: August 2010 |
19 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | 19 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> |
20 | Description: When read, this file returns the number of the actual profile in | 20 | Description: When read, this file returns the number of the actual profile in |
21 | range 0-4. | 21 | range 0-4. |
22 | This file is readonly. | 22 | This file is readonly. |
23 | 23 | ||
24 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/firmware_version | 24 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/firmware_version |
25 | Date: August 2010 | 25 | Date: August 2010 |
26 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | 26 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> |
27 | Description: When read, this file returns the raw integer version number of the | 27 | Description: When read, this file returns the raw integer version number of the |
@@ -31,7 +31,7 @@ Description: When read, this file returns the raw integer version number of the | |||
31 | left. E.g. a returned value of 138 means 1.38 | 31 | left. E.g. a returned value of 138 means 1.38 |
32 | This file is readonly. | 32 | This file is readonly. |
33 | 33 | ||
34 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/profile_settings | 34 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/profile_settings |
35 | Date: August 2010 | 35 | Date: August 2010 |
36 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | 36 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> |
37 | Description: The mouse can store 5 profiles which can be switched by the | 37 | Description: The mouse can store 5 profiles which can be switched by the |
@@ -45,7 +45,7 @@ Description: The mouse can store 5 profiles which can be switched by the | |||
45 | contained in the data. | 45 | contained in the data. |
46 | This file is writeonly. | 46 | This file is writeonly. |
47 | 47 | ||
48 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/profile[1-5]_settings | 48 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/profile[1-5]_settings |
49 | Date: August 2010 | 49 | Date: August 2010 |
50 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | 50 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> |
51 | Description: The mouse can store 5 profiles which can be switched by the | 51 | Description: The mouse can store 5 profiles which can be switched by the |
@@ -56,7 +56,7 @@ Description: The mouse can store 5 profiles which can be switched by the | |||
56 | The returned data is 13 bytes in size. | 56 | The returned data is 13 bytes in size. |
57 | This file is readonly. | 57 | This file is readonly. |
58 | 58 | ||
59 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/profile_buttons | 59 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/profile_buttons |
60 | Date: August 2010 | 60 | Date: August 2010 |
61 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | 61 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> |
62 | Description: The mouse can store 5 profiles which can be switched by the | 62 | Description: The mouse can store 5 profiles which can be switched by the |
@@ -69,7 +69,7 @@ Description: The mouse can store 5 profiles which can be switched by the | |||
69 | contained in the data. | 69 | contained in the data. |
70 | This file is writeonly. | 70 | This file is writeonly. |
71 | 71 | ||
72 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/profile[1-5]_buttons | 72 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/profile[1-5]_buttons |
73 | Date: August 2010 | 73 | Date: August 2010 |
74 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | 74 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> |
75 | Description: The mouse can store 5 profiles which can be switched by the | 75 | Description: The mouse can store 5 profiles which can be switched by the |
@@ -79,7 +79,7 @@ Description: The mouse can store 5 profiles which can be switched by the | |||
79 | The returned data is 19 bytes in size. | 79 | The returned data is 19 bytes in size. |
80 | This file is readonly. | 80 | This file is readonly. |
81 | 81 | ||
82 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/startup_profile | 82 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/startup_profile |
83 | Date: August 2010 | 83 | Date: August 2010 |
84 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | 84 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> |
85 | Description: The integer value of this attribute ranges from 0-4. | 85 | Description: The integer value of this attribute ranges from 0-4. |
@@ -87,7 +87,7 @@ Description: The integer value of this attribute ranges from 0-4. | |||
87 | that's active when the mouse is powered on. | 87 | that's active when the mouse is powered on. |
88 | This file is readonly. | 88 | This file is readonly. |
89 | 89 | ||
90 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/settings | 90 | What: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/pyra/roccatpyra<minor>/settings |
91 | Date: August 2010 | 91 | Date: August 2010 |
92 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> | 92 | Contact: Stefan Achatz <erazor_de@users.sourceforge.net> |
93 | Description: When read, this file returns the settings stored in the mouse. | 93 | Description: When read, this file returns the settings stored in the mouse. |
diff --git a/drivers/base/core.c b/drivers/base/core.c index 6ed645411c40..761359261589 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -338,6 +338,35 @@ static void device_remove_attributes(struct device *dev, | |||
338 | device_remove_file(dev, &attrs[i]); | 338 | device_remove_file(dev, &attrs[i]); |
339 | } | 339 | } |
340 | 340 | ||
341 | static int device_add_bin_attributes(struct device *dev, | ||
342 | struct bin_attribute *attrs) | ||
343 | { | ||
344 | int error = 0; | ||
345 | int i; | ||
346 | |||
347 | if (attrs) { | ||
348 | for (i = 0; attr_name(attrs[i]); i++) { | ||
349 | error = device_create_bin_file(dev, &attrs[i]); | ||
350 | if (error) | ||
351 | break; | ||
352 | } | ||
353 | if (error) | ||
354 | while (--i >= 0) | ||
355 | device_remove_bin_file(dev, &attrs[i]); | ||
356 | } | ||
357 | return error; | ||
358 | } | ||
359 | |||
360 | static void device_remove_bin_attributes(struct device *dev, | ||
361 | struct bin_attribute *attrs) | ||
362 | { | ||
363 | int i; | ||
364 | |||
365 | if (attrs) | ||
366 | for (i = 0; attr_name(attrs[i]); i++) | ||
367 | device_remove_bin_file(dev, &attrs[i]); | ||
368 | } | ||
369 | |||
341 | static int device_add_groups(struct device *dev, | 370 | static int device_add_groups(struct device *dev, |
342 | const struct attribute_group **groups) | 371 | const struct attribute_group **groups) |
343 | { | 372 | { |
@@ -378,12 +407,15 @@ static int device_add_attrs(struct device *dev) | |||
378 | error = device_add_attributes(dev, class->dev_attrs); | 407 | error = device_add_attributes(dev, class->dev_attrs); |
379 | if (error) | 408 | if (error) |
380 | return error; | 409 | return error; |
410 | error = device_add_bin_attributes(dev, class->dev_bin_attrs); | ||
411 | if (error) | ||
412 | goto err_remove_class_attrs; | ||
381 | } | 413 | } |
382 | 414 | ||
383 | if (type) { | 415 | if (type) { |
384 | error = device_add_groups(dev, type->groups); | 416 | error = device_add_groups(dev, type->groups); |
385 | if (error) | 417 | if (error) |
386 | goto err_remove_class_attrs; | 418 | goto err_remove_class_bin_attrs; |
387 | } | 419 | } |
388 | 420 | ||
389 | error = device_add_groups(dev, dev->groups); | 421 | error = device_add_groups(dev, dev->groups); |
@@ -395,6 +427,9 @@ static int device_add_attrs(struct device *dev) | |||
395 | err_remove_type_groups: | 427 | err_remove_type_groups: |
396 | if (type) | 428 | if (type) |
397 | device_remove_groups(dev, type->groups); | 429 | device_remove_groups(dev, type->groups); |
430 | err_remove_class_bin_attrs: | ||
431 | if (class) | ||
432 | device_remove_bin_attributes(dev, class->dev_bin_attrs); | ||
398 | err_remove_class_attrs: | 433 | err_remove_class_attrs: |
399 | if (class) | 434 | if (class) |
400 | device_remove_attributes(dev, class->dev_attrs); | 435 | device_remove_attributes(dev, class->dev_attrs); |
@@ -412,8 +447,10 @@ static void device_remove_attrs(struct device *dev) | |||
412 | if (type) | 447 | if (type) |
413 | device_remove_groups(dev, type->groups); | 448 | device_remove_groups(dev, type->groups); |
414 | 449 | ||
415 | if (class) | 450 | if (class) { |
416 | device_remove_attributes(dev, class->dev_attrs); | 451 | device_remove_attributes(dev, class->dev_attrs); |
452 | device_remove_bin_attributes(dev, class->dev_bin_attrs); | ||
453 | } | ||
417 | } | 454 | } |
418 | 455 | ||
419 | 456 | ||
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 401acecc7f32..ffbc278647bf 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig | |||
@@ -150,6 +150,16 @@ config DRAGONRISE_FF | |||
150 | Say Y here if you want to enable force feedback support for DragonRise Inc. | 150 | Say Y here if you want to enable force feedback support for DragonRise Inc. |
151 | game controllers. | 151 | game controllers. |
152 | 152 | ||
153 | config HID_EMS_FF | ||
154 | tristate "EMS Production Inc. force feedback support" | ||
155 | depends on USB_HID | ||
156 | select INPUT_FF_MEMLESS | ||
157 | ---help--- | ||
158 | Say Y here if you want to enable force feedback support for devices by | ||
159 | EMS Production Ltd. | ||
160 | Currently the following devices are known to be supported: | ||
161 | - Trio Linker Plus II | ||
162 | |||
153 | config HID_EGALAX | 163 | config HID_EGALAX |
154 | tristate "eGalax multi-touch panel" | 164 | tristate "eGalax multi-touch panel" |
155 | depends on USB_HID | 165 | depends on USB_HID |
@@ -397,6 +407,13 @@ config HID_ROCCAT_KONE | |||
397 | ---help--- | 407 | ---help--- |
398 | Support for Roccat Kone mouse. | 408 | Support for Roccat Kone mouse. |
399 | 409 | ||
410 | config HID_ROCCAT_KONEPLUS | ||
411 | tristate "Roccat Kone[+] mouse support" | ||
412 | depends on USB_HID | ||
413 | select HID_ROCCAT | ||
414 | ---help--- | ||
415 | Support for Roccat Kone[+] mouse. | ||
416 | |||
400 | config HID_ROCCAT_PYRA | 417 | config HID_ROCCAT_PYRA |
401 | tristate "Roccat Pyra mouse support" | 418 | tristate "Roccat Pyra mouse support" |
402 | depends on USB_HID | 419 | depends on USB_HID |
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index c335605b9200..6eae9a90b8dd 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile | |||
@@ -1,7 +1,7 @@ | |||
1 | # | 1 | # |
2 | # Makefile for the HID driver | 2 | # Makefile for the HID driver |
3 | # | 3 | # |
4 | hid-objs := hid-core.o hid-input.o | 4 | hid-y := hid-core.o hid-input.o |
5 | 5 | ||
6 | ifdef CONFIG_DEBUG_FS | 6 | ifdef CONFIG_DEBUG_FS |
7 | hid-objs += hid-debug.o | 7 | hid-objs += hid-debug.o |
@@ -11,18 +11,18 @@ obj-$(CONFIG_HID) += hid.o | |||
11 | 11 | ||
12 | hid-$(CONFIG_HIDRAW) += hidraw.o | 12 | hid-$(CONFIG_HIDRAW) += hidraw.o |
13 | 13 | ||
14 | hid-logitech-objs := hid-lg.o | 14 | hid-logitech-y := hid-lg.o |
15 | ifdef CONFIG_LOGITECH_FF | 15 | ifdef CONFIG_LOGITECH_FF |
16 | hid-logitech-objs += hid-lgff.o | 16 | hid-logitech-y += hid-lgff.o |
17 | endif | 17 | endif |
18 | ifdef CONFIG_LOGIRUMBLEPAD2_FF | 18 | ifdef CONFIG_LOGIRUMBLEPAD2_FF |
19 | hid-logitech-objs += hid-lg2ff.o | 19 | hid-logitech-y += hid-lg2ff.o |
20 | endif | 20 | endif |
21 | ifdef CONFIG_LOGIG940_FF | 21 | ifdef CONFIG_LOGIG940_FF |
22 | hid-logitech-objs += hid-lg3ff.o | 22 | hid-logitech-y += hid-lg3ff.o |
23 | endif | 23 | endif |
24 | ifdef CONFIG_LOGIWII_FF | 24 | ifdef CONFIG_LOGIWII_FF |
25 | hid-logitech-objs += hid-lg4ff.o | 25 | hid-logitech-y += hid-lg4ff.o |
26 | endif | 26 | endif |
27 | 27 | ||
28 | obj-$(CONFIG_HID_3M_PCT) += hid-3m-pct.o | 28 | obj-$(CONFIG_HID_3M_PCT) += hid-3m-pct.o |
@@ -35,6 +35,7 @@ obj-$(CONFIG_HID_CHERRY) += hid-cherry.o | |||
35 | obj-$(CONFIG_HID_CHICONY) += hid-chicony.o | 35 | obj-$(CONFIG_HID_CHICONY) += hid-chicony.o |
36 | obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o | 36 | obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o |
37 | obj-$(CONFIG_HID_DRAGONRISE) += hid-drff.o | 37 | obj-$(CONFIG_HID_DRAGONRISE) += hid-drff.o |
38 | obj-$(CONFIG_HID_EMS_FF) += hid-emsff.o | ||
38 | obj-$(CONFIG_HID_EGALAX) += hid-egalax.o | 39 | obj-$(CONFIG_HID_EGALAX) += hid-egalax.o |
39 | obj-$(CONFIG_HID_ELECOM) += hid-elecom.o | 40 | obj-$(CONFIG_HID_ELECOM) += hid-elecom.o |
40 | obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o | 41 | obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o |
@@ -55,6 +56,7 @@ obj-$(CONFIG_HID_PETALYNX) += hid-petalynx.o | |||
55 | obj-$(CONFIG_HID_PICOLCD) += hid-picolcd.o | 56 | obj-$(CONFIG_HID_PICOLCD) += hid-picolcd.o |
56 | obj-$(CONFIG_HID_ROCCAT) += hid-roccat.o | 57 | obj-$(CONFIG_HID_ROCCAT) += hid-roccat.o |
57 | obj-$(CONFIG_HID_ROCCAT_KONE) += hid-roccat-kone.o | 58 | obj-$(CONFIG_HID_ROCCAT_KONE) += hid-roccat-kone.o |
59 | obj-$(CONFIG_HID_ROCCAT_KONEPLUS) += hid-roccat-koneplus.o | ||
58 | obj-$(CONFIG_HID_ROCCAT_PYRA) += hid-roccat-pyra.o | 60 | obj-$(CONFIG_HID_ROCCAT_PYRA) += hid-roccat-pyra.o |
59 | obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o | 61 | obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o |
60 | obj-$(CONFIG_HID_SMARTJOYPLUS) += hid-sjoy.o | 62 | obj-$(CONFIG_HID_SMARTJOYPLUS) += hid-sjoy.o |
diff --git a/drivers/hid/hid-3m-pct.c b/drivers/hid/hid-3m-pct.c index 4fb7c7528d16..5243ae2d3730 100644 --- a/drivers/hid/hid-3m-pct.c +++ b/drivers/hid/hid-3m-pct.c | |||
@@ -246,7 +246,7 @@ static int mmm_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
246 | 246 | ||
247 | md = kzalloc(sizeof(struct mmm_data), GFP_KERNEL); | 247 | md = kzalloc(sizeof(struct mmm_data), GFP_KERNEL); |
248 | if (!md) { | 248 | if (!md) { |
249 | dev_err(&hdev->dev, "cannot allocate 3M data\n"); | 249 | hid_err(hdev, "cannot allocate 3M data\n"); |
250 | return -ENOMEM; | 250 | return -ENOMEM; |
251 | } | 251 | } |
252 | hid_set_drvdata(hdev, md); | 252 | hid_set_drvdata(hdev, md); |
diff --git a/drivers/hid/hid-a4tech.c b/drivers/hid/hid-a4tech.c index 1666c1684e79..902d1dfeb1b5 100644 --- a/drivers/hid/hid-a4tech.c +++ b/drivers/hid/hid-a4tech.c | |||
@@ -93,7 +93,7 @@ static int a4_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
93 | 93 | ||
94 | a4 = kzalloc(sizeof(*a4), GFP_KERNEL); | 94 | a4 = kzalloc(sizeof(*a4), GFP_KERNEL); |
95 | if (a4 == NULL) { | 95 | if (a4 == NULL) { |
96 | dev_err(&hdev->dev, "can't alloc device descriptor\n"); | 96 | hid_err(hdev, "can't alloc device descriptor\n"); |
97 | ret = -ENOMEM; | 97 | ret = -ENOMEM; |
98 | goto err_free; | 98 | goto err_free; |
99 | } | 99 | } |
@@ -104,13 +104,13 @@ static int a4_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
104 | 104 | ||
105 | ret = hid_parse(hdev); | 105 | ret = hid_parse(hdev); |
106 | if (ret) { | 106 | if (ret) { |
107 | dev_err(&hdev->dev, "parse failed\n"); | 107 | hid_err(hdev, "parse failed\n"); |
108 | goto err_free; | 108 | goto err_free; |
109 | } | 109 | } |
110 | 110 | ||
111 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); | 111 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); |
112 | if (ret) { | 112 | if (ret) { |
113 | dev_err(&hdev->dev, "hw start failed\n"); | 113 | hid_err(hdev, "hw start failed\n"); |
114 | goto err_free; | 114 | goto err_free; |
115 | } | 115 | } |
116 | 116 | ||
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c index eaeca564a8d3..61aa71233392 100644 --- a/drivers/hid/hid-apple.c +++ b/drivers/hid/hid-apple.c | |||
@@ -16,6 +16,8 @@ | |||
16 | * any later version. | 16 | * any later version. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
20 | |||
19 | #include <linux/device.h> | 21 | #include <linux/device.h> |
20 | #include <linux/hid.h> | 22 | #include <linux/hid.h> |
21 | #include <linux/module.h> | 23 | #include <linux/module.h> |
@@ -59,6 +61,27 @@ struct apple_key_translation { | |||
59 | u8 flags; | 61 | u8 flags; |
60 | }; | 62 | }; |
61 | 63 | ||
64 | static const struct apple_key_translation macbookair_fn_keys[] = { | ||
65 | { KEY_BACKSPACE, KEY_DELETE }, | ||
66 | { KEY_ENTER, KEY_INSERT }, | ||
67 | { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY }, | ||
68 | { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY }, | ||
69 | { KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY }, | ||
70 | { KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY }, | ||
71 | { KEY_F6, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY }, | ||
72 | { KEY_F7, KEY_PLAYPAUSE, APPLE_FLAG_FKEY }, | ||
73 | { KEY_F8, KEY_NEXTSONG, APPLE_FLAG_FKEY }, | ||
74 | { KEY_F9, KEY_MUTE, APPLE_FLAG_FKEY }, | ||
75 | { KEY_F10, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY }, | ||
76 | { KEY_F11, KEY_VOLUMEUP, APPLE_FLAG_FKEY }, | ||
77 | { KEY_F12, KEY_EJECTCD, APPLE_FLAG_FKEY }, | ||
78 | { KEY_UP, KEY_PAGEUP }, | ||
79 | { KEY_DOWN, KEY_PAGEDOWN }, | ||
80 | { KEY_LEFT, KEY_HOME }, | ||
81 | { KEY_RIGHT, KEY_END }, | ||
82 | { } | ||
83 | }; | ||
84 | |||
62 | static const struct apple_key_translation apple_fn_keys[] = { | 85 | static const struct apple_key_translation apple_fn_keys[] = { |
63 | { KEY_BACKSPACE, KEY_DELETE }, | 86 | { KEY_BACKSPACE, KEY_DELETE }, |
64 | { KEY_ENTER, KEY_INSERT }, | 87 | { KEY_ENTER, KEY_INSERT }, |
@@ -146,7 +169,7 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, | |||
146 | struct hid_usage *usage, __s32 value) | 169 | struct hid_usage *usage, __s32 value) |
147 | { | 170 | { |
148 | struct apple_sc *asc = hid_get_drvdata(hid); | 171 | struct apple_sc *asc = hid_get_drvdata(hid); |
149 | const struct apple_key_translation *trans; | 172 | const struct apple_key_translation *trans, *table; |
150 | 173 | ||
151 | if (usage->code == KEY_FN) { | 174 | if (usage->code == KEY_FN) { |
152 | asc->fn_on = !!value; | 175 | asc->fn_on = !!value; |
@@ -157,10 +180,16 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, | |||
157 | if (fnmode) { | 180 | if (fnmode) { |
158 | int do_translate; | 181 | int do_translate; |
159 | 182 | ||
160 | trans = apple_find_translation((hid->product < 0x21d || | 183 | if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI && |
161 | hid->product >= 0x300) ? | 184 | hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) |
162 | powerbook_fn_keys : apple_fn_keys, | 185 | table = macbookair_fn_keys; |
163 | usage->code); | 186 | else if (hid->product < 0x21d || hid->product >= 0x300) |
187 | table = powerbook_fn_keys; | ||
188 | else | ||
189 | table = apple_fn_keys; | ||
190 | |||
191 | trans = apple_find_translation (table, usage->code); | ||
192 | |||
164 | if (trans) { | 193 | if (trans) { |
165 | if (test_bit(usage->code, asc->pressed_fn)) | 194 | if (test_bit(usage->code, asc->pressed_fn)) |
166 | do_translate = 1; | 195 | do_translate = 1; |
@@ -253,8 +282,8 @@ static __u8 *apple_report_fixup(struct hid_device *hdev, __u8 *rdesc, | |||
253 | 282 | ||
254 | if ((asc->quirks & APPLE_RDESC_JIS) && *rsize >= 60 && | 283 | if ((asc->quirks & APPLE_RDESC_JIS) && *rsize >= 60 && |
255 | rdesc[53] == 0x65 && rdesc[59] == 0x65) { | 284 | rdesc[53] == 0x65 && rdesc[59] == 0x65) { |
256 | dev_info(&hdev->dev, "fixing up MacBook JIS keyboard report " | 285 | hid_info(hdev, |
257 | "descriptor\n"); | 286 | "fixing up MacBook JIS keyboard report descriptor\n"); |
258 | rdesc[53] = rdesc[59] = 0xe7; | 287 | rdesc[53] = rdesc[59] = 0xe7; |
259 | } | 288 | } |
260 | return rdesc; | 289 | return rdesc; |
@@ -324,7 +353,7 @@ static int apple_probe(struct hid_device *hdev, | |||
324 | 353 | ||
325 | asc = kzalloc(sizeof(*asc), GFP_KERNEL); | 354 | asc = kzalloc(sizeof(*asc), GFP_KERNEL); |
326 | if (asc == NULL) { | 355 | if (asc == NULL) { |
327 | dev_err(&hdev->dev, "can't alloc apple descriptor\n"); | 356 | hid_err(hdev, "can't alloc apple descriptor\n"); |
328 | return -ENOMEM; | 357 | return -ENOMEM; |
329 | } | 358 | } |
330 | 359 | ||
@@ -334,7 +363,7 @@ static int apple_probe(struct hid_device *hdev, | |||
334 | 363 | ||
335 | ret = hid_parse(hdev); | 364 | ret = hid_parse(hdev); |
336 | if (ret) { | 365 | if (ret) { |
337 | dev_err(&hdev->dev, "parse failed\n"); | 366 | hid_err(hdev, "parse failed\n"); |
338 | goto err_free; | 367 | goto err_free; |
339 | } | 368 | } |
340 | 369 | ||
@@ -345,7 +374,7 @@ static int apple_probe(struct hid_device *hdev, | |||
345 | 374 | ||
346 | ret = hid_hw_start(hdev, connect_mask); | 375 | ret = hid_hw_start(hdev, connect_mask); |
347 | if (ret) { | 376 | if (ret) { |
348 | dev_err(&hdev->dev, "hw start failed\n"); | 377 | hid_err(hdev, "hw start failed\n"); |
349 | goto err_free; | 378 | goto err_free; |
350 | } | 379 | } |
351 | 380 | ||
@@ -440,6 +469,18 @@ static const struct hid_device_id apple_devices[] = { | |||
440 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, | 469 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, |
441 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS), | 470 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS), |
442 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, | 471 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, |
472 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI), | ||
473 | .driver_data = APPLE_HAS_FN }, | ||
474 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO), | ||
475 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, | ||
476 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS), | ||
477 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, | ||
478 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI), | ||
479 | .driver_data = APPLE_HAS_FN }, | ||
480 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO), | ||
481 | .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, | ||
482 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS), | ||
483 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, | ||
443 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI), | 484 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI), |
444 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, | 485 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
445 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO), | 486 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO), |
@@ -473,7 +514,7 @@ static int __init apple_init(void) | |||
473 | 514 | ||
474 | ret = hid_register_driver(&apple_driver); | 515 | ret = hid_register_driver(&apple_driver); |
475 | if (ret) | 516 | if (ret) |
476 | printk(KERN_ERR "can't register apple driver\n"); | 517 | pr_err("can't register apple driver\n"); |
477 | 518 | ||
478 | return ret; | 519 | return ret; |
479 | } | 520 | } |
diff --git a/drivers/hid/hid-axff.c b/drivers/hid/hid-axff.c index f42ee140738a..e5b961d6ff22 100644 --- a/drivers/hid/hid-axff.c +++ b/drivers/hid/hid-axff.c | |||
@@ -73,14 +73,14 @@ static int axff_init(struct hid_device *hid) | |||
73 | int error; | 73 | int error; |
74 | 74 | ||
75 | if (list_empty(report_list)) { | 75 | if (list_empty(report_list)) { |
76 | dev_err(&hid->dev, "no output reports found\n"); | 76 | hid_err(hid, "no output reports found\n"); |
77 | return -ENODEV; | 77 | return -ENODEV; |
78 | } | 78 | } |
79 | 79 | ||
80 | report = list_first_entry(report_list, struct hid_report, list); | 80 | report = list_first_entry(report_list, struct hid_report, list); |
81 | 81 | ||
82 | if (report->maxfield < 4) { | 82 | if (report->maxfield < 4) { |
83 | dev_err(&hid->dev, "no fields in the report: %d\n", report->maxfield); | 83 | hid_err(hid, "no fields in the report: %d\n", report->maxfield); |
84 | return -ENODEV; | 84 | return -ENODEV; |
85 | } | 85 | } |
86 | 86 | ||
@@ -101,7 +101,7 @@ static int axff_init(struct hid_device *hid) | |||
101 | axff->report->field[3]->value[0] = 0x00; | 101 | axff->report->field[3]->value[0] = 0x00; |
102 | usbhid_submit_report(hid, axff->report, USB_DIR_OUT); | 102 | usbhid_submit_report(hid, axff->report, USB_DIR_OUT); |
103 | 103 | ||
104 | dev_info(&hid->dev, "Force Feedback for ACRUX game controllers by Sergei Kolzun<x0r@dv-life.ru>\n"); | 104 | hid_info(hid, "Force Feedback for ACRUX game controllers by Sergei Kolzun<x0r@dv-life.ru>\n"); |
105 | 105 | ||
106 | return 0; | 106 | return 0; |
107 | 107 | ||
@@ -114,17 +114,17 @@ static int ax_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
114 | { | 114 | { |
115 | int error; | 115 | int error; |
116 | 116 | ||
117 | dev_dbg(&hdev->dev, "ACRUX HID hardware probe..."); | 117 | dev_dbg(&hdev->dev, "ACRUX HID hardware probe...\n"); |
118 | 118 | ||
119 | error = hid_parse(hdev); | 119 | error = hid_parse(hdev); |
120 | if (error) { | 120 | if (error) { |
121 | dev_err(&hdev->dev, "parse failed\n"); | 121 | hid_err(hdev, "parse failed\n"); |
122 | return error; | 122 | return error; |
123 | } | 123 | } |
124 | 124 | ||
125 | error = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF); | 125 | error = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF); |
126 | if (error) { | 126 | if (error) { |
127 | dev_err(&hdev->dev, "hw start failed\n"); | 127 | hid_err(hdev, "hw start failed\n"); |
128 | return error; | 128 | return error; |
129 | } | 129 | } |
130 | 130 | ||
@@ -134,7 +134,7 @@ static int ax_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
134 | * Do not fail device initialization completely as device | 134 | * Do not fail device initialization completely as device |
135 | * may still be partially operable, just warn. | 135 | * may still be partially operable, just warn. |
136 | */ | 136 | */ |
137 | dev_warn(&hdev->dev, | 137 | hid_warn(hdev, |
138 | "Failed to enable force feedback support, error: %d\n", | 138 | "Failed to enable force feedback support, error: %d\n", |
139 | error); | 139 | error); |
140 | } | 140 | } |
diff --git a/drivers/hid/hid-belkin.c b/drivers/hid/hid-belkin.c index 4ce7aa3a519f..a1a765a5b08a 100644 --- a/drivers/hid/hid-belkin.c +++ b/drivers/hid/hid-belkin.c | |||
@@ -56,14 +56,14 @@ static int belkin_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
56 | 56 | ||
57 | ret = hid_parse(hdev); | 57 | ret = hid_parse(hdev); |
58 | if (ret) { | 58 | if (ret) { |
59 | dev_err(&hdev->dev, "parse failed\n"); | 59 | hid_err(hdev, "parse failed\n"); |
60 | goto err_free; | 60 | goto err_free; |
61 | } | 61 | } |
62 | 62 | ||
63 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT | | 63 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT | |
64 | ((quirks & BELKIN_HIDDEV) ? HID_CONNECT_HIDDEV_FORCE : 0)); | 64 | ((quirks & BELKIN_HIDDEV) ? HID_CONNECT_HIDDEV_FORCE : 0)); |
65 | if (ret) { | 65 | if (ret) { |
66 | dev_err(&hdev->dev, "hw start failed\n"); | 66 | hid_err(hdev, "hw start failed\n"); |
67 | goto err_free; | 67 | goto err_free; |
68 | } | 68 | } |
69 | 69 | ||
diff --git a/drivers/hid/hid-cando.c b/drivers/hid/hid-cando.c index 5925bdcd417d..375b50929a50 100644 --- a/drivers/hid/hid-cando.c +++ b/drivers/hid/hid-cando.c | |||
@@ -207,7 +207,7 @@ static int cando_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
207 | 207 | ||
208 | td = kmalloc(sizeof(struct cando_data), GFP_KERNEL); | 208 | td = kmalloc(sizeof(struct cando_data), GFP_KERNEL); |
209 | if (!td) { | 209 | if (!td) { |
210 | dev_err(&hdev->dev, "cannot allocate Cando Touch data\n"); | 210 | hid_err(hdev, "cannot allocate Cando Touch data\n"); |
211 | return -ENOMEM; | 211 | return -ENOMEM; |
212 | } | 212 | } |
213 | hid_set_drvdata(hdev, td); | 213 | hid_set_drvdata(hdev, td); |
diff --git a/drivers/hid/hid-cherry.c b/drivers/hid/hid-cherry.c index e880086c2311..888ece68a47c 100644 --- a/drivers/hid/hid-cherry.c +++ b/drivers/hid/hid-cherry.c | |||
@@ -30,8 +30,7 @@ static __u8 *ch_report_fixup(struct hid_device *hdev, __u8 *rdesc, | |||
30 | unsigned int *rsize) | 30 | unsigned int *rsize) |
31 | { | 31 | { |
32 | if (*rsize >= 17 && rdesc[11] == 0x3c && rdesc[12] == 0x02) { | 32 | if (*rsize >= 17 && rdesc[11] == 0x3c && rdesc[12] == 0x02) { |
33 | dev_info(&hdev->dev, "fixing up Cherry Cymotion report " | 33 | hid_info(hdev, "fixing up Cherry Cymotion report descriptor\n"); |
34 | "descriptor\n"); | ||
35 | rdesc[11] = rdesc[16] = 0xff; | 34 | rdesc[11] = rdesc[16] = 0xff; |
36 | rdesc[12] = rdesc[17] = 0x03; | 35 | rdesc[12] = rdesc[17] = 0x03; |
37 | } | 36 | } |
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 3f9673d94da9..261168607c91 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
@@ -14,6 +14,8 @@ | |||
14 | * any later version. | 14 | * any later version. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
18 | |||
17 | #include <linux/module.h> | 19 | #include <linux/module.h> |
18 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
19 | #include <linux/init.h> | 21 | #include <linux/init.h> |
@@ -59,7 +61,8 @@ struct hid_report *hid_register_report(struct hid_device *device, unsigned type, | |||
59 | if (report_enum->report_id_hash[id]) | 61 | if (report_enum->report_id_hash[id]) |
60 | return report_enum->report_id_hash[id]; | 62 | return report_enum->report_id_hash[id]; |
61 | 63 | ||
62 | if (!(report = kzalloc(sizeof(struct hid_report), GFP_KERNEL))) | 64 | report = kzalloc(sizeof(struct hid_report), GFP_KERNEL); |
65 | if (!report) | ||
63 | return NULL; | 66 | return NULL; |
64 | 67 | ||
65 | if (id != 0) | 68 | if (id != 0) |
@@ -90,8 +93,11 @@ static struct hid_field *hid_register_field(struct hid_report *report, unsigned | |||
90 | return NULL; | 93 | return NULL; |
91 | } | 94 | } |
92 | 95 | ||
93 | if (!(field = kzalloc(sizeof(struct hid_field) + usages * sizeof(struct hid_usage) | 96 | field = kzalloc((sizeof(struct hid_field) + |
94 | + values * sizeof(unsigned), GFP_KERNEL))) return NULL; | 97 | usages * sizeof(struct hid_usage) + |
98 | values * sizeof(unsigned)), GFP_KERNEL); | ||
99 | if (!field) | ||
100 | return NULL; | ||
95 | 101 | ||
96 | field->index = report->maxfield++; | 102 | field->index = report->maxfield++; |
97 | report->field[field->index] = field; | 103 | report->field[field->index] = field; |
@@ -172,10 +178,14 @@ static int close_collection(struct hid_parser *parser) | |||
172 | 178 | ||
173 | static unsigned hid_lookup_collection(struct hid_parser *parser, unsigned type) | 179 | static unsigned hid_lookup_collection(struct hid_parser *parser, unsigned type) |
174 | { | 180 | { |
181 | struct hid_collection *collection = parser->device->collection; | ||
175 | int n; | 182 | int n; |
176 | for (n = parser->collection_stack_ptr - 1; n >= 0; n--) | 183 | |
177 | if (parser->device->collection[parser->collection_stack[n]].type == type) | 184 | for (n = parser->collection_stack_ptr - 1; n >= 0; n--) { |
178 | return parser->device->collection[parser->collection_stack[n]].usage; | 185 | unsigned index = parser->collection_stack[n]; |
186 | if (collection[index].type == type) | ||
187 | return collection[index].usage; | ||
188 | } | ||
179 | return 0; /* we know nothing about this usage type */ | 189 | return 0; /* we know nothing about this usage type */ |
180 | } | 190 | } |
181 | 191 | ||
@@ -209,7 +219,8 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign | |||
209 | unsigned offset; | 219 | unsigned offset; |
210 | int i; | 220 | int i; |
211 | 221 | ||
212 | if (!(report = hid_register_report(parser->device, report_type, parser->global.report_id))) { | 222 | report = hid_register_report(parser->device, report_type, parser->global.report_id); |
223 | if (!report) { | ||
213 | dbg_hid("hid_register_report failed\n"); | 224 | dbg_hid("hid_register_report failed\n"); |
214 | return -1; | 225 | return -1; |
215 | } | 226 | } |
@@ -227,7 +238,8 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign | |||
227 | 238 | ||
228 | usages = max_t(int, parser->local.usage_index, parser->global.report_count); | 239 | usages = max_t(int, parser->local.usage_index, parser->global.report_count); |
229 | 240 | ||
230 | if ((field = hid_register_field(report, usages, parser->global.report_count)) == NULL) | 241 | field = hid_register_field(report, usages, parser->global.report_count); |
242 | if (!field) | ||
231 | return 0; | 243 | return 0; |
232 | 244 | ||
233 | field->physical = hid_lookup_collection(parser, HID_COLLECTION_PHYSICAL); | 245 | field->physical = hid_lookup_collection(parser, HID_COLLECTION_PHYSICAL); |
@@ -652,13 +664,12 @@ int hid_parse_report(struct hid_device *device, __u8 *start, | |||
652 | return -ENOMEM; | 664 | return -ENOMEM; |
653 | device->rsize = size; | 665 | device->rsize = size; |
654 | 666 | ||
655 | parser = vmalloc(sizeof(struct hid_parser)); | 667 | parser = vzalloc(sizeof(struct hid_parser)); |
656 | if (!parser) { | 668 | if (!parser) { |
657 | ret = -ENOMEM; | 669 | ret = -ENOMEM; |
658 | goto err; | 670 | goto err; |
659 | } | 671 | } |
660 | 672 | ||
661 | memset(parser, 0, sizeof(struct hid_parser)); | ||
662 | parser->device = device; | 673 | parser->device = device; |
663 | 674 | ||
664 | end = start + size; | 675 | end = start + size; |
@@ -672,7 +683,8 @@ int hid_parse_report(struct hid_device *device, __u8 *start, | |||
672 | 683 | ||
673 | if (dispatch_type[item.type](parser, &item)) { | 684 | if (dispatch_type[item.type](parser, &item)) { |
674 | dbg_hid("item %u %u %u %u parsing failed\n", | 685 | dbg_hid("item %u %u %u %u parsing failed\n", |
675 | item.format, (unsigned)item.size, (unsigned)item.type, (unsigned)item.tag); | 686 | item.format, (unsigned)item.size, |
687 | (unsigned)item.type, (unsigned)item.tag); | ||
676 | goto err; | 688 | goto err; |
677 | } | 689 | } |
678 | 690 | ||
@@ -737,13 +749,14 @@ static u32 s32ton(__s32 value, unsigned n) | |||
737 | * Search linux-kernel and linux-usb-devel archives for "hid-core extract". | 749 | * Search linux-kernel and linux-usb-devel archives for "hid-core extract". |
738 | */ | 750 | */ |
739 | 751 | ||
740 | static __inline__ __u32 extract(__u8 *report, unsigned offset, unsigned n) | 752 | static __u32 extract(const struct hid_device *hid, __u8 *report, |
753 | unsigned offset, unsigned n) | ||
741 | { | 754 | { |
742 | u64 x; | 755 | u64 x; |
743 | 756 | ||
744 | if (n > 32) | 757 | if (n > 32) |
745 | printk(KERN_WARNING "HID: extract() called with n (%d) > 32! (%s)\n", | 758 | hid_warn(hid, "extract() called with n (%d) > 32! (%s)\n", |
746 | n, current->comm); | 759 | n, current->comm); |
747 | 760 | ||
748 | report += offset >> 3; /* adjust byte index */ | 761 | report += offset >> 3; /* adjust byte index */ |
749 | offset &= 7; /* now only need bit offset into one byte */ | 762 | offset &= 7; /* now only need bit offset into one byte */ |
@@ -760,18 +773,19 @@ static __inline__ __u32 extract(__u8 *report, unsigned offset, unsigned n) | |||
760 | * endianness of register values by considering a register | 773 | * endianness of register values by considering a register |
761 | * a "cached" copy of the little endiad bit stream. | 774 | * a "cached" copy of the little endiad bit stream. |
762 | */ | 775 | */ |
763 | static __inline__ void implement(__u8 *report, unsigned offset, unsigned n, __u32 value) | 776 | static void implement(const struct hid_device *hid, __u8 *report, |
777 | unsigned offset, unsigned n, __u32 value) | ||
764 | { | 778 | { |
765 | u64 x; | 779 | u64 x; |
766 | u64 m = (1ULL << n) - 1; | 780 | u64 m = (1ULL << n) - 1; |
767 | 781 | ||
768 | if (n > 32) | 782 | if (n > 32) |
769 | printk(KERN_WARNING "HID: implement() called with n (%d) > 32! (%s)\n", | 783 | hid_warn(hid, "%s() called with n (%d) > 32! (%s)\n", |
770 | n, current->comm); | 784 | __func__, n, current->comm); |
771 | 785 | ||
772 | if (value > m) | 786 | if (value > m) |
773 | printk(KERN_WARNING "HID: implement() called with too large value %d! (%s)\n", | 787 | hid_warn(hid, "%s() called with too large value %d! (%s)\n", |
774 | value, current->comm); | 788 | __func__, value, current->comm); |
775 | WARN_ON(value > m); | 789 | WARN_ON(value > m); |
776 | value &= m; | 790 | value &= m; |
777 | 791 | ||
@@ -788,7 +802,7 @@ static __inline__ void implement(__u8 *report, unsigned offset, unsigned n, __u3 | |||
788 | * Search an array for a value. | 802 | * Search an array for a value. |
789 | */ | 803 | */ |
790 | 804 | ||
791 | static __inline__ int search(__s32 *array, __s32 value, unsigned n) | 805 | static int search(__s32 *array, __s32 value, unsigned n) |
792 | { | 806 | { |
793 | while (n--) { | 807 | while (n--) { |
794 | if (*array++ == value) | 808 | if (*array++ == value) |
@@ -887,18 +901,22 @@ static void hid_input_field(struct hid_device *hid, struct hid_field *field, | |||
887 | __s32 max = field->logical_maximum; | 901 | __s32 max = field->logical_maximum; |
888 | __s32 *value; | 902 | __s32 *value; |
889 | 903 | ||
890 | if (!(value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC))) | 904 | value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC); |
905 | if (!value) | ||
891 | return; | 906 | return; |
892 | 907 | ||
893 | for (n = 0; n < count; n++) { | 908 | for (n = 0; n < count; n++) { |
894 | 909 | ||
895 | value[n] = min < 0 ? snto32(extract(data, offset + n * size, size), size) : | 910 | value[n] = min < 0 ? |
896 | extract(data, offset + n * size, size); | 911 | snto32(extract(hid, data, offset + n * size, size), |
912 | size) : | ||
913 | extract(hid, data, offset + n * size, size); | ||
897 | 914 | ||
898 | if (!(field->flags & HID_MAIN_ITEM_VARIABLE) /* Ignore report if ErrorRollOver */ | 915 | /* Ignore report if ErrorRollOver */ |
899 | && value[n] >= min && value[n] <= max | 916 | if (!(field->flags & HID_MAIN_ITEM_VARIABLE) && |
900 | && field->usage[value[n] - min].hid == HID_UP_KEYBOARD + 1) | 917 | value[n] >= min && value[n] <= max && |
901 | goto exit; | 918 | field->usage[value[n] - min].hid == HID_UP_KEYBOARD + 1) |
919 | goto exit; | ||
902 | } | 920 | } |
903 | 921 | ||
904 | for (n = 0; n < count; n++) { | 922 | for (n = 0; n < count; n++) { |
@@ -928,7 +946,8 @@ exit: | |||
928 | * Output the field into the report. | 946 | * Output the field into the report. |
929 | */ | 947 | */ |
930 | 948 | ||
931 | static void hid_output_field(struct hid_field *field, __u8 *data) | 949 | static void hid_output_field(const struct hid_device *hid, |
950 | struct hid_field *field, __u8 *data) | ||
932 | { | 951 | { |
933 | unsigned count = field->report_count; | 952 | unsigned count = field->report_count; |
934 | unsigned offset = field->report_offset; | 953 | unsigned offset = field->report_offset; |
@@ -937,9 +956,11 @@ static void hid_output_field(struct hid_field *field, __u8 *data) | |||
937 | 956 | ||
938 | for (n = 0; n < count; n++) { | 957 | for (n = 0; n < count; n++) { |
939 | if (field->logical_minimum < 0) /* signed values */ | 958 | if (field->logical_minimum < 0) /* signed values */ |
940 | implement(data, offset + n * size, size, s32ton(field->value[n], size)); | 959 | implement(hid, data, offset + n * size, size, |
960 | s32ton(field->value[n], size)); | ||
941 | else /* unsigned values */ | 961 | else /* unsigned values */ |
942 | implement(data, offset + n * size, size, field->value[n]); | 962 | implement(hid, data, offset + n * size, size, |
963 | field->value[n]); | ||
943 | } | 964 | } |
944 | } | 965 | } |
945 | 966 | ||
@@ -956,7 +977,7 @@ void hid_output_report(struct hid_report *report, __u8 *data) | |||
956 | 977 | ||
957 | memset(data, 0, ((report->size - 1) >> 3) + 1); | 978 | memset(data, 0, ((report->size - 1) >> 3) + 1); |
958 | for (n = 0; n < report->maxfield; n++) | 979 | for (n = 0; n < report->maxfield; n++) |
959 | hid_output_field(report->field[n], data); | 980 | hid_output_field(report->device, report->field[n], data); |
960 | } | 981 | } |
961 | EXPORT_SYMBOL_GPL(hid_output_report); | 982 | EXPORT_SYMBOL_GPL(hid_output_report); |
962 | 983 | ||
@@ -1169,8 +1190,7 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask) | |||
1169 | hdev->claimed |= HID_CLAIMED_HIDRAW; | 1190 | hdev->claimed |= HID_CLAIMED_HIDRAW; |
1170 | 1191 | ||
1171 | if (!hdev->claimed) { | 1192 | if (!hdev->claimed) { |
1172 | dev_err(&hdev->dev, "claimed by neither input, hiddev nor " | 1193 | hid_err(hdev, "claimed by neither input, hiddev nor hidraw\n"); |
1173 | "hidraw\n"); | ||
1174 | return -ENODEV; | 1194 | return -ENODEV; |
1175 | } | 1195 | } |
1176 | 1196 | ||
@@ -1210,9 +1230,9 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask) | |||
1210 | bus = "<UNKNOWN>"; | 1230 | bus = "<UNKNOWN>"; |
1211 | } | 1231 | } |
1212 | 1232 | ||
1213 | dev_info(&hdev->dev, "%s: %s HID v%x.%02x %s [%s] on %s\n", | 1233 | hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n", |
1214 | buf, bus, hdev->version >> 8, hdev->version & 0xff, | 1234 | buf, bus, hdev->version >> 8, hdev->version & 0xff, |
1215 | type, hdev->name, hdev->phys); | 1235 | type, hdev->name, hdev->phys); |
1216 | 1236 | ||
1217 | return 0; | 1237 | return 0; |
1218 | } | 1238 | } |
@@ -1230,7 +1250,7 @@ void hid_disconnect(struct hid_device *hdev) | |||
1230 | EXPORT_SYMBOL_GPL(hid_disconnect); | 1250 | EXPORT_SYMBOL_GPL(hid_disconnect); |
1231 | 1251 | ||
1232 | /* a list of devices for which there is a specialized driver on HID bus */ | 1252 | /* a list of devices for which there is a specialized driver on HID bus */ |
1233 | static const struct hid_device_id hid_blacklist[] = { | 1253 | static const struct hid_device_id hid_have_special_driver[] = { |
1234 | { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M1968) }, | 1254 | { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M1968) }, |
1235 | { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M2256) }, | 1255 | { HID_USB_DEVICE(USB_VENDOR_ID_3M, USB_DEVICE_ID_3M2256) }, |
1236 | { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, | 1256 | { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, |
@@ -1276,6 +1296,12 @@ static const struct hid_device_id hid_blacklist[] = { | |||
1276 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) }, | 1296 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) }, |
1277 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) }, | 1297 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) }, |
1278 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) }, | 1298 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) }, |
1299 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI) }, | ||
1300 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO) }, | ||
1301 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS) }, | ||
1302 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) }, | ||
1303 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) }, | ||
1304 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) }, | ||
1279 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) }, | 1305 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) }, |
1280 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) }, | 1306 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) }, |
1281 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) }, | 1307 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) }, |
@@ -1292,6 +1318,7 @@ static const struct hid_device_id hid_blacklist[] = { | |||
1292 | { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, | 1318 | { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION) }, |
1293 | { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR) }, | 1319 | { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR) }, |
1294 | { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) }, | 1320 | { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) }, |
1321 | { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS) }, | ||
1295 | { HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_PRODIKEYS_PCMIDI) }, | 1322 | { HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_PRODIKEYS_PCMIDI) }, |
1296 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) }, | 1323 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) }, |
1297 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) }, | 1324 | { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) }, |
@@ -1304,6 +1331,7 @@ static const struct hid_device_id hid_blacklist[] = { | |||
1304 | { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH3) }, | 1331 | { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH3) }, |
1305 | { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH4) }, | 1332 | { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH4) }, |
1306 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) }, | 1333 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) }, |
1334 | { HID_USB_DEVICE(USB_VENDOR_ID_EMS, USB_DEVICE_ID_EMS_TRIO_LINKER_PLUS_II) }, | ||
1307 | { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) }, | 1335 | { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) }, |
1308 | { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) }, | 1336 | { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) }, |
1309 | { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR) }, | 1337 | { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR) }, |
@@ -1372,6 +1400,7 @@ static const struct hid_device_id hid_blacklist[] = { | |||
1372 | { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) }, | 1400 | { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) }, |
1373 | { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) }, | 1401 | { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA, USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) }, |
1374 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONE) }, | 1402 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONE) }, |
1403 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPLUS) }, | ||
1375 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRED) }, | 1404 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_PYRA_WIRED) }, |
1376 | { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) }, | 1405 | { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) }, |
1377 | { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) }, | 1406 | { HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) }, |
@@ -1499,9 +1528,9 @@ static int hid_bus_match(struct device *dev, struct device_driver *drv) | |||
1499 | if (!hid_match_device(hdev, hdrv)) | 1528 | if (!hid_match_device(hdev, hdrv)) |
1500 | return 0; | 1529 | return 0; |
1501 | 1530 | ||
1502 | /* generic wants all non-blacklisted */ | 1531 | /* generic wants all that don't have specialized driver */ |
1503 | if (!strncmp(hdrv->name, "generic-", 8)) | 1532 | if (!strncmp(hdrv->name, "generic-", 8)) |
1504 | return !hid_match_id(hdev, hid_blacklist); | 1533 | return !hid_match_id(hdev, hid_have_special_driver); |
1505 | 1534 | ||
1506 | return 1; | 1535 | return 1; |
1507 | } | 1536 | } |
@@ -1761,6 +1790,12 @@ static const struct hid_device_id hid_mouse_ignore_list[] = { | |||
1761 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) }, | 1790 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) }, |
1762 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) }, | 1791 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) }, |
1763 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) }, | 1792 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) }, |
1793 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI) }, | ||
1794 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO) }, | ||
1795 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS) }, | ||
1796 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) }, | ||
1797 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) }, | ||
1798 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) }, | ||
1764 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, | 1799 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, |
1765 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, | 1800 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, |
1766 | { } | 1801 | { } |
@@ -1952,12 +1987,12 @@ static int __init hid_init(void) | |||
1952 | int ret; | 1987 | int ret; |
1953 | 1988 | ||
1954 | if (hid_debug) | 1989 | if (hid_debug) |
1955 | printk(KERN_WARNING "HID: hid_debug is now used solely for parser and driver debugging.\n" | 1990 | pr_warn("hid_debug is now used solely for parser and driver debugging.\n" |
1956 | "HID: debugfs is now used for inspecting the device (report descriptor, reports)\n"); | 1991 | "debugfs is now used for inspecting the device (report descriptor, reports)\n"); |
1957 | 1992 | ||
1958 | ret = bus_register(&hid_bus_type); | 1993 | ret = bus_register(&hid_bus_type); |
1959 | if (ret) { | 1994 | if (ret) { |
1960 | printk(KERN_ERR "HID: can't register hid bus\n"); | 1995 | pr_err("can't register hid bus\n"); |
1961 | goto err; | 1996 | goto err; |
1962 | } | 1997 | } |
1963 | 1998 | ||
diff --git a/drivers/hid/hid-cypress.c b/drivers/hid/hid-cypress.c index 4cd0e2345991..2f0be4c66af7 100644 --- a/drivers/hid/hid-cypress.c +++ b/drivers/hid/hid-cypress.c | |||
@@ -107,13 +107,13 @@ static int cp_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
107 | 107 | ||
108 | ret = hid_parse(hdev); | 108 | ret = hid_parse(hdev); |
109 | if (ret) { | 109 | if (ret) { |
110 | dev_err(&hdev->dev, "parse failed\n"); | 110 | hid_err(hdev, "parse failed\n"); |
111 | goto err_free; | 111 | goto err_free; |
112 | } | 112 | } |
113 | 113 | ||
114 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); | 114 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); |
115 | if (ret) { | 115 | if (ret) { |
116 | dev_err(&hdev->dev, "hw start failed\n"); | 116 | hid_err(hdev, "hw start failed\n"); |
117 | goto err_free; | 117 | goto err_free; |
118 | } | 118 | } |
119 | 119 | ||
diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c index 75c5e23d09d2..555382fc7417 100644 --- a/drivers/hid/hid-debug.c +++ b/drivers/hid/hid-debug.c | |||
@@ -26,6 +26,8 @@ | |||
26 | * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic | 26 | * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
30 | |||
29 | #include <linux/debugfs.h> | 31 | #include <linux/debugfs.h> |
30 | #include <linux/seq_file.h> | 32 | #include <linux/seq_file.h> |
31 | #include <linux/sched.h> | 33 | #include <linux/sched.h> |
@@ -393,7 +395,7 @@ char *hid_resolv_usage(unsigned usage, struct seq_file *f) { | |||
393 | 395 | ||
394 | buf = resolv_usage_page(usage >> 16, f); | 396 | buf = resolv_usage_page(usage >> 16, f); |
395 | if (IS_ERR(buf)) { | 397 | if (IS_ERR(buf)) { |
396 | printk(KERN_ERR "error allocating HID debug buffer\n"); | 398 | pr_err("error allocating HID debug buffer\n"); |
397 | return NULL; | 399 | return NULL; |
398 | } | 400 | } |
399 | 401 | ||
diff --git a/drivers/hid/hid-drff.c b/drivers/hid/hid-drff.c index 968b04f9b796..afcf3d67eb02 100644 --- a/drivers/hid/hid-drff.c +++ b/drivers/hid/hid-drff.c | |||
@@ -96,18 +96,18 @@ static int drff_init(struct hid_device *hid) | |||
96 | int error; | 96 | int error; |
97 | 97 | ||
98 | if (list_empty(report_list)) { | 98 | if (list_empty(report_list)) { |
99 | dev_err(&hid->dev, "no output reports found\n"); | 99 | hid_err(hid, "no output reports found\n"); |
100 | return -ENODEV; | 100 | return -ENODEV; |
101 | } | 101 | } |
102 | 102 | ||
103 | report = list_first_entry(report_list, struct hid_report, list); | 103 | report = list_first_entry(report_list, struct hid_report, list); |
104 | if (report->maxfield < 1) { | 104 | if (report->maxfield < 1) { |
105 | dev_err(&hid->dev, "no fields in the report\n"); | 105 | hid_err(hid, "no fields in the report\n"); |
106 | return -ENODEV; | 106 | return -ENODEV; |
107 | } | 107 | } |
108 | 108 | ||
109 | if (report->field[0]->report_count < 7) { | 109 | if (report->field[0]->report_count < 7) { |
110 | dev_err(&hid->dev, "not enough values in the field\n"); | 110 | hid_err(hid, "not enough values in the field\n"); |
111 | return -ENODEV; | 111 | return -ENODEV; |
112 | } | 112 | } |
113 | 113 | ||
@@ -133,8 +133,8 @@ static int drff_init(struct hid_device *hid) | |||
133 | drff->report->field[0]->value[6] = 0x00; | 133 | drff->report->field[0]->value[6] = 0x00; |
134 | usbhid_submit_report(hid, drff->report, USB_DIR_OUT); | 134 | usbhid_submit_report(hid, drff->report, USB_DIR_OUT); |
135 | 135 | ||
136 | dev_info(&hid->dev, "Force Feedback for DragonRise Inc. game " | 136 | hid_info(hid, "Force Feedback for DragonRise Inc. " |
137 | "controllers by Richard Walmsley <richwalm@gmail.com>\n"); | 137 | "game controllers by Richard Walmsley <richwalm@gmail.com>\n"); |
138 | 138 | ||
139 | return 0; | 139 | return 0; |
140 | } | 140 | } |
@@ -153,13 +153,13 @@ static int dr_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
153 | 153 | ||
154 | ret = hid_parse(hdev); | 154 | ret = hid_parse(hdev); |
155 | if (ret) { | 155 | if (ret) { |
156 | dev_err(&hdev->dev, "parse failed\n"); | 156 | hid_err(hdev, "parse failed\n"); |
157 | goto err; | 157 | goto err; |
158 | } | 158 | } |
159 | 159 | ||
160 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF); | 160 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF); |
161 | if (ret) { | 161 | if (ret) { |
162 | dev_err(&hdev->dev, "hw start failed\n"); | 162 | hid_err(hdev, "hw start failed\n"); |
163 | goto err; | 163 | goto err; |
164 | } | 164 | } |
165 | 165 | ||
diff --git a/drivers/hid/hid-egalax.c b/drivers/hid/hid-egalax.c index 8fbff2358eb6..03bee1970d70 100644 --- a/drivers/hid/hid-egalax.c +++ b/drivers/hid/hid-egalax.c | |||
@@ -200,7 +200,7 @@ static int egalax_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
200 | 200 | ||
201 | td = kzalloc(sizeof(struct egalax_data), GFP_KERNEL); | 201 | td = kzalloc(sizeof(struct egalax_data), GFP_KERNEL); |
202 | if (!td) { | 202 | if (!td) { |
203 | dev_err(&hdev->dev, "cannot allocate eGalax data\n"); | 203 | hid_err(hdev, "cannot allocate eGalax data\n"); |
204 | return -ENOMEM; | 204 | return -ENOMEM; |
205 | } | 205 | } |
206 | hid_set_drvdata(hdev, td); | 206 | hid_set_drvdata(hdev, td); |
diff --git a/drivers/hid/hid-elecom.c b/drivers/hid/hid-elecom.c index 6e31f305397d..79d0c61e7214 100644 --- a/drivers/hid/hid-elecom.c +++ b/drivers/hid/hid-elecom.c | |||
@@ -24,8 +24,7 @@ static __u8 *elecom_report_fixup(struct hid_device *hdev, __u8 *rdesc, | |||
24 | unsigned int *rsize) | 24 | unsigned int *rsize) |
25 | { | 25 | { |
26 | if (*rsize >= 48 && rdesc[46] == 0x05 && rdesc[47] == 0x0c) { | 26 | if (*rsize >= 48 && rdesc[46] == 0x05 && rdesc[47] == 0x0c) { |
27 | dev_info(&hdev->dev, "Fixing up Elecom BM084 " | 27 | hid_info(hdev, "Fixing up Elecom BM084 report descriptor\n"); |
28 | "report descriptor.\n"); | ||
29 | rdesc[47] = 0x00; | 28 | rdesc[47] = 0x00; |
30 | } | 29 | } |
31 | return rdesc; | 30 | return rdesc; |
diff --git a/drivers/hid/hid-emsff.c b/drivers/hid/hid-emsff.c new file mode 100644 index 000000000000..81877c67caea --- /dev/null +++ b/drivers/hid/hid-emsff.c | |||
@@ -0,0 +1,161 @@ | |||
1 | /* | ||
2 | * Force feedback support for EMS Trio Linker Plus II | ||
3 | * | ||
4 | * Copyright (c) 2010 Ignaz Forster <ignaz.forster@gmx.de> | ||
5 | */ | ||
6 | |||
7 | /* | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | */ | ||
22 | |||
23 | |||
24 | #include <linux/hid.h> | ||
25 | #include <linux/input.h> | ||
26 | #include <linux/usb.h> | ||
27 | |||
28 | #include "hid-ids.h" | ||
29 | #include "usbhid/usbhid.h" | ||
30 | |||
31 | struct emsff_device { | ||
32 | struct hid_report *report; | ||
33 | }; | ||
34 | |||
35 | static int emsff_play(struct input_dev *dev, void *data, | ||
36 | struct ff_effect *effect) | ||
37 | { | ||
38 | struct hid_device *hid = input_get_drvdata(dev); | ||
39 | struct emsff_device *emsff = data; | ||
40 | int weak, strong; | ||
41 | |||
42 | weak = effect->u.rumble.weak_magnitude; | ||
43 | strong = effect->u.rumble.strong_magnitude; | ||
44 | |||
45 | dbg_hid("called with 0x%04x 0x%04x\n", strong, weak); | ||
46 | |||
47 | weak = weak * 0xff / 0xffff; | ||
48 | strong = strong * 0xff / 0xffff; | ||
49 | |||
50 | emsff->report->field[0]->value[1] = weak; | ||
51 | emsff->report->field[0]->value[2] = strong; | ||
52 | |||
53 | dbg_hid("running with 0x%02x 0x%02x\n", strong, weak); | ||
54 | usbhid_submit_report(hid, emsff->report, USB_DIR_OUT); | ||
55 | |||
56 | return 0; | ||
57 | } | ||
58 | |||
59 | static int emsff_init(struct hid_device *hid) | ||
60 | { | ||
61 | struct emsff_device *emsff; | ||
62 | struct hid_report *report; | ||
63 | struct hid_input *hidinput = list_first_entry(&hid->inputs, | ||
64 | struct hid_input, list); | ||
65 | struct list_head *report_list = | ||
66 | &hid->report_enum[HID_OUTPUT_REPORT].report_list; | ||
67 | struct input_dev *dev = hidinput->input; | ||
68 | int error; | ||
69 | |||
70 | if (list_empty(report_list)) { | ||
71 | hid_err(hid, "no output reports found\n"); | ||
72 | return -ENODEV; | ||
73 | } | ||
74 | |||
75 | report = list_first_entry(report_list, struct hid_report, list); | ||
76 | if (report->maxfield < 1) { | ||
77 | hid_err(hid, "no fields in the report\n"); | ||
78 | return -ENODEV; | ||
79 | } | ||
80 | |||
81 | if (report->field[0]->report_count < 7) { | ||
82 | hid_err(hid, "not enough values in the field\n"); | ||
83 | return -ENODEV; | ||
84 | } | ||
85 | |||
86 | emsff = kzalloc(sizeof(struct emsff_device), GFP_KERNEL); | ||
87 | if (!emsff) | ||
88 | return -ENOMEM; | ||
89 | |||
90 | set_bit(FF_RUMBLE, dev->ffbit); | ||
91 | |||
92 | error = input_ff_create_memless(dev, emsff, emsff_play); | ||
93 | if (error) { | ||
94 | kfree(emsff); | ||
95 | return error; | ||
96 | } | ||
97 | |||
98 | emsff->report = report; | ||
99 | emsff->report->field[0]->value[0] = 0x01; | ||
100 | emsff->report->field[0]->value[1] = 0x00; | ||
101 | emsff->report->field[0]->value[2] = 0x00; | ||
102 | emsff->report->field[0]->value[3] = 0x00; | ||
103 | emsff->report->field[0]->value[4] = 0x00; | ||
104 | emsff->report->field[0]->value[5] = 0x00; | ||
105 | emsff->report->field[0]->value[6] = 0x00; | ||
106 | usbhid_submit_report(hid, emsff->report, USB_DIR_OUT); | ||
107 | |||
108 | hid_info(hid, "force feedback for EMS based devices by Ignaz Forster <ignaz.forster@gmx.de>\n"); | ||
109 | |||
110 | return 0; | ||
111 | } | ||
112 | |||
113 | static int ems_probe(struct hid_device *hdev, const struct hid_device_id *id) | ||
114 | { | ||
115 | int ret; | ||
116 | |||
117 | ret = hid_parse(hdev); | ||
118 | if (ret) { | ||
119 | hid_err(hdev, "parse failed\n"); | ||
120 | goto err; | ||
121 | } | ||
122 | |||
123 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF); | ||
124 | if (ret) { | ||
125 | hid_err(hdev, "hw start failed\n"); | ||
126 | goto err; | ||
127 | } | ||
128 | |||
129 | emsff_init(hdev); | ||
130 | |||
131 | return 0; | ||
132 | err: | ||
133 | return ret; | ||
134 | } | ||
135 | |||
136 | static const struct hid_device_id ems_devices[] = { | ||
137 | { HID_USB_DEVICE(USB_VENDOR_ID_EMS, 0x118) }, | ||
138 | { } | ||
139 | }; | ||
140 | MODULE_DEVICE_TABLE(hid, ems_devices); | ||
141 | |||
142 | static struct hid_driver ems_driver = { | ||
143 | .name = "hkems", | ||
144 | .id_table = ems_devices, | ||
145 | .probe = ems_probe, | ||
146 | }; | ||
147 | |||
148 | static int ems_init(void) | ||
149 | { | ||
150 | return hid_register_driver(&ems_driver); | ||
151 | } | ||
152 | |||
153 | static void ems_exit(void) | ||
154 | { | ||
155 | hid_unregister_driver(&ems_driver); | ||
156 | } | ||
157 | |||
158 | module_init(ems_init); | ||
159 | module_exit(ems_exit); | ||
160 | MODULE_LICENSE("GPL"); | ||
161 | |||
diff --git a/drivers/hid/hid-gaff.c b/drivers/hid/hid-gaff.c index 88dfcf49a5d7..279ba530003c 100644 --- a/drivers/hid/hid-gaff.c +++ b/drivers/hid/hid-gaff.c | |||
@@ -87,7 +87,7 @@ static int gaff_init(struct hid_device *hid) | |||
87 | int error; | 87 | int error; |
88 | 88 | ||
89 | if (list_empty(report_list)) { | 89 | if (list_empty(report_list)) { |
90 | dev_err(&hid->dev, "no output reports found\n"); | 90 | hid_err(hid, "no output reports found\n"); |
91 | return -ENODEV; | 91 | return -ENODEV; |
92 | } | 92 | } |
93 | 93 | ||
@@ -95,12 +95,12 @@ static int gaff_init(struct hid_device *hid) | |||
95 | 95 | ||
96 | report = list_entry(report_ptr, struct hid_report, list); | 96 | report = list_entry(report_ptr, struct hid_report, list); |
97 | if (report->maxfield < 1) { | 97 | if (report->maxfield < 1) { |
98 | dev_err(&hid->dev, "no fields in the report\n"); | 98 | hid_err(hid, "no fields in the report\n"); |
99 | return -ENODEV; | 99 | return -ENODEV; |
100 | } | 100 | } |
101 | 101 | ||
102 | if (report->field[0]->report_count < 6) { | 102 | if (report->field[0]->report_count < 6) { |
103 | dev_err(&hid->dev, "not enough values in the field\n"); | 103 | hid_err(hid, "not enough values in the field\n"); |
104 | return -ENODEV; | 104 | return -ENODEV; |
105 | } | 105 | } |
106 | 106 | ||
@@ -128,8 +128,7 @@ static int gaff_init(struct hid_device *hid) | |||
128 | 128 | ||
129 | usbhid_submit_report(hid, gaff->report, USB_DIR_OUT); | 129 | usbhid_submit_report(hid, gaff->report, USB_DIR_OUT); |
130 | 130 | ||
131 | dev_info(&hid->dev, "Force Feedback for GreenAsia 0x12" | 131 | hid_info(hid, "Force Feedback for GreenAsia 0x12 devices by Lukasz Lubojanski <lukasz@lubojanski.info>\n"); |
132 | " devices by Lukasz Lubojanski <lukasz@lubojanski.info>\n"); | ||
133 | 132 | ||
134 | return 0; | 133 | return 0; |
135 | } | 134 | } |
@@ -148,13 +147,13 @@ static int ga_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
148 | 147 | ||
149 | ret = hid_parse(hdev); | 148 | ret = hid_parse(hdev); |
150 | if (ret) { | 149 | if (ret) { |
151 | dev_err(&hdev->dev, "parse failed\n"); | 150 | hid_err(hdev, "parse failed\n"); |
152 | goto err; | 151 | goto err; |
153 | } | 152 | } |
154 | 153 | ||
155 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF); | 154 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF); |
156 | if (ret) { | 155 | if (ret) { |
157 | dev_err(&hdev->dev, "hw start failed\n"); | 156 | hid_err(hdev, "hw start failed\n"); |
158 | goto err; | 157 | goto err; |
159 | } | 158 | } |
160 | 159 | ||
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 8e11af86b014..f65cace77729 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h | |||
@@ -97,6 +97,12 @@ | |||
97 | #define USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI 0x0236 | 97 | #define USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI 0x0236 |
98 | #define USB_DEVICE_ID_APPLE_WELLSPRING3_ISO 0x0237 | 98 | #define USB_DEVICE_ID_APPLE_WELLSPRING3_ISO 0x0237 |
99 | #define USB_DEVICE_ID_APPLE_WELLSPRING3_JIS 0x0238 | 99 | #define USB_DEVICE_ID_APPLE_WELLSPRING3_JIS 0x0238 |
100 | #define USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI 0x023f | ||
101 | #define USB_DEVICE_ID_APPLE_WELLSPRING4_ISO 0x0240 | ||
102 | #define USB_DEVICE_ID_APPLE_WELLSPRING4_JIS 0x0241 | ||
103 | #define USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI 0x0242 | ||
104 | #define USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO 0x0243 | ||
105 | #define USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS 0x0244 | ||
100 | #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI 0x0239 | 106 | #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI 0x0239 |
101 | #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO 0x023a | 107 | #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO 0x023a |
102 | #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS 0x023b | 108 | #define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS 0x023b |
@@ -156,6 +162,7 @@ | |||
156 | #define USB_VENDOR_ID_CHICONY 0x04f2 | 162 | #define USB_VENDOR_ID_CHICONY 0x04f2 |
157 | #define USB_DEVICE_ID_CHICONY_TACTICAL_PAD 0x0418 | 163 | #define USB_DEVICE_ID_CHICONY_TACTICAL_PAD 0x0418 |
158 | #define USB_DEVICE_ID_CHICONY_MULTI_TOUCH 0xb19d | 164 | #define USB_DEVICE_ID_CHICONY_MULTI_TOUCH 0xb19d |
165 | #define USB_DEVICE_ID_CHICONY_WIRELESS 0x0618 | ||
159 | 166 | ||
160 | #define USB_VENDOR_ID_CIDC 0x1677 | 167 | #define USB_VENDOR_ID_CIDC 0x1677 |
161 | 168 | ||
@@ -208,6 +215,9 @@ | |||
208 | #define USB_VENDOR_ID_ELO 0x04E7 | 215 | #define USB_VENDOR_ID_ELO 0x04E7 |
209 | #define USB_DEVICE_ID_ELO_TS2700 0x0020 | 216 | #define USB_DEVICE_ID_ELO_TS2700 0x0020 |
210 | 217 | ||
218 | #define USB_VENDOR_ID_EMS 0x2006 | ||
219 | #define USB_DEVICE_ID_EMS_TRIO_LINKER_PLUS_II 0x0118 | ||
220 | |||
211 | #define USB_VENDOR_ID_ESSENTIAL_REALITY 0x0d7f | 221 | #define USB_VENDOR_ID_ESSENTIAL_REALITY 0x0d7f |
212 | #define USB_DEVICE_ID_ESSENTIAL_REALITY_P5 0x0100 | 222 | #define USB_DEVICE_ID_ESSENTIAL_REALITY_P5 0x0100 |
213 | 223 | ||
@@ -480,6 +490,7 @@ | |||
480 | 490 | ||
481 | #define USB_VENDOR_ID_ROCCAT 0x1e7d | 491 | #define USB_VENDOR_ID_ROCCAT 0x1e7d |
482 | #define USB_DEVICE_ID_ROCCAT_KONE 0x2ced | 492 | #define USB_DEVICE_ID_ROCCAT_KONE 0x2ced |
493 | #define USB_DEVICE_ID_ROCCAT_KONEPLUS 0x2d51 | ||
483 | #define USB_DEVICE_ID_ROCCAT_PYRA_WIRED 0x2c24 | 494 | #define USB_DEVICE_ID_ROCCAT_PYRA_WIRED 0x2c24 |
484 | #define USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS 0x2cf6 | 495 | #define USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS 0x2cf6 |
485 | 496 | ||
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index d8d372bae3cc..e60fdb88101f 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c | |||
@@ -319,21 +319,21 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel | |||
319 | 319 | ||
320 | switch (field->application) { | 320 | switch (field->application) { |
321 | case HID_GD_MOUSE: | 321 | case HID_GD_MOUSE: |
322 | case HID_GD_POINTER: code += 0x110; break; | 322 | case HID_GD_POINTER: code += BTN_MOUSE; break; |
323 | case HID_GD_JOYSTICK: | 323 | case HID_GD_JOYSTICK: |
324 | if (code <= 0xf) | 324 | if (code <= 0xf) |
325 | code += BTN_JOYSTICK; | 325 | code += BTN_JOYSTICK; |
326 | else | 326 | else |
327 | code += BTN_TRIGGER_HAPPY; | 327 | code += BTN_TRIGGER_HAPPY; |
328 | break; | 328 | break; |
329 | case HID_GD_GAMEPAD: code += 0x130; break; | 329 | case HID_GD_GAMEPAD: code += BTN_GAMEPAD; break; |
330 | default: | 330 | default: |
331 | switch (field->physical) { | 331 | switch (field->physical) { |
332 | case HID_GD_MOUSE: | 332 | case HID_GD_MOUSE: |
333 | case HID_GD_POINTER: code += 0x110; break; | 333 | case HID_GD_POINTER: code += BTN_MOUSE; break; |
334 | case HID_GD_JOYSTICK: code += 0x120; break; | 334 | case HID_GD_JOYSTICK: code += BTN_JOYSTICK; break; |
335 | case HID_GD_GAMEPAD: code += 0x130; break; | 335 | case HID_GD_GAMEPAD: code += BTN_GAMEPAD; break; |
336 | default: code += 0x100; | 336 | default: code += BTN_MISC; |
337 | } | 337 | } |
338 | } | 338 | } |
339 | 339 | ||
@@ -817,14 +817,14 @@ static int hidinput_open(struct input_dev *dev) | |||
817 | { | 817 | { |
818 | struct hid_device *hid = input_get_drvdata(dev); | 818 | struct hid_device *hid = input_get_drvdata(dev); |
819 | 819 | ||
820 | return hid->ll_driver->open(hid); | 820 | return hid_hw_open(hid); |
821 | } | 821 | } |
822 | 822 | ||
823 | static void hidinput_close(struct input_dev *dev) | 823 | static void hidinput_close(struct input_dev *dev) |
824 | { | 824 | { |
825 | struct hid_device *hid = input_get_drvdata(dev); | 825 | struct hid_device *hid = input_get_drvdata(dev); |
826 | 826 | ||
827 | hid->ll_driver->close(hid); | 827 | hid_hw_close(hid); |
828 | } | 828 | } |
829 | 829 | ||
830 | /* | 830 | /* |
@@ -871,7 +871,7 @@ int hidinput_connect(struct hid_device *hid, unsigned int force) | |||
871 | if (!hidinput || !input_dev) { | 871 | if (!hidinput || !input_dev) { |
872 | kfree(hidinput); | 872 | kfree(hidinput); |
873 | input_free_device(input_dev); | 873 | input_free_device(input_dev); |
874 | err_hid("Out of memory during hid input probe"); | 874 | hid_err(hid, "Out of memory during hid input probe\n"); |
875 | goto out_unwind; | 875 | goto out_unwind; |
876 | } | 876 | } |
877 | 877 | ||
diff --git a/drivers/hid/hid-kye.c b/drivers/hid/hid-kye.c index 817247ee006c..f2ba9efc3a53 100644 --- a/drivers/hid/hid-kye.c +++ b/drivers/hid/hid-kye.c | |||
@@ -32,8 +32,8 @@ static __u8 *kye_report_fixup(struct hid_device *hdev, __u8 *rdesc, | |||
32 | rdesc[65] == 0x29 && rdesc[66] == 0x0f && | 32 | rdesc[65] == 0x29 && rdesc[66] == 0x0f && |
33 | rdesc[71] == 0x75 && rdesc[72] == 0x08 && | 33 | rdesc[71] == 0x75 && rdesc[72] == 0x08 && |
34 | rdesc[73] == 0x95 && rdesc[74] == 0x01) { | 34 | rdesc[73] == 0x95 && rdesc[74] == 0x01) { |
35 | dev_info(&hdev->dev, "fixing up Kye/Genius Ergo Mouse report " | 35 | hid_info(hdev, |
36 | "descriptor\n"); | 36 | "fixing up Kye/Genius Ergo Mouse report descriptor\n"); |
37 | rdesc[62] = 0x09; | 37 | rdesc[62] = 0x09; |
38 | rdesc[64] = 0x04; | 38 | rdesc[64] = 0x04; |
39 | rdesc[66] = 0x07; | 39 | rdesc[66] = 0x07; |
diff --git a/drivers/hid/hid-lg.c b/drivers/hid/hid-lg.c index b629fba5a057..aef4104da141 100644 --- a/drivers/hid/hid-lg.c +++ b/drivers/hid/hid-lg.c | |||
@@ -53,23 +53,22 @@ static __u8 *lg_report_fixup(struct hid_device *hdev, __u8 *rdesc, | |||
53 | 53 | ||
54 | if ((quirks & LG_RDESC) && *rsize >= 90 && rdesc[83] == 0x26 && | 54 | if ((quirks & LG_RDESC) && *rsize >= 90 && rdesc[83] == 0x26 && |
55 | rdesc[84] == 0x8c && rdesc[85] == 0x02) { | 55 | rdesc[84] == 0x8c && rdesc[85] == 0x02) { |
56 | dev_info(&hdev->dev, "fixing up Logitech keyboard report " | 56 | hid_info(hdev, |
57 | "descriptor\n"); | 57 | "fixing up Logitech keyboard report descriptor\n"); |
58 | rdesc[84] = rdesc[89] = 0x4d; | 58 | rdesc[84] = rdesc[89] = 0x4d; |
59 | rdesc[85] = rdesc[90] = 0x10; | 59 | rdesc[85] = rdesc[90] = 0x10; |
60 | } | 60 | } |
61 | if ((quirks & LG_RDESC_REL_ABS) && *rsize >= 50 && | 61 | if ((quirks & LG_RDESC_REL_ABS) && *rsize >= 50 && |
62 | rdesc[32] == 0x81 && rdesc[33] == 0x06 && | 62 | rdesc[32] == 0x81 && rdesc[33] == 0x06 && |
63 | rdesc[49] == 0x81 && rdesc[50] == 0x06) { | 63 | rdesc[49] == 0x81 && rdesc[50] == 0x06) { |
64 | dev_info(&hdev->dev, "fixing up rel/abs in Logitech " | 64 | hid_info(hdev, |
65 | "report descriptor\n"); | 65 | "fixing up rel/abs in Logitech report descriptor\n"); |
66 | rdesc[33] = rdesc[50] = 0x02; | 66 | rdesc[33] = rdesc[50] = 0x02; |
67 | } | 67 | } |
68 | if ((quirks & LG_FF4) && *rsize >= 101 && | 68 | if ((quirks & LG_FF4) && *rsize >= 101 && |
69 | rdesc[41] == 0x95 && rdesc[42] == 0x0B && | 69 | rdesc[41] == 0x95 && rdesc[42] == 0x0B && |
70 | rdesc[47] == 0x05 && rdesc[48] == 0x09) { | 70 | rdesc[47] == 0x05 && rdesc[48] == 0x09) { |
71 | dev_info(&hdev->dev, "fixing up Logitech Speed Force Wireless " | 71 | hid_info(hdev, "fixing up Logitech Speed Force Wireless button descriptor\n"); |
72 | "button descriptor\n"); | ||
73 | rdesc[41] = 0x05; | 72 | rdesc[41] = 0x05; |
74 | rdesc[42] = 0x09; | 73 | rdesc[42] = 0x09; |
75 | rdesc[47] = 0x95; | 74 | rdesc[47] = 0x95; |
@@ -288,7 +287,7 @@ static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
288 | 287 | ||
289 | ret = hid_parse(hdev); | 288 | ret = hid_parse(hdev); |
290 | if (ret) { | 289 | if (ret) { |
291 | dev_err(&hdev->dev, "parse failed\n"); | 290 | hid_err(hdev, "parse failed\n"); |
292 | goto err_free; | 291 | goto err_free; |
293 | } | 292 | } |
294 | 293 | ||
@@ -297,7 +296,7 @@ static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
297 | 296 | ||
298 | ret = hid_hw_start(hdev, connect_mask); | 297 | ret = hid_hw_start(hdev, connect_mask); |
299 | if (ret) { | 298 | if (ret) { |
300 | dev_err(&hdev->dev, "hw start failed\n"); | 299 | hid_err(hdev, "hw start failed\n"); |
301 | goto err_free; | 300 | goto err_free; |
302 | } | 301 | } |
303 | 302 | ||
diff --git a/drivers/hid/hid-lg2ff.c b/drivers/hid/hid-lg2ff.c index 4258253c36b3..3c31bc650e5d 100644 --- a/drivers/hid/hid-lg2ff.c +++ b/drivers/hid/hid-lg2ff.c | |||
@@ -72,18 +72,18 @@ int lg2ff_init(struct hid_device *hid) | |||
72 | int error; | 72 | int error; |
73 | 73 | ||
74 | if (list_empty(report_list)) { | 74 | if (list_empty(report_list)) { |
75 | dev_err(&hid->dev, "no output report found\n"); | 75 | hid_err(hid, "no output report found\n"); |
76 | return -ENODEV; | 76 | return -ENODEV; |
77 | } | 77 | } |
78 | 78 | ||
79 | report = list_entry(report_list->next, struct hid_report, list); | 79 | report = list_entry(report_list->next, struct hid_report, list); |
80 | 80 | ||
81 | if (report->maxfield < 1) { | 81 | if (report->maxfield < 1) { |
82 | dev_err(&hid->dev, "output report is empty\n"); | 82 | hid_err(hid, "output report is empty\n"); |
83 | return -ENODEV; | 83 | return -ENODEV; |
84 | } | 84 | } |
85 | if (report->field[0]->report_count < 7) { | 85 | if (report->field[0]->report_count < 7) { |
86 | dev_err(&hid->dev, "not enough values in the field\n"); | 86 | hid_err(hid, "not enough values in the field\n"); |
87 | return -ENODEV; | 87 | return -ENODEV; |
88 | } | 88 | } |
89 | 89 | ||
@@ -110,8 +110,7 @@ int lg2ff_init(struct hid_device *hid) | |||
110 | 110 | ||
111 | usbhid_submit_report(hid, report, USB_DIR_OUT); | 111 | usbhid_submit_report(hid, report, USB_DIR_OUT); |
112 | 112 | ||
113 | dev_info(&hid->dev, "Force feedback for Logitech RumblePad/Rumblepad 2 by " | 113 | hid_info(hid, "Force feedback for Logitech RumblePad/Rumblepad 2 by Anssi Hannula <anssi.hannula@gmail.com>\n"); |
114 | "Anssi Hannula <anssi.hannula@gmail.com>\n"); | ||
115 | 114 | ||
116 | return 0; | 115 | return 0; |
117 | } | 116 | } |
diff --git a/drivers/hid/hid-lg3ff.c b/drivers/hid/hid-lg3ff.c index 4002832ee4af..f98644c26c1d 100644 --- a/drivers/hid/hid-lg3ff.c +++ b/drivers/hid/hid-lg3ff.c | |||
@@ -141,20 +141,20 @@ int lg3ff_init(struct hid_device *hid) | |||
141 | 141 | ||
142 | /* Find the report to use */ | 142 | /* Find the report to use */ |
143 | if (list_empty(report_list)) { | 143 | if (list_empty(report_list)) { |
144 | err_hid("No output report found"); | 144 | hid_err(hid, "No output report found\n"); |
145 | return -1; | 145 | return -1; |
146 | } | 146 | } |
147 | 147 | ||
148 | /* Check that the report looks ok */ | 148 | /* Check that the report looks ok */ |
149 | report = list_entry(report_list->next, struct hid_report, list); | 149 | report = list_entry(report_list->next, struct hid_report, list); |
150 | if (!report) { | 150 | if (!report) { |
151 | err_hid("NULL output report"); | 151 | hid_err(hid, "NULL output report\n"); |
152 | return -1; | 152 | return -1; |
153 | } | 153 | } |
154 | 154 | ||
155 | field = report->field[0]; | 155 | field = report->field[0]; |
156 | if (!field) { | 156 | if (!field) { |
157 | err_hid("NULL field"); | 157 | hid_err(hid, "NULL field\n"); |
158 | return -1; | 158 | return -1; |
159 | } | 159 | } |
160 | 160 | ||
@@ -169,8 +169,7 @@ int lg3ff_init(struct hid_device *hid) | |||
169 | if (test_bit(FF_AUTOCENTER, dev->ffbit)) | 169 | if (test_bit(FF_AUTOCENTER, dev->ffbit)) |
170 | dev->ff->set_autocenter = hid_lg3ff_set_autocenter; | 170 | dev->ff->set_autocenter = hid_lg3ff_set_autocenter; |
171 | 171 | ||
172 | dev_info(&hid->dev, "Force feedback for Logitech Flight System G940 by " | 172 | hid_info(hid, "Force feedback for Logitech Flight System G940 by Gary Stein <LordCnidarian@gmail.com>\n"); |
173 | "Gary Stein <LordCnidarian@gmail.com>\n"); | ||
174 | return 0; | 173 | return 0; |
175 | } | 174 | } |
176 | 175 | ||
diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c index 7eef5a2ce948..fa550c8e1d1b 100644 --- a/drivers/hid/hid-lg4ff.c +++ b/drivers/hid/hid-lg4ff.c | |||
@@ -101,20 +101,20 @@ int lg4ff_init(struct hid_device *hid) | |||
101 | 101 | ||
102 | /* Find the report to use */ | 102 | /* Find the report to use */ |
103 | if (list_empty(report_list)) { | 103 | if (list_empty(report_list)) { |
104 | err_hid("No output report found"); | 104 | hid_err(hid, "No output report found\n"); |
105 | return -1; | 105 | return -1; |
106 | } | 106 | } |
107 | 107 | ||
108 | /* Check that the report looks ok */ | 108 | /* Check that the report looks ok */ |
109 | report = list_entry(report_list->next, struct hid_report, list); | 109 | report = list_entry(report_list->next, struct hid_report, list); |
110 | if (!report) { | 110 | if (!report) { |
111 | err_hid("NULL output report"); | 111 | hid_err(hid, "NULL output report\n"); |
112 | return -1; | 112 | return -1; |
113 | } | 113 | } |
114 | 114 | ||
115 | field = report->field[0]; | 115 | field = report->field[0]; |
116 | if (!field) { | 116 | if (!field) { |
117 | err_hid("NULL field"); | 117 | hid_err(hid, "NULL field\n"); |
118 | return -1; | 118 | return -1; |
119 | } | 119 | } |
120 | 120 | ||
@@ -129,8 +129,7 @@ int lg4ff_init(struct hid_device *hid) | |||
129 | if (test_bit(FF_AUTOCENTER, dev->ffbit)) | 129 | if (test_bit(FF_AUTOCENTER, dev->ffbit)) |
130 | dev->ff->set_autocenter = hid_lg4ff_set_autocenter; | 130 | dev->ff->set_autocenter = hid_lg4ff_set_autocenter; |
131 | 131 | ||
132 | dev_info(&hid->dev, "Force feedback for Logitech Speed Force Wireless by " | 132 | hid_info(hid, "Force feedback for Logitech Speed Force Wireless by Simon Wood <simon@mungewell.org>\n"); |
133 | "Simon Wood <simon@mungewell.org>\n"); | ||
134 | return 0; | 133 | return 0; |
135 | } | 134 | } |
136 | 135 | ||
diff --git a/drivers/hid/hid-lgff.c b/drivers/hid/hid-lgff.c index 61142b76a9b1..90d0ef2c92be 100644 --- a/drivers/hid/hid-lgff.c +++ b/drivers/hid/hid-lgff.c | |||
@@ -27,6 +27,8 @@ | |||
27 | * e-mail - mail your message to <johann.deneux@it.uu.se> | 27 | * e-mail - mail your message to <johann.deneux@it.uu.se> |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
31 | |||
30 | #include <linux/input.h> | 32 | #include <linux/input.h> |
31 | #include <linux/usb.h> | 33 | #include <linux/usb.h> |
32 | #include <linux/hid.h> | 34 | #include <linux/hid.h> |
@@ -146,7 +148,7 @@ int lgff_init(struct hid_device* hid) | |||
146 | 148 | ||
147 | /* Find the report to use */ | 149 | /* Find the report to use */ |
148 | if (list_empty(report_list)) { | 150 | if (list_empty(report_list)) { |
149 | err_hid("No output report found"); | 151 | hid_err(hid, "No output report found\n"); |
150 | return -1; | 152 | return -1; |
151 | } | 153 | } |
152 | 154 | ||
@@ -154,7 +156,7 @@ int lgff_init(struct hid_device* hid) | |||
154 | report = list_entry(report_list->next, struct hid_report, list); | 156 | report = list_entry(report_list->next, struct hid_report, list); |
155 | field = report->field[0]; | 157 | field = report->field[0]; |
156 | if (!field) { | 158 | if (!field) { |
157 | err_hid("NULL field"); | 159 | hid_err(hid, "NULL field\n"); |
158 | return -1; | 160 | return -1; |
159 | } | 161 | } |
160 | 162 | ||
@@ -176,7 +178,7 @@ int lgff_init(struct hid_device* hid) | |||
176 | if ( test_bit(FF_AUTOCENTER, dev->ffbit) ) | 178 | if ( test_bit(FF_AUTOCENTER, dev->ffbit) ) |
177 | dev->ff->set_autocenter = hid_lgff_set_autocenter; | 179 | dev->ff->set_autocenter = hid_lgff_set_autocenter; |
178 | 180 | ||
179 | printk(KERN_INFO "Force feedback for Logitech force feedback devices by Johann Deneux <johann.deneux@it.uu.se>\n"); | 181 | pr_info("Force feedback for Logitech force feedback devices by Johann Deneux <johann.deneux@it.uu.se>\n"); |
180 | 182 | ||
181 | return 0; | 183 | return 0; |
182 | } | 184 | } |
diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c index e6dc15171664..698e6459fd0b 100644 --- a/drivers/hid/hid-magicmouse.c +++ b/drivers/hid/hid-magicmouse.c | |||
@@ -12,6 +12,8 @@ | |||
12 | * any later version. | 12 | * any later version. |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
16 | |||
15 | #include <linux/device.h> | 17 | #include <linux/device.h> |
16 | #include <linux/hid.h> | 18 | #include <linux/hid.h> |
17 | #include <linux/module.h> | 19 | #include <linux/module.h> |
@@ -433,6 +435,11 @@ static int magicmouse_input_mapping(struct hid_device *hdev, | |||
433 | if (!msc->input) | 435 | if (!msc->input) |
434 | msc->input = hi->input; | 436 | msc->input = hi->input; |
435 | 437 | ||
438 | /* Magic Trackpad does not give relative data after switching to MT */ | ||
439 | if (hi->input->id.product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD && | ||
440 | field->flags & HID_MAIN_ITEM_RELATIVE) | ||
441 | return -1; | ||
442 | |||
436 | return 0; | 443 | return 0; |
437 | } | 444 | } |
438 | 445 | ||
@@ -446,7 +453,7 @@ static int magicmouse_probe(struct hid_device *hdev, | |||
446 | 453 | ||
447 | msc = kzalloc(sizeof(*msc), GFP_KERNEL); | 454 | msc = kzalloc(sizeof(*msc), GFP_KERNEL); |
448 | if (msc == NULL) { | 455 | if (msc == NULL) { |
449 | dev_err(&hdev->dev, "can't alloc magicmouse descriptor\n"); | 456 | hid_err(hdev, "can't alloc magicmouse descriptor\n"); |
450 | return -ENOMEM; | 457 | return -ENOMEM; |
451 | } | 458 | } |
452 | 459 | ||
@@ -459,13 +466,13 @@ static int magicmouse_probe(struct hid_device *hdev, | |||
459 | 466 | ||
460 | ret = hid_parse(hdev); | 467 | ret = hid_parse(hdev); |
461 | if (ret) { | 468 | if (ret) { |
462 | dev_err(&hdev->dev, "magicmouse hid parse failed\n"); | 469 | hid_err(hdev, "magicmouse hid parse failed\n"); |
463 | goto err_free; | 470 | goto err_free; |
464 | } | 471 | } |
465 | 472 | ||
466 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); | 473 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); |
467 | if (ret) { | 474 | if (ret) { |
468 | dev_err(&hdev->dev, "magicmouse hw start failed\n"); | 475 | hid_err(hdev, "magicmouse hw start failed\n"); |
469 | goto err_free; | 476 | goto err_free; |
470 | } | 477 | } |
471 | 478 | ||
@@ -486,7 +493,7 @@ static int magicmouse_probe(struct hid_device *hdev, | |||
486 | } | 493 | } |
487 | 494 | ||
488 | if (!report) { | 495 | if (!report) { |
489 | dev_err(&hdev->dev, "unable to register touch report\n"); | 496 | hid_err(hdev, "unable to register touch report\n"); |
490 | ret = -ENOMEM; | 497 | ret = -ENOMEM; |
491 | goto err_stop_hw; | 498 | goto err_stop_hw; |
492 | } | 499 | } |
@@ -495,8 +502,7 @@ static int magicmouse_probe(struct hid_device *hdev, | |||
495 | ret = hdev->hid_output_raw_report(hdev, feature, sizeof(feature), | 502 | ret = hdev->hid_output_raw_report(hdev, feature, sizeof(feature), |
496 | HID_FEATURE_REPORT); | 503 | HID_FEATURE_REPORT); |
497 | if (ret != sizeof(feature)) { | 504 | if (ret != sizeof(feature)) { |
498 | dev_err(&hdev->dev, "unable to request touch data (%d)\n", | 505 | hid_err(hdev, "unable to request touch data (%d)\n", ret); |
499 | ret); | ||
500 | goto err_stop_hw; | 506 | goto err_stop_hw; |
501 | } | 507 | } |
502 | 508 | ||
@@ -540,7 +546,7 @@ static int __init magicmouse_init(void) | |||
540 | 546 | ||
541 | ret = hid_register_driver(&magicmouse_driver); | 547 | ret = hid_register_driver(&magicmouse_driver); |
542 | if (ret) | 548 | if (ret) |
543 | printk(KERN_ERR "can't register magicmouse driver\n"); | 549 | pr_err("can't register magicmouse driver\n"); |
544 | 550 | ||
545 | return ret; | 551 | return ret; |
546 | } | 552 | } |
diff --git a/drivers/hid/hid-microsoft.c b/drivers/hid/hid-microsoft.c index dc618c33d0a2..0f6fc54dc196 100644 --- a/drivers/hid/hid-microsoft.c +++ b/drivers/hid/hid-microsoft.c | |||
@@ -40,8 +40,7 @@ static __u8 *ms_report_fixup(struct hid_device *hdev, __u8 *rdesc, | |||
40 | 40 | ||
41 | if ((quirks & MS_RDESC) && *rsize == 571 && rdesc[557] == 0x19 && | 41 | if ((quirks & MS_RDESC) && *rsize == 571 && rdesc[557] == 0x19 && |
42 | rdesc[559] == 0x29) { | 42 | rdesc[559] == 0x29) { |
43 | dev_info(&hdev->dev, "fixing up Microsoft Wireless Receiver " | 43 | hid_info(hdev, "fixing up Microsoft Wireless Receiver Model 1028 report descriptor\n"); |
44 | "Model 1028 report descriptor\n"); | ||
45 | rdesc[557] = 0x35; | 44 | rdesc[557] = 0x35; |
46 | rdesc[559] = 0x45; | 45 | rdesc[559] = 0x45; |
47 | } | 46 | } |
@@ -155,14 +154,14 @@ static int ms_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
155 | 154 | ||
156 | ret = hid_parse(hdev); | 155 | ret = hid_parse(hdev); |
157 | if (ret) { | 156 | if (ret) { |
158 | dev_err(&hdev->dev, "parse failed\n"); | 157 | hid_err(hdev, "parse failed\n"); |
159 | goto err_free; | 158 | goto err_free; |
160 | } | 159 | } |
161 | 160 | ||
162 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT | ((quirks & MS_HIDINPUT) ? | 161 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT | ((quirks & MS_HIDINPUT) ? |
163 | HID_CONNECT_HIDINPUT_FORCE : 0)); | 162 | HID_CONNECT_HIDINPUT_FORCE : 0)); |
164 | if (ret) { | 163 | if (ret) { |
165 | dev_err(&hdev->dev, "hw start failed\n"); | 164 | hid_err(hdev, "hw start failed\n"); |
166 | goto err_free; | 165 | goto err_free; |
167 | } | 166 | } |
168 | 167 | ||
diff --git a/drivers/hid/hid-monterey.c b/drivers/hid/hid-monterey.c index c95c31e2d869..dedf757781ae 100644 --- a/drivers/hid/hid-monterey.c +++ b/drivers/hid/hid-monterey.c | |||
@@ -26,8 +26,7 @@ static __u8 *mr_report_fixup(struct hid_device *hdev, __u8 *rdesc, | |||
26 | unsigned int *rsize) | 26 | unsigned int *rsize) |
27 | { | 27 | { |
28 | if (*rsize >= 30 && rdesc[29] == 0x05 && rdesc[30] == 0x09) { | 28 | if (*rsize >= 30 && rdesc[29] == 0x05 && rdesc[30] == 0x09) { |
29 | dev_info(&hdev->dev, "fixing up button/consumer in HID report " | 29 | hid_info(hdev, "fixing up button/consumer in HID report descriptor\n"); |
30 | "descriptor\n"); | ||
31 | rdesc[30] = 0x0c; | 30 | rdesc[30] = 0x0c; |
32 | } | 31 | } |
33 | return rdesc; | 32 | return rdesc; |
diff --git a/drivers/hid/hid-mosart.c b/drivers/hid/hid-mosart.c index ac5421d568f1..9fb050ce6f04 100644 --- a/drivers/hid/hid-mosart.c +++ b/drivers/hid/hid-mosart.c | |||
@@ -90,6 +90,10 @@ static int mosart_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
90 | case 0xff000000: | 90 | case 0xff000000: |
91 | /* ignore HID features */ | 91 | /* ignore HID features */ |
92 | return -1; | 92 | return -1; |
93 | |||
94 | case HID_UP_BUTTON: | ||
95 | /* ignore buttons */ | ||
96 | return -1; | ||
93 | } | 97 | } |
94 | 98 | ||
95 | return 0; | 99 | return 0; |
@@ -199,7 +203,7 @@ static int mosart_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
199 | 203 | ||
200 | td = kmalloc(sizeof(struct mosart_data), GFP_KERNEL); | 204 | td = kmalloc(sizeof(struct mosart_data), GFP_KERNEL); |
201 | if (!td) { | 205 | if (!td) { |
202 | dev_err(&hdev->dev, "cannot allocate MosArt data\n"); | 206 | hid_err(hdev, "cannot allocate MosArt data\n"); |
203 | return -ENOMEM; | 207 | return -ENOMEM; |
204 | } | 208 | } |
205 | td->valid = false; | 209 | td->valid = false; |
@@ -230,6 +234,19 @@ static int mosart_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
230 | return ret; | 234 | return ret; |
231 | } | 235 | } |
232 | 236 | ||
237 | #ifdef CONFIG_PM | ||
238 | static int mosart_reset_resume(struct hid_device *hdev) | ||
239 | { | ||
240 | struct hid_report_enum *re = hdev->report_enum | ||
241 | + HID_FEATURE_REPORT; | ||
242 | struct hid_report *r = re->report_id_hash[7]; | ||
243 | |||
244 | r->field[0]->value[0] = 0x02; | ||
245 | usbhid_submit_report(hdev, r, USB_DIR_OUT); | ||
246 | return 0; | ||
247 | } | ||
248 | #endif | ||
249 | |||
233 | static void mosart_remove(struct hid_device *hdev) | 250 | static void mosart_remove(struct hid_device *hdev) |
234 | { | 251 | { |
235 | hid_hw_stop(hdev); | 252 | hid_hw_stop(hdev); |
@@ -258,6 +275,9 @@ static struct hid_driver mosart_driver = { | |||
258 | .input_mapped = mosart_input_mapped, | 275 | .input_mapped = mosart_input_mapped, |
259 | .usage_table = mosart_grabbed_usages, | 276 | .usage_table = mosart_grabbed_usages, |
260 | .event = mosart_event, | 277 | .event = mosart_event, |
278 | #ifdef CONFIG_PM | ||
279 | .reset_resume = mosart_reset_resume, | ||
280 | #endif | ||
261 | }; | 281 | }; |
262 | 282 | ||
263 | static int __init mosart_init(void) | 283 | static int __init mosart_init(void) |
diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c index 69169efa1e16..beb403421e72 100644 --- a/drivers/hid/hid-ntrig.c +++ b/drivers/hid/hid-ntrig.c | |||
@@ -130,8 +130,7 @@ static void ntrig_report_version(struct hid_device *hdev) | |||
130 | if (ret == 8) { | 130 | if (ret == 8) { |
131 | ret = ntrig_version_string(&data[2], buf); | 131 | ret = ntrig_version_string(&data[2], buf); |
132 | 132 | ||
133 | dev_info(&hdev->dev, | 133 | hid_info(hdev, "Firmware version: %s (%02x%02x %02x%02x)\n", |
134 | "Firmware version: %s (%02x%02x %02x%02x)\n", | ||
135 | buf, data[2], data[3], data[4], data[5]); | 134 | buf, data[2], data[3], data[4], data[5]); |
136 | } | 135 | } |
137 | 136 | ||
@@ -831,7 +830,7 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
831 | 830 | ||
832 | nd = kmalloc(sizeof(struct ntrig_data), GFP_KERNEL); | 831 | nd = kmalloc(sizeof(struct ntrig_data), GFP_KERNEL); |
833 | if (!nd) { | 832 | if (!nd) { |
834 | dev_err(&hdev->dev, "cannot allocate N-Trig data\n"); | 833 | hid_err(hdev, "cannot allocate N-Trig data\n"); |
835 | return -ENOMEM; | 834 | return -ENOMEM; |
836 | } | 835 | } |
837 | 836 | ||
@@ -850,13 +849,13 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
850 | 849 | ||
851 | ret = hid_parse(hdev); | 850 | ret = hid_parse(hdev); |
852 | if (ret) { | 851 | if (ret) { |
853 | dev_err(&hdev->dev, "parse failed\n"); | 852 | hid_err(hdev, "parse failed\n"); |
854 | goto err_free; | 853 | goto err_free; |
855 | } | 854 | } |
856 | 855 | ||
857 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF); | 856 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF); |
858 | if (ret) { | 857 | if (ret) { |
859 | dev_err(&hdev->dev, "hw start failed\n"); | 858 | hid_err(hdev, "hw start failed\n"); |
860 | goto err_free; | 859 | goto err_free; |
861 | } | 860 | } |
862 | 861 | ||
diff --git a/drivers/hid/hid-ortek.c b/drivers/hid/hid-ortek.c index 2e79716dca31..e90edfc63051 100644 --- a/drivers/hid/hid-ortek.c +++ b/drivers/hid/hid-ortek.c | |||
@@ -23,8 +23,7 @@ static __u8 *ortek_report_fixup(struct hid_device *hdev, __u8 *rdesc, | |||
23 | unsigned int *rsize) | 23 | unsigned int *rsize) |
24 | { | 24 | { |
25 | if (*rsize >= 56 && rdesc[54] == 0x25 && rdesc[55] == 0x01) { | 25 | if (*rsize >= 56 && rdesc[54] == 0x25 && rdesc[55] == 0x01) { |
26 | dev_info(&hdev->dev, "Fixing up Ortek WKB-2000 " | 26 | hid_info(hdev, "Fixing up Ortek WKB-2000 report descriptor\n"); |
27 | "report descriptor.\n"); | ||
28 | rdesc[55] = 0x92; | 27 | rdesc[55] = 0x92; |
29 | } | 28 | } |
30 | return rdesc; | 29 | return rdesc; |
diff --git a/drivers/hid/hid-petalynx.c b/drivers/hid/hid-petalynx.c index 308d6ae48a3e..f1ea3ff8a98d 100644 --- a/drivers/hid/hid-petalynx.c +++ b/drivers/hid/hid-petalynx.c | |||
@@ -29,8 +29,7 @@ static __u8 *pl_report_fixup(struct hid_device *hdev, __u8 *rdesc, | |||
29 | if (*rsize >= 60 && rdesc[39] == 0x2a && rdesc[40] == 0xf5 && | 29 | if (*rsize >= 60 && rdesc[39] == 0x2a && rdesc[40] == 0xf5 && |
30 | rdesc[41] == 0x00 && rdesc[59] == 0x26 && | 30 | rdesc[41] == 0x00 && rdesc[59] == 0x26 && |
31 | rdesc[60] == 0xf9 && rdesc[61] == 0x00) { | 31 | rdesc[60] == 0xf9 && rdesc[61] == 0x00) { |
32 | dev_info(&hdev->dev, "fixing up Petalynx Maxter Remote report " | 32 | hid_info(hdev, "fixing up Petalynx Maxter Remote report descriptor\n"); |
33 | "descriptor\n"); | ||
34 | rdesc[60] = 0xfa; | 33 | rdesc[60] = 0xfa; |
35 | rdesc[40] = 0xfa; | 34 | rdesc[40] = 0xfa; |
36 | } | 35 | } |
@@ -77,13 +76,13 @@ static int pl_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
77 | 76 | ||
78 | ret = hid_parse(hdev); | 77 | ret = hid_parse(hdev); |
79 | if (ret) { | 78 | if (ret) { |
80 | dev_err(&hdev->dev, "parse failed\n"); | 79 | hid_err(hdev, "parse failed\n"); |
81 | goto err_free; | 80 | goto err_free; |
82 | } | 81 | } |
83 | 82 | ||
84 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); | 83 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); |
85 | if (ret) { | 84 | if (ret) { |
86 | dev_err(&hdev->dev, "hw start failed\n"); | 85 | hid_err(hdev, "hw start failed\n"); |
87 | goto err_free; | 86 | goto err_free; |
88 | } | 87 | } |
89 | 88 | ||
diff --git a/drivers/hid/hid-picolcd.c b/drivers/hid/hid-picolcd.c index bc2e07740628..de9cf21b3494 100644 --- a/drivers/hid/hid-picolcd.c +++ b/drivers/hid/hid-picolcd.c | |||
@@ -253,7 +253,7 @@ static struct hid_report *picolcd_report(int id, struct hid_device *hdev, int di | |||
253 | if (report->id == id) | 253 | if (report->id == id) |
254 | return report; | 254 | return report; |
255 | } | 255 | } |
256 | dev_warn(&hdev->dev, "No report with id 0x%x found\n", id); | 256 | hid_warn(hdev, "No report with id 0x%x found\n", id); |
257 | return NULL; | 257 | return NULL; |
258 | } | 258 | } |
259 | 259 | ||
@@ -1329,7 +1329,7 @@ static int picolcd_check_version(struct hid_device *hdev) | |||
1329 | 1329 | ||
1330 | verinfo = picolcd_send_and_wait(hdev, REPORT_VERSION, NULL, 0); | 1330 | verinfo = picolcd_send_and_wait(hdev, REPORT_VERSION, NULL, 0); |
1331 | if (!verinfo) { | 1331 | if (!verinfo) { |
1332 | dev_err(&hdev->dev, "no version response from PicoLCD"); | 1332 | hid_err(hdev, "no version response from PicoLCD\n"); |
1333 | return -ENODEV; | 1333 | return -ENODEV; |
1334 | } | 1334 | } |
1335 | 1335 | ||
@@ -1337,14 +1337,14 @@ static int picolcd_check_version(struct hid_device *hdev) | |||
1337 | data->version[0] = verinfo->raw_data[1]; | 1337 | data->version[0] = verinfo->raw_data[1]; |
1338 | data->version[1] = verinfo->raw_data[0]; | 1338 | data->version[1] = verinfo->raw_data[0]; |
1339 | if (data->status & PICOLCD_BOOTLOADER) { | 1339 | if (data->status & PICOLCD_BOOTLOADER) { |
1340 | dev_info(&hdev->dev, "PicoLCD, bootloader version %d.%d\n", | 1340 | hid_info(hdev, "PicoLCD, bootloader version %d.%d\n", |
1341 | verinfo->raw_data[1], verinfo->raw_data[0]); | 1341 | verinfo->raw_data[1], verinfo->raw_data[0]); |
1342 | } else { | 1342 | } else { |
1343 | dev_info(&hdev->dev, "PicoLCD, firmware version %d.%d\n", | 1343 | hid_info(hdev, "PicoLCD, firmware version %d.%d\n", |
1344 | verinfo->raw_data[1], verinfo->raw_data[0]); | 1344 | verinfo->raw_data[1], verinfo->raw_data[0]); |
1345 | } | 1345 | } |
1346 | } else { | 1346 | } else { |
1347 | dev_err(&hdev->dev, "confused, got unexpected version response from PicoLCD\n"); | 1347 | hid_err(hdev, "confused, got unexpected version response from PicoLCD\n"); |
1348 | ret = -EINVAL; | 1348 | ret = -EINVAL; |
1349 | } | 1349 | } |
1350 | kfree(verinfo); | 1350 | kfree(verinfo); |
@@ -1544,7 +1544,7 @@ static ssize_t picolcd_debug_eeprom_read(struct file *f, char __user *u, | |||
1544 | 1544 | ||
1545 | /* prepare buffer with info about what we want to read (addr & len) */ | 1545 | /* prepare buffer with info about what we want to read (addr & len) */ |
1546 | raw_data[0] = *off & 0xff; | 1546 | raw_data[0] = *off & 0xff; |
1547 | raw_data[1] = (*off >> 8) && 0xff; | 1547 | raw_data[1] = (*off >> 8) & 0xff; |
1548 | raw_data[2] = s < 20 ? s : 20; | 1548 | raw_data[2] = s < 20 ? s : 20; |
1549 | if (*off + raw_data[2] > 0xff) | 1549 | if (*off + raw_data[2] > 0xff) |
1550 | raw_data[2] = 0x100 - *off; | 1550 | raw_data[2] = 0x100 - *off; |
@@ -1583,7 +1583,7 @@ static ssize_t picolcd_debug_eeprom_write(struct file *f, const char __user *u, | |||
1583 | 1583 | ||
1584 | memset(raw_data, 0, sizeof(raw_data)); | 1584 | memset(raw_data, 0, sizeof(raw_data)); |
1585 | raw_data[0] = *off & 0xff; | 1585 | raw_data[0] = *off & 0xff; |
1586 | raw_data[1] = (*off >> 8) && 0xff; | 1586 | raw_data[1] = (*off >> 8) & 0xff; |
1587 | raw_data[2] = s < 20 ? s : 20; | 1587 | raw_data[2] = s < 20 ? s : 20; |
1588 | if (*off + raw_data[2] > 0xff) | 1588 | if (*off + raw_data[2] > 0xff) |
1589 | raw_data[2] = 0x100 - *off; | 1589 | raw_data[2] = 0x100 - *off; |
@@ -1867,6 +1867,7 @@ static void picolcd_debug_out_report(struct picolcd_data *data, | |||
1867 | report->id, raw_size); | 1867 | report->id, raw_size); |
1868 | hid_debug_event(hdev, buff); | 1868 | hid_debug_event(hdev, buff); |
1869 | if (raw_size + 5 > sizeof(raw_data)) { | 1869 | if (raw_size + 5 > sizeof(raw_data)) { |
1870 | kfree(buff); | ||
1870 | hid_debug_event(hdev, " TOO BIG\n"); | 1871 | hid_debug_event(hdev, " TOO BIG\n"); |
1871 | return; | 1872 | return; |
1872 | } else { | 1873 | } else { |
@@ -2328,8 +2329,7 @@ static void picolcd_init_devfs(struct picolcd_data *data, | |||
2328 | (flash_w ? S_IWUSR : 0) | (flash_r ? S_IRUSR : 0), | 2329 | (flash_w ? S_IWUSR : 0) | (flash_r ? S_IRUSR : 0), |
2329 | hdev->debug_dir, data, &picolcd_debug_flash_fops); | 2330 | hdev->debug_dir, data, &picolcd_debug_flash_fops); |
2330 | } else if (flash_r || flash_w) | 2331 | } else if (flash_r || flash_w) |
2331 | dev_warn(&hdev->dev, "Unexpected FLASH access reports, " | 2332 | hid_warn(hdev, "Unexpected FLASH access reports, please submit rdesc for review\n"); |
2332 | "please submit rdesc for review\n"); | ||
2333 | } | 2333 | } |
2334 | 2334 | ||
2335 | static void picolcd_exit_devfs(struct picolcd_data *data) | 2335 | static void picolcd_exit_devfs(struct picolcd_data *data) |
@@ -2457,13 +2457,13 @@ static int picolcd_init_keys(struct picolcd_data *data, | |||
2457 | return -ENODEV; | 2457 | return -ENODEV; |
2458 | if (report->maxfield != 1 || report->field[0]->report_count != 2 || | 2458 | if (report->maxfield != 1 || report->field[0]->report_count != 2 || |
2459 | report->field[0]->report_size != 8) { | 2459 | report->field[0]->report_size != 8) { |
2460 | dev_err(&hdev->dev, "unsupported KEY_STATE report"); | 2460 | hid_err(hdev, "unsupported KEY_STATE report\n"); |
2461 | return -EINVAL; | 2461 | return -EINVAL; |
2462 | } | 2462 | } |
2463 | 2463 | ||
2464 | idev = input_allocate_device(); | 2464 | idev = input_allocate_device(); |
2465 | if (idev == NULL) { | 2465 | if (idev == NULL) { |
2466 | dev_err(&hdev->dev, "failed to allocate input device"); | 2466 | hid_err(hdev, "failed to allocate input device\n"); |
2467 | return -ENOMEM; | 2467 | return -ENOMEM; |
2468 | } | 2468 | } |
2469 | input_set_drvdata(idev, hdev); | 2469 | input_set_drvdata(idev, hdev); |
@@ -2485,7 +2485,7 @@ static int picolcd_init_keys(struct picolcd_data *data, | |||
2485 | input_set_capability(idev, EV_KEY, data->keycode[i]); | 2485 | input_set_capability(idev, EV_KEY, data->keycode[i]); |
2486 | error = input_register_device(idev); | 2486 | error = input_register_device(idev); |
2487 | if (error) { | 2487 | if (error) { |
2488 | dev_err(&hdev->dev, "error registering the input device"); | 2488 | hid_err(hdev, "error registering the input device\n"); |
2489 | input_free_device(idev); | 2489 | input_free_device(idev); |
2490 | return error; | 2490 | return error; |
2491 | } | 2491 | } |
@@ -2522,9 +2522,8 @@ static int picolcd_probe_lcd(struct hid_device *hdev, struct picolcd_data *data) | |||
2522 | return error; | 2522 | return error; |
2523 | 2523 | ||
2524 | if (data->version[0] != 0 && data->version[1] != 3) | 2524 | if (data->version[0] != 0 && data->version[1] != 3) |
2525 | dev_info(&hdev->dev, "Device with untested firmware revision, " | 2525 | hid_info(hdev, "Device with untested firmware revision, please submit /sys/kernel/debug/hid/%s/rdesc for this device.\n", |
2526 | "please submit /sys/kernel/debug/hid/%s/rdesc for this device.\n", | 2526 | dev_name(&hdev->dev)); |
2527 | dev_name(&hdev->dev)); | ||
2528 | 2527 | ||
2529 | /* Setup keypad input device */ | 2528 | /* Setup keypad input device */ |
2530 | error = picolcd_init_keys(data, picolcd_in_report(REPORT_KEY_STATE, hdev)); | 2529 | error = picolcd_init_keys(data, picolcd_in_report(REPORT_KEY_STATE, hdev)); |
@@ -2581,9 +2580,8 @@ static int picolcd_probe_bootloader(struct hid_device *hdev, struct picolcd_data | |||
2581 | return error; | 2580 | return error; |
2582 | 2581 | ||
2583 | if (data->version[0] != 1 && data->version[1] != 0) | 2582 | if (data->version[0] != 1 && data->version[1] != 0) |
2584 | dev_info(&hdev->dev, "Device with untested bootloader revision, " | 2583 | hid_info(hdev, "Device with untested bootloader revision, please submit /sys/kernel/debug/hid/%s/rdesc for this device.\n", |
2585 | "please submit /sys/kernel/debug/hid/%s/rdesc for this device.\n", | 2584 | dev_name(&hdev->dev)); |
2586 | dev_name(&hdev->dev)); | ||
2587 | 2585 | ||
2588 | picolcd_init_devfs(data, NULL, NULL, | 2586 | picolcd_init_devfs(data, NULL, NULL, |
2589 | picolcd_out_report(REPORT_BL_READ_MEMORY, hdev), | 2587 | picolcd_out_report(REPORT_BL_READ_MEMORY, hdev), |
@@ -2605,7 +2603,7 @@ static int picolcd_probe(struct hid_device *hdev, | |||
2605 | */ | 2603 | */ |
2606 | data = kzalloc(sizeof(struct picolcd_data), GFP_KERNEL); | 2604 | data = kzalloc(sizeof(struct picolcd_data), GFP_KERNEL); |
2607 | if (data == NULL) { | 2605 | if (data == NULL) { |
2608 | dev_err(&hdev->dev, "can't allocate space for Minibox PicoLCD device data\n"); | 2606 | hid_err(hdev, "can't allocate space for Minibox PicoLCD device data\n"); |
2609 | error = -ENOMEM; | 2607 | error = -ENOMEM; |
2610 | goto err_no_cleanup; | 2608 | goto err_no_cleanup; |
2611 | } | 2609 | } |
@@ -2621,7 +2619,7 @@ static int picolcd_probe(struct hid_device *hdev, | |||
2621 | /* Parse the device reports and start it up */ | 2619 | /* Parse the device reports and start it up */ |
2622 | error = hid_parse(hdev); | 2620 | error = hid_parse(hdev); |
2623 | if (error) { | 2621 | if (error) { |
2624 | dev_err(&hdev->dev, "device report parse failed\n"); | 2622 | hid_err(hdev, "device report parse failed\n"); |
2625 | goto err_cleanup_data; | 2623 | goto err_cleanup_data; |
2626 | } | 2624 | } |
2627 | 2625 | ||
@@ -2631,25 +2629,25 @@ static int picolcd_probe(struct hid_device *hdev, | |||
2631 | error = hid_hw_start(hdev, 0); | 2629 | error = hid_hw_start(hdev, 0); |
2632 | hdev->claimed = 0; | 2630 | hdev->claimed = 0; |
2633 | if (error) { | 2631 | if (error) { |
2634 | dev_err(&hdev->dev, "hardware start failed\n"); | 2632 | hid_err(hdev, "hardware start failed\n"); |
2635 | goto err_cleanup_data; | 2633 | goto err_cleanup_data; |
2636 | } | 2634 | } |
2637 | 2635 | ||
2638 | error = hdev->ll_driver->open(hdev); | 2636 | error = hid_hw_open(hdev); |
2639 | if (error) { | 2637 | if (error) { |
2640 | dev_err(&hdev->dev, "failed to open input interrupt pipe for key and IR events\n"); | 2638 | hid_err(hdev, "failed to open input interrupt pipe for key and IR events\n"); |
2641 | goto err_cleanup_hid_hw; | 2639 | goto err_cleanup_hid_hw; |
2642 | } | 2640 | } |
2643 | 2641 | ||
2644 | error = device_create_file(&hdev->dev, &dev_attr_operation_mode_delay); | 2642 | error = device_create_file(&hdev->dev, &dev_attr_operation_mode_delay); |
2645 | if (error) { | 2643 | if (error) { |
2646 | dev_err(&hdev->dev, "failed to create sysfs attributes\n"); | 2644 | hid_err(hdev, "failed to create sysfs attributes\n"); |
2647 | goto err_cleanup_hid_ll; | 2645 | goto err_cleanup_hid_ll; |
2648 | } | 2646 | } |
2649 | 2647 | ||
2650 | error = device_create_file(&hdev->dev, &dev_attr_operation_mode); | 2648 | error = device_create_file(&hdev->dev, &dev_attr_operation_mode); |
2651 | if (error) { | 2649 | if (error) { |
2652 | dev_err(&hdev->dev, "failed to create sysfs attributes\n"); | 2650 | hid_err(hdev, "failed to create sysfs attributes\n"); |
2653 | goto err_cleanup_sysfs1; | 2651 | goto err_cleanup_sysfs1; |
2654 | } | 2652 | } |
2655 | 2653 | ||
@@ -2668,7 +2666,7 @@ err_cleanup_sysfs2: | |||
2668 | err_cleanup_sysfs1: | 2666 | err_cleanup_sysfs1: |
2669 | device_remove_file(&hdev->dev, &dev_attr_operation_mode_delay); | 2667 | device_remove_file(&hdev->dev, &dev_attr_operation_mode_delay); |
2670 | err_cleanup_hid_ll: | 2668 | err_cleanup_hid_ll: |
2671 | hdev->ll_driver->close(hdev); | 2669 | hid_hw_close(hdev); |
2672 | err_cleanup_hid_hw: | 2670 | err_cleanup_hid_hw: |
2673 | hid_hw_stop(hdev); | 2671 | hid_hw_stop(hdev); |
2674 | err_cleanup_data: | 2672 | err_cleanup_data: |
@@ -2699,7 +2697,7 @@ static void picolcd_remove(struct hid_device *hdev) | |||
2699 | picolcd_exit_devfs(data); | 2697 | picolcd_exit_devfs(data); |
2700 | device_remove_file(&hdev->dev, &dev_attr_operation_mode); | 2698 | device_remove_file(&hdev->dev, &dev_attr_operation_mode); |
2701 | device_remove_file(&hdev->dev, &dev_attr_operation_mode_delay); | 2699 | device_remove_file(&hdev->dev, &dev_attr_operation_mode_delay); |
2702 | hdev->ll_driver->close(hdev); | 2700 | hid_hw_close(hdev); |
2703 | hid_hw_stop(hdev); | 2701 | hid_hw_stop(hdev); |
2704 | hid_set_drvdata(hdev, NULL); | 2702 | hid_set_drvdata(hdev, NULL); |
2705 | 2703 | ||
@@ -2753,7 +2751,7 @@ static void __exit picolcd_exit(void) | |||
2753 | { | 2751 | { |
2754 | hid_unregister_driver(&picolcd_driver); | 2752 | hid_unregister_driver(&picolcd_driver); |
2755 | #ifdef CONFIG_HID_PICOLCD_FB | 2753 | #ifdef CONFIG_HID_PICOLCD_FB |
2756 | flush_scheduled_work(); | 2754 | flush_work_sync(&picolcd_fb_cleanup); |
2757 | WARN_ON(fb_pending); | 2755 | WARN_ON(fb_pending); |
2758 | #endif | 2756 | #endif |
2759 | } | 2757 | } |
diff --git a/drivers/hid/hid-pl.c b/drivers/hid/hid-pl.c index 9f41e2bd8483..06e5300d43d2 100644 --- a/drivers/hid/hid-pl.c +++ b/drivers/hid/hid-pl.c | |||
@@ -103,7 +103,7 @@ static int plff_init(struct hid_device *hid) | |||
103 | */ | 103 | */ |
104 | 104 | ||
105 | if (list_empty(report_list)) { | 105 | if (list_empty(report_list)) { |
106 | dev_err(&hid->dev, "no output reports found\n"); | 106 | hid_err(hid, "no output reports found\n"); |
107 | return -ENODEV; | 107 | return -ENODEV; |
108 | } | 108 | } |
109 | 109 | ||
@@ -112,14 +112,13 @@ static int plff_init(struct hid_device *hid) | |||
112 | report_ptr = report_ptr->next; | 112 | report_ptr = report_ptr->next; |
113 | 113 | ||
114 | if (report_ptr == report_list) { | 114 | if (report_ptr == report_list) { |
115 | dev_err(&hid->dev, "required output report is " | 115 | hid_err(hid, "required output report is missing\n"); |
116 | "missing\n"); | ||
117 | return -ENODEV; | 116 | return -ENODEV; |
118 | } | 117 | } |
119 | 118 | ||
120 | report = list_entry(report_ptr, struct hid_report, list); | 119 | report = list_entry(report_ptr, struct hid_report, list); |
121 | if (report->maxfield < 1) { | 120 | if (report->maxfield < 1) { |
122 | dev_err(&hid->dev, "no fields in the report\n"); | 121 | hid_err(hid, "no fields in the report\n"); |
123 | return -ENODEV; | 122 | return -ENODEV; |
124 | } | 123 | } |
125 | 124 | ||
@@ -137,7 +136,7 @@ static int plff_init(struct hid_device *hid) | |||
137 | weak = &report->field[3]->value[0]; | 136 | weak = &report->field[3]->value[0]; |
138 | debug("detected 4-field device"); | 137 | debug("detected 4-field device"); |
139 | } else { | 138 | } else { |
140 | dev_err(&hid->dev, "not enough fields or values\n"); | 139 | hid_err(hid, "not enough fields or values\n"); |
141 | return -ENODEV; | 140 | return -ENODEV; |
142 | } | 141 | } |
143 | 142 | ||
@@ -164,8 +163,7 @@ static int plff_init(struct hid_device *hid) | |||
164 | usbhid_submit_report(hid, plff->report, USB_DIR_OUT); | 163 | usbhid_submit_report(hid, plff->report, USB_DIR_OUT); |
165 | } | 164 | } |
166 | 165 | ||
167 | dev_info(&hid->dev, "Force feedback for PantherLord/GreenAsia " | 166 | hid_info(hid, "Force feedback for PantherLord/GreenAsia devices by Anssi Hannula <anssi.hannula@gmail.com>\n"); |
168 | "devices by Anssi Hannula <anssi.hannula@gmail.com>\n"); | ||
169 | 167 | ||
170 | return 0; | 168 | return 0; |
171 | } | 169 | } |
@@ -185,13 +183,13 @@ static int pl_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
185 | 183 | ||
186 | ret = hid_parse(hdev); | 184 | ret = hid_parse(hdev); |
187 | if (ret) { | 185 | if (ret) { |
188 | dev_err(&hdev->dev, "parse failed\n"); | 186 | hid_err(hdev, "parse failed\n"); |
189 | goto err; | 187 | goto err; |
190 | } | 188 | } |
191 | 189 | ||
192 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF); | 190 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF); |
193 | if (ret) { | 191 | if (ret) { |
194 | dev_err(&hdev->dev, "hw start failed\n"); | 192 | hid_err(hdev, "hw start failed\n"); |
195 | goto err; | 193 | goto err; |
196 | } | 194 | } |
197 | 195 | ||
diff --git a/drivers/hid/hid-prodikeys.c b/drivers/hid/hid-prodikeys.c index 48eab84f53b5..ab19f2905d27 100644 --- a/drivers/hid/hid-prodikeys.c +++ b/drivers/hid/hid-prodikeys.c | |||
@@ -16,6 +16,8 @@ | |||
16 | * any later version. | 16 | * any later version. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
20 | |||
19 | #include <linux/device.h> | 21 | #include <linux/device.h> |
20 | #include <linux/module.h> | 22 | #include <linux/module.h> |
21 | #include <linux/usb.h> | 23 | #include <linux/usb.h> |
@@ -130,7 +132,7 @@ static ssize_t store_channel(struct device *dev, | |||
130 | return -EINVAL; | 132 | return -EINVAL; |
131 | } | 133 | } |
132 | 134 | ||
133 | static DEVICE_ATTR(channel, S_IRUGO | S_IWUGO, show_channel, | 135 | static DEVICE_ATTR(channel, S_IRUGO | S_IWUSR | S_IWGRP , show_channel, |
134 | store_channel); | 136 | store_channel); |
135 | 137 | ||
136 | static struct device_attribute *sysfs_device_attr_channel = { | 138 | static struct device_attribute *sysfs_device_attr_channel = { |
@@ -169,7 +171,7 @@ static ssize_t store_sustain(struct device *dev, | |||
169 | return -EINVAL; | 171 | return -EINVAL; |
170 | } | 172 | } |
171 | 173 | ||
172 | static DEVICE_ATTR(sustain, S_IRUGO | S_IWUGO, show_sustain, | 174 | static DEVICE_ATTR(sustain, S_IRUGO | S_IWUSR | S_IWGRP, show_sustain, |
173 | store_sustain); | 175 | store_sustain); |
174 | 176 | ||
175 | static struct device_attribute *sysfs_device_attr_sustain = { | 177 | static struct device_attribute *sysfs_device_attr_sustain = { |
@@ -207,7 +209,7 @@ static ssize_t store_octave(struct device *dev, | |||
207 | return -EINVAL; | 209 | return -EINVAL; |
208 | } | 210 | } |
209 | 211 | ||
210 | static DEVICE_ATTR(octave, S_IRUGO | S_IWUGO, show_octave, | 212 | static DEVICE_ATTR(octave, S_IRUGO | S_IWUSR | S_IWGRP, show_octave, |
211 | store_octave); | 213 | store_octave); |
212 | 214 | ||
213 | static struct device_attribute *sysfs_device_attr_octave = { | 215 | static struct device_attribute *sysfs_device_attr_octave = { |
@@ -285,11 +287,11 @@ static int pcmidi_get_output_report(struct pcmidi_snd *pm) | |||
285 | continue; | 287 | continue; |
286 | 288 | ||
287 | if (report->maxfield < 1) { | 289 | if (report->maxfield < 1) { |
288 | dev_err(&hdev->dev, "output report is empty\n"); | 290 | hid_err(hdev, "output report is empty\n"); |
289 | break; | 291 | break; |
290 | } | 292 | } |
291 | if (report->field[0]->report_count != 2) { | 293 | if (report->field[0]->report_count != 2) { |
292 | dev_err(&hdev->dev, "field count too low\n"); | 294 | hid_err(hdev, "field count too low\n"); |
293 | break; | 295 | break; |
294 | } | 296 | } |
295 | pm->pcmidi_report6 = report; | 297 | pm->pcmidi_report6 = report; |
@@ -746,8 +748,8 @@ static __u8 *pk_report_fixup(struct hid_device *hdev, __u8 *rdesc, | |||
746 | if (*rsize == 178 && | 748 | if (*rsize == 178 && |
747 | rdesc[111] == 0x06 && rdesc[112] == 0x00 && | 749 | rdesc[111] == 0x06 && rdesc[112] == 0x00 && |
748 | rdesc[113] == 0xff) { | 750 | rdesc[113] == 0xff) { |
749 | dev_info(&hdev->dev, "fixing up pc-midi keyboard report " | 751 | hid_info(hdev, |
750 | "descriptor\n"); | 752 | "fixing up pc-midi keyboard report descriptor\n"); |
751 | 753 | ||
752 | rdesc[144] = 0x18; /* report 4: was 0x10 report count */ | 754 | rdesc[144] = 0x18; /* report 4: was 0x10 report count */ |
753 | } | 755 | } |
@@ -805,7 +807,7 @@ static int pk_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
805 | 807 | ||
806 | pk = kzalloc(sizeof(*pk), GFP_KERNEL); | 808 | pk = kzalloc(sizeof(*pk), GFP_KERNEL); |
807 | if (pk == NULL) { | 809 | if (pk == NULL) { |
808 | dev_err(&hdev->dev, "prodikeys: can't alloc descriptor\n"); | 810 | hid_err(hdev, "can't alloc descriptor\n"); |
809 | return -ENOMEM; | 811 | return -ENOMEM; |
810 | } | 812 | } |
811 | 813 | ||
@@ -813,8 +815,7 @@ static int pk_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
813 | 815 | ||
814 | pm = kzalloc(sizeof(*pm), GFP_KERNEL); | 816 | pm = kzalloc(sizeof(*pm), GFP_KERNEL); |
815 | if (pm == NULL) { | 817 | if (pm == NULL) { |
816 | dev_err(&hdev->dev, | 818 | hid_err(hdev, "can't alloc descriptor\n"); |
817 | "prodikeys: can't alloc descriptor\n"); | ||
818 | ret = -ENOMEM; | 819 | ret = -ENOMEM; |
819 | goto err_free; | 820 | goto err_free; |
820 | } | 821 | } |
@@ -827,7 +828,7 @@ static int pk_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
827 | 828 | ||
828 | ret = hid_parse(hdev); | 829 | ret = hid_parse(hdev); |
829 | if (ret) { | 830 | if (ret) { |
830 | dev_err(&hdev->dev, "prodikeys: hid parse failed\n"); | 831 | hid_err(hdev, "hid parse failed\n"); |
831 | goto err_free; | 832 | goto err_free; |
832 | } | 833 | } |
833 | 834 | ||
@@ -837,7 +838,7 @@ static int pk_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
837 | 838 | ||
838 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); | 839 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); |
839 | if (ret) { | 840 | if (ret) { |
840 | dev_err(&hdev->dev, "prodikeys: hw start failed\n"); | 841 | hid_err(hdev, "hw start failed\n"); |
841 | goto err_free; | 842 | goto err_free; |
842 | } | 843 | } |
843 | 844 | ||
@@ -896,7 +897,7 @@ static int pk_init(void) | |||
896 | 897 | ||
897 | ret = hid_register_driver(&pk_driver); | 898 | ret = hid_register_driver(&pk_driver); |
898 | if (ret) | 899 | if (ret) |
899 | printk(KERN_ERR "can't register prodikeys driver\n"); | 900 | pr_err("can't register prodikeys driver\n"); |
900 | 901 | ||
901 | return ret; | 902 | return ret; |
902 | } | 903 | } |
diff --git a/drivers/hid/hid-quanta.c b/drivers/hid/hid-quanta.c index 54d3db50605b..87a54df4d4ac 100644 --- a/drivers/hid/hid-quanta.c +++ b/drivers/hid/hid-quanta.c | |||
@@ -195,7 +195,7 @@ static int quanta_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
195 | 195 | ||
196 | td = kmalloc(sizeof(struct quanta_data), GFP_KERNEL); | 196 | td = kmalloc(sizeof(struct quanta_data), GFP_KERNEL); |
197 | if (!td) { | 197 | if (!td) { |
198 | dev_err(&hdev->dev, "cannot allocate Quanta Touch data\n"); | 198 | hid_err(hdev, "cannot allocate Quanta Touch data\n"); |
199 | return -ENOMEM; | 199 | return -ENOMEM; |
200 | } | 200 | } |
201 | td->valid = false; | 201 | td->valid = false; |
diff --git a/drivers/hid/hid-roccat-kone.c b/drivers/hid/hid-roccat-kone.c index f77695762cb5..cbd8cc42e75a 100644 --- a/drivers/hid/hid-roccat-kone.c +++ b/drivers/hid/hid-roccat-kone.c | |||
@@ -35,6 +35,11 @@ | |||
35 | #include "hid-roccat.h" | 35 | #include "hid-roccat.h" |
36 | #include "hid-roccat-kone.h" | 36 | #include "hid-roccat-kone.h" |
37 | 37 | ||
38 | static uint profile_numbers[5] = {0, 1, 2, 3, 4}; | ||
39 | |||
40 | /* kone_class is used for creating sysfs attributes via roccat char device */ | ||
41 | static struct class *kone_class; | ||
42 | |||
38 | static void kone_set_settings_checksum(struct kone_settings *settings) | 43 | static void kone_set_settings_checksum(struct kone_settings *settings) |
39 | { | 44 | { |
40 | uint16_t checksum = 0; | 45 | uint16_t checksum = 0; |
@@ -90,8 +95,7 @@ static int kone_check_write(struct usb_device *usb_dev) | |||
90 | kfree(data); | 95 | kfree(data); |
91 | return 0; | 96 | return 0; |
92 | } else { /* unknown answer */ | 97 | } else { /* unknown answer */ |
93 | dev_err(&usb_dev->dev, "got retval %d when checking write\n", | 98 | hid_err(usb_dev, "got retval %d when checking write\n", *data); |
94 | *data); | ||
95 | kfree(data); | 99 | kfree(data); |
96 | return -EIO; | 100 | return -EIO; |
97 | } | 101 | } |
@@ -262,7 +266,8 @@ static int kone_get_firmware_version(struct usb_device *usb_dev, int *result) | |||
262 | static ssize_t kone_sysfs_read_settings(struct file *fp, struct kobject *kobj, | 266 | static ssize_t kone_sysfs_read_settings(struct file *fp, struct kobject *kobj, |
263 | struct bin_attribute *attr, char *buf, | 267 | struct bin_attribute *attr, char *buf, |
264 | loff_t off, size_t count) { | 268 | loff_t off, size_t count) { |
265 | struct device *dev = container_of(kobj, struct device, kobj); | 269 | struct device *dev = |
270 | container_of(kobj, struct device, kobj)->parent->parent; | ||
266 | struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev)); | 271 | struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev)); |
267 | 272 | ||
268 | if (off >= sizeof(struct kone_settings)) | 273 | if (off >= sizeof(struct kone_settings)) |
@@ -286,7 +291,8 @@ static ssize_t kone_sysfs_read_settings(struct file *fp, struct kobject *kobj, | |||
286 | static ssize_t kone_sysfs_write_settings(struct file *fp, struct kobject *kobj, | 291 | static ssize_t kone_sysfs_write_settings(struct file *fp, struct kobject *kobj, |
287 | struct bin_attribute *attr, char *buf, | 292 | struct bin_attribute *attr, char *buf, |
288 | loff_t off, size_t count) { | 293 | loff_t off, size_t count) { |
289 | struct device *dev = container_of(kobj, struct device, kobj); | 294 | struct device *dev = |
295 | container_of(kobj, struct device, kobj)->parent->parent; | ||
290 | struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev)); | 296 | struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev)); |
291 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 297 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
292 | int retval = 0, difference; | 298 | int retval = 0, difference; |
@@ -319,10 +325,11 @@ static ssize_t kone_sysfs_write_settings(struct file *fp, struct kobject *kobj, | |||
319 | return sizeof(struct kone_settings); | 325 | return sizeof(struct kone_settings); |
320 | } | 326 | } |
321 | 327 | ||
322 | static ssize_t kone_sysfs_read_profilex(struct kobject *kobj, | 328 | static ssize_t kone_sysfs_read_profilex(struct file *fp, |
323 | struct bin_attribute *attr, char *buf, | 329 | struct kobject *kobj, struct bin_attribute *attr, |
324 | loff_t off, size_t count, int number) { | 330 | char *buf, loff_t off, size_t count) { |
325 | struct device *dev = container_of(kobj, struct device, kobj); | 331 | struct device *dev = |
332 | container_of(kobj, struct device, kobj)->parent->parent; | ||
326 | struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev)); | 333 | struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev)); |
327 | 334 | ||
328 | if (off >= sizeof(struct kone_profile)) | 335 | if (off >= sizeof(struct kone_profile)) |
@@ -332,47 +339,18 @@ static ssize_t kone_sysfs_read_profilex(struct kobject *kobj, | |||
332 | count = sizeof(struct kone_profile) - off; | 339 | count = sizeof(struct kone_profile) - off; |
333 | 340 | ||
334 | mutex_lock(&kone->kone_lock); | 341 | mutex_lock(&kone->kone_lock); |
335 | memcpy(buf, ((char const *)&kone->profiles[number - 1]) + off, count); | 342 | memcpy(buf, ((char const *)&kone->profiles[*(uint *)(attr->private)]) + off, count); |
336 | mutex_unlock(&kone->kone_lock); | 343 | mutex_unlock(&kone->kone_lock); |
337 | 344 | ||
338 | return count; | 345 | return count; |
339 | } | 346 | } |
340 | 347 | ||
341 | static ssize_t kone_sysfs_read_profile1(struct file *fp, struct kobject *kobj, | ||
342 | struct bin_attribute *attr, char *buf, | ||
343 | loff_t off, size_t count) { | ||
344 | return kone_sysfs_read_profilex(kobj, attr, buf, off, count, 1); | ||
345 | } | ||
346 | |||
347 | static ssize_t kone_sysfs_read_profile2(struct file *fp, struct kobject *kobj, | ||
348 | struct bin_attribute *attr, char *buf, | ||
349 | loff_t off, size_t count) { | ||
350 | return kone_sysfs_read_profilex(kobj, attr, buf, off, count, 2); | ||
351 | } | ||
352 | |||
353 | static ssize_t kone_sysfs_read_profile3(struct file *fp, struct kobject *kobj, | ||
354 | struct bin_attribute *attr, char *buf, | ||
355 | loff_t off, size_t count) { | ||
356 | return kone_sysfs_read_profilex(kobj, attr, buf, off, count, 3); | ||
357 | } | ||
358 | |||
359 | static ssize_t kone_sysfs_read_profile4(struct file *fp, struct kobject *kobj, | ||
360 | struct bin_attribute *attr, char *buf, | ||
361 | loff_t off, size_t count) { | ||
362 | return kone_sysfs_read_profilex(kobj, attr, buf, off, count, 4); | ||
363 | } | ||
364 | |||
365 | static ssize_t kone_sysfs_read_profile5(struct file *fp, struct kobject *kobj, | ||
366 | struct bin_attribute *attr, char *buf, | ||
367 | loff_t off, size_t count) { | ||
368 | return kone_sysfs_read_profilex(kobj, attr, buf, off, count, 5); | ||
369 | } | ||
370 | |||
371 | /* Writes data only if different to stored data */ | 348 | /* Writes data only if different to stored data */ |
372 | static ssize_t kone_sysfs_write_profilex(struct kobject *kobj, | 349 | static ssize_t kone_sysfs_write_profilex(struct file *fp, |
373 | struct bin_attribute *attr, char *buf, | 350 | struct kobject *kobj, struct bin_attribute *attr, |
374 | loff_t off, size_t count, int number) { | 351 | char *buf, loff_t off, size_t count) { |
375 | struct device *dev = container_of(kobj, struct device, kobj); | 352 | struct device *dev = |
353 | container_of(kobj, struct device, kobj)->parent->parent; | ||
376 | struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev)); | 354 | struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev)); |
377 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 355 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
378 | struct kone_profile *profile; | 356 | struct kone_profile *profile; |
@@ -382,13 +360,14 @@ static ssize_t kone_sysfs_write_profilex(struct kobject *kobj, | |||
382 | if (off != 0 || count != sizeof(struct kone_profile)) | 360 | if (off != 0 || count != sizeof(struct kone_profile)) |
383 | return -EINVAL; | 361 | return -EINVAL; |
384 | 362 | ||
385 | profile = &kone->profiles[number - 1]; | 363 | profile = &kone->profiles[*(uint *)(attr->private)]; |
386 | 364 | ||
387 | mutex_lock(&kone->kone_lock); | 365 | mutex_lock(&kone->kone_lock); |
388 | difference = memcmp(buf, profile, sizeof(struct kone_profile)); | 366 | difference = memcmp(buf, profile, sizeof(struct kone_profile)); |
389 | if (difference) { | 367 | if (difference) { |
390 | retval = kone_set_profile(usb_dev, | 368 | retval = kone_set_profile(usb_dev, |
391 | (struct kone_profile const *)buf, number); | 369 | (struct kone_profile const *)buf, |
370 | *(uint *)(attr->private) + 1); | ||
392 | if (!retval) | 371 | if (!retval) |
393 | memcpy(profile, buf, sizeof(struct kone_profile)); | 372 | memcpy(profile, buf, sizeof(struct kone_profile)); |
394 | } | 373 | } |
@@ -400,47 +379,19 @@ static ssize_t kone_sysfs_write_profilex(struct kobject *kobj, | |||
400 | return sizeof(struct kone_profile); | 379 | return sizeof(struct kone_profile); |
401 | } | 380 | } |
402 | 381 | ||
403 | static ssize_t kone_sysfs_write_profile1(struct file *fp, struct kobject *kobj, | ||
404 | struct bin_attribute *attr, char *buf, | ||
405 | loff_t off, size_t count) { | ||
406 | return kone_sysfs_write_profilex(kobj, attr, buf, off, count, 1); | ||
407 | } | ||
408 | |||
409 | static ssize_t kone_sysfs_write_profile2(struct file *fp, struct kobject *kobj, | ||
410 | struct bin_attribute *attr, char *buf, | ||
411 | loff_t off, size_t count) { | ||
412 | return kone_sysfs_write_profilex(kobj, attr, buf, off, count, 2); | ||
413 | } | ||
414 | |||
415 | static ssize_t kone_sysfs_write_profile3(struct file *fp, struct kobject *kobj, | ||
416 | struct bin_attribute *attr, char *buf, | ||
417 | loff_t off, size_t count) { | ||
418 | return kone_sysfs_write_profilex(kobj, attr, buf, off, count, 3); | ||
419 | } | ||
420 | |||
421 | static ssize_t kone_sysfs_write_profile4(struct file *fp, struct kobject *kobj, | ||
422 | struct bin_attribute *attr, char *buf, | ||
423 | loff_t off, size_t count) { | ||
424 | return kone_sysfs_write_profilex(kobj, attr, buf, off, count, 4); | ||
425 | } | ||
426 | |||
427 | static ssize_t kone_sysfs_write_profile5(struct file *fp, struct kobject *kobj, | ||
428 | struct bin_attribute *attr, char *buf, | ||
429 | loff_t off, size_t count) { | ||
430 | return kone_sysfs_write_profilex(kobj, attr, buf, off, count, 5); | ||
431 | } | ||
432 | |||
433 | static ssize_t kone_sysfs_show_actual_profile(struct device *dev, | 382 | static ssize_t kone_sysfs_show_actual_profile(struct device *dev, |
434 | struct device_attribute *attr, char *buf) | 383 | struct device_attribute *attr, char *buf) |
435 | { | 384 | { |
436 | struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev)); | 385 | struct kone_device *kone = |
386 | hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); | ||
437 | return snprintf(buf, PAGE_SIZE, "%d\n", kone->actual_profile); | 387 | return snprintf(buf, PAGE_SIZE, "%d\n", kone->actual_profile); |
438 | } | 388 | } |
439 | 389 | ||
440 | static ssize_t kone_sysfs_show_actual_dpi(struct device *dev, | 390 | static ssize_t kone_sysfs_show_actual_dpi(struct device *dev, |
441 | struct device_attribute *attr, char *buf) | 391 | struct device_attribute *attr, char *buf) |
442 | { | 392 | { |
443 | struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev)); | 393 | struct kone_device *kone = |
394 | hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); | ||
444 | return snprintf(buf, PAGE_SIZE, "%d\n", kone->actual_dpi); | 395 | return snprintf(buf, PAGE_SIZE, "%d\n", kone->actual_dpi); |
445 | } | 396 | } |
446 | 397 | ||
@@ -448,11 +399,15 @@ static ssize_t kone_sysfs_show_actual_dpi(struct device *dev, | |||
448 | static ssize_t kone_sysfs_show_weight(struct device *dev, | 399 | static ssize_t kone_sysfs_show_weight(struct device *dev, |
449 | struct device_attribute *attr, char *buf) | 400 | struct device_attribute *attr, char *buf) |
450 | { | 401 | { |
451 | struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev)); | 402 | struct kone_device *kone; |
452 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 403 | struct usb_device *usb_dev; |
453 | int weight = 0; | 404 | int weight = 0; |
454 | int retval; | 405 | int retval; |
455 | 406 | ||
407 | dev = dev->parent->parent; | ||
408 | kone = hid_get_drvdata(dev_get_drvdata(dev)); | ||
409 | usb_dev = interface_to_usbdev(to_usb_interface(dev)); | ||
410 | |||
456 | mutex_lock(&kone->kone_lock); | 411 | mutex_lock(&kone->kone_lock); |
457 | retval = kone_get_weight(usb_dev, &weight); | 412 | retval = kone_get_weight(usb_dev, &weight); |
458 | mutex_unlock(&kone->kone_lock); | 413 | mutex_unlock(&kone->kone_lock); |
@@ -465,14 +420,16 @@ static ssize_t kone_sysfs_show_weight(struct device *dev, | |||
465 | static ssize_t kone_sysfs_show_firmware_version(struct device *dev, | 420 | static ssize_t kone_sysfs_show_firmware_version(struct device *dev, |
466 | struct device_attribute *attr, char *buf) | 421 | struct device_attribute *attr, char *buf) |
467 | { | 422 | { |
468 | struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev)); | 423 | struct kone_device *kone = |
424 | hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); | ||
469 | return snprintf(buf, PAGE_SIZE, "%d\n", kone->firmware_version); | 425 | return snprintf(buf, PAGE_SIZE, "%d\n", kone->firmware_version); |
470 | } | 426 | } |
471 | 427 | ||
472 | static ssize_t kone_sysfs_show_tcu(struct device *dev, | 428 | static ssize_t kone_sysfs_show_tcu(struct device *dev, |
473 | struct device_attribute *attr, char *buf) | 429 | struct device_attribute *attr, char *buf) |
474 | { | 430 | { |
475 | struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev)); | 431 | struct kone_device *kone = |
432 | hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); | ||
476 | return snprintf(buf, PAGE_SIZE, "%d\n", kone->settings.tcu); | 433 | return snprintf(buf, PAGE_SIZE, "%d\n", kone->settings.tcu); |
477 | } | 434 | } |
478 | 435 | ||
@@ -504,11 +461,15 @@ static int kone_tcu_command(struct usb_device *usb_dev, int number) | |||
504 | static ssize_t kone_sysfs_set_tcu(struct device *dev, | 461 | static ssize_t kone_sysfs_set_tcu(struct device *dev, |
505 | struct device_attribute *attr, char const *buf, size_t size) | 462 | struct device_attribute *attr, char const *buf, size_t size) |
506 | { | 463 | { |
507 | struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev)); | 464 | struct kone_device *kone; |
508 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 465 | struct usb_device *usb_dev; |
509 | int retval; | 466 | int retval; |
510 | unsigned long state; | 467 | unsigned long state; |
511 | 468 | ||
469 | dev = dev->parent->parent; | ||
470 | kone = hid_get_drvdata(dev_get_drvdata(dev)); | ||
471 | usb_dev = interface_to_usbdev(to_usb_interface(dev)); | ||
472 | |||
512 | retval = strict_strtoul(buf, 10, &state); | 473 | retval = strict_strtoul(buf, 10, &state); |
513 | if (retval) | 474 | if (retval) |
514 | return retval; | 475 | return retval; |
@@ -556,7 +517,7 @@ static ssize_t kone_sysfs_set_tcu(struct device *dev, | |||
556 | 517 | ||
557 | retval = kone_set_settings(usb_dev, &kone->settings); | 518 | retval = kone_set_settings(usb_dev, &kone->settings); |
558 | if (retval) { | 519 | if (retval) { |
559 | dev_err(&usb_dev->dev, "couldn't set tcu state\n"); | 520 | hid_err(usb_dev, "couldn't set tcu state\n"); |
560 | /* | 521 | /* |
561 | * try to reread valid settings into buffer overwriting | 522 | * try to reread valid settings into buffer overwriting |
562 | * first error code | 523 | * first error code |
@@ -570,7 +531,7 @@ static ssize_t kone_sysfs_set_tcu(struct device *dev, | |||
570 | 531 | ||
571 | retval = size; | 532 | retval = size; |
572 | exit_no_settings: | 533 | exit_no_settings: |
573 | dev_err(&usb_dev->dev, "couldn't read settings\n"); | 534 | hid_err(usb_dev, "couldn't read settings\n"); |
574 | exit_unlock: | 535 | exit_unlock: |
575 | mutex_unlock(&kone->kone_lock); | 536 | mutex_unlock(&kone->kone_lock); |
576 | return retval; | 537 | return retval; |
@@ -579,18 +540,23 @@ exit_unlock: | |||
579 | static ssize_t kone_sysfs_show_startup_profile(struct device *dev, | 540 | static ssize_t kone_sysfs_show_startup_profile(struct device *dev, |
580 | struct device_attribute *attr, char *buf) | 541 | struct device_attribute *attr, char *buf) |
581 | { | 542 | { |
582 | struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev)); | 543 | struct kone_device *kone = |
544 | hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); | ||
583 | return snprintf(buf, PAGE_SIZE, "%d\n", kone->settings.startup_profile); | 545 | return snprintf(buf, PAGE_SIZE, "%d\n", kone->settings.startup_profile); |
584 | } | 546 | } |
585 | 547 | ||
586 | static ssize_t kone_sysfs_set_startup_profile(struct device *dev, | 548 | static ssize_t kone_sysfs_set_startup_profile(struct device *dev, |
587 | struct device_attribute *attr, char const *buf, size_t size) | 549 | struct device_attribute *attr, char const *buf, size_t size) |
588 | { | 550 | { |
589 | struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev)); | 551 | struct kone_device *kone; |
590 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 552 | struct usb_device *usb_dev; |
591 | int retval; | 553 | int retval; |
592 | unsigned long new_startup_profile; | 554 | unsigned long new_startup_profile; |
593 | 555 | ||
556 | dev = dev->parent->parent; | ||
557 | kone = hid_get_drvdata(dev_get_drvdata(dev)); | ||
558 | usb_dev = interface_to_usbdev(to_usb_interface(dev)); | ||
559 | |||
594 | retval = strict_strtoul(buf, 10, &new_startup_profile); | 560 | retval = strict_strtoul(buf, 10, &new_startup_profile); |
595 | if (retval) | 561 | if (retval) |
596 | return retval; | 562 | return retval; |
@@ -617,160 +583,92 @@ static ssize_t kone_sysfs_set_startup_profile(struct device *dev, | |||
617 | return size; | 583 | return size; |
618 | } | 584 | } |
619 | 585 | ||
620 | /* | 586 | static struct device_attribute kone_attributes[] = { |
621 | * Read actual dpi settings. | 587 | /* |
622 | * Returns raw value for further processing. Refer to enum kone_polling_rates to | 588 | * Read actual dpi settings. |
623 | * get real value. | 589 | * Returns raw value for further processing. Refer to enum |
624 | */ | 590 | * kone_polling_rates to get real value. |
625 | static DEVICE_ATTR(actual_dpi, 0440, kone_sysfs_show_actual_dpi, NULL); | 591 | */ |
626 | 592 | __ATTR(actual_dpi, 0440, kone_sysfs_show_actual_dpi, NULL), | |
627 | static DEVICE_ATTR(actual_profile, 0440, kone_sysfs_show_actual_profile, NULL); | 593 | __ATTR(actual_profile, 0440, kone_sysfs_show_actual_profile, NULL), |
628 | |||
629 | /* | ||
630 | * The mouse can be equipped with one of four supplied weights from 5 to 20 | ||
631 | * grams which are recognized and its value can be read out. | ||
632 | * This returns the raw value reported by the mouse for easy evaluation by | ||
633 | * software. Refer to enum kone_weights to get corresponding real weight. | ||
634 | */ | ||
635 | static DEVICE_ATTR(weight, 0440, kone_sysfs_show_weight, NULL); | ||
636 | |||
637 | /* | ||
638 | * Prints firmware version stored in mouse as integer. | ||
639 | * The raw value reported by the mouse is returned for easy evaluation, to get | ||
640 | * the real version number the decimal point has to be shifted 2 positions to | ||
641 | * the left. E.g. a value of 138 means 1.38. | ||
642 | */ | ||
643 | static DEVICE_ATTR(firmware_version, 0440, | ||
644 | kone_sysfs_show_firmware_version, NULL); | ||
645 | |||
646 | /* | ||
647 | * Prints state of Tracking Control Unit as number where 0 = off and 1 = on | ||
648 | * Writing 0 deactivates tcu and writing 1 calibrates and activates the tcu | ||
649 | */ | ||
650 | static DEVICE_ATTR(tcu, 0660, kone_sysfs_show_tcu, kone_sysfs_set_tcu); | ||
651 | |||
652 | /* Prints and takes the number of the profile the mouse starts with */ | ||
653 | static DEVICE_ATTR(startup_profile, 0660, | ||
654 | kone_sysfs_show_startup_profile, | ||
655 | kone_sysfs_set_startup_profile); | ||
656 | |||
657 | static struct attribute *kone_attributes[] = { | ||
658 | &dev_attr_actual_dpi.attr, | ||
659 | &dev_attr_actual_profile.attr, | ||
660 | &dev_attr_weight.attr, | ||
661 | &dev_attr_firmware_version.attr, | ||
662 | &dev_attr_tcu.attr, | ||
663 | &dev_attr_startup_profile.attr, | ||
664 | NULL | ||
665 | }; | ||
666 | |||
667 | static struct attribute_group kone_attribute_group = { | ||
668 | .attrs = kone_attributes | ||
669 | }; | ||
670 | |||
671 | static struct bin_attribute kone_settings_attr = { | ||
672 | .attr = { .name = "settings", .mode = 0660 }, | ||
673 | .size = sizeof(struct kone_settings), | ||
674 | .read = kone_sysfs_read_settings, | ||
675 | .write = kone_sysfs_write_settings | ||
676 | }; | ||
677 | 594 | ||
678 | static struct bin_attribute kone_profile1_attr = { | 595 | /* |
679 | .attr = { .name = "profile1", .mode = 0660 }, | 596 | * The mouse can be equipped with one of four supplied weights from 5 |
680 | .size = sizeof(struct kone_profile), | 597 | * to 20 grams which are recognized and its value can be read out. |
681 | .read = kone_sysfs_read_profile1, | 598 | * This returns the raw value reported by the mouse for easy evaluation |
682 | .write = kone_sysfs_write_profile1 | 599 | * by software. Refer to enum kone_weights to get corresponding real |
683 | }; | 600 | * weight. |
601 | */ | ||
602 | __ATTR(weight, 0440, kone_sysfs_show_weight, NULL), | ||
684 | 603 | ||
685 | static struct bin_attribute kone_profile2_attr = { | 604 | /* |
686 | .attr = { .name = "profile2", .mode = 0660 }, | 605 | * Prints firmware version stored in mouse as integer. |
687 | .size = sizeof(struct kone_profile), | 606 | * The raw value reported by the mouse is returned for easy evaluation, |
688 | .read = kone_sysfs_read_profile2, | 607 | * to get the real version number the decimal point has to be shifted 2 |
689 | .write = kone_sysfs_write_profile2 | 608 | * positions to the left. E.g. a value of 138 means 1.38. |
690 | }; | 609 | */ |
610 | __ATTR(firmware_version, 0440, | ||
611 | kone_sysfs_show_firmware_version, NULL), | ||
691 | 612 | ||
692 | static struct bin_attribute kone_profile3_attr = { | 613 | /* |
693 | .attr = { .name = "profile3", .mode = 0660 }, | 614 | * Prints state of Tracking Control Unit as number where 0 = off and |
694 | .size = sizeof(struct kone_profile), | 615 | * 1 = on. Writing 0 deactivates tcu and writing 1 calibrates and |
695 | .read = kone_sysfs_read_profile3, | 616 | * activates the tcu |
696 | .write = kone_sysfs_write_profile3 | 617 | */ |
697 | }; | 618 | __ATTR(tcu, 0660, kone_sysfs_show_tcu, kone_sysfs_set_tcu), |
698 | 619 | ||
699 | static struct bin_attribute kone_profile4_attr = { | 620 | /* Prints and takes the number of the profile the mouse starts with */ |
700 | .attr = { .name = "profile4", .mode = 0660 }, | 621 | __ATTR(startup_profile, 0660, |
701 | .size = sizeof(struct kone_profile), | 622 | kone_sysfs_show_startup_profile, |
702 | .read = kone_sysfs_read_profile4, | 623 | kone_sysfs_set_startup_profile), |
703 | .write = kone_sysfs_write_profile4 | 624 | __ATTR_NULL |
704 | }; | 625 | }; |
705 | 626 | ||
706 | static struct bin_attribute kone_profile5_attr = { | 627 | static struct bin_attribute kone_bin_attributes[] = { |
707 | .attr = { .name = "profile5", .mode = 0660 }, | 628 | { |
708 | .size = sizeof(struct kone_profile), | 629 | .attr = { .name = "settings", .mode = 0660 }, |
709 | .read = kone_sysfs_read_profile5, | 630 | .size = sizeof(struct kone_settings), |
710 | .write = kone_sysfs_write_profile5 | 631 | .read = kone_sysfs_read_settings, |
632 | .write = kone_sysfs_write_settings | ||
633 | }, | ||
634 | { | ||
635 | .attr = { .name = "profile1", .mode = 0660 }, | ||
636 | .size = sizeof(struct kone_profile), | ||
637 | .read = kone_sysfs_read_profilex, | ||
638 | .write = kone_sysfs_write_profilex, | ||
639 | .private = &profile_numbers[0] | ||
640 | }, | ||
641 | { | ||
642 | .attr = { .name = "profile2", .mode = 0660 }, | ||
643 | .size = sizeof(struct kone_profile), | ||
644 | .read = kone_sysfs_read_profilex, | ||
645 | .write = kone_sysfs_write_profilex, | ||
646 | .private = &profile_numbers[1] | ||
647 | }, | ||
648 | { | ||
649 | .attr = { .name = "profile3", .mode = 0660 }, | ||
650 | .size = sizeof(struct kone_profile), | ||
651 | .read = kone_sysfs_read_profilex, | ||
652 | .write = kone_sysfs_write_profilex, | ||
653 | .private = &profile_numbers[2] | ||
654 | }, | ||
655 | { | ||
656 | .attr = { .name = "profile4", .mode = 0660 }, | ||
657 | .size = sizeof(struct kone_profile), | ||
658 | .read = kone_sysfs_read_profilex, | ||
659 | .write = kone_sysfs_write_profilex, | ||
660 | .private = &profile_numbers[3] | ||
661 | }, | ||
662 | { | ||
663 | .attr = { .name = "profile5", .mode = 0660 }, | ||
664 | .size = sizeof(struct kone_profile), | ||
665 | .read = kone_sysfs_read_profilex, | ||
666 | .write = kone_sysfs_write_profilex, | ||
667 | .private = &profile_numbers[4] | ||
668 | }, | ||
669 | __ATTR_NULL | ||
711 | }; | 670 | }; |
712 | 671 | ||
713 | static int kone_create_sysfs_attributes(struct usb_interface *intf) | ||
714 | { | ||
715 | int retval; | ||
716 | |||
717 | retval = sysfs_create_group(&intf->dev.kobj, &kone_attribute_group); | ||
718 | if (retval) | ||
719 | goto exit_1; | ||
720 | |||
721 | retval = sysfs_create_bin_file(&intf->dev.kobj, &kone_settings_attr); | ||
722 | if (retval) | ||
723 | goto exit_2; | ||
724 | |||
725 | retval = sysfs_create_bin_file(&intf->dev.kobj, &kone_profile1_attr); | ||
726 | if (retval) | ||
727 | goto exit_3; | ||
728 | |||
729 | retval = sysfs_create_bin_file(&intf->dev.kobj, &kone_profile2_attr); | ||
730 | if (retval) | ||
731 | goto exit_4; | ||
732 | |||
733 | retval = sysfs_create_bin_file(&intf->dev.kobj, &kone_profile3_attr); | ||
734 | if (retval) | ||
735 | goto exit_5; | ||
736 | |||
737 | retval = sysfs_create_bin_file(&intf->dev.kobj, &kone_profile4_attr); | ||
738 | if (retval) | ||
739 | goto exit_6; | ||
740 | |||
741 | retval = sysfs_create_bin_file(&intf->dev.kobj, &kone_profile5_attr); | ||
742 | if (retval) | ||
743 | goto exit_7; | ||
744 | |||
745 | return 0; | ||
746 | |||
747 | exit_7: | ||
748 | sysfs_remove_bin_file(&intf->dev.kobj, &kone_profile4_attr); | ||
749 | exit_6: | ||
750 | sysfs_remove_bin_file(&intf->dev.kobj, &kone_profile3_attr); | ||
751 | exit_5: | ||
752 | sysfs_remove_bin_file(&intf->dev.kobj, &kone_profile2_attr); | ||
753 | exit_4: | ||
754 | sysfs_remove_bin_file(&intf->dev.kobj, &kone_profile1_attr); | ||
755 | exit_3: | ||
756 | sysfs_remove_bin_file(&intf->dev.kobj, &kone_settings_attr); | ||
757 | exit_2: | ||
758 | sysfs_remove_group(&intf->dev.kobj, &kone_attribute_group); | ||
759 | exit_1: | ||
760 | return retval; | ||
761 | } | ||
762 | |||
763 | static void kone_remove_sysfs_attributes(struct usb_interface *intf) | ||
764 | { | ||
765 | sysfs_remove_bin_file(&intf->dev.kobj, &kone_profile5_attr); | ||
766 | sysfs_remove_bin_file(&intf->dev.kobj, &kone_profile4_attr); | ||
767 | sysfs_remove_bin_file(&intf->dev.kobj, &kone_profile3_attr); | ||
768 | sysfs_remove_bin_file(&intf->dev.kobj, &kone_profile2_attr); | ||
769 | sysfs_remove_bin_file(&intf->dev.kobj, &kone_profile1_attr); | ||
770 | sysfs_remove_bin_file(&intf->dev.kobj, &kone_settings_attr); | ||
771 | sysfs_remove_group(&intf->dev.kobj, &kone_attribute_group); | ||
772 | } | ||
773 | |||
774 | static int kone_init_kone_device_struct(struct usb_device *usb_dev, | 672 | static int kone_init_kone_device_struct(struct usb_device *usb_dev, |
775 | struct kone_device *kone) | 673 | struct kone_device *kone) |
776 | { | 674 | { |
@@ -818,32 +716,25 @@ static int kone_init_specials(struct hid_device *hdev) | |||
818 | 716 | ||
819 | kone = kzalloc(sizeof(*kone), GFP_KERNEL); | 717 | kone = kzalloc(sizeof(*kone), GFP_KERNEL); |
820 | if (!kone) { | 718 | if (!kone) { |
821 | dev_err(&hdev->dev, "can't alloc device descriptor\n"); | 719 | hid_err(hdev, "can't alloc device descriptor\n"); |
822 | return -ENOMEM; | 720 | return -ENOMEM; |
823 | } | 721 | } |
824 | hid_set_drvdata(hdev, kone); | 722 | hid_set_drvdata(hdev, kone); |
825 | 723 | ||
826 | retval = kone_init_kone_device_struct(usb_dev, kone); | 724 | retval = kone_init_kone_device_struct(usb_dev, kone); |
827 | if (retval) { | 725 | if (retval) { |
828 | dev_err(&hdev->dev, | 726 | hid_err(hdev, "couldn't init struct kone_device\n"); |
829 | "couldn't init struct kone_device\n"); | ||
830 | goto exit_free; | 727 | goto exit_free; |
831 | } | 728 | } |
832 | 729 | ||
833 | retval = roccat_connect(hdev); | 730 | retval = roccat_connect(kone_class, hdev); |
834 | if (retval < 0) { | 731 | if (retval < 0) { |
835 | dev_err(&hdev->dev, "couldn't init char dev\n"); | 732 | hid_err(hdev, "couldn't init char dev\n"); |
836 | /* be tolerant about not getting chrdev */ | 733 | /* be tolerant about not getting chrdev */ |
837 | } else { | 734 | } else { |
838 | kone->roccat_claimed = 1; | 735 | kone->roccat_claimed = 1; |
839 | kone->chrdev_minor = retval; | 736 | kone->chrdev_minor = retval; |
840 | } | 737 | } |
841 | |||
842 | retval = kone_create_sysfs_attributes(intf); | ||
843 | if (retval) { | ||
844 | dev_err(&hdev->dev, "cannot create sysfs files\n"); | ||
845 | goto exit_free; | ||
846 | } | ||
847 | } else { | 738 | } else { |
848 | hid_set_drvdata(hdev, NULL); | 739 | hid_set_drvdata(hdev, NULL); |
849 | } | 740 | } |
@@ -854,7 +745,6 @@ exit_free: | |||
854 | return retval; | 745 | return retval; |
855 | } | 746 | } |
856 | 747 | ||
857 | |||
858 | static void kone_remove_specials(struct hid_device *hdev) | 748 | static void kone_remove_specials(struct hid_device *hdev) |
859 | { | 749 | { |
860 | struct usb_interface *intf = to_usb_interface(hdev->dev.parent); | 750 | struct usb_interface *intf = to_usb_interface(hdev->dev.parent); |
@@ -862,7 +752,6 @@ static void kone_remove_specials(struct hid_device *hdev) | |||
862 | 752 | ||
863 | if (intf->cur_altsetting->desc.bInterfaceProtocol | 753 | if (intf->cur_altsetting->desc.bInterfaceProtocol |
864 | == USB_INTERFACE_PROTOCOL_MOUSE) { | 754 | == USB_INTERFACE_PROTOCOL_MOUSE) { |
865 | kone_remove_sysfs_attributes(intf); | ||
866 | kone = hid_get_drvdata(hdev); | 755 | kone = hid_get_drvdata(hdev); |
867 | if (kone->roccat_claimed) | 756 | if (kone->roccat_claimed) |
868 | roccat_disconnect(kone->chrdev_minor); | 757 | roccat_disconnect(kone->chrdev_minor); |
@@ -876,19 +765,19 @@ static int kone_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
876 | 765 | ||
877 | retval = hid_parse(hdev); | 766 | retval = hid_parse(hdev); |
878 | if (retval) { | 767 | if (retval) { |
879 | dev_err(&hdev->dev, "parse failed\n"); | 768 | hid_err(hdev, "parse failed\n"); |
880 | goto exit; | 769 | goto exit; |
881 | } | 770 | } |
882 | 771 | ||
883 | retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT); | 772 | retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT); |
884 | if (retval) { | 773 | if (retval) { |
885 | dev_err(&hdev->dev, "hw start failed\n"); | 774 | hid_err(hdev, "hw start failed\n"); |
886 | goto exit; | 775 | goto exit; |
887 | } | 776 | } |
888 | 777 | ||
889 | retval = kone_init_specials(hdev); | 778 | retval = kone_init_specials(hdev); |
890 | if (retval) { | 779 | if (retval) { |
891 | dev_err(&hdev->dev, "couldn't install mouse\n"); | 780 | hid_err(hdev, "couldn't install mouse\n"); |
892 | goto exit_stop; | 781 | goto exit_stop; |
893 | } | 782 | } |
894 | 783 | ||
@@ -1006,11 +895,24 @@ static struct hid_driver kone_driver = { | |||
1006 | 895 | ||
1007 | static int __init kone_init(void) | 896 | static int __init kone_init(void) |
1008 | { | 897 | { |
1009 | return hid_register_driver(&kone_driver); | 898 | int retval; |
899 | |||
900 | /* class name has to be same as driver name */ | ||
901 | kone_class = class_create(THIS_MODULE, "kone"); | ||
902 | if (IS_ERR(kone_class)) | ||
903 | return PTR_ERR(kone_class); | ||
904 | kone_class->dev_attrs = kone_attributes; | ||
905 | kone_class->dev_bin_attrs = kone_bin_attributes; | ||
906 | |||
907 | retval = hid_register_driver(&kone_driver); | ||
908 | if (retval) | ||
909 | class_destroy(kone_class); | ||
910 | return retval; | ||
1010 | } | 911 | } |
1011 | 912 | ||
1012 | static void __exit kone_exit(void) | 913 | static void __exit kone_exit(void) |
1013 | { | 914 | { |
915 | class_destroy(kone_class); | ||
1014 | hid_unregister_driver(&kone_driver); | 916 | hid_unregister_driver(&kone_driver); |
1015 | } | 917 | } |
1016 | 918 | ||
diff --git a/drivers/hid/hid-roccat-kone.h b/drivers/hid/hid-roccat-kone.h index 130d6566ea82..64abb5b8a59a 100644 --- a/drivers/hid/hid-roccat-kone.h +++ b/drivers/hid/hid-roccat-kone.h | |||
@@ -14,14 +14,11 @@ | |||
14 | 14 | ||
15 | #include <linux/types.h> | 15 | #include <linux/types.h> |
16 | 16 | ||
17 | #pragma pack(push) | ||
18 | #pragma pack(1) | ||
19 | |||
20 | struct kone_keystroke { | 17 | struct kone_keystroke { |
21 | uint8_t key; | 18 | uint8_t key; |
22 | uint8_t action; | 19 | uint8_t action; |
23 | uint16_t period; /* in milliseconds */ | 20 | uint16_t period; /* in milliseconds */ |
24 | }; | 21 | } __attribute__ ((__packed__)); |
25 | 22 | ||
26 | enum kone_keystroke_buttons { | 23 | enum kone_keystroke_buttons { |
27 | kone_keystroke_button_1 = 0xf0, /* left mouse button */ | 24 | kone_keystroke_button_1 = 0xf0, /* left mouse button */ |
@@ -44,7 +41,7 @@ struct kone_button_info { | |||
44 | uint8_t macro_name[16]; /* can be max 15 chars long */ | 41 | uint8_t macro_name[16]; /* can be max 15 chars long */ |
45 | uint8_t count; | 42 | uint8_t count; |
46 | struct kone_keystroke keystrokes[20]; | 43 | struct kone_keystroke keystrokes[20]; |
47 | }; | 44 | } __attribute__ ((__packed__)); |
48 | 45 | ||
49 | enum kone_button_info_types { | 46 | enum kone_button_info_types { |
50 | /* valid button types until firmware 1.32 */ | 47 | /* valid button types until firmware 1.32 */ |
@@ -95,7 +92,7 @@ struct kone_light_info { | |||
95 | uint8_t red; /* range 0x00-0xff */ | 92 | uint8_t red; /* range 0x00-0xff */ |
96 | uint8_t green; /* range 0x00-0xff */ | 93 | uint8_t green; /* range 0x00-0xff */ |
97 | uint8_t blue; /* range 0x00-0xff */ | 94 | uint8_t blue; /* range 0x00-0xff */ |
98 | }; | 95 | } __attribute__ ((__packed__)); |
99 | 96 | ||
100 | struct kone_profile { | 97 | struct kone_profile { |
101 | uint16_t size; /* always 975 */ | 98 | uint16_t size; /* always 975 */ |
@@ -130,7 +127,7 @@ struct kone_profile { | |||
130 | struct kone_button_info button_infos[8]; | 127 | struct kone_button_info button_infos[8]; |
131 | 128 | ||
132 | uint16_t checksum; /* \brief holds checksum of struct */ | 129 | uint16_t checksum; /* \brief holds checksum of struct */ |
133 | }; | 130 | } __attribute__ ((__packed__)); |
134 | 131 | ||
135 | enum kone_polling_rates { | 132 | enum kone_polling_rates { |
136 | kone_polling_rate_125 = 1, | 133 | kone_polling_rate_125 = 1, |
@@ -147,7 +144,7 @@ struct kone_settings { | |||
147 | uint8_t calibration_data[4]; | 144 | uint8_t calibration_data[4]; |
148 | uint8_t unknown3[2]; | 145 | uint8_t unknown3[2]; |
149 | uint16_t checksum; | 146 | uint16_t checksum; |
150 | }; | 147 | } __attribute__ ((__packed__)); |
151 | 148 | ||
152 | /* | 149 | /* |
153 | * 12 byte mouse event read by interrupt_read | 150 | * 12 byte mouse event read by interrupt_read |
@@ -163,7 +160,7 @@ struct kone_mouse_event { | |||
163 | uint8_t event; | 160 | uint8_t event; |
164 | uint8_t value; /* press = 0, release = 1 */ | 161 | uint8_t value; /* press = 0, release = 1 */ |
165 | uint8_t macro_key; /* 0 to 8 */ | 162 | uint8_t macro_key; /* 0 to 8 */ |
166 | }; | 163 | } __attribute__ ((__packed__)); |
167 | 164 | ||
168 | enum kone_mouse_events { | 165 | enum kone_mouse_events { |
169 | /* osd events are thought to be display on screen */ | 166 | /* osd events are thought to be display on screen */ |
@@ -191,9 +188,7 @@ struct kone_roccat_report { | |||
191 | uint8_t event; | 188 | uint8_t event; |
192 | uint8_t value; /* holds dpi or profile value */ | 189 | uint8_t value; /* holds dpi or profile value */ |
193 | uint8_t key; /* macro key on overlong macro execution */ | 190 | uint8_t key; /* macro key on overlong macro execution */ |
194 | }; | 191 | } __attribute__ ((__packed__)); |
195 | |||
196 | #pragma pack(pop) | ||
197 | 192 | ||
198 | struct kone_device { | 193 | struct kone_device { |
199 | /* | 194 | /* |
diff --git a/drivers/hid/hid-roccat-koneplus.c b/drivers/hid/hid-roccat-koneplus.c new file mode 100644 index 000000000000..1608c8d1efd6 --- /dev/null +++ b/drivers/hid/hid-roccat-koneplus.c | |||
@@ -0,0 +1,837 @@ | |||
1 | /* | ||
2 | * Roccat Kone[+] driver for Linux | ||
3 | * | ||
4 | * Copyright (c) 2010 Stefan Achatz <erazor_de@users.sourceforge.net> | ||
5 | */ | ||
6 | |||
7 | /* | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the Free | ||
10 | * Software Foundation; either version 2 of the License, or (at your option) | ||
11 | * any later version. | ||
12 | */ | ||
13 | |||
14 | /* | ||
15 | * Roccat Kone[+] is an updated/improved version of the Kone with more memory | ||
16 | * and functionality and without the non-standard behaviours the Kone had. | ||
17 | */ | ||
18 | |||
19 | #include <linux/device.h> | ||
20 | #include <linux/input.h> | ||
21 | #include <linux/hid.h> | ||
22 | #include <linux/usb.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/slab.h> | ||
25 | #include "hid-ids.h" | ||
26 | #include "hid-roccat.h" | ||
27 | #include "hid-roccat-koneplus.h" | ||
28 | |||
29 | static uint profile_numbers[5] = {0, 1, 2, 3, 4}; | ||
30 | |||
31 | static struct class *koneplus_class; | ||
32 | |||
33 | static void koneplus_profile_activated(struct koneplus_device *koneplus, | ||
34 | uint new_profile) | ||
35 | { | ||
36 | koneplus->actual_profile = new_profile; | ||
37 | } | ||
38 | |||
39 | static int koneplus_send_control(struct usb_device *usb_dev, uint value, | ||
40 | enum koneplus_control_requests request) | ||
41 | { | ||
42 | int len; | ||
43 | struct koneplus_control *control; | ||
44 | |||
45 | if ((request == KONEPLUS_CONTROL_REQUEST_PROFILE_SETTINGS || | ||
46 | request == KONEPLUS_CONTROL_REQUEST_PROFILE_BUTTONS) && | ||
47 | value > 4) | ||
48 | return -EINVAL; | ||
49 | |||
50 | control = kmalloc(sizeof(struct koneplus_control), GFP_KERNEL); | ||
51 | if (!control) | ||
52 | return -ENOMEM; | ||
53 | |||
54 | control->command = KONEPLUS_COMMAND_CONTROL; | ||
55 | control->value = value; | ||
56 | control->request = request; | ||
57 | |||
58 | len = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0), | ||
59 | USB_REQ_SET_CONFIGURATION, | ||
60 | USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT, | ||
61 | KONEPLUS_USB_COMMAND_CONTROL, 0, control, | ||
62 | sizeof(struct koneplus_control), | ||
63 | USB_CTRL_SET_TIMEOUT); | ||
64 | |||
65 | kfree(control); | ||
66 | |||
67 | if (len != sizeof(struct koneplus_control)) | ||
68 | return len; | ||
69 | |||
70 | return 0; | ||
71 | } | ||
72 | |||
73 | static int koneplus_receive(struct usb_device *usb_dev, uint usb_command, | ||
74 | void *buf, uint size) { | ||
75 | int len; | ||
76 | |||
77 | len = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0), | ||
78 | USB_REQ_CLEAR_FEATURE, | ||
79 | USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_IN, | ||
80 | usb_command, 0, buf, size, USB_CTRL_SET_TIMEOUT); | ||
81 | |||
82 | return (len != size) ? -EIO : 0; | ||
83 | } | ||
84 | |||
85 | static int koneplus_receive_control_status(struct usb_device *usb_dev) | ||
86 | { | ||
87 | int retval; | ||
88 | struct koneplus_control *control; | ||
89 | |||
90 | control = kmalloc(sizeof(struct koneplus_control), GFP_KERNEL); | ||
91 | if (!control) | ||
92 | return -ENOMEM; | ||
93 | |||
94 | do { | ||
95 | retval = koneplus_receive(usb_dev, KONEPLUS_USB_COMMAND_CONTROL, | ||
96 | control, sizeof(struct koneplus_control)); | ||
97 | |||
98 | /* check if we get a completely wrong answer */ | ||
99 | if (retval) | ||
100 | goto out; | ||
101 | |||
102 | if (control->value == KONEPLUS_CONTROL_REQUEST_STATUS_OK) { | ||
103 | retval = 0; | ||
104 | goto out; | ||
105 | } | ||
106 | |||
107 | /* indicates that hardware needs some more time to complete action */ | ||
108 | if (control->value == KONEPLUS_CONTROL_REQUEST_STATUS_WAIT) { | ||
109 | msleep(500); /* windows driver uses 1000 */ | ||
110 | continue; | ||
111 | } | ||
112 | |||
113 | /* seems to be critical - replug necessary */ | ||
114 | if (control->value == KONEPLUS_CONTROL_REQUEST_STATUS_OVERLOAD) { | ||
115 | retval = -EINVAL; | ||
116 | goto out; | ||
117 | } | ||
118 | |||
119 | dev_err(&usb_dev->dev, "koneplus_receive_control_status: " | ||
120 | "unknown response value 0x%x\n", control->value); | ||
121 | retval = -EINVAL; | ||
122 | goto out; | ||
123 | |||
124 | } while (1); | ||
125 | out: | ||
126 | kfree(control); | ||
127 | return retval; | ||
128 | } | ||
129 | |||
130 | static int koneplus_send(struct usb_device *usb_dev, uint command, | ||
131 | void *buf, uint size) { | ||
132 | int len; | ||
133 | |||
134 | len = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0), | ||
135 | USB_REQ_SET_CONFIGURATION, | ||
136 | USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT, | ||
137 | command, 0, buf, size, USB_CTRL_SET_TIMEOUT); | ||
138 | |||
139 | if (len != size) | ||
140 | return -EIO; | ||
141 | |||
142 | if (koneplus_receive_control_status(usb_dev)) | ||
143 | return -EIO; | ||
144 | |||
145 | return 0; | ||
146 | } | ||
147 | |||
148 | static int koneplus_select_profile(struct usb_device *usb_dev, uint number, | ||
149 | enum koneplus_control_requests request) | ||
150 | { | ||
151 | int retval; | ||
152 | |||
153 | retval = koneplus_send_control(usb_dev, number, request); | ||
154 | if (retval) | ||
155 | return retval; | ||
156 | |||
157 | /* allow time to settle things - windows driver uses 500 */ | ||
158 | msleep(100); | ||
159 | |||
160 | retval = koneplus_receive_control_status(usb_dev); | ||
161 | if (retval) | ||
162 | return retval; | ||
163 | |||
164 | return 0; | ||
165 | } | ||
166 | |||
167 | static int koneplus_get_info(struct usb_device *usb_dev, | ||
168 | struct koneplus_info *buf) | ||
169 | { | ||
170 | return koneplus_receive(usb_dev, KONEPLUS_USB_COMMAND_INFO, | ||
171 | buf, sizeof(struct koneplus_info)); | ||
172 | } | ||
173 | |||
174 | static int koneplus_get_profile_settings(struct usb_device *usb_dev, | ||
175 | struct koneplus_profile_settings *buf, uint number) | ||
176 | { | ||
177 | int retval; | ||
178 | |||
179 | retval = koneplus_select_profile(usb_dev, number, | ||
180 | KONEPLUS_CONTROL_REQUEST_PROFILE_SETTINGS); | ||
181 | if (retval) | ||
182 | return retval; | ||
183 | |||
184 | return koneplus_receive(usb_dev, KONEPLUS_USB_COMMAND_PROFILE_SETTINGS, | ||
185 | buf, sizeof(struct koneplus_profile_settings)); | ||
186 | } | ||
187 | |||
188 | static int koneplus_set_profile_settings(struct usb_device *usb_dev, | ||
189 | struct koneplus_profile_settings const *settings) | ||
190 | { | ||
191 | return koneplus_send(usb_dev, KONEPLUS_USB_COMMAND_PROFILE_SETTINGS, | ||
192 | (void *)settings, sizeof(struct koneplus_profile_settings)); | ||
193 | } | ||
194 | |||
195 | static int koneplus_get_profile_buttons(struct usb_device *usb_dev, | ||
196 | struct koneplus_profile_buttons *buf, int number) | ||
197 | { | ||
198 | int retval; | ||
199 | |||
200 | retval = koneplus_select_profile(usb_dev, number, | ||
201 | KONEPLUS_CONTROL_REQUEST_PROFILE_BUTTONS); | ||
202 | if (retval) | ||
203 | return retval; | ||
204 | |||
205 | return koneplus_receive(usb_dev, KONEPLUS_USB_COMMAND_PROFILE_BUTTONS, | ||
206 | buf, sizeof(struct koneplus_profile_buttons)); | ||
207 | } | ||
208 | |||
209 | static int koneplus_set_profile_buttons(struct usb_device *usb_dev, | ||
210 | struct koneplus_profile_buttons const *buttons) | ||
211 | { | ||
212 | return koneplus_send(usb_dev, KONEPLUS_USB_COMMAND_PROFILE_BUTTONS, | ||
213 | (void *)buttons, sizeof(struct koneplus_profile_buttons)); | ||
214 | } | ||
215 | |||
216 | /* retval is 0-4 on success, < 0 on error */ | ||
217 | static int koneplus_get_startup_profile(struct usb_device *usb_dev) | ||
218 | { | ||
219 | struct koneplus_startup_profile *buf; | ||
220 | int retval; | ||
221 | |||
222 | buf = kmalloc(sizeof(struct koneplus_startup_profile), GFP_KERNEL); | ||
223 | |||
224 | retval = koneplus_receive(usb_dev, KONEPLUS_USB_COMMAND_STARTUP_PROFILE, | ||
225 | buf, sizeof(struct koneplus_startup_profile)); | ||
226 | |||
227 | if (retval) | ||
228 | goto out; | ||
229 | |||
230 | retval = buf->startup_profile; | ||
231 | out: | ||
232 | kfree(buf); | ||
233 | return retval; | ||
234 | } | ||
235 | |||
236 | static int koneplus_set_startup_profile(struct usb_device *usb_dev, | ||
237 | int startup_profile) | ||
238 | { | ||
239 | struct koneplus_startup_profile buf; | ||
240 | |||
241 | buf.command = KONEPLUS_COMMAND_STARTUP_PROFILE; | ||
242 | buf.size = sizeof(struct koneplus_startup_profile); | ||
243 | buf.startup_profile = startup_profile; | ||
244 | |||
245 | return koneplus_send(usb_dev, KONEPLUS_USB_COMMAND_STARTUP_PROFILE, | ||
246 | (char *)&buf, sizeof(struct koneplus_profile_buttons)); | ||
247 | } | ||
248 | |||
249 | static ssize_t koneplus_sysfs_read(struct file *fp, struct kobject *kobj, | ||
250 | char *buf, loff_t off, size_t count, | ||
251 | size_t real_size, uint command) | ||
252 | { | ||
253 | struct device *dev = | ||
254 | container_of(kobj, struct device, kobj)->parent->parent; | ||
255 | struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev)); | ||
256 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | ||
257 | int retval; | ||
258 | |||
259 | if (off != 0 || count != real_size) | ||
260 | return -EINVAL; | ||
261 | |||
262 | mutex_lock(&koneplus->koneplus_lock); | ||
263 | retval = koneplus_receive(usb_dev, command, buf, real_size); | ||
264 | mutex_unlock(&koneplus->koneplus_lock); | ||
265 | |||
266 | if (retval) | ||
267 | return retval; | ||
268 | |||
269 | return real_size; | ||
270 | } | ||
271 | |||
272 | static ssize_t koneplus_sysfs_write(struct file *fp, struct kobject *kobj, | ||
273 | void const *buf, loff_t off, size_t count, | ||
274 | size_t real_size, uint command) | ||
275 | { | ||
276 | struct device *dev = | ||
277 | container_of(kobj, struct device, kobj)->parent->parent; | ||
278 | struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev)); | ||
279 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | ||
280 | int retval; | ||
281 | |||
282 | if (off != 0 || count != real_size) | ||
283 | return -EINVAL; | ||
284 | |||
285 | mutex_lock(&koneplus->koneplus_lock); | ||
286 | retval = koneplus_send(usb_dev, command, (void *)buf, real_size); | ||
287 | mutex_unlock(&koneplus->koneplus_lock); | ||
288 | |||
289 | if (retval) | ||
290 | return retval; | ||
291 | |||
292 | return real_size; | ||
293 | } | ||
294 | |||
295 | static ssize_t koneplus_sysfs_write_macro(struct file *fp, | ||
296 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | ||
297 | loff_t off, size_t count) | ||
298 | { | ||
299 | return koneplus_sysfs_write(fp, kobj, buf, off, count, | ||
300 | sizeof(struct koneplus_macro), KONEPLUS_USB_COMMAND_MACRO); | ||
301 | } | ||
302 | |||
303 | static ssize_t koneplus_sysfs_read_sensor(struct file *fp, | ||
304 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | ||
305 | loff_t off, size_t count) | ||
306 | { | ||
307 | return koneplus_sysfs_read(fp, kobj, buf, off, count, | ||
308 | sizeof(struct koneplus_sensor), KONEPLUS_USB_COMMAND_SENSOR); | ||
309 | } | ||
310 | |||
311 | static ssize_t koneplus_sysfs_write_sensor(struct file *fp, | ||
312 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | ||
313 | loff_t off, size_t count) | ||
314 | { | ||
315 | return koneplus_sysfs_write(fp, kobj, buf, off, count, | ||
316 | sizeof(struct koneplus_sensor), KONEPLUS_USB_COMMAND_SENSOR); | ||
317 | } | ||
318 | |||
319 | static ssize_t koneplus_sysfs_write_tcu(struct file *fp, | ||
320 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | ||
321 | loff_t off, size_t count) | ||
322 | { | ||
323 | return koneplus_sysfs_write(fp, kobj, buf, off, count, | ||
324 | sizeof(struct koneplus_tcu), KONEPLUS_USB_COMMAND_TCU); | ||
325 | } | ||
326 | |||
327 | static ssize_t koneplus_sysfs_read_tcu_image(struct file *fp, | ||
328 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | ||
329 | loff_t off, size_t count) | ||
330 | { | ||
331 | return koneplus_sysfs_read(fp, kobj, buf, off, count, | ||
332 | sizeof(struct koneplus_tcu_image), KONEPLUS_USB_COMMAND_TCU); | ||
333 | } | ||
334 | |||
335 | static ssize_t koneplus_sysfs_read_profilex_settings(struct file *fp, | ||
336 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | ||
337 | loff_t off, size_t count) | ||
338 | { | ||
339 | struct device *dev = | ||
340 | container_of(kobj, struct device, kobj)->parent->parent; | ||
341 | struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev)); | ||
342 | |||
343 | if (off >= sizeof(struct koneplus_profile_settings)) | ||
344 | return 0; | ||
345 | |||
346 | if (off + count > sizeof(struct koneplus_profile_settings)) | ||
347 | count = sizeof(struct koneplus_profile_settings) - off; | ||
348 | |||
349 | mutex_lock(&koneplus->koneplus_lock); | ||
350 | memcpy(buf, ((void const *)&koneplus->profile_settings[*(uint *)(attr->private)]) + off, | ||
351 | count); | ||
352 | mutex_unlock(&koneplus->koneplus_lock); | ||
353 | |||
354 | return count; | ||
355 | } | ||
356 | |||
357 | static ssize_t koneplus_sysfs_write_profile_settings(struct file *fp, | ||
358 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | ||
359 | loff_t off, size_t count) | ||
360 | { | ||
361 | struct device *dev = | ||
362 | container_of(kobj, struct device, kobj)->parent->parent; | ||
363 | struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev)); | ||
364 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | ||
365 | int retval = 0; | ||
366 | int difference; | ||
367 | int profile_number; | ||
368 | struct koneplus_profile_settings *profile_settings; | ||
369 | |||
370 | if (off != 0 || count != sizeof(struct koneplus_profile_settings)) | ||
371 | return -EINVAL; | ||
372 | |||
373 | profile_number = ((struct koneplus_profile_settings const *)buf)->number; | ||
374 | profile_settings = &koneplus->profile_settings[profile_number]; | ||
375 | |||
376 | mutex_lock(&koneplus->koneplus_lock); | ||
377 | difference = memcmp(buf, profile_settings, | ||
378 | sizeof(struct koneplus_profile_settings)); | ||
379 | if (difference) { | ||
380 | retval = koneplus_set_profile_settings(usb_dev, | ||
381 | (struct koneplus_profile_settings const *)buf); | ||
382 | if (!retval) | ||
383 | memcpy(profile_settings, buf, | ||
384 | sizeof(struct koneplus_profile_settings)); | ||
385 | } | ||
386 | mutex_unlock(&koneplus->koneplus_lock); | ||
387 | |||
388 | if (retval) | ||
389 | return retval; | ||
390 | |||
391 | return sizeof(struct koneplus_profile_settings); | ||
392 | } | ||
393 | |||
394 | static ssize_t koneplus_sysfs_read_profilex_buttons(struct file *fp, | ||
395 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | ||
396 | loff_t off, size_t count) | ||
397 | { | ||
398 | struct device *dev = | ||
399 | container_of(kobj, struct device, kobj)->parent->parent; | ||
400 | struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev)); | ||
401 | |||
402 | if (off >= sizeof(struct koneplus_profile_buttons)) | ||
403 | return 0; | ||
404 | |||
405 | if (off + count > sizeof(struct koneplus_profile_buttons)) | ||
406 | count = sizeof(struct koneplus_profile_buttons) - off; | ||
407 | |||
408 | mutex_lock(&koneplus->koneplus_lock); | ||
409 | memcpy(buf, ((void const *)&koneplus->profile_buttons[*(uint *)(attr->private)]) + off, | ||
410 | count); | ||
411 | mutex_unlock(&koneplus->koneplus_lock); | ||
412 | |||
413 | return count; | ||
414 | } | ||
415 | |||
416 | static ssize_t koneplus_sysfs_write_profile_buttons(struct file *fp, | ||
417 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | ||
418 | loff_t off, size_t count) | ||
419 | { | ||
420 | struct device *dev = | ||
421 | container_of(kobj, struct device, kobj)->parent->parent; | ||
422 | struct koneplus_device *koneplus = hid_get_drvdata(dev_get_drvdata(dev)); | ||
423 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | ||
424 | int retval = 0; | ||
425 | int difference; | ||
426 | uint profile_number; | ||
427 | struct koneplus_profile_buttons *profile_buttons; | ||
428 | |||
429 | if (off != 0 || count != sizeof(struct koneplus_profile_buttons)) | ||
430 | return -EINVAL; | ||
431 | |||
432 | profile_number = ((struct koneplus_profile_buttons const *)buf)->number; | ||
433 | profile_buttons = &koneplus->profile_buttons[profile_number]; | ||
434 | |||
435 | mutex_lock(&koneplus->koneplus_lock); | ||
436 | difference = memcmp(buf, profile_buttons, | ||
437 | sizeof(struct koneplus_profile_buttons)); | ||
438 | if (difference) { | ||
439 | retval = koneplus_set_profile_buttons(usb_dev, | ||
440 | (struct koneplus_profile_buttons const *)buf); | ||
441 | if (!retval) | ||
442 | memcpy(profile_buttons, buf, | ||
443 | sizeof(struct koneplus_profile_buttons)); | ||
444 | } | ||
445 | mutex_unlock(&koneplus->koneplus_lock); | ||
446 | |||
447 | if (retval) | ||
448 | return retval; | ||
449 | |||
450 | return sizeof(struct koneplus_profile_buttons); | ||
451 | } | ||
452 | |||
453 | static ssize_t koneplus_sysfs_show_startup_profile(struct device *dev, | ||
454 | struct device_attribute *attr, char *buf) | ||
455 | { | ||
456 | struct koneplus_device *koneplus = | ||
457 | hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); | ||
458 | return snprintf(buf, PAGE_SIZE, "%d\n", koneplus->startup_profile); | ||
459 | } | ||
460 | |||
461 | static ssize_t koneplus_sysfs_set_startup_profile(struct device *dev, | ||
462 | struct device_attribute *attr, char const *buf, size_t size) | ||
463 | { | ||
464 | struct koneplus_device *koneplus; | ||
465 | struct usb_device *usb_dev; | ||
466 | unsigned long profile; | ||
467 | int retval; | ||
468 | |||
469 | dev = dev->parent->parent; | ||
470 | koneplus = hid_get_drvdata(dev_get_drvdata(dev)); | ||
471 | usb_dev = interface_to_usbdev(to_usb_interface(dev)); | ||
472 | |||
473 | retval = strict_strtoul(buf, 10, &profile); | ||
474 | if (retval) | ||
475 | return retval; | ||
476 | |||
477 | mutex_lock(&koneplus->koneplus_lock); | ||
478 | retval = koneplus_set_startup_profile(usb_dev, profile); | ||
479 | mutex_unlock(&koneplus->koneplus_lock); | ||
480 | if (retval) | ||
481 | return retval; | ||
482 | |||
483 | return size; | ||
484 | } | ||
485 | |||
486 | static ssize_t koneplus_sysfs_show_actual_profile(struct device *dev, | ||
487 | struct device_attribute *attr, char *buf) | ||
488 | { | ||
489 | struct koneplus_device *koneplus = | ||
490 | hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); | ||
491 | return snprintf(buf, PAGE_SIZE, "%d\n", koneplus->actual_profile); | ||
492 | } | ||
493 | |||
494 | static ssize_t koneplus_sysfs_show_firmware_version(struct device *dev, | ||
495 | struct device_attribute *attr, char *buf) | ||
496 | { | ||
497 | struct koneplus_device *koneplus = | ||
498 | hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); | ||
499 | return snprintf(buf, PAGE_SIZE, "%d\n", koneplus->info.firmware_version); | ||
500 | } | ||
501 | |||
502 | static struct device_attribute koneplus_attributes[] = { | ||
503 | __ATTR(startup_profile, 0660, | ||
504 | koneplus_sysfs_show_startup_profile, | ||
505 | koneplus_sysfs_set_startup_profile), | ||
506 | __ATTR(actual_profile, 0440, | ||
507 | koneplus_sysfs_show_actual_profile, NULL), | ||
508 | __ATTR(firmware_version, 0440, | ||
509 | koneplus_sysfs_show_firmware_version, NULL), | ||
510 | __ATTR_NULL | ||
511 | }; | ||
512 | |||
513 | static struct bin_attribute koneplus_bin_attributes[] = { | ||
514 | { | ||
515 | .attr = { .name = "sensor", .mode = 0220 }, | ||
516 | .size = sizeof(struct koneplus_sensor), | ||
517 | .read = koneplus_sysfs_read_sensor, | ||
518 | .write = koneplus_sysfs_write_sensor | ||
519 | }, | ||
520 | { | ||
521 | .attr = { .name = "tcu", .mode = 0220 }, | ||
522 | .size = sizeof(struct koneplus_tcu), | ||
523 | .write = koneplus_sysfs_write_tcu | ||
524 | }, | ||
525 | { | ||
526 | .attr = { .name = "tcu_image", .mode = 0440 }, | ||
527 | .size = sizeof(struct koneplus_tcu_image), | ||
528 | .read = koneplus_sysfs_read_tcu_image | ||
529 | }, | ||
530 | { | ||
531 | .attr = { .name = "profile_settings", .mode = 0220 }, | ||
532 | .size = sizeof(struct koneplus_profile_settings), | ||
533 | .write = koneplus_sysfs_write_profile_settings | ||
534 | }, | ||
535 | { | ||
536 | .attr = { .name = "profile1_settings", .mode = 0440 }, | ||
537 | .size = sizeof(struct koneplus_profile_settings), | ||
538 | .read = koneplus_sysfs_read_profilex_settings, | ||
539 | .private = &profile_numbers[0] | ||
540 | }, | ||
541 | { | ||
542 | .attr = { .name = "profile2_settings", .mode = 0440 }, | ||
543 | .size = sizeof(struct koneplus_profile_settings), | ||
544 | .read = koneplus_sysfs_read_profilex_settings, | ||
545 | .private = &profile_numbers[1] | ||
546 | }, | ||
547 | { | ||
548 | .attr = { .name = "profile3_settings", .mode = 0440 }, | ||
549 | .size = sizeof(struct koneplus_profile_settings), | ||
550 | .read = koneplus_sysfs_read_profilex_settings, | ||
551 | .private = &profile_numbers[2] | ||
552 | }, | ||
553 | { | ||
554 | .attr = { .name = "profile4_settings", .mode = 0440 }, | ||
555 | .size = sizeof(struct koneplus_profile_settings), | ||
556 | .read = koneplus_sysfs_read_profilex_settings, | ||
557 | .private = &profile_numbers[3] | ||
558 | }, | ||
559 | { | ||
560 | .attr = { .name = "profile5_settings", .mode = 0440 }, | ||
561 | .size = sizeof(struct koneplus_profile_settings), | ||
562 | .read = koneplus_sysfs_read_profilex_settings, | ||
563 | .private = &profile_numbers[4] | ||
564 | }, | ||
565 | { | ||
566 | .attr = { .name = "profile_buttons", .mode = 0220 }, | ||
567 | .size = sizeof(struct koneplus_profile_buttons), | ||
568 | .write = koneplus_sysfs_write_profile_buttons | ||
569 | }, | ||
570 | { | ||
571 | .attr = { .name = "profile1_buttons", .mode = 0440 }, | ||
572 | .size = sizeof(struct koneplus_profile_buttons), | ||
573 | .read = koneplus_sysfs_read_profilex_buttons, | ||
574 | .private = &profile_numbers[0] | ||
575 | }, | ||
576 | { | ||
577 | .attr = { .name = "profile2_buttons", .mode = 0440 }, | ||
578 | .size = sizeof(struct koneplus_profile_buttons), | ||
579 | .read = koneplus_sysfs_read_profilex_buttons, | ||
580 | .private = &profile_numbers[1] | ||
581 | }, | ||
582 | { | ||
583 | .attr = { .name = "profile3_buttons", .mode = 0440 }, | ||
584 | .size = sizeof(struct koneplus_profile_buttons), | ||
585 | .read = koneplus_sysfs_read_profilex_buttons, | ||
586 | .private = &profile_numbers[2] | ||
587 | }, | ||
588 | { | ||
589 | .attr = { .name = "profile4_buttons", .mode = 0440 }, | ||
590 | .size = sizeof(struct koneplus_profile_buttons), | ||
591 | .read = koneplus_sysfs_read_profilex_buttons, | ||
592 | .private = &profile_numbers[3] | ||
593 | }, | ||
594 | { | ||
595 | .attr = { .name = "profile5_buttons", .mode = 0440 }, | ||
596 | .size = sizeof(struct koneplus_profile_buttons), | ||
597 | .read = koneplus_sysfs_read_profilex_buttons, | ||
598 | .private = &profile_numbers[4] | ||
599 | }, | ||
600 | { | ||
601 | .attr = { .name = "macro", .mode = 0220 }, | ||
602 | .size = sizeof(struct koneplus_macro), | ||
603 | .write = koneplus_sysfs_write_macro | ||
604 | }, | ||
605 | __ATTR_NULL | ||
606 | }; | ||
607 | |||
608 | static int koneplus_init_koneplus_device_struct(struct usb_device *usb_dev, | ||
609 | struct koneplus_device *koneplus) | ||
610 | { | ||
611 | int retval, i; | ||
612 | static uint wait = 70; /* device will freeze with just 60 */ | ||
613 | |||
614 | mutex_init(&koneplus->koneplus_lock); | ||
615 | |||
616 | koneplus->startup_profile = koneplus_get_startup_profile(usb_dev); | ||
617 | |||
618 | msleep(wait); | ||
619 | retval = koneplus_get_info(usb_dev, &koneplus->info); | ||
620 | if (retval) | ||
621 | return retval; | ||
622 | |||
623 | for (i = 0; i < 5; ++i) { | ||
624 | msleep(wait); | ||
625 | retval = koneplus_get_profile_settings(usb_dev, | ||
626 | &koneplus->profile_settings[i], i); | ||
627 | if (retval) | ||
628 | return retval; | ||
629 | |||
630 | msleep(wait); | ||
631 | retval = koneplus_get_profile_buttons(usb_dev, | ||
632 | &koneplus->profile_buttons[i], i); | ||
633 | if (retval) | ||
634 | return retval; | ||
635 | } | ||
636 | |||
637 | koneplus_profile_activated(koneplus, koneplus->startup_profile); | ||
638 | |||
639 | return 0; | ||
640 | } | ||
641 | |||
642 | static int koneplus_init_specials(struct hid_device *hdev) | ||
643 | { | ||
644 | struct usb_interface *intf = to_usb_interface(hdev->dev.parent); | ||
645 | struct usb_device *usb_dev = interface_to_usbdev(intf); | ||
646 | struct koneplus_device *koneplus; | ||
647 | int retval; | ||
648 | |||
649 | if (intf->cur_altsetting->desc.bInterfaceProtocol | ||
650 | == USB_INTERFACE_PROTOCOL_MOUSE) { | ||
651 | |||
652 | koneplus = kzalloc(sizeof(*koneplus), GFP_KERNEL); | ||
653 | if (!koneplus) { | ||
654 | dev_err(&hdev->dev, "can't alloc device descriptor\n"); | ||
655 | return -ENOMEM; | ||
656 | } | ||
657 | hid_set_drvdata(hdev, koneplus); | ||
658 | |||
659 | retval = koneplus_init_koneplus_device_struct(usb_dev, koneplus); | ||
660 | if (retval) { | ||
661 | dev_err(&hdev->dev, | ||
662 | "couldn't init struct koneplus_device\n"); | ||
663 | goto exit_free; | ||
664 | } | ||
665 | |||
666 | retval = roccat_connect(koneplus_class, hdev); | ||
667 | if (retval < 0) { | ||
668 | dev_err(&hdev->dev, "couldn't init char dev\n"); | ||
669 | } else { | ||
670 | koneplus->chrdev_minor = retval; | ||
671 | koneplus->roccat_claimed = 1; | ||
672 | } | ||
673 | } else { | ||
674 | hid_set_drvdata(hdev, NULL); | ||
675 | } | ||
676 | |||
677 | return 0; | ||
678 | exit_free: | ||
679 | kfree(koneplus); | ||
680 | return retval; | ||
681 | } | ||
682 | |||
683 | static void koneplus_remove_specials(struct hid_device *hdev) | ||
684 | { | ||
685 | struct usb_interface *intf = to_usb_interface(hdev->dev.parent); | ||
686 | struct koneplus_device *koneplus; | ||
687 | |||
688 | if (intf->cur_altsetting->desc.bInterfaceProtocol | ||
689 | == USB_INTERFACE_PROTOCOL_MOUSE) { | ||
690 | koneplus = hid_get_drvdata(hdev); | ||
691 | if (koneplus->roccat_claimed) | ||
692 | roccat_disconnect(koneplus->chrdev_minor); | ||
693 | kfree(koneplus); | ||
694 | } | ||
695 | } | ||
696 | |||
697 | static int koneplus_probe(struct hid_device *hdev, | ||
698 | const struct hid_device_id *id) | ||
699 | { | ||
700 | int retval; | ||
701 | |||
702 | retval = hid_parse(hdev); | ||
703 | if (retval) { | ||
704 | dev_err(&hdev->dev, "parse failed\n"); | ||
705 | goto exit; | ||
706 | } | ||
707 | |||
708 | retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT); | ||
709 | if (retval) { | ||
710 | dev_err(&hdev->dev, "hw start failed\n"); | ||
711 | goto exit; | ||
712 | } | ||
713 | |||
714 | retval = koneplus_init_specials(hdev); | ||
715 | if (retval) { | ||
716 | dev_err(&hdev->dev, "couldn't install mouse\n"); | ||
717 | goto exit_stop; | ||
718 | } | ||
719 | |||
720 | return 0; | ||
721 | |||
722 | exit_stop: | ||
723 | hid_hw_stop(hdev); | ||
724 | exit: | ||
725 | return retval; | ||
726 | } | ||
727 | |||
728 | static void koneplus_remove(struct hid_device *hdev) | ||
729 | { | ||
730 | koneplus_remove_specials(hdev); | ||
731 | hid_hw_stop(hdev); | ||
732 | } | ||
733 | |||
734 | static void koneplus_keep_values_up_to_date(struct koneplus_device *koneplus, | ||
735 | u8 const *data) | ||
736 | { | ||
737 | struct koneplus_mouse_report_button const *button_report; | ||
738 | |||
739 | switch (data[0]) { | ||
740 | case KONEPLUS_MOUSE_REPORT_NUMBER_BUTTON: | ||
741 | button_report = (struct koneplus_mouse_report_button const *)data; | ||
742 | switch (button_report->type) { | ||
743 | case KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_PROFILE: | ||
744 | koneplus_profile_activated(koneplus, button_report->data1 - 1); | ||
745 | break; | ||
746 | } | ||
747 | break; | ||
748 | } | ||
749 | } | ||
750 | |||
751 | static void koneplus_report_to_chrdev(struct koneplus_device const *koneplus, | ||
752 | u8 const *data) | ||
753 | { | ||
754 | struct koneplus_roccat_report roccat_report; | ||
755 | struct koneplus_mouse_report_button const *button_report; | ||
756 | |||
757 | if (data[0] != KONEPLUS_MOUSE_REPORT_NUMBER_BUTTON) | ||
758 | return; | ||
759 | |||
760 | button_report = (struct koneplus_mouse_report_button const *)data; | ||
761 | |||
762 | if ((button_report->type == KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_QUICKLAUNCH || | ||
763 | button_report->type == KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_TIMER) && | ||
764 | button_report->data2 != KONEPLUS_MOUSE_REPORT_BUTTON_ACTION_PRESS) | ||
765 | return; | ||
766 | |||
767 | roccat_report.type = button_report->type; | ||
768 | roccat_report.data1 = button_report->data1; | ||
769 | roccat_report.data2 = button_report->data2; | ||
770 | roccat_report.profile = koneplus->actual_profile + 1; | ||
771 | roccat_report_event(koneplus->chrdev_minor, | ||
772 | (uint8_t const *)&roccat_report, | ||
773 | sizeof(struct koneplus_roccat_report)); | ||
774 | } | ||
775 | |||
776 | static int koneplus_raw_event(struct hid_device *hdev, | ||
777 | struct hid_report *report, u8 *data, int size) | ||
778 | { | ||
779 | struct usb_interface *intf = to_usb_interface(hdev->dev.parent); | ||
780 | struct koneplus_device *koneplus = hid_get_drvdata(hdev); | ||
781 | |||
782 | if (intf->cur_altsetting->desc.bInterfaceProtocol | ||
783 | != USB_INTERFACE_PROTOCOL_MOUSE) | ||
784 | return 0; | ||
785 | |||
786 | koneplus_keep_values_up_to_date(koneplus, data); | ||
787 | |||
788 | if (koneplus->roccat_claimed) | ||
789 | koneplus_report_to_chrdev(koneplus, data); | ||
790 | |||
791 | return 0; | ||
792 | } | ||
793 | |||
794 | static const struct hid_device_id koneplus_devices[] = { | ||
795 | { HID_USB_DEVICE(USB_VENDOR_ID_ROCCAT, USB_DEVICE_ID_ROCCAT_KONEPLUS) }, | ||
796 | { } | ||
797 | }; | ||
798 | |||
799 | MODULE_DEVICE_TABLE(hid, koneplus_devices); | ||
800 | |||
801 | static struct hid_driver koneplus_driver = { | ||
802 | .name = "koneplus", | ||
803 | .id_table = koneplus_devices, | ||
804 | .probe = koneplus_probe, | ||
805 | .remove = koneplus_remove, | ||
806 | .raw_event = koneplus_raw_event | ||
807 | }; | ||
808 | |||
809 | static int __init koneplus_init(void) | ||
810 | { | ||
811 | int retval; | ||
812 | |||
813 | /* class name has to be same as driver name */ | ||
814 | koneplus_class = class_create(THIS_MODULE, "koneplus"); | ||
815 | if (IS_ERR(koneplus_class)) | ||
816 | return PTR_ERR(koneplus_class); | ||
817 | koneplus_class->dev_attrs = koneplus_attributes; | ||
818 | koneplus_class->dev_bin_attrs = koneplus_bin_attributes; | ||
819 | |||
820 | retval = hid_register_driver(&koneplus_driver); | ||
821 | if (retval) | ||
822 | class_destroy(koneplus_class); | ||
823 | return retval; | ||
824 | } | ||
825 | |||
826 | static void __exit koneplus_exit(void) | ||
827 | { | ||
828 | class_destroy(koneplus_class); | ||
829 | hid_unregister_driver(&koneplus_driver); | ||
830 | } | ||
831 | |||
832 | module_init(koneplus_init); | ||
833 | module_exit(koneplus_exit); | ||
834 | |||
835 | MODULE_AUTHOR("Stefan Achatz"); | ||
836 | MODULE_DESCRIPTION("USB Roccat Kone[+] driver"); | ||
837 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/hid/hid-roccat-koneplus.h b/drivers/hid/hid-roccat-koneplus.h new file mode 100644 index 000000000000..57a5c1ab7b05 --- /dev/null +++ b/drivers/hid/hid-roccat-koneplus.h | |||
@@ -0,0 +1,224 @@ | |||
1 | #ifndef __HID_ROCCAT_KONEPLUS_H | ||
2 | #define __HID_ROCCAT_KONEPLUS_H | ||
3 | |||
4 | /* | ||
5 | * Copyright (c) 2010 Stefan Achatz <erazor_de@users.sourceforge.net> | ||
6 | */ | ||
7 | |||
8 | /* | ||
9 | * This program is free software; you can redistribute it and/or modify it | ||
10 | * under the terms of the GNU General Public License as published by the Free | ||
11 | * Software Foundation; either version 2 of the License, or (at your option) | ||
12 | * any later version. | ||
13 | */ | ||
14 | |||
15 | #include <linux/types.h> | ||
16 | |||
17 | /* | ||
18 | * case 1: writes request 80 and reads value 1 | ||
19 | * | ||
20 | */ | ||
21 | struct koneplus_control { | ||
22 | uint8_t command; /* KONEPLUS_COMMAND_CONTROL */ | ||
23 | /* | ||
24 | * value is profile number in range 0-4 for requesting settings and buttons | ||
25 | * 1 if status ok for requesting status | ||
26 | */ | ||
27 | uint8_t value; | ||
28 | uint8_t request; | ||
29 | } __attribute__ ((__packed__)); | ||
30 | |||
31 | enum koneplus_control_requests { | ||
32 | KONEPLUS_CONTROL_REQUEST_STATUS = 0x00, | ||
33 | KONEPLUS_CONTROL_REQUEST_PROFILE_SETTINGS = 0x80, | ||
34 | KONEPLUS_CONTROL_REQUEST_PROFILE_BUTTONS = 0x90, | ||
35 | }; | ||
36 | |||
37 | enum koneplus_control_values { | ||
38 | KONEPLUS_CONTROL_REQUEST_STATUS_OVERLOAD = 0, | ||
39 | KONEPLUS_CONTROL_REQUEST_STATUS_OK = 1, | ||
40 | KONEPLUS_CONTROL_REQUEST_STATUS_WAIT = 3, | ||
41 | }; | ||
42 | |||
43 | struct koneplus_startup_profile { | ||
44 | uint8_t command; /* KONEPLUS_COMMAND_STARTUP_PROFILE */ | ||
45 | uint8_t size; /* always 3 */ | ||
46 | uint8_t startup_profile; /* Range 0-4! */ | ||
47 | } __attribute__ ((__packed__)); | ||
48 | |||
49 | struct koneplus_profile_settings { | ||
50 | uint8_t command; /* KONEPLUS_COMMAND_PROFILE_SETTINGS */ | ||
51 | uint8_t size; /* always 43 */ | ||
52 | uint8_t number; /* range 0-4 */ | ||
53 | uint8_t advanced_sensitivity; | ||
54 | uint8_t sensitivity_x; | ||
55 | uint8_t sensitivity_y; | ||
56 | uint8_t cpi_levels_enabled; | ||
57 | uint8_t cpi_levels_x[5]; | ||
58 | uint8_t cpi_startup_level; /* range 0-4 */ | ||
59 | uint8_t cpi_levels_y[5]; /* range 1-60 means 100-6000 cpi */ | ||
60 | uint8_t unknown1; | ||
61 | uint8_t polling_rate; | ||
62 | uint8_t lights_enabled; | ||
63 | uint8_t light_effect_mode; | ||
64 | uint8_t color_flow_effect; | ||
65 | uint8_t light_effect_type; | ||
66 | uint8_t light_effect_speed; | ||
67 | uint8_t lights[16]; | ||
68 | uint16_t checksum; | ||
69 | } __attribute__ ((__packed__)); | ||
70 | |||
71 | struct koneplus_profile_buttons { | ||
72 | uint8_t command; /* KONEPLUS_COMMAND_PROFILE_BUTTONS */ | ||
73 | uint8_t size; /* always 77 */ | ||
74 | uint8_t number; /* range 0-4 */ | ||
75 | uint8_t data[72]; | ||
76 | uint16_t checksum; | ||
77 | } __attribute__ ((__packed__)); | ||
78 | |||
79 | struct koneplus_macro { | ||
80 | uint8_t command; /* KONEPLUS_COMMAND_MACRO */ | ||
81 | uint16_t size; /* always 0x822 little endian */ | ||
82 | uint8_t profile; /* range 0-4 */ | ||
83 | uint8_t button; /* range 0-23 */ | ||
84 | uint8_t data[2075]; | ||
85 | uint16_t checksum; | ||
86 | } __attribute__ ((__packed__)); | ||
87 | |||
88 | struct koneplus_info { | ||
89 | uint8_t command; /* KONEPLUS_COMMAND_INFO */ | ||
90 | uint8_t size; /* always 6 */ | ||
91 | uint8_t firmware_version; | ||
92 | uint8_t unknown[3]; | ||
93 | } __attribute__ ((__packed__)); | ||
94 | |||
95 | struct koneplus_e { | ||
96 | uint8_t command; /* KONEPLUS_COMMAND_E */ | ||
97 | uint8_t size; /* always 3 */ | ||
98 | uint8_t unknown; /* TODO 1; 0 before firmware update */ | ||
99 | } __attribute__ ((__packed__)); | ||
100 | |||
101 | struct koneplus_sensor { | ||
102 | uint8_t command; /* KONEPLUS_COMMAND_SENSOR */ | ||
103 | uint8_t size; /* always 6 */ | ||
104 | uint8_t data[4]; | ||
105 | } __attribute__ ((__packed__)); | ||
106 | |||
107 | struct koneplus_firmware_write { | ||
108 | uint8_t command; /* KONEPLUS_COMMAND_FIRMWARE_WRITE */ | ||
109 | uint8_t unknown[1025]; | ||
110 | } __attribute__ ((__packed__)); | ||
111 | |||
112 | struct koneplus_firmware_write_control { | ||
113 | uint8_t command; /* KONEPLUS_COMMAND_FIRMWARE_WRITE_CONTROL */ | ||
114 | /* | ||
115 | * value is 1 on success | ||
116 | * 3 means "not finished yet" | ||
117 | */ | ||
118 | uint8_t value; | ||
119 | uint8_t unknown; /* always 0x75 */ | ||
120 | } __attribute__ ((__packed__)); | ||
121 | |||
122 | struct koneplus_tcu { | ||
123 | uint16_t usb_command; /* KONEPLUS_USB_COMMAND_TCU */ | ||
124 | uint8_t data[2]; | ||
125 | } __attribute__ ((__packed__)); | ||
126 | |||
127 | struct koneplus_tcu_image { | ||
128 | uint16_t usb_command; /* KONEPLUS_USB_COMMAND_TCU */ | ||
129 | uint8_t data[1024]; | ||
130 | uint16_t checksum; | ||
131 | } __attribute__ ((__packed__)); | ||
132 | |||
133 | enum koneplus_commands { | ||
134 | KONEPLUS_COMMAND_CONTROL = 0x4, | ||
135 | KONEPLUS_COMMAND_STARTUP_PROFILE = 0x5, | ||
136 | KONEPLUS_COMMAND_PROFILE_SETTINGS = 0x6, | ||
137 | KONEPLUS_COMMAND_PROFILE_BUTTONS = 0x7, | ||
138 | KONEPLUS_COMMAND_MACRO = 0x8, | ||
139 | KONEPLUS_COMMAND_INFO = 0x9, | ||
140 | KONEPLUS_COMMAND_E = 0xe, | ||
141 | KONEPLUS_COMMAND_SENSOR = 0xf, | ||
142 | KONEPLUS_COMMAND_FIRMWARE_WRITE = 0x1b, | ||
143 | KONEPLUS_COMMAND_FIRMWARE_WRITE_CONTROL = 0x1c, | ||
144 | }; | ||
145 | |||
146 | enum koneplus_usb_commands { | ||
147 | KONEPLUS_USB_COMMAND_CONTROL = 0x304, | ||
148 | KONEPLUS_USB_COMMAND_STARTUP_PROFILE = 0x305, | ||
149 | KONEPLUS_USB_COMMAND_PROFILE_SETTINGS = 0x306, | ||
150 | KONEPLUS_USB_COMMAND_PROFILE_BUTTONS = 0x307, | ||
151 | KONEPLUS_USB_COMMAND_MACRO = 0x308, | ||
152 | KONEPLUS_USB_COMMAND_INFO = 0x309, | ||
153 | KONEPLUS_USB_COMMAND_TCU = 0x30c, | ||
154 | KONEPLUS_USB_COMMAND_E = 0x30e, | ||
155 | KONEPLUS_USB_COMMAND_SENSOR = 0x30f, | ||
156 | KONEPLUS_USB_COMMAND_FIRMWARE_WRITE = 0x31b, | ||
157 | KONEPLUS_USB_COMMAND_FIRMWARE_WRITE_CONTROL = 0x31c, | ||
158 | }; | ||
159 | |||
160 | enum koneplus_mouse_report_numbers { | ||
161 | KONEPLUS_MOUSE_REPORT_NUMBER_HID = 1, | ||
162 | KONEPLUS_MOUSE_REPORT_NUMBER_AUDIO = 2, | ||
163 | KONEPLUS_MOUSE_REPORT_NUMBER_BUTTON = 3, | ||
164 | }; | ||
165 | |||
166 | struct koneplus_mouse_report_button { | ||
167 | uint8_t report_number; /* always KONEPLUS_MOUSE_REPORT_NUMBER_BUTTON */ | ||
168 | uint8_t zero1; | ||
169 | uint8_t type; | ||
170 | uint8_t data1; | ||
171 | uint8_t data2; | ||
172 | uint8_t zero2; | ||
173 | uint8_t unknown[2]; | ||
174 | } __attribute__ ((__packed__)); | ||
175 | |||
176 | enum koneplus_mouse_report_button_types { | ||
177 | /* data1 = new profile range 1-5 */ | ||
178 | KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_PROFILE = 0x20, | ||
179 | |||
180 | /* data1 = button number range 1-24; data2 = action */ | ||
181 | KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_QUICKLAUNCH = 0x60, | ||
182 | |||
183 | /* data1 = button number range 1-24; data2 = action */ | ||
184 | KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_TIMER = 0x80, | ||
185 | |||
186 | /* data1 = setting number range 1-5 */ | ||
187 | KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_CPI = 0xb0, | ||
188 | |||
189 | /* data1 and data2 = range 0x1-0xb */ | ||
190 | KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_SENSITIVITY = 0xc0, | ||
191 | |||
192 | /* data1 = 22 = next track... | ||
193 | * data2 = action | ||
194 | */ | ||
195 | KONEPLUS_MOUSE_REPORT_BUTTON_TYPE_MULTIMEDIA = 0xf0, | ||
196 | }; | ||
197 | |||
198 | enum koneplus_mouse_report_button_action { | ||
199 | KONEPLUS_MOUSE_REPORT_BUTTON_ACTION_PRESS = 0, | ||
200 | KONEPLUS_MOUSE_REPORT_BUTTON_ACTION_RELEASE = 1, | ||
201 | }; | ||
202 | |||
203 | struct koneplus_roccat_report { | ||
204 | uint8_t type; | ||
205 | uint8_t data1; | ||
206 | uint8_t data2; | ||
207 | uint8_t profile; | ||
208 | } __attribute__ ((__packed__)); | ||
209 | |||
210 | struct koneplus_device { | ||
211 | int actual_profile; | ||
212 | |||
213 | int roccat_claimed; | ||
214 | int chrdev_minor; | ||
215 | |||
216 | struct mutex koneplus_lock; | ||
217 | |||
218 | int startup_profile; | ||
219 | struct koneplus_info info; | ||
220 | struct koneplus_profile_settings profile_settings[5]; | ||
221 | struct koneplus_profile_buttons profile_buttons[5]; | ||
222 | }; | ||
223 | |||
224 | #endif | ||
diff --git a/drivers/hid/hid-roccat-pyra.c b/drivers/hid/hid-roccat-pyra.c index 9bf23047892a..02c58e015bee 100644 --- a/drivers/hid/hid-roccat-pyra.c +++ b/drivers/hid/hid-roccat-pyra.c | |||
@@ -27,6 +27,11 @@ | |||
27 | #include "hid-roccat.h" | 27 | #include "hid-roccat.h" |
28 | #include "hid-roccat-pyra.h" | 28 | #include "hid-roccat-pyra.h" |
29 | 29 | ||
30 | static uint profile_numbers[5] = {0, 1, 2, 3, 4}; | ||
31 | |||
32 | /* pyra_class is used for creating sysfs attributes via roccat char device */ | ||
33 | static struct class *pyra_class; | ||
34 | |||
30 | static void profile_activated(struct pyra_device *pyra, | 35 | static void profile_activated(struct pyra_device *pyra, |
31 | unsigned int new_profile) | 36 | unsigned int new_profile) |
32 | { | 37 | { |
@@ -87,9 +92,8 @@ static int pyra_receive_control_status(struct usb_device *usb_dev) | |||
87 | control.value == 1) | 92 | control.value == 1) |
88 | return 0; | 93 | return 0; |
89 | else { | 94 | else { |
90 | dev_err(&usb_dev->dev, "receive control status: " | 95 | hid_err(usb_dev, "receive control status: unknown response 0x%x 0x%x\n", |
91 | "unknown response 0x%x 0x%x\n", | 96 | control.request, control.value); |
92 | control.request, control.value); | ||
93 | return -EINVAL; | 97 | return -EINVAL; |
94 | } | 98 | } |
95 | } | 99 | } |
@@ -221,9 +225,10 @@ static int pyra_set_settings(struct usb_device *usb_dev, | |||
221 | 225 | ||
222 | static ssize_t pyra_sysfs_read_profilex_settings(struct file *fp, | 226 | static ssize_t pyra_sysfs_read_profilex_settings(struct file *fp, |
223 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 227 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
224 | loff_t off, size_t count, int number) | 228 | loff_t off, size_t count) |
225 | { | 229 | { |
226 | struct device *dev = container_of(kobj, struct device, kobj); | 230 | struct device *dev = |
231 | container_of(kobj, struct device, kobj)->parent->parent; | ||
227 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); | 232 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); |
228 | 233 | ||
229 | if (off >= sizeof(struct pyra_profile_settings)) | 234 | if (off >= sizeof(struct pyra_profile_settings)) |
@@ -233,58 +238,19 @@ static ssize_t pyra_sysfs_read_profilex_settings(struct file *fp, | |||
233 | count = sizeof(struct pyra_profile_settings) - off; | 238 | count = sizeof(struct pyra_profile_settings) - off; |
234 | 239 | ||
235 | mutex_lock(&pyra->pyra_lock); | 240 | mutex_lock(&pyra->pyra_lock); |
236 | memcpy(buf, ((char const *)&pyra->profile_settings[number]) + off, | 241 | memcpy(buf, ((char const *)&pyra->profile_settings[*(uint *)(attr->private)]) + off, |
237 | count); | 242 | count); |
238 | mutex_unlock(&pyra->pyra_lock); | 243 | mutex_unlock(&pyra->pyra_lock); |
239 | 244 | ||
240 | return count; | 245 | return count; |
241 | } | 246 | } |
242 | 247 | ||
243 | static ssize_t pyra_sysfs_read_profile1_settings(struct file *fp, | ||
244 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | ||
245 | loff_t off, size_t count) | ||
246 | { | ||
247 | return pyra_sysfs_read_profilex_settings(fp, kobj, | ||
248 | attr, buf, off, count, 0); | ||
249 | } | ||
250 | |||
251 | static ssize_t pyra_sysfs_read_profile2_settings(struct file *fp, | ||
252 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | ||
253 | loff_t off, size_t count) | ||
254 | { | ||
255 | return pyra_sysfs_read_profilex_settings(fp, kobj, | ||
256 | attr, buf, off, count, 1); | ||
257 | } | ||
258 | |||
259 | static ssize_t pyra_sysfs_read_profile3_settings(struct file *fp, | ||
260 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | ||
261 | loff_t off, size_t count) | ||
262 | { | ||
263 | return pyra_sysfs_read_profilex_settings(fp, kobj, | ||
264 | attr, buf, off, count, 2); | ||
265 | } | ||
266 | |||
267 | static ssize_t pyra_sysfs_read_profile4_settings(struct file *fp, | ||
268 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | ||
269 | loff_t off, size_t count) | ||
270 | { | ||
271 | return pyra_sysfs_read_profilex_settings(fp, kobj, | ||
272 | attr, buf, off, count, 3); | ||
273 | } | ||
274 | |||
275 | static ssize_t pyra_sysfs_read_profile5_settings(struct file *fp, | ||
276 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | ||
277 | loff_t off, size_t count) | ||
278 | { | ||
279 | return pyra_sysfs_read_profilex_settings(fp, kobj, | ||
280 | attr, buf, off, count, 4); | ||
281 | } | ||
282 | |||
283 | static ssize_t pyra_sysfs_read_profilex_buttons(struct file *fp, | 248 | static ssize_t pyra_sysfs_read_profilex_buttons(struct file *fp, |
284 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 249 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
285 | loff_t off, size_t count, int number) | 250 | loff_t off, size_t count) |
286 | { | 251 | { |
287 | struct device *dev = container_of(kobj, struct device, kobj); | 252 | struct device *dev = |
253 | container_of(kobj, struct device, kobj)->parent->parent; | ||
288 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); | 254 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); |
289 | 255 | ||
290 | if (off >= sizeof(struct pyra_profile_buttons)) | 256 | if (off >= sizeof(struct pyra_profile_buttons)) |
@@ -294,58 +260,19 @@ static ssize_t pyra_sysfs_read_profilex_buttons(struct file *fp, | |||
294 | count = sizeof(struct pyra_profile_buttons) - off; | 260 | count = sizeof(struct pyra_profile_buttons) - off; |
295 | 261 | ||
296 | mutex_lock(&pyra->pyra_lock); | 262 | mutex_lock(&pyra->pyra_lock); |
297 | memcpy(buf, ((char const *)&pyra->profile_buttons[number]) + off, | 263 | memcpy(buf, ((char const *)&pyra->profile_buttons[*(uint *)(attr->private)]) + off, |
298 | count); | 264 | count); |
299 | mutex_unlock(&pyra->pyra_lock); | 265 | mutex_unlock(&pyra->pyra_lock); |
300 | 266 | ||
301 | return count; | 267 | return count; |
302 | } | 268 | } |
303 | 269 | ||
304 | static ssize_t pyra_sysfs_read_profile1_buttons(struct file *fp, | ||
305 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | ||
306 | loff_t off, size_t count) | ||
307 | { | ||
308 | return pyra_sysfs_read_profilex_buttons(fp, kobj, | ||
309 | attr, buf, off, count, 0); | ||
310 | } | ||
311 | |||
312 | static ssize_t pyra_sysfs_read_profile2_buttons(struct file *fp, | ||
313 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | ||
314 | loff_t off, size_t count) | ||
315 | { | ||
316 | return pyra_sysfs_read_profilex_buttons(fp, kobj, | ||
317 | attr, buf, off, count, 1); | ||
318 | } | ||
319 | |||
320 | static ssize_t pyra_sysfs_read_profile3_buttons(struct file *fp, | ||
321 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | ||
322 | loff_t off, size_t count) | ||
323 | { | ||
324 | return pyra_sysfs_read_profilex_buttons(fp, kobj, | ||
325 | attr, buf, off, count, 2); | ||
326 | } | ||
327 | |||
328 | static ssize_t pyra_sysfs_read_profile4_buttons(struct file *fp, | ||
329 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | ||
330 | loff_t off, size_t count) | ||
331 | { | ||
332 | return pyra_sysfs_read_profilex_buttons(fp, kobj, | ||
333 | attr, buf, off, count, 3); | ||
334 | } | ||
335 | |||
336 | static ssize_t pyra_sysfs_read_profile5_buttons(struct file *fp, | ||
337 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | ||
338 | loff_t off, size_t count) | ||
339 | { | ||
340 | return pyra_sysfs_read_profilex_buttons(fp, kobj, | ||
341 | attr, buf, off, count, 4); | ||
342 | } | ||
343 | |||
344 | static ssize_t pyra_sysfs_write_profile_settings(struct file *fp, | 270 | static ssize_t pyra_sysfs_write_profile_settings(struct file *fp, |
345 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 271 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
346 | loff_t off, size_t count) | 272 | loff_t off, size_t count) |
347 | { | 273 | { |
348 | struct device *dev = container_of(kobj, struct device, kobj); | 274 | struct device *dev = |
275 | container_of(kobj, struct device, kobj)->parent->parent; | ||
349 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); | 276 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); |
350 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 277 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
351 | int retval = 0; | 278 | int retval = 0; |
@@ -381,7 +308,8 @@ static ssize_t pyra_sysfs_write_profile_buttons(struct file *fp, | |||
381 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 308 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
382 | loff_t off, size_t count) | 309 | loff_t off, size_t count) |
383 | { | 310 | { |
384 | struct device *dev = container_of(kobj, struct device, kobj); | 311 | struct device *dev = |
312 | container_of(kobj, struct device, kobj)->parent->parent; | ||
385 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); | 313 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); |
386 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 314 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
387 | int retval = 0; | 315 | int retval = 0; |
@@ -417,7 +345,8 @@ static ssize_t pyra_sysfs_read_settings(struct file *fp, | |||
417 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 345 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
418 | loff_t off, size_t count) | 346 | loff_t off, size_t count) |
419 | { | 347 | { |
420 | struct device *dev = container_of(kobj, struct device, kobj); | 348 | struct device *dev = |
349 | container_of(kobj, struct device, kobj)->parent->parent; | ||
421 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); | 350 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); |
422 | 351 | ||
423 | if (off >= sizeof(struct pyra_settings)) | 352 | if (off >= sizeof(struct pyra_settings)) |
@@ -437,7 +366,8 @@ static ssize_t pyra_sysfs_write_settings(struct file *fp, | |||
437 | struct kobject *kobj, struct bin_attribute *attr, char *buf, | 366 | struct kobject *kobj, struct bin_attribute *attr, char *buf, |
438 | loff_t off, size_t count) | 367 | loff_t off, size_t count) |
439 | { | 368 | { |
440 | struct device *dev = container_of(kobj, struct device, kobj); | 369 | struct device *dev = |
370 | container_of(kobj, struct device, kobj)->parent->parent; | ||
441 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); | 371 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); |
442 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); | 372 | struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); |
443 | int retval = 0; | 373 | int retval = 0; |
@@ -469,255 +399,125 @@ static ssize_t pyra_sysfs_write_settings(struct file *fp, | |||
469 | static ssize_t pyra_sysfs_show_actual_cpi(struct device *dev, | 399 | static ssize_t pyra_sysfs_show_actual_cpi(struct device *dev, |
470 | struct device_attribute *attr, char *buf) | 400 | struct device_attribute *attr, char *buf) |
471 | { | 401 | { |
472 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); | 402 | struct pyra_device *pyra = |
403 | hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); | ||
473 | return snprintf(buf, PAGE_SIZE, "%d\n", pyra->actual_cpi); | 404 | return snprintf(buf, PAGE_SIZE, "%d\n", pyra->actual_cpi); |
474 | } | 405 | } |
475 | 406 | ||
476 | static ssize_t pyra_sysfs_show_actual_profile(struct device *dev, | 407 | static ssize_t pyra_sysfs_show_actual_profile(struct device *dev, |
477 | struct device_attribute *attr, char *buf) | 408 | struct device_attribute *attr, char *buf) |
478 | { | 409 | { |
479 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); | 410 | struct pyra_device *pyra = |
411 | hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); | ||
480 | return snprintf(buf, PAGE_SIZE, "%d\n", pyra->actual_profile); | 412 | return snprintf(buf, PAGE_SIZE, "%d\n", pyra->actual_profile); |
481 | } | 413 | } |
482 | 414 | ||
483 | static ssize_t pyra_sysfs_show_firmware_version(struct device *dev, | 415 | static ssize_t pyra_sysfs_show_firmware_version(struct device *dev, |
484 | struct device_attribute *attr, char *buf) | 416 | struct device_attribute *attr, char *buf) |
485 | { | 417 | { |
486 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); | 418 | struct pyra_device *pyra = |
419 | hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); | ||
487 | return snprintf(buf, PAGE_SIZE, "%d\n", pyra->firmware_version); | 420 | return snprintf(buf, PAGE_SIZE, "%d\n", pyra->firmware_version); |
488 | } | 421 | } |
489 | 422 | ||
490 | static ssize_t pyra_sysfs_show_startup_profile(struct device *dev, | 423 | static ssize_t pyra_sysfs_show_startup_profile(struct device *dev, |
491 | struct device_attribute *attr, char *buf) | 424 | struct device_attribute *attr, char *buf) |
492 | { | 425 | { |
493 | struct pyra_device *pyra = hid_get_drvdata(dev_get_drvdata(dev)); | 426 | struct pyra_device *pyra = |
427 | hid_get_drvdata(dev_get_drvdata(dev->parent->parent)); | ||
494 | return snprintf(buf, PAGE_SIZE, "%d\n", pyra->settings.startup_profile); | 428 | return snprintf(buf, PAGE_SIZE, "%d\n", pyra->settings.startup_profile); |
495 | } | 429 | } |
496 | 430 | ||
497 | static DEVICE_ATTR(actual_cpi, 0440, pyra_sysfs_show_actual_cpi, NULL); | 431 | static struct device_attribute pyra_attributes[] = { |
498 | 432 | __ATTR(actual_cpi, 0440, pyra_sysfs_show_actual_cpi, NULL), | |
499 | static DEVICE_ATTR(actual_profile, 0440, pyra_sysfs_show_actual_profile, NULL); | 433 | __ATTR(actual_profile, 0440, pyra_sysfs_show_actual_profile, NULL), |
500 | 434 | __ATTR(firmware_version, 0440, | |
501 | static DEVICE_ATTR(firmware_version, 0440, | 435 | pyra_sysfs_show_firmware_version, NULL), |
502 | pyra_sysfs_show_firmware_version, NULL); | 436 | __ATTR(startup_profile, 0440, |
503 | 437 | pyra_sysfs_show_startup_profile, NULL), | |
504 | static DEVICE_ATTR(startup_profile, 0440, | 438 | __ATTR_NULL |
505 | pyra_sysfs_show_startup_profile, NULL); | ||
506 | |||
507 | static struct attribute *pyra_attributes[] = { | ||
508 | &dev_attr_actual_cpi.attr, | ||
509 | &dev_attr_actual_profile.attr, | ||
510 | &dev_attr_firmware_version.attr, | ||
511 | &dev_attr_startup_profile.attr, | ||
512 | NULL | ||
513 | }; | ||
514 | |||
515 | static struct attribute_group pyra_attribute_group = { | ||
516 | .attrs = pyra_attributes | ||
517 | }; | 439 | }; |
518 | 440 | ||
519 | static struct bin_attribute pyra_profile_settings_attr = { | 441 | static struct bin_attribute pyra_bin_attributes[] = { |
442 | { | ||
520 | .attr = { .name = "profile_settings", .mode = 0220 }, | 443 | .attr = { .name = "profile_settings", .mode = 0220 }, |
521 | .size = sizeof(struct pyra_profile_settings), | 444 | .size = sizeof(struct pyra_profile_settings), |
522 | .write = pyra_sysfs_write_profile_settings | 445 | .write = pyra_sysfs_write_profile_settings |
523 | }; | 446 | }, |
524 | 447 | { | |
525 | static struct bin_attribute pyra_profile1_settings_attr = { | ||
526 | .attr = { .name = "profile1_settings", .mode = 0440 }, | 448 | .attr = { .name = "profile1_settings", .mode = 0440 }, |
527 | .size = sizeof(struct pyra_profile_settings), | 449 | .size = sizeof(struct pyra_profile_settings), |
528 | .read = pyra_sysfs_read_profile1_settings | 450 | .read = pyra_sysfs_read_profilex_settings, |
529 | }; | 451 | .private = &profile_numbers[0] |
530 | 452 | }, | |
531 | static struct bin_attribute pyra_profile2_settings_attr = { | 453 | { |
532 | .attr = { .name = "profile2_settings", .mode = 0440 }, | 454 | .attr = { .name = "profile2_settings", .mode = 0440 }, |
533 | .size = sizeof(struct pyra_profile_settings), | 455 | .size = sizeof(struct pyra_profile_settings), |
534 | .read = pyra_sysfs_read_profile2_settings | 456 | .read = pyra_sysfs_read_profilex_settings, |
535 | }; | 457 | .private = &profile_numbers[1] |
536 | 458 | }, | |
537 | static struct bin_attribute pyra_profile3_settings_attr = { | 459 | { |
538 | .attr = { .name = "profile3_settings", .mode = 0440 }, | 460 | .attr = { .name = "profile3_settings", .mode = 0440 }, |
539 | .size = sizeof(struct pyra_profile_settings), | 461 | .size = sizeof(struct pyra_profile_settings), |
540 | .read = pyra_sysfs_read_profile3_settings | 462 | .read = pyra_sysfs_read_profilex_settings, |
541 | }; | 463 | .private = &profile_numbers[2] |
542 | 464 | }, | |
543 | static struct bin_attribute pyra_profile4_settings_attr = { | 465 | { |
544 | .attr = { .name = "profile4_settings", .mode = 0440 }, | 466 | .attr = { .name = "profile4_settings", .mode = 0440 }, |
545 | .size = sizeof(struct pyra_profile_settings), | 467 | .size = sizeof(struct pyra_profile_settings), |
546 | .read = pyra_sysfs_read_profile4_settings | 468 | .read = pyra_sysfs_read_profilex_settings, |
547 | }; | 469 | .private = &profile_numbers[3] |
548 | 470 | }, | |
549 | static struct bin_attribute pyra_profile5_settings_attr = { | 471 | { |
550 | .attr = { .name = "profile5_settings", .mode = 0440 }, | 472 | .attr = { .name = "profile5_settings", .mode = 0440 }, |
551 | .size = sizeof(struct pyra_profile_settings), | 473 | .size = sizeof(struct pyra_profile_settings), |
552 | .read = pyra_sysfs_read_profile5_settings | 474 | .read = pyra_sysfs_read_profilex_settings, |
553 | }; | 475 | .private = &profile_numbers[4] |
554 | 476 | }, | |
555 | static struct bin_attribute pyra_profile_buttons_attr = { | 477 | { |
556 | .attr = { .name = "profile_buttons", .mode = 0220 }, | 478 | .attr = { .name = "profile_buttons", .mode = 0220 }, |
557 | .size = sizeof(struct pyra_profile_buttons), | 479 | .size = sizeof(struct pyra_profile_buttons), |
558 | .write = pyra_sysfs_write_profile_buttons | 480 | .write = pyra_sysfs_write_profile_buttons |
559 | }; | 481 | }, |
560 | 482 | { | |
561 | static struct bin_attribute pyra_profile1_buttons_attr = { | ||
562 | .attr = { .name = "profile1_buttons", .mode = 0440 }, | 483 | .attr = { .name = "profile1_buttons", .mode = 0440 }, |
563 | .size = sizeof(struct pyra_profile_buttons), | 484 | .size = sizeof(struct pyra_profile_buttons), |
564 | .read = pyra_sysfs_read_profile1_buttons | 485 | .read = pyra_sysfs_read_profilex_buttons, |
565 | }; | 486 | .private = &profile_numbers[0] |
566 | 487 | }, | |
567 | static struct bin_attribute pyra_profile2_buttons_attr = { | 488 | { |
568 | .attr = { .name = "profile2_buttons", .mode = 0440 }, | 489 | .attr = { .name = "profile2_buttons", .mode = 0440 }, |
569 | .size = sizeof(struct pyra_profile_buttons), | 490 | .size = sizeof(struct pyra_profile_buttons), |
570 | .read = pyra_sysfs_read_profile2_buttons | 491 | .read = pyra_sysfs_read_profilex_buttons, |
571 | }; | 492 | .private = &profile_numbers[1] |
572 | 493 | }, | |
573 | static struct bin_attribute pyra_profile3_buttons_attr = { | 494 | { |
574 | .attr = { .name = "profile3_buttons", .mode = 0440 }, | 495 | .attr = { .name = "profile3_buttons", .mode = 0440 }, |
575 | .size = sizeof(struct pyra_profile_buttons), | 496 | .size = sizeof(struct pyra_profile_buttons), |
576 | .read = pyra_sysfs_read_profile3_buttons | 497 | .read = pyra_sysfs_read_profilex_buttons, |
577 | }; | 498 | .private = &profile_numbers[2] |
578 | 499 | }, | |
579 | static struct bin_attribute pyra_profile4_buttons_attr = { | 500 | { |
580 | .attr = { .name = "profile4_buttons", .mode = 0440 }, | 501 | .attr = { .name = "profile4_buttons", .mode = 0440 }, |
581 | .size = sizeof(struct pyra_profile_buttons), | 502 | .size = sizeof(struct pyra_profile_buttons), |
582 | .read = pyra_sysfs_read_profile4_buttons | 503 | .read = pyra_sysfs_read_profilex_buttons, |
583 | }; | 504 | .private = &profile_numbers[3] |
584 | 505 | }, | |
585 | static struct bin_attribute pyra_profile5_buttons_attr = { | 506 | { |
586 | .attr = { .name = "profile5_buttons", .mode = 0440 }, | 507 | .attr = { .name = "profile5_buttons", .mode = 0440 }, |
587 | .size = sizeof(struct pyra_profile_buttons), | 508 | .size = sizeof(struct pyra_profile_buttons), |
588 | .read = pyra_sysfs_read_profile5_buttons | 509 | .read = pyra_sysfs_read_profilex_buttons, |
589 | }; | 510 | .private = &profile_numbers[4] |
590 | 511 | }, | |
591 | static struct bin_attribute pyra_settings_attr = { | 512 | { |
592 | .attr = { .name = "settings", .mode = 0660 }, | 513 | .attr = { .name = "settings", .mode = 0660 }, |
593 | .size = sizeof(struct pyra_settings), | 514 | .size = sizeof(struct pyra_settings), |
594 | .read = pyra_sysfs_read_settings, | 515 | .read = pyra_sysfs_read_settings, |
595 | .write = pyra_sysfs_write_settings | 516 | .write = pyra_sysfs_write_settings |
517 | }, | ||
518 | __ATTR_NULL | ||
596 | }; | 519 | }; |
597 | 520 | ||
598 | static int pyra_create_sysfs_attributes(struct usb_interface *intf) | ||
599 | { | ||
600 | int retval; | ||
601 | |||
602 | retval = sysfs_create_group(&intf->dev.kobj, &pyra_attribute_group); | ||
603 | if (retval) | ||
604 | goto exit_1; | ||
605 | |||
606 | retval = sysfs_create_bin_file(&intf->dev.kobj, | ||
607 | &pyra_profile_settings_attr); | ||
608 | if (retval) | ||
609 | goto exit_2; | ||
610 | |||
611 | retval = sysfs_create_bin_file(&intf->dev.kobj, | ||
612 | &pyra_profile1_settings_attr); | ||
613 | if (retval) | ||
614 | goto exit_3; | ||
615 | |||
616 | retval = sysfs_create_bin_file(&intf->dev.kobj, | ||
617 | &pyra_profile2_settings_attr); | ||
618 | if (retval) | ||
619 | goto exit_4; | ||
620 | |||
621 | retval = sysfs_create_bin_file(&intf->dev.kobj, | ||
622 | &pyra_profile3_settings_attr); | ||
623 | if (retval) | ||
624 | goto exit_5; | ||
625 | |||
626 | retval = sysfs_create_bin_file(&intf->dev.kobj, | ||
627 | &pyra_profile4_settings_attr); | ||
628 | if (retval) | ||
629 | goto exit_6; | ||
630 | |||
631 | retval = sysfs_create_bin_file(&intf->dev.kobj, | ||
632 | &pyra_profile5_settings_attr); | ||
633 | if (retval) | ||
634 | goto exit_7; | ||
635 | |||
636 | retval = sysfs_create_bin_file(&intf->dev.kobj, | ||
637 | &pyra_profile_buttons_attr); | ||
638 | if (retval) | ||
639 | goto exit_8; | ||
640 | |||
641 | retval = sysfs_create_bin_file(&intf->dev.kobj, | ||
642 | &pyra_profile1_buttons_attr); | ||
643 | if (retval) | ||
644 | goto exit_9; | ||
645 | |||
646 | retval = sysfs_create_bin_file(&intf->dev.kobj, | ||
647 | &pyra_profile2_buttons_attr); | ||
648 | if (retval) | ||
649 | goto exit_10; | ||
650 | |||
651 | retval = sysfs_create_bin_file(&intf->dev.kobj, | ||
652 | &pyra_profile3_buttons_attr); | ||
653 | if (retval) | ||
654 | goto exit_11; | ||
655 | |||
656 | retval = sysfs_create_bin_file(&intf->dev.kobj, | ||
657 | &pyra_profile4_buttons_attr); | ||
658 | if (retval) | ||
659 | goto exit_12; | ||
660 | |||
661 | retval = sysfs_create_bin_file(&intf->dev.kobj, | ||
662 | &pyra_profile5_buttons_attr); | ||
663 | if (retval) | ||
664 | goto exit_13; | ||
665 | |||
666 | retval = sysfs_create_bin_file(&intf->dev.kobj, | ||
667 | &pyra_settings_attr); | ||
668 | if (retval) | ||
669 | goto exit_14; | ||
670 | |||
671 | return 0; | ||
672 | |||
673 | exit_14: | ||
674 | sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile5_buttons_attr); | ||
675 | exit_13: | ||
676 | sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile4_buttons_attr); | ||
677 | exit_12: | ||
678 | sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile3_buttons_attr); | ||
679 | exit_11: | ||
680 | sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile2_buttons_attr); | ||
681 | exit_10: | ||
682 | sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile1_buttons_attr); | ||
683 | exit_9: | ||
684 | sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile_buttons_attr); | ||
685 | exit_8: | ||
686 | sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile5_settings_attr); | ||
687 | exit_7: | ||
688 | sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile4_settings_attr); | ||
689 | exit_6: | ||
690 | sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile3_settings_attr); | ||
691 | exit_5: | ||
692 | sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile2_settings_attr); | ||
693 | exit_4: | ||
694 | sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile1_settings_attr); | ||
695 | exit_3: | ||
696 | sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile_settings_attr); | ||
697 | exit_2: | ||
698 | sysfs_remove_group(&intf->dev.kobj, &pyra_attribute_group); | ||
699 | exit_1: | ||
700 | return retval; | ||
701 | } | ||
702 | |||
703 | static void pyra_remove_sysfs_attributes(struct usb_interface *intf) | ||
704 | { | ||
705 | sysfs_remove_bin_file(&intf->dev.kobj, &pyra_settings_attr); | ||
706 | sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile5_buttons_attr); | ||
707 | sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile4_buttons_attr); | ||
708 | sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile3_buttons_attr); | ||
709 | sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile2_buttons_attr); | ||
710 | sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile1_buttons_attr); | ||
711 | sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile_buttons_attr); | ||
712 | sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile5_settings_attr); | ||
713 | sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile4_settings_attr); | ||
714 | sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile3_settings_attr); | ||
715 | sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile2_settings_attr); | ||
716 | sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile1_settings_attr); | ||
717 | sysfs_remove_bin_file(&intf->dev.kobj, &pyra_profile_settings_attr); | ||
718 | sysfs_remove_group(&intf->dev.kobj, &pyra_attribute_group); | ||
719 | } | ||
720 | |||
721 | static int pyra_init_pyra_device_struct(struct usb_device *usb_dev, | 521 | static int pyra_init_pyra_device_struct(struct usb_device *usb_dev, |
722 | struct pyra_device *pyra) | 522 | struct pyra_device *pyra) |
723 | { | 523 | { |
@@ -770,31 +570,24 @@ static int pyra_init_specials(struct hid_device *hdev) | |||
770 | 570 | ||
771 | pyra = kzalloc(sizeof(*pyra), GFP_KERNEL); | 571 | pyra = kzalloc(sizeof(*pyra), GFP_KERNEL); |
772 | if (!pyra) { | 572 | if (!pyra) { |
773 | dev_err(&hdev->dev, "can't alloc device descriptor\n"); | 573 | hid_err(hdev, "can't alloc device descriptor\n"); |
774 | return -ENOMEM; | 574 | return -ENOMEM; |
775 | } | 575 | } |
776 | hid_set_drvdata(hdev, pyra); | 576 | hid_set_drvdata(hdev, pyra); |
777 | 577 | ||
778 | retval = pyra_init_pyra_device_struct(usb_dev, pyra); | 578 | retval = pyra_init_pyra_device_struct(usb_dev, pyra); |
779 | if (retval) { | 579 | if (retval) { |
780 | dev_err(&hdev->dev, | 580 | hid_err(hdev, "couldn't init struct pyra_device\n"); |
781 | "couldn't init struct pyra_device\n"); | ||
782 | goto exit_free; | 581 | goto exit_free; |
783 | } | 582 | } |
784 | 583 | ||
785 | retval = roccat_connect(hdev); | 584 | retval = roccat_connect(pyra_class, hdev); |
786 | if (retval < 0) { | 585 | if (retval < 0) { |
787 | dev_err(&hdev->dev, "couldn't init char dev\n"); | 586 | hid_err(hdev, "couldn't init char dev\n"); |
788 | } else { | 587 | } else { |
789 | pyra->chrdev_minor = retval; | 588 | pyra->chrdev_minor = retval; |
790 | pyra->roccat_claimed = 1; | 589 | pyra->roccat_claimed = 1; |
791 | } | 590 | } |
792 | |||
793 | retval = pyra_create_sysfs_attributes(intf); | ||
794 | if (retval) { | ||
795 | dev_err(&hdev->dev, "cannot create sysfs files\n"); | ||
796 | goto exit_free; | ||
797 | } | ||
798 | } else { | 591 | } else { |
799 | hid_set_drvdata(hdev, NULL); | 592 | hid_set_drvdata(hdev, NULL); |
800 | } | 593 | } |
@@ -812,7 +605,6 @@ static void pyra_remove_specials(struct hid_device *hdev) | |||
812 | 605 | ||
813 | if (intf->cur_altsetting->desc.bInterfaceProtocol | 606 | if (intf->cur_altsetting->desc.bInterfaceProtocol |
814 | == USB_INTERFACE_PROTOCOL_MOUSE) { | 607 | == USB_INTERFACE_PROTOCOL_MOUSE) { |
815 | pyra_remove_sysfs_attributes(intf); | ||
816 | pyra = hid_get_drvdata(hdev); | 608 | pyra = hid_get_drvdata(hdev); |
817 | if (pyra->roccat_claimed) | 609 | if (pyra->roccat_claimed) |
818 | roccat_disconnect(pyra->chrdev_minor); | 610 | roccat_disconnect(pyra->chrdev_minor); |
@@ -826,19 +618,19 @@ static int pyra_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
826 | 618 | ||
827 | retval = hid_parse(hdev); | 619 | retval = hid_parse(hdev); |
828 | if (retval) { | 620 | if (retval) { |
829 | dev_err(&hdev->dev, "parse failed\n"); | 621 | hid_err(hdev, "parse failed\n"); |
830 | goto exit; | 622 | goto exit; |
831 | } | 623 | } |
832 | 624 | ||
833 | retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT); | 625 | retval = hid_hw_start(hdev, HID_CONNECT_DEFAULT); |
834 | if (retval) { | 626 | if (retval) { |
835 | dev_err(&hdev->dev, "hw start failed\n"); | 627 | hid_err(hdev, "hw start failed\n"); |
836 | goto exit; | 628 | goto exit; |
837 | } | 629 | } |
838 | 630 | ||
839 | retval = pyra_init_specials(hdev); | 631 | retval = pyra_init_specials(hdev); |
840 | if (retval) { | 632 | if (retval) { |
841 | dev_err(&hdev->dev, "couldn't install mouse\n"); | 633 | hid_err(hdev, "couldn't install mouse\n"); |
842 | goto exit_stop; | 634 | goto exit_stop; |
843 | } | 635 | } |
844 | return 0; | 636 | return 0; |
@@ -952,11 +744,24 @@ static struct hid_driver pyra_driver = { | |||
952 | 744 | ||
953 | static int __init pyra_init(void) | 745 | static int __init pyra_init(void) |
954 | { | 746 | { |
955 | return hid_register_driver(&pyra_driver); | 747 | int retval; |
748 | |||
749 | /* class name has to be same as driver name */ | ||
750 | pyra_class = class_create(THIS_MODULE, "pyra"); | ||
751 | if (IS_ERR(pyra_class)) | ||
752 | return PTR_ERR(pyra_class); | ||
753 | pyra_class->dev_attrs = pyra_attributes; | ||
754 | pyra_class->dev_bin_attrs = pyra_bin_attributes; | ||
755 | |||
756 | retval = hid_register_driver(&pyra_driver); | ||
757 | if (retval) | ||
758 | class_destroy(pyra_class); | ||
759 | return retval; | ||
956 | } | 760 | } |
957 | 761 | ||
958 | static void __exit pyra_exit(void) | 762 | static void __exit pyra_exit(void) |
959 | { | 763 | { |
764 | class_destroy(pyra_class); | ||
960 | hid_unregister_driver(&pyra_driver); | 765 | hid_unregister_driver(&pyra_driver); |
961 | } | 766 | } |
962 | 767 | ||
diff --git a/drivers/hid/hid-roccat-pyra.h b/drivers/hid/hid-roccat-pyra.h index 22f80a8f26f9..14cbbe1621e0 100644 --- a/drivers/hid/hid-roccat-pyra.h +++ b/drivers/hid/hid-roccat-pyra.h | |||
@@ -14,14 +14,11 @@ | |||
14 | 14 | ||
15 | #include <linux/types.h> | 15 | #include <linux/types.h> |
16 | 16 | ||
17 | #pragma pack(push) | ||
18 | #pragma pack(1) | ||
19 | |||
20 | struct pyra_b { | 17 | struct pyra_b { |
21 | uint8_t command; /* PYRA_COMMAND_B */ | 18 | uint8_t command; /* PYRA_COMMAND_B */ |
22 | uint8_t size; /* always 3 */ | 19 | uint8_t size; /* always 3 */ |
23 | uint8_t unknown; /* 1 */ | 20 | uint8_t unknown; /* 1 */ |
24 | }; | 21 | } __attribute__ ((__packed__)); |
25 | 22 | ||
26 | struct pyra_control { | 23 | struct pyra_control { |
27 | uint8_t command; /* PYRA_COMMAND_CONTROL */ | 24 | uint8_t command; /* PYRA_COMMAND_CONTROL */ |
@@ -31,7 +28,7 @@ struct pyra_control { | |||
31 | */ | 28 | */ |
32 | uint8_t value; /* Range 0-4 */ | 29 | uint8_t value; /* Range 0-4 */ |
33 | uint8_t request; | 30 | uint8_t request; |
34 | }; | 31 | } __attribute__ ((__packed__)); |
35 | 32 | ||
36 | enum pyra_control_requests { | 33 | enum pyra_control_requests { |
37 | PYRA_CONTROL_REQUEST_STATUS = 0x00, | 34 | PYRA_CONTROL_REQUEST_STATUS = 0x00, |
@@ -43,7 +40,7 @@ struct pyra_settings { | |||
43 | uint8_t command; /* PYRA_COMMAND_SETTINGS */ | 40 | uint8_t command; /* PYRA_COMMAND_SETTINGS */ |
44 | uint8_t size; /* always 3 */ | 41 | uint8_t size; /* always 3 */ |
45 | uint8_t startup_profile; /* Range 0-4! */ | 42 | uint8_t startup_profile; /* Range 0-4! */ |
46 | }; | 43 | } __attribute__ ((__packed__)); |
47 | 44 | ||
48 | struct pyra_profile_settings { | 45 | struct pyra_profile_settings { |
49 | uint8_t command; /* PYRA_COMMAND_PROFILE_SETTINGS */ | 46 | uint8_t command; /* PYRA_COMMAND_PROFILE_SETTINGS */ |
@@ -58,7 +55,7 @@ struct pyra_profile_settings { | |||
58 | uint8_t light_effect; | 55 | uint8_t light_effect; |
59 | uint8_t handedness; | 56 | uint8_t handedness; |
60 | uint16_t checksum; /* byte sum */ | 57 | uint16_t checksum; /* byte sum */ |
61 | }; | 58 | } __attribute__ ((__packed__)); |
62 | 59 | ||
63 | struct pyra_profile_buttons { | 60 | struct pyra_profile_buttons { |
64 | uint8_t command; /* PYRA_COMMAND_PROFILE_BUTTONS */ | 61 | uint8_t command; /* PYRA_COMMAND_PROFILE_BUTTONS */ |
@@ -66,7 +63,7 @@ struct pyra_profile_buttons { | |||
66 | uint8_t number; /* Range 0-4 */ | 63 | uint8_t number; /* Range 0-4 */ |
67 | uint8_t buttons[14]; | 64 | uint8_t buttons[14]; |
68 | uint16_t checksum; /* byte sum */ | 65 | uint16_t checksum; /* byte sum */ |
69 | }; | 66 | } __attribute__ ((__packed__)); |
70 | 67 | ||
71 | struct pyra_info { | 68 | struct pyra_info { |
72 | uint8_t command; /* PYRA_COMMAND_INFO */ | 69 | uint8_t command; /* PYRA_COMMAND_INFO */ |
@@ -75,7 +72,7 @@ struct pyra_info { | |||
75 | uint8_t unknown1; /* always 0 */ | 72 | uint8_t unknown1; /* always 0 */ |
76 | uint8_t unknown2; /* always 1 */ | 73 | uint8_t unknown2; /* always 1 */ |
77 | uint8_t unknown3; /* always 0 */ | 74 | uint8_t unknown3; /* always 0 */ |
78 | }; | 75 | } __attribute__ ((__packed__)); |
79 | 76 | ||
80 | enum pyra_commands { | 77 | enum pyra_commands { |
81 | PYRA_COMMAND_CONTROL = 0x4, | 78 | PYRA_COMMAND_CONTROL = 0x4, |
@@ -107,13 +104,13 @@ struct pyra_mouse_event_button { | |||
107 | uint8_t type; | 104 | uint8_t type; |
108 | uint8_t data1; | 105 | uint8_t data1; |
109 | uint8_t data2; | 106 | uint8_t data2; |
110 | }; | 107 | } __attribute__ ((__packed__)); |
111 | 108 | ||
112 | struct pyra_mouse_event_audio { | 109 | struct pyra_mouse_event_audio { |
113 | uint8_t report_number; /* always 2 */ | 110 | uint8_t report_number; /* always 2 */ |
114 | uint8_t type; | 111 | uint8_t type; |
115 | uint8_t unused; /* always 0 */ | 112 | uint8_t unused; /* always 0 */ |
116 | }; | 113 | } __attribute__ ((__packed__)); |
117 | 114 | ||
118 | /* hid audio controls */ | 115 | /* hid audio controls */ |
119 | enum pyra_mouse_event_audio_types { | 116 | enum pyra_mouse_event_audio_types { |
@@ -167,9 +164,7 @@ struct pyra_roccat_report { | |||
167 | uint8_t type; | 164 | uint8_t type; |
168 | uint8_t value; | 165 | uint8_t value; |
169 | uint8_t key; | 166 | uint8_t key; |
170 | }; | 167 | } __attribute__ ((__packed__)); |
171 | |||
172 | #pragma pack(pop) | ||
173 | 168 | ||
174 | struct pyra_device { | 169 | struct pyra_device { |
175 | int actual_profile; | 170 | int actual_profile; |
diff --git a/drivers/hid/hid-roccat.c b/drivers/hid/hid-roccat.c index 5a6879e235ac..a14c579ea781 100644 --- a/drivers/hid/hid-roccat.c +++ b/drivers/hid/hid-roccat.c | |||
@@ -21,6 +21,8 @@ | |||
21 | * It is inspired by hidraw, but uses only one circular buffer for all readers. | 21 | * It is inspired by hidraw, but uses only one circular buffer for all readers. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
25 | |||
24 | #include <linux/cdev.h> | 26 | #include <linux/cdev.h> |
25 | #include <linux/poll.h> | 27 | #include <linux/poll.h> |
26 | #include <linux/sched.h> | 28 | #include <linux/sched.h> |
@@ -65,7 +67,6 @@ struct roccat_reader { | |||
65 | }; | 67 | }; |
66 | 68 | ||
67 | static int roccat_major; | 69 | static int roccat_major; |
68 | static struct class *roccat_class; | ||
69 | static struct cdev roccat_cdev; | 70 | static struct cdev roccat_cdev; |
70 | 71 | ||
71 | static struct roccat_device *devices[ROCCAT_MAX_DEVICES]; | 72 | static struct roccat_device *devices[ROCCAT_MAX_DEVICES]; |
@@ -165,27 +166,22 @@ static int roccat_open(struct inode *inode, struct file *file) | |||
165 | mutex_lock(&device->readers_lock); | 166 | mutex_lock(&device->readers_lock); |
166 | 167 | ||
167 | if (!device) { | 168 | if (!device) { |
168 | printk(KERN_EMERG "roccat device with minor %d doesn't exist\n", | 169 | pr_emerg("roccat device with minor %d doesn't exist\n", minor); |
169 | minor); | ||
170 | error = -ENODEV; | 170 | error = -ENODEV; |
171 | goto exit_err; | 171 | goto exit_err; |
172 | } | 172 | } |
173 | 173 | ||
174 | if (!device->open++) { | 174 | if (!device->open++) { |
175 | /* power on device on adding first reader */ | 175 | /* power on device on adding first reader */ |
176 | if (device->hid->ll_driver->power) { | 176 | error = hid_hw_power(device->hid, PM_HINT_FULLON); |
177 | error = device->hid->ll_driver->power(device->hid, | 177 | if (error < 0) { |
178 | PM_HINT_FULLON); | 178 | --device->open; |
179 | if (error < 0) { | 179 | goto exit_err; |
180 | --device->open; | ||
181 | goto exit_err; | ||
182 | } | ||
183 | } | 180 | } |
184 | error = device->hid->ll_driver->open(device->hid); | 181 | |
182 | error = hid_hw_open(device->hid); | ||
185 | if (error < 0) { | 183 | if (error < 0) { |
186 | if (device->hid->ll_driver->power) | 184 | hid_hw_power(device->hid, PM_HINT_NORMAL); |
187 | device->hid->ll_driver->power(device->hid, | ||
188 | PM_HINT_NORMAL); | ||
189 | --device->open; | 185 | --device->open; |
190 | goto exit_err; | 186 | goto exit_err; |
191 | } | 187 | } |
@@ -218,8 +214,7 @@ static int roccat_release(struct inode *inode, struct file *file) | |||
218 | device = devices[minor]; | 214 | device = devices[minor]; |
219 | if (!device) { | 215 | if (!device) { |
220 | mutex_unlock(&devices_lock); | 216 | mutex_unlock(&devices_lock); |
221 | printk(KERN_EMERG "roccat device with minor %d doesn't exist\n", | 217 | pr_emerg("roccat device with minor %d doesn't exist\n", minor); |
222 | minor); | ||
223 | return -ENODEV; | 218 | return -ENODEV; |
224 | } | 219 | } |
225 | 220 | ||
@@ -231,10 +226,8 @@ static int roccat_release(struct inode *inode, struct file *file) | |||
231 | if (!--device->open) { | 226 | if (!--device->open) { |
232 | /* removing last reader */ | 227 | /* removing last reader */ |
233 | if (device->exist) { | 228 | if (device->exist) { |
234 | if (device->hid->ll_driver->power) | 229 | hid_hw_power(device->hid, PM_HINT_NORMAL); |
235 | device->hid->ll_driver->power(device->hid, | 230 | hid_hw_close(device->hid); |
236 | PM_HINT_NORMAL); | ||
237 | device->hid->ll_driver->close(device->hid); | ||
238 | } else { | 231 | } else { |
239 | kfree(device); | 232 | kfree(device); |
240 | } | 233 | } |
@@ -295,12 +288,14 @@ EXPORT_SYMBOL_GPL(roccat_report_event); | |||
295 | 288 | ||
296 | /* | 289 | /* |
297 | * roccat_connect() - create a char device for special event output | 290 | * roccat_connect() - create a char device for special event output |
291 | * @class: the class thats used to create the device. Meant to hold device | ||
292 | * specific sysfs attributes. | ||
298 | * @hid: the hid device the char device should be connected to. | 293 | * @hid: the hid device the char device should be connected to. |
299 | * | 294 | * |
300 | * Return value is minor device number in Range [0, ROCCAT_MAX_DEVICES] on | 295 | * Return value is minor device number in Range [0, ROCCAT_MAX_DEVICES] on |
301 | * success, a negative error code on failure. | 296 | * success, a negative error code on failure. |
302 | */ | 297 | */ |
303 | int roccat_connect(struct hid_device *hid) | 298 | int roccat_connect(struct class *klass, struct hid_device *hid) |
304 | { | 299 | { |
305 | unsigned int minor; | 300 | unsigned int minor; |
306 | struct roccat_device *device; | 301 | struct roccat_device *device; |
@@ -326,7 +321,7 @@ int roccat_connect(struct hid_device *hid) | |||
326 | return -EINVAL; | 321 | return -EINVAL; |
327 | } | 322 | } |
328 | 323 | ||
329 | device->dev = device_create(roccat_class, &hid->dev, | 324 | device->dev = device_create(klass, &hid->dev, |
330 | MKDEV(roccat_major, minor), NULL, | 325 | MKDEV(roccat_major, minor), NULL, |
331 | "%s%s%d", "roccat", hid->driver->name, minor); | 326 | "%s%s%d", "roccat", hid->driver->name, minor); |
332 | 327 | ||
@@ -367,10 +362,10 @@ void roccat_disconnect(int minor) | |||
367 | 362 | ||
368 | device->exist = 0; /* TODO exist maybe not needed */ | 363 | device->exist = 0; /* TODO exist maybe not needed */ |
369 | 364 | ||
370 | device_destroy(roccat_class, MKDEV(roccat_major, minor)); | 365 | device_destroy(device->dev->class, MKDEV(roccat_major, minor)); |
371 | 366 | ||
372 | if (device->open) { | 367 | if (device->open) { |
373 | device->hid->ll_driver->close(device->hid); | 368 | hid_hw_close(device->hid); |
374 | wake_up_interruptible(&device->wait); | 369 | wake_up_interruptible(&device->wait); |
375 | } else { | 370 | } else { |
376 | kfree(device); | 371 | kfree(device); |
@@ -398,14 +393,7 @@ static int __init roccat_init(void) | |||
398 | roccat_major = MAJOR(dev_id); | 393 | roccat_major = MAJOR(dev_id); |
399 | 394 | ||
400 | if (retval < 0) { | 395 | if (retval < 0) { |
401 | printk(KERN_WARNING "roccat: can't get major number\n"); | 396 | pr_warn("can't get major number\n"); |
402 | return retval; | ||
403 | } | ||
404 | |||
405 | roccat_class = class_create(THIS_MODULE, "roccat"); | ||
406 | if (IS_ERR(roccat_class)) { | ||
407 | retval = PTR_ERR(roccat_class); | ||
408 | unregister_chrdev_region(dev_id, ROCCAT_MAX_DEVICES); | ||
409 | return retval; | 397 | return retval; |
410 | } | 398 | } |
411 | 399 | ||
@@ -420,7 +408,6 @@ static void __exit roccat_exit(void) | |||
420 | dev_t dev_id = MKDEV(roccat_major, 0); | 408 | dev_t dev_id = MKDEV(roccat_major, 0); |
421 | 409 | ||
422 | cdev_del(&roccat_cdev); | 410 | cdev_del(&roccat_cdev); |
423 | class_destroy(roccat_class); | ||
424 | unregister_chrdev_region(dev_id, ROCCAT_MAX_DEVICES); | 411 | unregister_chrdev_region(dev_id, ROCCAT_MAX_DEVICES); |
425 | } | 412 | } |
426 | 413 | ||
diff --git a/drivers/hid/hid-roccat.h b/drivers/hid/hid-roccat.h index 09e864e9f79d..5784281d613f 100644 --- a/drivers/hid/hid-roccat.h +++ b/drivers/hid/hid-roccat.h | |||
@@ -16,11 +16,12 @@ | |||
16 | #include <linux/types.h> | 16 | #include <linux/types.h> |
17 | 17 | ||
18 | #if defined(CONFIG_HID_ROCCAT) || defined(CONFIG_HID_ROCCAT_MODULE) | 18 | #if defined(CONFIG_HID_ROCCAT) || defined(CONFIG_HID_ROCCAT_MODULE) |
19 | int roccat_connect(struct hid_device *hid); | 19 | int roccat_connect(struct class *klass, struct hid_device *hid); |
20 | void roccat_disconnect(int minor); | 20 | void roccat_disconnect(int minor); |
21 | int roccat_report_event(int minor, u8 const *data, int len); | 21 | int roccat_report_event(int minor, u8 const *data, int len); |
22 | #else | 22 | #else |
23 | static inline int roccat_connect(struct hid_device *hid) { return -1; } | 23 | static inline int roccat_connect(struct class *klass, |
24 | struct hid_device *hid) { return -1; } | ||
24 | static inline void roccat_disconnect(int minor) {} | 25 | static inline void roccat_disconnect(int minor) {} |
25 | static inline int roccat_report_event(int minor, u8 const *data, int len) | 26 | static inline int roccat_report_event(int minor, u8 const *data, int len) |
26 | { | 27 | { |
diff --git a/drivers/hid/hid-samsung.c b/drivers/hid/hid-samsung.c index 35894444e000..3c1fd8af5e0c 100644 --- a/drivers/hid/hid-samsung.c +++ b/drivers/hid/hid-samsung.c | |||
@@ -57,8 +57,8 @@ | |||
57 | static inline void samsung_irda_dev_trace(struct hid_device *hdev, | 57 | static inline void samsung_irda_dev_trace(struct hid_device *hdev, |
58 | unsigned int rsize) | 58 | unsigned int rsize) |
59 | { | 59 | { |
60 | dev_info(&hdev->dev, "fixing up Samsung IrDA %d byte report " | 60 | hid_info(hdev, "fixing up Samsung IrDA %d byte report descriptor\n", |
61 | "descriptor\n", rsize); | 61 | rsize); |
62 | } | 62 | } |
63 | 63 | ||
64 | static __u8 *samsung_irda_report_fixup(struct hid_device *hdev, __u8 *rdesc, | 64 | static __u8 *samsung_irda_report_fixup(struct hid_device *hdev, __u8 *rdesc, |
@@ -160,7 +160,7 @@ static int samsung_probe(struct hid_device *hdev, | |||
160 | 160 | ||
161 | ret = hid_parse(hdev); | 161 | ret = hid_parse(hdev); |
162 | if (ret) { | 162 | if (ret) { |
163 | dev_err(&hdev->dev, "parse failed\n"); | 163 | hid_err(hdev, "parse failed\n"); |
164 | goto err_free; | 164 | goto err_free; |
165 | } | 165 | } |
166 | 166 | ||
@@ -174,7 +174,7 @@ static int samsung_probe(struct hid_device *hdev, | |||
174 | 174 | ||
175 | ret = hid_hw_start(hdev, cmask); | 175 | ret = hid_hw_start(hdev, cmask); |
176 | if (ret) { | 176 | if (ret) { |
177 | dev_err(&hdev->dev, "hw start failed\n"); | 177 | hid_err(hdev, "hw start failed\n"); |
178 | goto err_free; | 178 | goto err_free; |
179 | } | 179 | } |
180 | 180 | ||
diff --git a/drivers/hid/hid-sjoy.c b/drivers/hid/hid-sjoy.c index e10a7687ebf2..16f7cafc9695 100644 --- a/drivers/hid/hid-sjoy.c +++ b/drivers/hid/hid-sjoy.c | |||
@@ -74,26 +74,25 @@ static int sjoyff_init(struct hid_device *hid) | |||
74 | int error; | 74 | int error; |
75 | 75 | ||
76 | if (list_empty(report_list)) { | 76 | if (list_empty(report_list)) { |
77 | dev_err(&hid->dev, "no output reports found\n"); | 77 | hid_err(hid, "no output reports found\n"); |
78 | return -ENODEV; | 78 | return -ENODEV; |
79 | } | 79 | } |
80 | 80 | ||
81 | report_ptr = report_ptr->next; | 81 | report_ptr = report_ptr->next; |
82 | 82 | ||
83 | if (report_ptr == report_list) { | 83 | if (report_ptr == report_list) { |
84 | dev_err(&hid->dev, "required output report is " | 84 | hid_err(hid, "required output report is missing\n"); |
85 | "missing\n"); | ||
86 | return -ENODEV; | 85 | return -ENODEV; |
87 | } | 86 | } |
88 | 87 | ||
89 | report = list_entry(report_ptr, struct hid_report, list); | 88 | report = list_entry(report_ptr, struct hid_report, list); |
90 | if (report->maxfield < 1) { | 89 | if (report->maxfield < 1) { |
91 | dev_err(&hid->dev, "no fields in the report\n"); | 90 | hid_err(hid, "no fields in the report\n"); |
92 | return -ENODEV; | 91 | return -ENODEV; |
93 | } | 92 | } |
94 | 93 | ||
95 | if (report->field[0]->report_count < 3) { | 94 | if (report->field[0]->report_count < 3) { |
96 | dev_err(&hid->dev, "not enough values in the field\n"); | 95 | hid_err(hid, "not enough values in the field\n"); |
97 | return -ENODEV; | 96 | return -ENODEV; |
98 | } | 97 | } |
99 | 98 | ||
@@ -117,8 +116,7 @@ static int sjoyff_init(struct hid_device *hid) | |||
117 | sjoyff->report->field[0]->value[2] = 0x00; | 116 | sjoyff->report->field[0]->value[2] = 0x00; |
118 | usbhid_submit_report(hid, sjoyff->report, USB_DIR_OUT); | 117 | usbhid_submit_report(hid, sjoyff->report, USB_DIR_OUT); |
119 | 118 | ||
120 | dev_info(&hid->dev, | 119 | hid_info(hid, "Force feedback for SmartJoy PLUS PS2/USB adapter\n"); |
121 | "Force feedback for SmartJoy PLUS PS2/USB adapter\n"); | ||
122 | 120 | ||
123 | return 0; | 121 | return 0; |
124 | } | 122 | } |
@@ -135,13 +133,13 @@ static int sjoy_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
135 | 133 | ||
136 | ret = hid_parse(hdev); | 134 | ret = hid_parse(hdev); |
137 | if (ret) { | 135 | if (ret) { |
138 | dev_err(&hdev->dev, "parse failed\n"); | 136 | hid_err(hdev, "parse failed\n"); |
139 | goto err; | 137 | goto err; |
140 | } | 138 | } |
141 | 139 | ||
142 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF); | 140 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF); |
143 | if (ret) { | 141 | if (ret) { |
144 | dev_err(&hdev->dev, "hw start failed\n"); | 142 | hid_err(hdev, "hw start failed\n"); |
145 | goto err; | 143 | goto err; |
146 | } | 144 | } |
147 | 145 | ||
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index 677bb3da10e8..68d7b36e31e4 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c | |||
@@ -40,8 +40,7 @@ static __u8 *sony_report_fixup(struct hid_device *hdev, __u8 *rdesc, | |||
40 | 40 | ||
41 | if ((sc->quirks & VAIO_RDESC_CONSTANT) && | 41 | if ((sc->quirks & VAIO_RDESC_CONSTANT) && |
42 | *rsize >= 56 && rdesc[54] == 0x81 && rdesc[55] == 0x07) { | 42 | *rsize >= 56 && rdesc[54] == 0x81 && rdesc[55] == 0x07) { |
43 | dev_info(&hdev->dev, "Fixing up Sony Vaio VGX report " | 43 | hid_info(hdev, "Fixing up Sony Vaio VGX report descriptor\n"); |
44 | "descriptor\n"); | ||
45 | rdesc[55] = 0x06; | 44 | rdesc[55] = 0x06; |
46 | } | 45 | } |
47 | return rdesc; | 46 | return rdesc; |
@@ -89,7 +88,7 @@ static int sixaxis_set_operational_usb(struct hid_device *hdev) | |||
89 | (3 << 8) | 0xf2, ifnum, buf, 17, | 88 | (3 << 8) | 0xf2, ifnum, buf, 17, |
90 | USB_CTRL_GET_TIMEOUT); | 89 | USB_CTRL_GET_TIMEOUT); |
91 | if (ret < 0) | 90 | if (ret < 0) |
92 | dev_err(&hdev->dev, "can't set operational mode\n"); | 91 | hid_err(hdev, "can't set operational mode\n"); |
93 | 92 | ||
94 | kfree(buf); | 93 | kfree(buf); |
95 | 94 | ||
@@ -110,7 +109,7 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
110 | 109 | ||
111 | sc = kzalloc(sizeof(*sc), GFP_KERNEL); | 110 | sc = kzalloc(sizeof(*sc), GFP_KERNEL); |
112 | if (sc == NULL) { | 111 | if (sc == NULL) { |
113 | dev_err(&hdev->dev, "can't alloc sony descriptor\n"); | 112 | hid_err(hdev, "can't alloc sony descriptor\n"); |
114 | return -ENOMEM; | 113 | return -ENOMEM; |
115 | } | 114 | } |
116 | 115 | ||
@@ -119,14 +118,14 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
119 | 118 | ||
120 | ret = hid_parse(hdev); | 119 | ret = hid_parse(hdev); |
121 | if (ret) { | 120 | if (ret) { |
122 | dev_err(&hdev->dev, "parse failed\n"); | 121 | hid_err(hdev, "parse failed\n"); |
123 | goto err_free; | 122 | goto err_free; |
124 | } | 123 | } |
125 | 124 | ||
126 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT | | 125 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT | |
127 | HID_CONNECT_HIDDEV_FORCE); | 126 | HID_CONNECT_HIDDEV_FORCE); |
128 | if (ret) { | 127 | if (ret) { |
129 | dev_err(&hdev->dev, "hw start failed\n"); | 128 | hid_err(hdev, "hw start failed\n"); |
130 | goto err_free; | 129 | goto err_free; |
131 | } | 130 | } |
132 | 131 | ||
diff --git a/drivers/hid/hid-stantum.c b/drivers/hid/hid-stantum.c index 3171be28c3d5..b2be1d11916b 100644 --- a/drivers/hid/hid-stantum.c +++ b/drivers/hid/hid-stantum.c | |||
@@ -222,7 +222,7 @@ static int stantum_probe(struct hid_device *hdev, | |||
222 | 222 | ||
223 | sd = kmalloc(sizeof(struct stantum_data), GFP_KERNEL); | 223 | sd = kmalloc(sizeof(struct stantum_data), GFP_KERNEL); |
224 | if (!sd) { | 224 | if (!sd) { |
225 | dev_err(&hdev->dev, "cannot allocate Stantum data\n"); | 225 | hid_err(hdev, "cannot allocate Stantum data\n"); |
226 | return -ENOMEM; | 226 | return -ENOMEM; |
227 | } | 227 | } |
228 | sd->valid = false; | 228 | sd->valid = false; |
diff --git a/drivers/hid/hid-sunplus.c b/drivers/hid/hid-sunplus.c index 164ed568f6cf..d484a0043dd4 100644 --- a/drivers/hid/hid-sunplus.c +++ b/drivers/hid/hid-sunplus.c | |||
@@ -27,8 +27,7 @@ static __u8 *sp_report_fixup(struct hid_device *hdev, __u8 *rdesc, | |||
27 | { | 27 | { |
28 | if (*rsize >= 107 && rdesc[104] == 0x26 && rdesc[105] == 0x80 && | 28 | if (*rsize >= 107 && rdesc[104] == 0x26 && rdesc[105] == 0x80 && |
29 | rdesc[106] == 0x03) { | 29 | rdesc[106] == 0x03) { |
30 | dev_info(&hdev->dev, "fixing up Sunplus Wireless Desktop " | 30 | hid_info(hdev, "fixing up Sunplus Wireless Desktop report descriptor\n"); |
31 | "report descriptor\n"); | ||
32 | rdesc[105] = rdesc[110] = 0x03; | 31 | rdesc[105] = rdesc[110] = 0x03; |
33 | rdesc[106] = rdesc[111] = 0x21; | 32 | rdesc[106] = rdesc[111] = 0x21; |
34 | } | 33 | } |
diff --git a/drivers/hid/hid-tmff.c b/drivers/hid/hid-tmff.c index 25be4e1461bd..575862b0688e 100644 --- a/drivers/hid/hid-tmff.c +++ b/drivers/hid/hid-tmff.c | |||
@@ -151,28 +151,23 @@ static int tmff_init(struct hid_device *hid, const signed short *ff_bits) | |||
151 | switch (field->usage[0].hid) { | 151 | switch (field->usage[0].hid) { |
152 | case THRUSTMASTER_USAGE_FF: | 152 | case THRUSTMASTER_USAGE_FF: |
153 | if (field->report_count < 2) { | 153 | if (field->report_count < 2) { |
154 | dev_warn(&hid->dev, "ignoring FF field " | 154 | hid_warn(hid, "ignoring FF field with report_count < 2\n"); |
155 | "with report_count < 2\n"); | ||
156 | continue; | 155 | continue; |
157 | } | 156 | } |
158 | 157 | ||
159 | if (field->logical_maximum == | 158 | if (field->logical_maximum == |
160 | field->logical_minimum) { | 159 | field->logical_minimum) { |
161 | dev_warn(&hid->dev, "ignoring FF field " | 160 | hid_warn(hid, "ignoring FF field with logical_maximum == logical_minimum\n"); |
162 | "with logical_maximum " | ||
163 | "== logical_minimum\n"); | ||
164 | continue; | 161 | continue; |
165 | } | 162 | } |
166 | 163 | ||
167 | if (tmff->report && tmff->report != report) { | 164 | if (tmff->report && tmff->report != report) { |
168 | dev_warn(&hid->dev, "ignoring FF field " | 165 | hid_warn(hid, "ignoring FF field in other report\n"); |
169 | "in other report\n"); | ||
170 | continue; | 166 | continue; |
171 | } | 167 | } |
172 | 168 | ||
173 | if (tmff->ff_field && tmff->ff_field != field) { | 169 | if (tmff->ff_field && tmff->ff_field != field) { |
174 | dev_warn(&hid->dev, "ignoring " | 170 | hid_warn(hid, "ignoring duplicate FF field\n"); |
175 | "duplicate FF field\n"); | ||
176 | continue; | 171 | continue; |
177 | } | 172 | } |
178 | 173 | ||
@@ -185,16 +180,15 @@ static int tmff_init(struct hid_device *hid, const signed short *ff_bits) | |||
185 | break; | 180 | break; |
186 | 181 | ||
187 | default: | 182 | default: |
188 | dev_warn(&hid->dev, "ignoring unknown output " | 183 | hid_warn(hid, "ignoring unknown output usage %08x\n", |
189 | "usage %08x\n", | 184 | field->usage[0].hid); |
190 | field->usage[0].hid); | ||
191 | continue; | 185 | continue; |
192 | } | 186 | } |
193 | } | 187 | } |
194 | } | 188 | } |
195 | 189 | ||
196 | if (!tmff->report) { | 190 | if (!tmff->report) { |
197 | dev_err(&hid->dev, "can't find FF field in output reports\n"); | 191 | hid_err(hid, "can't find FF field in output reports\n"); |
198 | error = -ENODEV; | 192 | error = -ENODEV; |
199 | goto fail; | 193 | goto fail; |
200 | } | 194 | } |
@@ -203,8 +197,7 @@ static int tmff_init(struct hid_device *hid, const signed short *ff_bits) | |||
203 | if (error) | 197 | if (error) |
204 | goto fail; | 198 | goto fail; |
205 | 199 | ||
206 | dev_info(&hid->dev, "force feedback for ThrustMaster devices by Zinx " | 200 | hid_info(hid, "force feedback for ThrustMaster devices by Zinx Verituse <zinx@epicsol.org>\n"); |
207 | "Verituse <zinx@epicsol.org>"); | ||
208 | return 0; | 201 | return 0; |
209 | 202 | ||
210 | fail: | 203 | fail: |
@@ -224,13 +217,13 @@ static int tm_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
224 | 217 | ||
225 | ret = hid_parse(hdev); | 218 | ret = hid_parse(hdev); |
226 | if (ret) { | 219 | if (ret) { |
227 | dev_err(&hdev->dev, "parse failed\n"); | 220 | hid_err(hdev, "parse failed\n"); |
228 | goto err; | 221 | goto err; |
229 | } | 222 | } |
230 | 223 | ||
231 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF); | 224 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF); |
232 | if (ret) { | 225 | if (ret) { |
233 | dev_err(&hdev->dev, "hw start failed\n"); | 226 | hid_err(hdev, "hw start failed\n"); |
234 | goto err; | 227 | goto err; |
235 | } | 228 | } |
236 | 229 | ||
diff --git a/drivers/hid/hid-topseed.c b/drivers/hid/hid-topseed.c index 956ed9ac19d4..613ff7b1d746 100644 --- a/drivers/hid/hid-topseed.c +++ b/drivers/hid/hid-topseed.c | |||
@@ -66,6 +66,7 @@ static const struct hid_device_id ts_devices[] = { | |||
66 | { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE) }, | 66 | { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE) }, |
67 | { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE_2) }, | 67 | { HID_USB_DEVICE(USB_VENDOR_ID_BTC, USB_DEVICE_ID_BTC_EMPREX_REMOTE_2) }, |
68 | { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED2, USB_DEVICE_ID_TOPSEED2_RF_COMBO) }, | 68 | { HID_USB_DEVICE(USB_VENDOR_ID_TOPSEED2, USB_DEVICE_ID_TOPSEED2_RF_COMBO) }, |
69 | { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS) }, | ||
69 | { } | 70 | { } |
70 | }; | 71 | }; |
71 | MODULE_DEVICE_TABLE(hid, ts_devices); | 72 | MODULE_DEVICE_TABLE(hid, ts_devices); |
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index 724f46ed612f..06888323828c 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c | |||
@@ -18,6 +18,8 @@ | |||
18 | * any later version. | 18 | * any later version. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
22 | |||
21 | #include <linux/device.h> | 23 | #include <linux/device.h> |
22 | #include <linux/hid.h> | 24 | #include <linux/hid.h> |
23 | #include <linux/module.h> | 25 | #include <linux/module.h> |
@@ -141,8 +143,8 @@ static void wacom_poke(struct hid_device *hdev, u8 speed) | |||
141 | * Note that if the raw queries fail, it's not a hard failure and it | 143 | * Note that if the raw queries fail, it's not a hard failure and it |
142 | * is safe to continue | 144 | * is safe to continue |
143 | */ | 145 | */ |
144 | dev_warn(&hdev->dev, "failed to poke device, command %d, err %d\n", | 146 | hid_warn(hdev, "failed to poke device, command %d, err %d\n", |
145 | rep_data[0], ret); | 147 | rep_data[0], ret); |
146 | return; | 148 | return; |
147 | } | 149 | } |
148 | 150 | ||
@@ -172,7 +174,7 @@ static ssize_t wacom_store_speed(struct device *dev, | |||
172 | return -EINVAL; | 174 | return -EINVAL; |
173 | } | 175 | } |
174 | 176 | ||
175 | static DEVICE_ATTR(speed, S_IRUGO | S_IWUGO, | 177 | static DEVICE_ATTR(speed, S_IRUGO | S_IWUSR | S_IWGRP, |
176 | wacom_show_speed, wacom_store_speed); | 178 | wacom_show_speed, wacom_store_speed); |
177 | 179 | ||
178 | static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report, | 180 | static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report, |
@@ -312,7 +314,7 @@ static int wacom_probe(struct hid_device *hdev, | |||
312 | 314 | ||
313 | wdata = kzalloc(sizeof(*wdata), GFP_KERNEL); | 315 | wdata = kzalloc(sizeof(*wdata), GFP_KERNEL); |
314 | if (wdata == NULL) { | 316 | if (wdata == NULL) { |
315 | dev_err(&hdev->dev, "can't alloc wacom descriptor\n"); | 317 | hid_err(hdev, "can't alloc wacom descriptor\n"); |
316 | return -ENOMEM; | 318 | return -ENOMEM; |
317 | } | 319 | } |
318 | 320 | ||
@@ -321,20 +323,20 @@ static int wacom_probe(struct hid_device *hdev, | |||
321 | /* Parse the HID report now */ | 323 | /* Parse the HID report now */ |
322 | ret = hid_parse(hdev); | 324 | ret = hid_parse(hdev); |
323 | if (ret) { | 325 | if (ret) { |
324 | dev_err(&hdev->dev, "parse failed\n"); | 326 | hid_err(hdev, "parse failed\n"); |
325 | goto err_free; | 327 | goto err_free; |
326 | } | 328 | } |
327 | 329 | ||
328 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); | 330 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); |
329 | if (ret) { | 331 | if (ret) { |
330 | dev_err(&hdev->dev, "hw start failed\n"); | 332 | hid_err(hdev, "hw start failed\n"); |
331 | goto err_free; | 333 | goto err_free; |
332 | } | 334 | } |
333 | 335 | ||
334 | ret = device_create_file(&hdev->dev, &dev_attr_speed); | 336 | ret = device_create_file(&hdev->dev, &dev_attr_speed); |
335 | if (ret) | 337 | if (ret) |
336 | dev_warn(&hdev->dev, | 338 | hid_warn(hdev, |
337 | "can't create sysfs speed attribute err: %d\n", ret); | 339 | "can't create sysfs speed attribute err: %d\n", ret); |
338 | 340 | ||
339 | /* Set Wacom mode 2 with high reporting speed */ | 341 | /* Set Wacom mode 2 with high reporting speed */ |
340 | wacom_poke(hdev, 1); | 342 | wacom_poke(hdev, 1); |
@@ -349,8 +351,8 @@ static int wacom_probe(struct hid_device *hdev, | |||
349 | 351 | ||
350 | ret = power_supply_register(&hdev->dev, &wdata->battery); | 352 | ret = power_supply_register(&hdev->dev, &wdata->battery); |
351 | if (ret) { | 353 | if (ret) { |
352 | dev_warn(&hdev->dev, | 354 | hid_warn(hdev, "can't create sysfs battery attribute, err: %d\n", |
353 | "can't create sysfs battery attribute, err: %d\n", ret); | 355 | ret); |
354 | /* | 356 | /* |
355 | * battery attribute is not critical for the tablet, but if it | 357 | * battery attribute is not critical for the tablet, but if it |
356 | * failed then there is no need to create ac attribute | 358 | * failed then there is no need to create ac attribute |
@@ -367,8 +369,8 @@ static int wacom_probe(struct hid_device *hdev, | |||
367 | 369 | ||
368 | ret = power_supply_register(&hdev->dev, &wdata->ac); | 370 | ret = power_supply_register(&hdev->dev, &wdata->ac); |
369 | if (ret) { | 371 | if (ret) { |
370 | dev_warn(&hdev->dev, | 372 | hid_warn(hdev, |
371 | "can't create ac battery attribute, err: %d\n", ret); | 373 | "can't create ac battery attribute, err: %d\n", ret); |
372 | /* | 374 | /* |
373 | * ac attribute is not critical for the tablet, but if it | 375 | * ac attribute is not critical for the tablet, but if it |
374 | * failed then we don't want to battery attribute to exist | 376 | * failed then we don't want to battery attribute to exist |
@@ -454,7 +456,7 @@ static int __init wacom_init(void) | |||
454 | 456 | ||
455 | ret = hid_register_driver(&wacom_driver); | 457 | ret = hid_register_driver(&wacom_driver); |
456 | if (ret) | 458 | if (ret) |
457 | printk(KERN_ERR "can't register wacom driver\n"); | 459 | pr_err("can't register wacom driver\n"); |
458 | return ret; | 460 | return ret; |
459 | } | 461 | } |
460 | 462 | ||
diff --git a/drivers/hid/hid-zpff.c b/drivers/hid/hid-zpff.c index b7acceabba80..f31fab012f2f 100644 --- a/drivers/hid/hid-zpff.c +++ b/drivers/hid/hid-zpff.c | |||
@@ -75,14 +75,14 @@ static int zpff_init(struct hid_device *hid) | |||
75 | int error; | 75 | int error; |
76 | 76 | ||
77 | if (list_empty(report_list)) { | 77 | if (list_empty(report_list)) { |
78 | dev_err(&hid->dev, "no output report found\n"); | 78 | hid_err(hid, "no output report found\n"); |
79 | return -ENODEV; | 79 | return -ENODEV; |
80 | } | 80 | } |
81 | 81 | ||
82 | report = list_entry(report_list->next, struct hid_report, list); | 82 | report = list_entry(report_list->next, struct hid_report, list); |
83 | 83 | ||
84 | if (report->maxfield < 4) { | 84 | if (report->maxfield < 4) { |
85 | dev_err(&hid->dev, "not enough fields in report\n"); | 85 | hid_err(hid, "not enough fields in report\n"); |
86 | return -ENODEV; | 86 | return -ENODEV; |
87 | } | 87 | } |
88 | 88 | ||
@@ -105,8 +105,7 @@ static int zpff_init(struct hid_device *hid) | |||
105 | zpff->report->field[3]->value[0] = 0x00; | 105 | zpff->report->field[3]->value[0] = 0x00; |
106 | usbhid_submit_report(hid, zpff->report, USB_DIR_OUT); | 106 | usbhid_submit_report(hid, zpff->report, USB_DIR_OUT); |
107 | 107 | ||
108 | dev_info(&hid->dev, "force feedback for Zeroplus based devices by " | 108 | hid_info(hid, "force feedback for Zeroplus based devices by Anssi Hannula <anssi.hannula@gmail.com>\n"); |
109 | "Anssi Hannula <anssi.hannula@gmail.com>\n"); | ||
110 | 109 | ||
111 | return 0; | 110 | return 0; |
112 | } | 111 | } |
@@ -123,13 +122,13 @@ static int zp_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
123 | 122 | ||
124 | ret = hid_parse(hdev); | 123 | ret = hid_parse(hdev); |
125 | if (ret) { | 124 | if (ret) { |
126 | dev_err(&hdev->dev, "parse failed\n"); | 125 | hid_err(hdev, "parse failed\n"); |
127 | goto err; | 126 | goto err; |
128 | } | 127 | } |
129 | 128 | ||
130 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF); | 129 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF); |
131 | if (ret) { | 130 | if (ret) { |
132 | dev_err(&hdev->dev, "hw start failed\n"); | 131 | hid_err(hdev, "hw start failed\n"); |
133 | goto err; | 132 | goto err; |
134 | } | 133 | } |
135 | 134 | ||
diff --git a/drivers/hid/hid-zydacron.c b/drivers/hid/hid-zydacron.c index aac1f9273149..e90371508fd2 100644 --- a/drivers/hid/hid-zydacron.c +++ b/drivers/hid/hid-zydacron.c | |||
@@ -34,9 +34,8 @@ static __u8 *zc_report_fixup(struct hid_device *hdev, __u8 *rdesc, | |||
34 | rdesc[0x96] == 0xbc && rdesc[0x97] == 0xff && | 34 | rdesc[0x96] == 0xbc && rdesc[0x97] == 0xff && |
35 | rdesc[0xca] == 0xbc && rdesc[0xcb] == 0xff && | 35 | rdesc[0xca] == 0xbc && rdesc[0xcb] == 0xff && |
36 | rdesc[0xe1] == 0xbc && rdesc[0xe2] == 0xff) { | 36 | rdesc[0xe1] == 0xbc && rdesc[0xe2] == 0xff) { |
37 | dev_info(&hdev->dev, | 37 | hid_info(hdev, |
38 | "fixing up zydacron remote control report " | 38 | "fixing up zydacron remote control report descriptor\n"); |
39 | "descriptor\n"); | ||
40 | rdesc[0x96] = rdesc[0xca] = rdesc[0xe1] = 0x0c; | 39 | rdesc[0x96] = rdesc[0xca] = rdesc[0xe1] = 0x0c; |
41 | rdesc[0x97] = rdesc[0xcb] = rdesc[0xe2] = 0x00; | 40 | rdesc[0x97] = rdesc[0xcb] = rdesc[0xe2] = 0x00; |
42 | } | 41 | } |
@@ -172,7 +171,7 @@ static int zc_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
172 | 171 | ||
173 | zc = kzalloc(sizeof(*zc), GFP_KERNEL); | 172 | zc = kzalloc(sizeof(*zc), GFP_KERNEL); |
174 | if (zc == NULL) { | 173 | if (zc == NULL) { |
175 | dev_err(&hdev->dev, "zydacron: can't alloc descriptor\n"); | 174 | hid_err(hdev, "can't alloc descriptor\n"); |
176 | return -ENOMEM; | 175 | return -ENOMEM; |
177 | } | 176 | } |
178 | 177 | ||
@@ -180,13 +179,13 @@ static int zc_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
180 | 179 | ||
181 | ret = hid_parse(hdev); | 180 | ret = hid_parse(hdev); |
182 | if (ret) { | 181 | if (ret) { |
183 | dev_err(&hdev->dev, "zydacron: parse failed\n"); | 182 | hid_err(hdev, "parse failed\n"); |
184 | goto err_free; | 183 | goto err_free; |
185 | } | 184 | } |
186 | 185 | ||
187 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); | 186 | ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT); |
188 | if (ret) { | 187 | if (ret) { |
189 | dev_err(&hdev->dev, "zydacron: hw start failed\n"); | 188 | hid_err(hdev, "hw start failed\n"); |
190 | goto err_free; | 189 | goto err_free; |
191 | } | 190 | } |
192 | 191 | ||
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c index e1f07483691f..468e87b53ed2 100644 --- a/drivers/hid/hidraw.c +++ b/drivers/hid/hidraw.c | |||
@@ -19,6 +19,8 @@ | |||
19 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | 19 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
23 | |||
22 | #include <linux/fs.h> | 24 | #include <linux/fs.h> |
23 | #include <linux/module.h> | 25 | #include <linux/module.h> |
24 | #include <linux/errno.h> | 26 | #include <linux/errno.h> |
@@ -122,15 +124,15 @@ static ssize_t hidraw_write(struct file *file, const char __user *buffer, size_t | |||
122 | } | 124 | } |
123 | 125 | ||
124 | if (count > HID_MAX_BUFFER_SIZE) { | 126 | if (count > HID_MAX_BUFFER_SIZE) { |
125 | printk(KERN_WARNING "hidraw: pid %d passed too large report\n", | 127 | hid_warn(dev, "pid %d passed too large report\n", |
126 | task_pid_nr(current)); | 128 | task_pid_nr(current)); |
127 | ret = -EINVAL; | 129 | ret = -EINVAL; |
128 | goto out; | 130 | goto out; |
129 | } | 131 | } |
130 | 132 | ||
131 | if (count < 2) { | 133 | if (count < 2) { |
132 | printk(KERN_WARNING "hidraw: pid %d passed too short report\n", | 134 | hid_warn(dev, "pid %d passed too short report\n", |
133 | task_pid_nr(current)); | 135 | task_pid_nr(current)); |
134 | ret = -EINVAL; | 136 | ret = -EINVAL; |
135 | goto out; | 137 | goto out; |
136 | } | 138 | } |
@@ -192,15 +194,13 @@ static int hidraw_open(struct inode *inode, struct file *file) | |||
192 | 194 | ||
193 | dev = hidraw_table[minor]; | 195 | dev = hidraw_table[minor]; |
194 | if (!dev->open++) { | 196 | if (!dev->open++) { |
195 | if (dev->hid->ll_driver->power) { | 197 | err = hid_hw_power(dev->hid, PM_HINT_FULLON); |
196 | err = dev->hid->ll_driver->power(dev->hid, PM_HINT_FULLON); | 198 | if (err < 0) |
197 | if (err < 0) | 199 | goto out_unlock; |
198 | goto out_unlock; | 200 | |
199 | } | 201 | err = hid_hw_open(dev->hid); |
200 | err = dev->hid->ll_driver->open(dev->hid); | ||
201 | if (err < 0) { | 202 | if (err < 0) { |
202 | if (dev->hid->ll_driver->power) | 203 | hid_hw_power(dev->hid, PM_HINT_NORMAL); |
203 | dev->hid->ll_driver->power(dev->hid, PM_HINT_NORMAL); | ||
204 | dev->open--; | 204 | dev->open--; |
205 | } | 205 | } |
206 | } | 206 | } |
@@ -229,9 +229,8 @@ static int hidraw_release(struct inode * inode, struct file * file) | |||
229 | dev = hidraw_table[minor]; | 229 | dev = hidraw_table[minor]; |
230 | if (!--dev->open) { | 230 | if (!--dev->open) { |
231 | if (list->hidraw->exist) { | 231 | if (list->hidraw->exist) { |
232 | if (dev->hid->ll_driver->power) | 232 | hid_hw_power(dev->hid, PM_HINT_NORMAL); |
233 | dev->hid->ll_driver->power(dev->hid, PM_HINT_NORMAL); | 233 | hid_hw_close(dev->hid); |
234 | dev->hid->ll_driver->close(dev->hid); | ||
235 | } else { | 234 | } else { |
236 | kfree(list->hidraw); | 235 | kfree(list->hidraw); |
237 | } | 236 | } |
@@ -345,6 +344,9 @@ static const struct file_operations hidraw_ops = { | |||
345 | .open = hidraw_open, | 344 | .open = hidraw_open, |
346 | .release = hidraw_release, | 345 | .release = hidraw_release, |
347 | .unlocked_ioctl = hidraw_ioctl, | 346 | .unlocked_ioctl = hidraw_ioctl, |
347 | #ifdef CONFIG_COMPAT | ||
348 | .compat_ioctl = hidraw_ioctl, | ||
349 | #endif | ||
348 | .llseek = noop_llseek, | 350 | .llseek = noop_llseek, |
349 | }; | 351 | }; |
350 | 352 | ||
@@ -433,7 +435,7 @@ void hidraw_disconnect(struct hid_device *hid) | |||
433 | device_destroy(hidraw_class, MKDEV(hidraw_major, hidraw->minor)); | 435 | device_destroy(hidraw_class, MKDEV(hidraw_major, hidraw->minor)); |
434 | 436 | ||
435 | if (hidraw->open) { | 437 | if (hidraw->open) { |
436 | hid->ll_driver->close(hid); | 438 | hid_hw_close(hid); |
437 | wake_up_interruptible(&hidraw->wait); | 439 | wake_up_interruptible(&hidraw->wait); |
438 | } else { | 440 | } else { |
439 | kfree(hidraw); | 441 | kfree(hidraw); |
@@ -452,7 +454,7 @@ int __init hidraw_init(void) | |||
452 | hidraw_major = MAJOR(dev_id); | 454 | hidraw_major = MAJOR(dev_id); |
453 | 455 | ||
454 | if (result < 0) { | 456 | if (result < 0) { |
455 | printk(KERN_WARNING "hidraw: can't get major number\n"); | 457 | pr_warn("can't get major number\n"); |
456 | result = 0; | 458 | result = 0; |
457 | goto out; | 459 | goto out; |
458 | } | 460 | } |
diff --git a/drivers/hid/usbhid/Makefile b/drivers/hid/usbhid/Makefile index 1329ecb37a1c..db3cf31c6fa1 100644 --- a/drivers/hid/usbhid/Makefile +++ b/drivers/hid/usbhid/Makefile | |||
@@ -3,15 +3,15 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | # Multipart objects. | 5 | # Multipart objects. |
6 | usbhid-objs := hid-core.o hid-quirks.o | 6 | usbhid-y := hid-core.o hid-quirks.o |
7 | 7 | ||
8 | # Optional parts of multipart objects. | 8 | # Optional parts of multipart objects. |
9 | 9 | ||
10 | ifeq ($(CONFIG_USB_HIDDEV),y) | 10 | ifeq ($(CONFIG_USB_HIDDEV),y) |
11 | usbhid-objs += hiddev.o | 11 | usbhid-y += hiddev.o |
12 | endif | 12 | endif |
13 | ifeq ($(CONFIG_HID_PID),y) | 13 | ifeq ($(CONFIG_HID_PID),y) |
14 | usbhid-objs += hid-pidff.o | 14 | usbhid-y += hid-pidff.o |
15 | endif | 15 | endif |
16 | 16 | ||
17 | obj-$(CONFIG_USB_HID) += usbhid.o | 17 | obj-$(CONFIG_USB_HID) += usbhid.o |
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c index 5489eab3a6bd..b336dd84036f 100644 --- a/drivers/hid/usbhid/hid-core.c +++ b/drivers/hid/usbhid/hid-core.c | |||
@@ -67,7 +67,6 @@ MODULE_PARM_DESC(quirks, "Add/modify USB HID quirks by specifying " | |||
67 | * Input submission and I/O error handler. | 67 | * Input submission and I/O error handler. |
68 | */ | 68 | */ |
69 | static DEFINE_MUTEX(hid_open_mut); | 69 | static DEFINE_MUTEX(hid_open_mut); |
70 | static struct workqueue_struct *resumption_waker; | ||
71 | 70 | ||
72 | static void hid_io_error(struct hid_device *hid); | 71 | static void hid_io_error(struct hid_device *hid); |
73 | static int hid_submit_out(struct hid_device *hid); | 72 | static int hid_submit_out(struct hid_device *hid); |
@@ -136,10 +135,10 @@ static void hid_reset(struct work_struct *work) | |||
136 | hid_io_error(hid); | 135 | hid_io_error(hid); |
137 | break; | 136 | break; |
138 | default: | 137 | default: |
139 | err_hid("can't reset device, %s-%s/input%d, status %d", | 138 | hid_err(hid, "can't reset device, %s-%s/input%d, status %d\n", |
140 | hid_to_usb_dev(hid)->bus->bus_name, | 139 | hid_to_usb_dev(hid)->bus->bus_name, |
141 | hid_to_usb_dev(hid)->devpath, | 140 | hid_to_usb_dev(hid)->devpath, |
142 | usbhid->ifnum, rc); | 141 | usbhid->ifnum, rc); |
143 | /* FALLTHROUGH */ | 142 | /* FALLTHROUGH */ |
144 | case -EHOSTUNREACH: | 143 | case -EHOSTUNREACH: |
145 | case -ENODEV: | 144 | case -ENODEV: |
@@ -278,18 +277,18 @@ static void hid_irq_in(struct urb *urb) | |||
278 | hid_io_error(hid); | 277 | hid_io_error(hid); |
279 | return; | 278 | return; |
280 | default: /* error */ | 279 | default: /* error */ |
281 | dev_warn(&urb->dev->dev, "input irq status %d " | 280 | hid_warn(urb->dev, "input irq status %d received\n", |
282 | "received\n", urb->status); | 281 | urb->status); |
283 | } | 282 | } |
284 | 283 | ||
285 | status = usb_submit_urb(urb, GFP_ATOMIC); | 284 | status = usb_submit_urb(urb, GFP_ATOMIC); |
286 | if (status) { | 285 | if (status) { |
287 | clear_bit(HID_IN_RUNNING, &usbhid->iofl); | 286 | clear_bit(HID_IN_RUNNING, &usbhid->iofl); |
288 | if (status != -EPERM) { | 287 | if (status != -EPERM) { |
289 | err_hid("can't resubmit intr, %s-%s/input%d, status %d", | 288 | hid_err(hid, "can't resubmit intr, %s-%s/input%d, status %d\n", |
290 | hid_to_usb_dev(hid)->bus->bus_name, | 289 | hid_to_usb_dev(hid)->bus->bus_name, |
291 | hid_to_usb_dev(hid)->devpath, | 290 | hid_to_usb_dev(hid)->devpath, |
292 | usbhid->ifnum, status); | 291 | usbhid->ifnum, status); |
293 | hid_io_error(hid); | 292 | hid_io_error(hid); |
294 | } | 293 | } |
295 | } | 294 | } |
@@ -300,10 +299,19 @@ static int hid_submit_out(struct hid_device *hid) | |||
300 | struct hid_report *report; | 299 | struct hid_report *report; |
301 | char *raw_report; | 300 | char *raw_report; |
302 | struct usbhid_device *usbhid = hid->driver_data; | 301 | struct usbhid_device *usbhid = hid->driver_data; |
302 | int r; | ||
303 | 303 | ||
304 | report = usbhid->out[usbhid->outtail].report; | 304 | report = usbhid->out[usbhid->outtail].report; |
305 | raw_report = usbhid->out[usbhid->outtail].raw_report; | 305 | raw_report = usbhid->out[usbhid->outtail].raw_report; |
306 | 306 | ||
307 | r = usb_autopm_get_interface_async(usbhid->intf); | ||
308 | if (r < 0) | ||
309 | return -1; | ||
310 | |||
311 | /* | ||
312 | * if the device hasn't been woken, we leave the output | ||
313 | * to resume() | ||
314 | */ | ||
307 | if (!test_bit(HID_REPORTED_IDLE, &usbhid->iofl)) { | 315 | if (!test_bit(HID_REPORTED_IDLE, &usbhid->iofl)) { |
308 | usbhid->urbout->transfer_buffer_length = ((report->size - 1) >> 3) + 1 + (report->id > 0); | 316 | usbhid->urbout->transfer_buffer_length = ((report->size - 1) >> 3) + 1 + (report->id > 0); |
309 | usbhid->urbout->dev = hid_to_usb_dev(hid); | 317 | usbhid->urbout->dev = hid_to_usb_dev(hid); |
@@ -313,17 +321,11 @@ static int hid_submit_out(struct hid_device *hid) | |||
313 | dbg_hid("submitting out urb\n"); | 321 | dbg_hid("submitting out urb\n"); |
314 | 322 | ||
315 | if (usb_submit_urb(usbhid->urbout, GFP_ATOMIC)) { | 323 | if (usb_submit_urb(usbhid->urbout, GFP_ATOMIC)) { |
316 | err_hid("usb_submit_urb(out) failed"); | 324 | hid_err(hid, "usb_submit_urb(out) failed\n"); |
325 | usb_autopm_put_interface_async(usbhid->intf); | ||
317 | return -1; | 326 | return -1; |
318 | } | 327 | } |
319 | usbhid->last_out = jiffies; | 328 | usbhid->last_out = jiffies; |
320 | } else { | ||
321 | /* | ||
322 | * queue work to wake up the device. | ||
323 | * as the work queue is freezeable, this is safe | ||
324 | * with respect to STD and STR | ||
325 | */ | ||
326 | queue_work(resumption_waker, &usbhid->restart_work); | ||
327 | } | 329 | } |
328 | 330 | ||
329 | return 0; | 331 | return 0; |
@@ -334,13 +336,16 @@ static int hid_submit_ctrl(struct hid_device *hid) | |||
334 | struct hid_report *report; | 336 | struct hid_report *report; |
335 | unsigned char dir; | 337 | unsigned char dir; |
336 | char *raw_report; | 338 | char *raw_report; |
337 | int len; | 339 | int len, r; |
338 | struct usbhid_device *usbhid = hid->driver_data; | 340 | struct usbhid_device *usbhid = hid->driver_data; |
339 | 341 | ||
340 | report = usbhid->ctrl[usbhid->ctrltail].report; | 342 | report = usbhid->ctrl[usbhid->ctrltail].report; |
341 | raw_report = usbhid->ctrl[usbhid->ctrltail].raw_report; | 343 | raw_report = usbhid->ctrl[usbhid->ctrltail].raw_report; |
342 | dir = usbhid->ctrl[usbhid->ctrltail].dir; | 344 | dir = usbhid->ctrl[usbhid->ctrltail].dir; |
343 | 345 | ||
346 | r = usb_autopm_get_interface_async(usbhid->intf); | ||
347 | if (r < 0) | ||
348 | return -1; | ||
344 | if (!test_bit(HID_REPORTED_IDLE, &usbhid->iofl)) { | 349 | if (!test_bit(HID_REPORTED_IDLE, &usbhid->iofl)) { |
345 | len = ((report->size - 1) >> 3) + 1 + (report->id > 0); | 350 | len = ((report->size - 1) >> 3) + 1 + (report->id > 0); |
346 | if (dir == USB_DIR_OUT) { | 351 | if (dir == USB_DIR_OUT) { |
@@ -375,17 +380,11 @@ static int hid_submit_ctrl(struct hid_device *hid) | |||
375 | usbhid->cr->wValue, usbhid->cr->wIndex, usbhid->cr->wLength); | 380 | usbhid->cr->wValue, usbhid->cr->wIndex, usbhid->cr->wLength); |
376 | 381 | ||
377 | if (usb_submit_urb(usbhid->urbctrl, GFP_ATOMIC)) { | 382 | if (usb_submit_urb(usbhid->urbctrl, GFP_ATOMIC)) { |
378 | err_hid("usb_submit_urb(ctrl) failed"); | 383 | usb_autopm_put_interface_async(usbhid->intf); |
384 | hid_err(hid, "usb_submit_urb(ctrl) failed\n"); | ||
379 | return -1; | 385 | return -1; |
380 | } | 386 | } |
381 | usbhid->last_ctrl = jiffies; | 387 | usbhid->last_ctrl = jiffies; |
382 | } else { | ||
383 | /* | ||
384 | * queue work to wake up the device. | ||
385 | * as the work queue is freezeable, this is safe | ||
386 | * with respect to STD and STR | ||
387 | */ | ||
388 | queue_work(resumption_waker, &usbhid->restart_work); | ||
389 | } | 388 | } |
390 | 389 | ||
391 | return 0; | 390 | return 0; |
@@ -413,8 +412,8 @@ static void hid_irq_out(struct urb *urb) | |||
413 | case -ENOENT: | 412 | case -ENOENT: |
414 | break; | 413 | break; |
415 | default: /* error */ | 414 | default: /* error */ |
416 | dev_warn(&urb->dev->dev, "output irq status %d " | 415 | hid_warn(urb->dev, "output irq status %d received\n", |
417 | "received\n", urb->status); | 416 | urb->status); |
418 | } | 417 | } |
419 | 418 | ||
420 | spin_lock_irqsave(&usbhid->lock, flags); | 419 | spin_lock_irqsave(&usbhid->lock, flags); |
@@ -435,6 +434,7 @@ static void hid_irq_out(struct urb *urb) | |||
435 | 434 | ||
436 | clear_bit(HID_OUT_RUNNING, &usbhid->iofl); | 435 | clear_bit(HID_OUT_RUNNING, &usbhid->iofl); |
437 | spin_unlock_irqrestore(&usbhid->lock, flags); | 436 | spin_unlock_irqrestore(&usbhid->lock, flags); |
437 | usb_autopm_put_interface_async(usbhid->intf); | ||
438 | wake_up(&usbhid->wait); | 438 | wake_up(&usbhid->wait); |
439 | } | 439 | } |
440 | 440 | ||
@@ -466,8 +466,7 @@ static void hid_ctrl(struct urb *urb) | |||
466 | case -EPIPE: /* report not available */ | 466 | case -EPIPE: /* report not available */ |
467 | break; | 467 | break; |
468 | default: /* error */ | 468 | default: /* error */ |
469 | dev_warn(&urb->dev->dev, "ctrl urb status %d " | 469 | hid_warn(urb->dev, "ctrl urb status %d received\n", status); |
470 | "received\n", status); | ||
471 | } | 470 | } |
472 | 471 | ||
473 | if (unplug) | 472 | if (unplug) |
@@ -481,11 +480,13 @@ static void hid_ctrl(struct urb *urb) | |||
481 | wake_up(&usbhid->wait); | 480 | wake_up(&usbhid->wait); |
482 | } | 481 | } |
483 | spin_unlock(&usbhid->lock); | 482 | spin_unlock(&usbhid->lock); |
483 | usb_autopm_put_interface_async(usbhid->intf); | ||
484 | return; | 484 | return; |
485 | } | 485 | } |
486 | 486 | ||
487 | clear_bit(HID_CTRL_RUNNING, &usbhid->iofl); | 487 | clear_bit(HID_CTRL_RUNNING, &usbhid->iofl); |
488 | spin_unlock(&usbhid->lock); | 488 | spin_unlock(&usbhid->lock); |
489 | usb_autopm_put_interface_async(usbhid->intf); | ||
489 | wake_up(&usbhid->wait); | 490 | wake_up(&usbhid->wait); |
490 | } | 491 | } |
491 | 492 | ||
@@ -501,13 +502,13 @@ static void __usbhid_submit_report(struct hid_device *hid, struct hid_report *re | |||
501 | 502 | ||
502 | if (usbhid->urbout && dir == USB_DIR_OUT && report->type == HID_OUTPUT_REPORT) { | 503 | if (usbhid->urbout && dir == USB_DIR_OUT && report->type == HID_OUTPUT_REPORT) { |
503 | if ((head = (usbhid->outhead + 1) & (HID_OUTPUT_FIFO_SIZE - 1)) == usbhid->outtail) { | 504 | if ((head = (usbhid->outhead + 1) & (HID_OUTPUT_FIFO_SIZE - 1)) == usbhid->outtail) { |
504 | dev_warn(&hid->dev, "output queue full\n"); | 505 | hid_warn(hid, "output queue full\n"); |
505 | return; | 506 | return; |
506 | } | 507 | } |
507 | 508 | ||
508 | usbhid->out[usbhid->outhead].raw_report = kmalloc(len, GFP_ATOMIC); | 509 | usbhid->out[usbhid->outhead].raw_report = kmalloc(len, GFP_ATOMIC); |
509 | if (!usbhid->out[usbhid->outhead].raw_report) { | 510 | if (!usbhid->out[usbhid->outhead].raw_report) { |
510 | dev_warn(&hid->dev, "output queueing failed\n"); | 511 | hid_warn(hid, "output queueing failed\n"); |
511 | return; | 512 | return; |
512 | } | 513 | } |
513 | hid_output_report(report, usbhid->out[usbhid->outhead].raw_report); | 514 | hid_output_report(report, usbhid->out[usbhid->outhead].raw_report); |
@@ -532,14 +533,14 @@ static void __usbhid_submit_report(struct hid_device *hid, struct hid_report *re | |||
532 | } | 533 | } |
533 | 534 | ||
534 | if ((head = (usbhid->ctrlhead + 1) & (HID_CONTROL_FIFO_SIZE - 1)) == usbhid->ctrltail) { | 535 | if ((head = (usbhid->ctrlhead + 1) & (HID_CONTROL_FIFO_SIZE - 1)) == usbhid->ctrltail) { |
535 | dev_warn(&hid->dev, "control queue full\n"); | 536 | hid_warn(hid, "control queue full\n"); |
536 | return; | 537 | return; |
537 | } | 538 | } |
538 | 539 | ||
539 | if (dir == USB_DIR_OUT) { | 540 | if (dir == USB_DIR_OUT) { |
540 | usbhid->ctrl[usbhid->ctrlhead].raw_report = kmalloc(len, GFP_ATOMIC); | 541 | usbhid->ctrl[usbhid->ctrlhead].raw_report = kmalloc(len, GFP_ATOMIC); |
541 | if (!usbhid->ctrl[usbhid->ctrlhead].raw_report) { | 542 | if (!usbhid->ctrl[usbhid->ctrlhead].raw_report) { |
542 | dev_warn(&hid->dev, "control queueing failed\n"); | 543 | hid_warn(hid, "control queueing failed\n"); |
543 | return; | 544 | return; |
544 | } | 545 | } |
545 | hid_output_report(report, usbhid->ctrl[usbhid->ctrlhead].raw_report); | 546 | hid_output_report(report, usbhid->ctrl[usbhid->ctrlhead].raw_report); |
@@ -590,7 +591,7 @@ static int usb_hidinput_input_event(struct input_dev *dev, unsigned int type, un | |||
590 | return -1; | 591 | return -1; |
591 | 592 | ||
592 | if ((offset = hidinput_find_field(hid, type, code, &field)) == -1) { | 593 | if ((offset = hidinput_find_field(hid, type, code, &field)) == -1) { |
593 | dev_warn(&dev->dev, "event field not found\n"); | 594 | hid_warn(dev, "event field not found\n"); |
594 | return -1; | 595 | return -1; |
595 | } | 596 | } |
596 | 597 | ||
@@ -656,7 +657,7 @@ int usbhid_open(struct hid_device *hid) | |||
656 | mutex_lock(&hid_open_mut); | 657 | mutex_lock(&hid_open_mut); |
657 | if (!hid->open++) { | 658 | if (!hid->open++) { |
658 | res = usb_autopm_get_interface(usbhid->intf); | 659 | res = usb_autopm_get_interface(usbhid->intf); |
659 | /* the device must be awake to reliable request remote wakeup */ | 660 | /* the device must be awake to reliably request remote wakeup */ |
660 | if (res < 0) { | 661 | if (res < 0) { |
661 | hid->open--; | 662 | hid->open--; |
662 | mutex_unlock(&hid_open_mut); | 663 | mutex_unlock(&hid_open_mut); |
@@ -722,7 +723,7 @@ void usbhid_init_reports(struct hid_device *hid) | |||
722 | } | 723 | } |
723 | 724 | ||
724 | if (err) | 725 | if (err) |
725 | dev_warn(&hid->dev, "timeout initializing reports\n"); | 726 | hid_warn(hid, "timeout initializing reports\n"); |
726 | } | 727 | } |
727 | 728 | ||
728 | /* | 729 | /* |
@@ -857,18 +858,6 @@ static void usbhid_restart_queues(struct usbhid_device *usbhid) | |||
857 | usbhid_restart_ctrl_queue(usbhid); | 858 | usbhid_restart_ctrl_queue(usbhid); |
858 | } | 859 | } |
859 | 860 | ||
860 | static void __usbhid_restart_queues(struct work_struct *work) | ||
861 | { | ||
862 | struct usbhid_device *usbhid = | ||
863 | container_of(work, struct usbhid_device, restart_work); | ||
864 | int r; | ||
865 | |||
866 | r = usb_autopm_get_interface(usbhid->intf); | ||
867 | if (r < 0) | ||
868 | return; | ||
869 | usb_autopm_put_interface(usbhid->intf); | ||
870 | } | ||
871 | |||
872 | static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid) | 861 | static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid) |
873 | { | 862 | { |
874 | struct usbhid_device *usbhid = hid->driver_data; | 863 | struct usbhid_device *usbhid = hid->driver_data; |
@@ -1140,8 +1129,7 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id * | |||
1140 | if (usb_endpoint_is_int_in(&interface->endpoint[n].desc)) | 1129 | if (usb_endpoint_is_int_in(&interface->endpoint[n].desc)) |
1141 | has_in++; | 1130 | has_in++; |
1142 | if (!has_in) { | 1131 | if (!has_in) { |
1143 | dev_err(&intf->dev, "couldn't find an input interrupt " | 1132 | hid_err(intf, "couldn't find an input interrupt endpoint\n"); |
1144 | "endpoint\n"); | ||
1145 | return -ENODEV; | 1133 | return -ENODEV; |
1146 | } | 1134 | } |
1147 | 1135 | ||
@@ -1206,14 +1194,13 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id * | |||
1206 | 1194 | ||
1207 | init_waitqueue_head(&usbhid->wait); | 1195 | init_waitqueue_head(&usbhid->wait); |
1208 | INIT_WORK(&usbhid->reset_work, hid_reset); | 1196 | INIT_WORK(&usbhid->reset_work, hid_reset); |
1209 | INIT_WORK(&usbhid->restart_work, __usbhid_restart_queues); | ||
1210 | setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid); | 1197 | setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid); |
1211 | spin_lock_init(&usbhid->lock); | 1198 | spin_lock_init(&usbhid->lock); |
1212 | 1199 | ||
1213 | ret = hid_add_device(hid); | 1200 | ret = hid_add_device(hid); |
1214 | if (ret) { | 1201 | if (ret) { |
1215 | if (ret != -ENODEV) | 1202 | if (ret != -ENODEV) |
1216 | dev_err(&intf->dev, "can't add hid device: %d\n", ret); | 1203 | hid_err(intf, "can't add hid device: %d\n", ret); |
1217 | goto err_free; | 1204 | goto err_free; |
1218 | } | 1205 | } |
1219 | 1206 | ||
@@ -1241,7 +1228,6 @@ static void usbhid_disconnect(struct usb_interface *intf) | |||
1241 | static void hid_cancel_delayed_stuff(struct usbhid_device *usbhid) | 1228 | static void hid_cancel_delayed_stuff(struct usbhid_device *usbhid) |
1242 | { | 1229 | { |
1243 | del_timer_sync(&usbhid->io_retry); | 1230 | del_timer_sync(&usbhid->io_retry); |
1244 | cancel_work_sync(&usbhid->restart_work); | ||
1245 | cancel_work_sync(&usbhid->reset_work); | 1231 | cancel_work_sync(&usbhid->reset_work); |
1246 | } | 1232 | } |
1247 | 1233 | ||
@@ -1262,7 +1248,6 @@ static int hid_pre_reset(struct usb_interface *intf) | |||
1262 | spin_lock_irq(&usbhid->lock); | 1248 | spin_lock_irq(&usbhid->lock); |
1263 | set_bit(HID_RESET_PENDING, &usbhid->iofl); | 1249 | set_bit(HID_RESET_PENDING, &usbhid->iofl); |
1264 | spin_unlock_irq(&usbhid->lock); | 1250 | spin_unlock_irq(&usbhid->lock); |
1265 | cancel_work_sync(&usbhid->restart_work); | ||
1266 | hid_cease_io(usbhid); | 1251 | hid_cease_io(usbhid); |
1267 | 1252 | ||
1268 | return 0; | 1253 | return 0; |
@@ -1461,9 +1446,6 @@ static int __init hid_init(void) | |||
1461 | { | 1446 | { |
1462 | int retval = -ENOMEM; | 1447 | int retval = -ENOMEM; |
1463 | 1448 | ||
1464 | resumption_waker = create_freezeable_workqueue("usbhid_resumer"); | ||
1465 | if (!resumption_waker) | ||
1466 | goto no_queue; | ||
1467 | retval = hid_register_driver(&hid_usb_driver); | 1449 | retval = hid_register_driver(&hid_usb_driver); |
1468 | if (retval) | 1450 | if (retval) |
1469 | goto hid_register_fail; | 1451 | goto hid_register_fail; |
@@ -1481,8 +1463,6 @@ usb_register_fail: | |||
1481 | usbhid_quirks_init_fail: | 1463 | usbhid_quirks_init_fail: |
1482 | hid_unregister_driver(&hid_usb_driver); | 1464 | hid_unregister_driver(&hid_usb_driver); |
1483 | hid_register_fail: | 1465 | hid_register_fail: |
1484 | destroy_workqueue(resumption_waker); | ||
1485 | no_queue: | ||
1486 | return retval; | 1466 | return retval; |
1487 | } | 1467 | } |
1488 | 1468 | ||
@@ -1491,7 +1471,6 @@ static void __exit hid_exit(void) | |||
1491 | usb_deregister(&hid_driver); | 1471 | usb_deregister(&hid_driver); |
1492 | usbhid_quirks_exit(); | 1472 | usbhid_quirks_exit(); |
1493 | hid_unregister_driver(&hid_usb_driver); | 1473 | hid_unregister_driver(&hid_usb_driver); |
1494 | destroy_workqueue(resumption_waker); | ||
1495 | } | 1474 | } |
1496 | 1475 | ||
1497 | module_init(hid_init); | 1476 | module_init(hid_init); |
diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c index ef381d79cfa8..f91c136821f7 100644 --- a/drivers/hid/usbhid/hid-pidff.c +++ b/drivers/hid/usbhid/hid-pidff.c | |||
@@ -22,7 +22,7 @@ | |||
22 | 22 | ||
23 | /* #define DEBUG */ | 23 | /* #define DEBUG */ |
24 | 24 | ||
25 | #define debug(format, arg...) pr_debug("hid-pidff: " format "\n" , ## arg) | 25 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
26 | 26 | ||
27 | #include <linux/input.h> | 27 | #include <linux/input.h> |
28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
@@ -220,7 +220,7 @@ static int pidff_rescale_signed(int i, struct hid_field *field) | |||
220 | static void pidff_set(struct pidff_usage *usage, u16 value) | 220 | static void pidff_set(struct pidff_usage *usage, u16 value) |
221 | { | 221 | { |
222 | usage->value[0] = pidff_rescale(value, 0xffff, usage->field); | 222 | usage->value[0] = pidff_rescale(value, 0xffff, usage->field); |
223 | debug("calculated from %d to %d", value, usage->value[0]); | 223 | pr_debug("calculated from %d to %d\n", value, usage->value[0]); |
224 | } | 224 | } |
225 | 225 | ||
226 | static void pidff_set_signed(struct pidff_usage *usage, s16 value) | 226 | static void pidff_set_signed(struct pidff_usage *usage, s16 value) |
@@ -235,7 +235,7 @@ static void pidff_set_signed(struct pidff_usage *usage, s16 value) | |||
235 | usage->value[0] = | 235 | usage->value[0] = |
236 | pidff_rescale(value, 0x7fff, usage->field); | 236 | pidff_rescale(value, 0x7fff, usage->field); |
237 | } | 237 | } |
238 | debug("calculated from %d to %d", value, usage->value[0]); | 238 | pr_debug("calculated from %d to %d\n", value, usage->value[0]); |
239 | } | 239 | } |
240 | 240 | ||
241 | /* | 241 | /* |
@@ -259,8 +259,9 @@ static void pidff_set_envelope_report(struct pidff_device *pidff, | |||
259 | pidff->set_envelope[PID_ATTACK_TIME].value[0] = envelope->attack_length; | 259 | pidff->set_envelope[PID_ATTACK_TIME].value[0] = envelope->attack_length; |
260 | pidff->set_envelope[PID_FADE_TIME].value[0] = envelope->fade_length; | 260 | pidff->set_envelope[PID_FADE_TIME].value[0] = envelope->fade_length; |
261 | 261 | ||
262 | debug("attack %u => %d", envelope->attack_level, | 262 | hid_dbg(pidff->hid, "attack %u => %d\n", |
263 | pidff->set_envelope[PID_ATTACK_LEVEL].value[0]); | 263 | envelope->attack_level, |
264 | pidff->set_envelope[PID_ATTACK_LEVEL].value[0]); | ||
264 | 265 | ||
265 | usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_ENVELOPE], | 266 | usbhid_submit_report(pidff->hid, pidff->reports[PID_SET_ENVELOPE], |
266 | USB_DIR_OUT); | 267 | USB_DIR_OUT); |
@@ -466,33 +467,33 @@ static int pidff_request_effect_upload(struct pidff_device *pidff, int efnum) | |||
466 | pidff->create_new_effect_type->value[0] = efnum; | 467 | pidff->create_new_effect_type->value[0] = efnum; |
467 | usbhid_submit_report(pidff->hid, pidff->reports[PID_CREATE_NEW_EFFECT], | 468 | usbhid_submit_report(pidff->hid, pidff->reports[PID_CREATE_NEW_EFFECT], |
468 | USB_DIR_OUT); | 469 | USB_DIR_OUT); |
469 | debug("create_new_effect sent, type: %d", efnum); | 470 | hid_dbg(pidff->hid, "create_new_effect sent, type: %d\n", efnum); |
470 | 471 | ||
471 | pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0] = 0; | 472 | pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0] = 0; |
472 | pidff->block_load_status->value[0] = 0; | 473 | pidff->block_load_status->value[0] = 0; |
473 | usbhid_wait_io(pidff->hid); | 474 | usbhid_wait_io(pidff->hid); |
474 | 475 | ||
475 | for (j = 0; j < 60; j++) { | 476 | for (j = 0; j < 60; j++) { |
476 | debug("pid_block_load requested"); | 477 | hid_dbg(pidff->hid, "pid_block_load requested\n"); |
477 | usbhid_submit_report(pidff->hid, pidff->reports[PID_BLOCK_LOAD], | 478 | usbhid_submit_report(pidff->hid, pidff->reports[PID_BLOCK_LOAD], |
478 | USB_DIR_IN); | 479 | USB_DIR_IN); |
479 | usbhid_wait_io(pidff->hid); | 480 | usbhid_wait_io(pidff->hid); |
480 | if (pidff->block_load_status->value[0] == | 481 | if (pidff->block_load_status->value[0] == |
481 | pidff->status_id[PID_BLOCK_LOAD_SUCCESS]) { | 482 | pidff->status_id[PID_BLOCK_LOAD_SUCCESS]) { |
482 | debug("device reported free memory: %d bytes", | 483 | hid_dbg(pidff->hid, "device reported free memory: %d bytes\n", |
483 | pidff->block_load[PID_RAM_POOL_AVAILABLE].value ? | 484 | pidff->block_load[PID_RAM_POOL_AVAILABLE].value ? |
484 | pidff->block_load[PID_RAM_POOL_AVAILABLE].value[0] : -1); | 485 | pidff->block_load[PID_RAM_POOL_AVAILABLE].value[0] : -1); |
485 | return 0; | 486 | return 0; |
486 | } | 487 | } |
487 | if (pidff->block_load_status->value[0] == | 488 | if (pidff->block_load_status->value[0] == |
488 | pidff->status_id[PID_BLOCK_LOAD_FULL]) { | 489 | pidff->status_id[PID_BLOCK_LOAD_FULL]) { |
489 | debug("not enough memory free: %d bytes", | 490 | hid_dbg(pidff->hid, "not enough memory free: %d bytes\n", |
490 | pidff->block_load[PID_RAM_POOL_AVAILABLE].value ? | 491 | pidff->block_load[PID_RAM_POOL_AVAILABLE].value ? |
491 | pidff->block_load[PID_RAM_POOL_AVAILABLE].value[0] : -1); | 492 | pidff->block_load[PID_RAM_POOL_AVAILABLE].value[0] : -1); |
492 | return -ENOSPC; | 493 | return -ENOSPC; |
493 | } | 494 | } |
494 | } | 495 | } |
495 | printk(KERN_ERR "hid-pidff: pid_block_load failed 60 times\n"); | 496 | hid_err(pidff->hid, "pid_block_load failed 60 times\n"); |
496 | return -EIO; | 497 | return -EIO; |
497 | } | 498 | } |
498 | 499 | ||
@@ -546,7 +547,8 @@ static int pidff_erase_effect(struct input_dev *dev, int effect_id) | |||
546 | struct pidff_device *pidff = dev->ff->private; | 547 | struct pidff_device *pidff = dev->ff->private; |
547 | int pid_id = pidff->pid_id[effect_id]; | 548 | int pid_id = pidff->pid_id[effect_id]; |
548 | 549 | ||
549 | debug("starting to erase %d/%d", effect_id, pidff->pid_id[effect_id]); | 550 | hid_dbg(pidff->hid, "starting to erase %d/%d\n", |
551 | effect_id, pidff->pid_id[effect_id]); | ||
550 | /* Wait for the queue to clear. We do not want a full fifo to | 552 | /* Wait for the queue to clear. We do not want a full fifo to |
551 | prevent the effect removal. */ | 553 | prevent the effect removal. */ |
552 | usbhid_wait_io(pidff->hid); | 554 | usbhid_wait_io(pidff->hid); |
@@ -604,8 +606,7 @@ static int pidff_upload_effect(struct input_dev *dev, struct ff_effect *effect, | |||
604 | type_id = PID_SAW_DOWN; | 606 | type_id = PID_SAW_DOWN; |
605 | break; | 607 | break; |
606 | default: | 608 | default: |
607 | printk(KERN_ERR | 609 | hid_err(pidff->hid, "invalid waveform\n"); |
608 | "hid-pidff: invalid waveform\n"); | ||
609 | return -EINVAL; | 610 | return -EINVAL; |
610 | } | 611 | } |
611 | 612 | ||
@@ -696,7 +697,7 @@ static int pidff_upload_effect(struct input_dev *dev, struct ff_effect *effect, | |||
696 | break; | 697 | break; |
697 | 698 | ||
698 | default: | 699 | default: |
699 | printk(KERN_ERR "hid-pidff: invalid type\n"); | 700 | hid_err(pidff->hid, "invalid type\n"); |
700 | return -EINVAL; | 701 | return -EINVAL; |
701 | } | 702 | } |
702 | 703 | ||
@@ -704,7 +705,7 @@ static int pidff_upload_effect(struct input_dev *dev, struct ff_effect *effect, | |||
704 | pidff->pid_id[effect->id] = | 705 | pidff->pid_id[effect->id] = |
705 | pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0]; | 706 | pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0]; |
706 | 707 | ||
707 | debug("uploaded"); | 708 | hid_dbg(pidff->hid, "uploaded\n"); |
708 | 709 | ||
709 | return 0; | 710 | return 0; |
710 | } | 711 | } |
@@ -770,14 +771,14 @@ static int pidff_find_fields(struct pidff_usage *usage, const u8 *table, | |||
770 | for (i = 0; i < report->maxfield; i++) { | 771 | for (i = 0; i < report->maxfield; i++) { |
771 | if (report->field[i]->maxusage != | 772 | if (report->field[i]->maxusage != |
772 | report->field[i]->report_count) { | 773 | report->field[i]->report_count) { |
773 | debug("maxusage and report_count do not match, " | 774 | pr_debug("maxusage and report_count do not match, skipping\n"); |
774 | "skipping"); | ||
775 | continue; | 775 | continue; |
776 | } | 776 | } |
777 | for (j = 0; j < report->field[i]->maxusage; j++) { | 777 | for (j = 0; j < report->field[i]->maxusage; j++) { |
778 | if (report->field[i]->usage[j].hid == | 778 | if (report->field[i]->usage[j].hid == |
779 | (HID_UP_PID | table[k])) { | 779 | (HID_UP_PID | table[k])) { |
780 | debug("found %d at %d->%d", k, i, j); | 780 | pr_debug("found %d at %d->%d\n", |
781 | k, i, j); | ||
781 | usage[k].field = report->field[i]; | 782 | usage[k].field = report->field[i]; |
782 | usage[k].value = | 783 | usage[k].value = |
783 | &report->field[i]->value[j]; | 784 | &report->field[i]->value[j]; |
@@ -789,7 +790,7 @@ static int pidff_find_fields(struct pidff_usage *usage, const u8 *table, | |||
789 | break; | 790 | break; |
790 | } | 791 | } |
791 | if (!found && strict) { | 792 | if (!found && strict) { |
792 | debug("failed to locate %d", k); | 793 | pr_debug("failed to locate %d\n", k); |
793 | return -1; | 794 | return -1; |
794 | } | 795 | } |
795 | } | 796 | } |
@@ -826,8 +827,8 @@ static void pidff_find_reports(struct hid_device *hid, int report_type, | |||
826 | continue; | 827 | continue; |
827 | ret = pidff_check_usage(report->field[0]->logical); | 828 | ret = pidff_check_usage(report->field[0]->logical); |
828 | if (ret != -1) { | 829 | if (ret != -1) { |
829 | debug("found usage 0x%02x from field->logical", | 830 | hid_dbg(hid, "found usage 0x%02x from field->logical\n", |
830 | pidff_reports[ret]); | 831 | pidff_reports[ret]); |
831 | pidff->reports[ret] = report; | 832 | pidff->reports[ret] = report; |
832 | continue; | 833 | continue; |
833 | } | 834 | } |
@@ -845,8 +846,9 @@ static void pidff_find_reports(struct hid_device *hid, int report_type, | |||
845 | continue; | 846 | continue; |
846 | ret = pidff_check_usage(hid->collection[i - 1].usage); | 847 | ret = pidff_check_usage(hid->collection[i - 1].usage); |
847 | if (ret != -1 && !pidff->reports[ret]) { | 848 | if (ret != -1 && !pidff->reports[ret]) { |
848 | debug("found usage 0x%02x from collection array", | 849 | hid_dbg(hid, |
849 | pidff_reports[ret]); | 850 | "found usage 0x%02x from collection array\n", |
851 | pidff_reports[ret]); | ||
850 | pidff->reports[ret] = report; | 852 | pidff->reports[ret] = report; |
851 | } | 853 | } |
852 | } | 854 | } |
@@ -861,7 +863,7 @@ static int pidff_reports_ok(struct pidff_device *pidff) | |||
861 | 863 | ||
862 | for (i = 0; i <= PID_REQUIRED_REPORTS; i++) { | 864 | for (i = 0; i <= PID_REQUIRED_REPORTS; i++) { |
863 | if (!pidff->reports[i]) { | 865 | if (!pidff->reports[i]) { |
864 | debug("%d missing", i); | 866 | hid_dbg(pidff->hid, "%d missing\n", i); |
865 | return 0; | 867 | return 0; |
866 | } | 868 | } |
867 | } | 869 | } |
@@ -884,8 +886,7 @@ static struct hid_field *pidff_find_special_field(struct hid_report *report, | |||
884 | report->field[i]->logical_minimum == 1) | 886 | report->field[i]->logical_minimum == 1) |
885 | return report->field[i]; | 887 | return report->field[i]; |
886 | else { | 888 | else { |
887 | printk(KERN_ERR "hid-pidff: logical_minimum " | 889 | pr_err("logical_minimum is not 1 as it should be\n"); |
888 | "is not 1 as it should be\n"); | ||
889 | return NULL; | 890 | return NULL; |
890 | } | 891 | } |
891 | } | 892 | } |
@@ -924,7 +925,7 @@ static int pidff_find_special_keys(int *keys, struct hid_field *fld, | |||
924 | */ | 925 | */ |
925 | static int pidff_find_special_fields(struct pidff_device *pidff) | 926 | static int pidff_find_special_fields(struct pidff_device *pidff) |
926 | { | 927 | { |
927 | debug("finding special fields"); | 928 | hid_dbg(pidff->hid, "finding special fields\n"); |
928 | 929 | ||
929 | pidff->create_new_effect_type = | 930 | pidff->create_new_effect_type = |
930 | pidff_find_special_field(pidff->reports[PID_CREATE_NEW_EFFECT], | 931 | pidff_find_special_field(pidff->reports[PID_CREATE_NEW_EFFECT], |
@@ -945,32 +946,30 @@ static int pidff_find_special_fields(struct pidff_device *pidff) | |||
945 | pidff_find_special_field(pidff->reports[PID_EFFECT_OPERATION], | 946 | pidff_find_special_field(pidff->reports[PID_EFFECT_OPERATION], |
946 | 0x78, 1); | 947 | 0x78, 1); |
947 | 948 | ||
948 | debug("search done"); | 949 | hid_dbg(pidff->hid, "search done\n"); |
949 | 950 | ||
950 | if (!pidff->create_new_effect_type || !pidff->set_effect_type) { | 951 | if (!pidff->create_new_effect_type || !pidff->set_effect_type) { |
951 | printk(KERN_ERR "hid-pidff: effect lists not found\n"); | 952 | hid_err(pidff->hid, "effect lists not found\n"); |
952 | return -1; | 953 | return -1; |
953 | } | 954 | } |
954 | 955 | ||
955 | if (!pidff->effect_direction) { | 956 | if (!pidff->effect_direction) { |
956 | printk(KERN_ERR "hid-pidff: direction field not found\n"); | 957 | hid_err(pidff->hid, "direction field not found\n"); |
957 | return -1; | 958 | return -1; |
958 | } | 959 | } |
959 | 960 | ||
960 | if (!pidff->device_control) { | 961 | if (!pidff->device_control) { |
961 | printk(KERN_ERR "hid-pidff: device control field not found\n"); | 962 | hid_err(pidff->hid, "device control field not found\n"); |
962 | return -1; | 963 | return -1; |
963 | } | 964 | } |
964 | 965 | ||
965 | if (!pidff->block_load_status) { | 966 | if (!pidff->block_load_status) { |
966 | printk(KERN_ERR | 967 | hid_err(pidff->hid, "block load status field not found\n"); |
967 | "hid-pidff: block load status field not found\n"); | ||
968 | return -1; | 968 | return -1; |
969 | } | 969 | } |
970 | 970 | ||
971 | if (!pidff->effect_operation_status) { | 971 | if (!pidff->effect_operation_status) { |
972 | printk(KERN_ERR | 972 | hid_err(pidff->hid, "effect operation field not found\n"); |
973 | "hid-pidff: effect operation field not found\n"); | ||
974 | return -1; | 973 | return -1; |
975 | } | 974 | } |
976 | 975 | ||
@@ -982,23 +981,22 @@ static int pidff_find_special_fields(struct pidff_device *pidff) | |||
982 | 981 | ||
983 | if (!PIDFF_FIND_SPECIAL_KEYS(type_id, create_new_effect_type, | 982 | if (!PIDFF_FIND_SPECIAL_KEYS(type_id, create_new_effect_type, |
984 | effect_types)) { | 983 | effect_types)) { |
985 | printk(KERN_ERR "hid-pidff: no effect types found\n"); | 984 | hid_err(pidff->hid, "no effect types found\n"); |
986 | return -1; | 985 | return -1; |
987 | } | 986 | } |
988 | 987 | ||
989 | if (PIDFF_FIND_SPECIAL_KEYS(status_id, block_load_status, | 988 | if (PIDFF_FIND_SPECIAL_KEYS(status_id, block_load_status, |
990 | block_load_status) != | 989 | block_load_status) != |
991 | sizeof(pidff_block_load_status)) { | 990 | sizeof(pidff_block_load_status)) { |
992 | printk(KERN_ERR | 991 | hid_err(pidff->hid, |
993 | "hidpidff: block load status identifiers not found\n"); | 992 | "block load status identifiers not found\n"); |
994 | return -1; | 993 | return -1; |
995 | } | 994 | } |
996 | 995 | ||
997 | if (PIDFF_FIND_SPECIAL_KEYS(operation_id, effect_operation_status, | 996 | if (PIDFF_FIND_SPECIAL_KEYS(operation_id, effect_operation_status, |
998 | effect_operation_status) != | 997 | effect_operation_status) != |
999 | sizeof(pidff_effect_operation_status)) { | 998 | sizeof(pidff_effect_operation_status)) { |
1000 | printk(KERN_ERR | 999 | hid_err(pidff->hid, "effect operation identifiers not found\n"); |
1001 | "hidpidff: effect operation identifiers not found\n"); | ||
1002 | return -1; | 1000 | return -1; |
1003 | } | 1001 | } |
1004 | 1002 | ||
@@ -1017,8 +1015,8 @@ static int pidff_find_effects(struct pidff_device *pidff, | |||
1017 | int pidff_type = pidff->type_id[i]; | 1015 | int pidff_type = pidff->type_id[i]; |
1018 | if (pidff->set_effect_type->usage[pidff_type].hid != | 1016 | if (pidff->set_effect_type->usage[pidff_type].hid != |
1019 | pidff->create_new_effect_type->usage[pidff_type].hid) { | 1017 | pidff->create_new_effect_type->usage[pidff_type].hid) { |
1020 | printk(KERN_ERR "hid-pidff: " | 1018 | hid_err(pidff->hid, |
1021 | "effect type number %d is invalid\n", i); | 1019 | "effect type number %d is invalid\n", i); |
1022 | return -1; | 1020 | return -1; |
1023 | } | 1021 | } |
1024 | } | 1022 | } |
@@ -1073,27 +1071,23 @@ static int pidff_init_fields(struct pidff_device *pidff, struct input_dev *dev) | |||
1073 | int envelope_ok = 0; | 1071 | int envelope_ok = 0; |
1074 | 1072 | ||
1075 | if (PIDFF_FIND_FIELDS(set_effect, PID_SET_EFFECT, 1)) { | 1073 | if (PIDFF_FIND_FIELDS(set_effect, PID_SET_EFFECT, 1)) { |
1076 | printk(KERN_ERR | 1074 | hid_err(pidff->hid, "unknown set_effect report layout\n"); |
1077 | "hid-pidff: unknown set_effect report layout\n"); | ||
1078 | return -ENODEV; | 1075 | return -ENODEV; |
1079 | } | 1076 | } |
1080 | 1077 | ||
1081 | PIDFF_FIND_FIELDS(block_load, PID_BLOCK_LOAD, 0); | 1078 | PIDFF_FIND_FIELDS(block_load, PID_BLOCK_LOAD, 0); |
1082 | if (!pidff->block_load[PID_EFFECT_BLOCK_INDEX].value) { | 1079 | if (!pidff->block_load[PID_EFFECT_BLOCK_INDEX].value) { |
1083 | printk(KERN_ERR | 1080 | hid_err(pidff->hid, "unknown pid_block_load report layout\n"); |
1084 | "hid-pidff: unknown pid_block_load report layout\n"); | ||
1085 | return -ENODEV; | 1081 | return -ENODEV; |
1086 | } | 1082 | } |
1087 | 1083 | ||
1088 | if (PIDFF_FIND_FIELDS(effect_operation, PID_EFFECT_OPERATION, 1)) { | 1084 | if (PIDFF_FIND_FIELDS(effect_operation, PID_EFFECT_OPERATION, 1)) { |
1089 | printk(KERN_ERR | 1085 | hid_err(pidff->hid, "unknown effect_operation report layout\n"); |
1090 | "hid-pidff: unknown effect_operation report layout\n"); | ||
1091 | return -ENODEV; | 1086 | return -ENODEV; |
1092 | } | 1087 | } |
1093 | 1088 | ||
1094 | if (PIDFF_FIND_FIELDS(block_free, PID_BLOCK_FREE, 1)) { | 1089 | if (PIDFF_FIND_FIELDS(block_free, PID_BLOCK_FREE, 1)) { |
1095 | printk(KERN_ERR | 1090 | hid_err(pidff->hid, "unknown pid_block_free report layout\n"); |
1096 | "hid-pidff: unknown pid_block_free report layout\n"); | ||
1097 | return -ENODEV; | 1091 | return -ENODEV; |
1098 | } | 1092 | } |
1099 | 1093 | ||
@@ -1105,27 +1099,26 @@ static int pidff_init_fields(struct pidff_device *pidff, struct input_dev *dev) | |||
1105 | 1099 | ||
1106 | if (!envelope_ok) { | 1100 | if (!envelope_ok) { |
1107 | if (test_and_clear_bit(FF_CONSTANT, dev->ffbit)) | 1101 | if (test_and_clear_bit(FF_CONSTANT, dev->ffbit)) |
1108 | printk(KERN_WARNING "hid-pidff: " | 1102 | hid_warn(pidff->hid, |
1109 | "has constant effect but no envelope\n"); | 1103 | "has constant effect but no envelope\n"); |
1110 | if (test_and_clear_bit(FF_RAMP, dev->ffbit)) | 1104 | if (test_and_clear_bit(FF_RAMP, dev->ffbit)) |
1111 | printk(KERN_WARNING "hid-pidff: " | 1105 | hid_warn(pidff->hid, |
1112 | "has ramp effect but no envelope\n"); | 1106 | "has ramp effect but no envelope\n"); |
1113 | 1107 | ||
1114 | if (test_and_clear_bit(FF_PERIODIC, dev->ffbit)) | 1108 | if (test_and_clear_bit(FF_PERIODIC, dev->ffbit)) |
1115 | printk(KERN_WARNING "hid-pidff: " | 1109 | hid_warn(pidff->hid, |
1116 | "has periodic effect but no envelope\n"); | 1110 | "has periodic effect but no envelope\n"); |
1117 | } | 1111 | } |
1118 | 1112 | ||
1119 | if (test_bit(FF_CONSTANT, dev->ffbit) && | 1113 | if (test_bit(FF_CONSTANT, dev->ffbit) && |
1120 | PIDFF_FIND_FIELDS(set_constant, PID_SET_CONSTANT, 1)) { | 1114 | PIDFF_FIND_FIELDS(set_constant, PID_SET_CONSTANT, 1)) { |
1121 | printk(KERN_WARNING | 1115 | hid_warn(pidff->hid, "unknown constant effect layout\n"); |
1122 | "hid-pidff: unknown constant effect layout\n"); | ||
1123 | clear_bit(FF_CONSTANT, dev->ffbit); | 1116 | clear_bit(FF_CONSTANT, dev->ffbit); |
1124 | } | 1117 | } |
1125 | 1118 | ||
1126 | if (test_bit(FF_RAMP, dev->ffbit) && | 1119 | if (test_bit(FF_RAMP, dev->ffbit) && |
1127 | PIDFF_FIND_FIELDS(set_ramp, PID_SET_RAMP, 1)) { | 1120 | PIDFF_FIND_FIELDS(set_ramp, PID_SET_RAMP, 1)) { |
1128 | printk(KERN_WARNING "hid-pidff: unknown ramp effect layout\n"); | 1121 | hid_warn(pidff->hid, "unknown ramp effect layout\n"); |
1129 | clear_bit(FF_RAMP, dev->ffbit); | 1122 | clear_bit(FF_RAMP, dev->ffbit); |
1130 | } | 1123 | } |
1131 | 1124 | ||
@@ -1134,8 +1127,7 @@ static int pidff_init_fields(struct pidff_device *pidff, struct input_dev *dev) | |||
1134 | test_bit(FF_FRICTION, dev->ffbit) || | 1127 | test_bit(FF_FRICTION, dev->ffbit) || |
1135 | test_bit(FF_INERTIA, dev->ffbit)) && | 1128 | test_bit(FF_INERTIA, dev->ffbit)) && |
1136 | PIDFF_FIND_FIELDS(set_condition, PID_SET_CONDITION, 1)) { | 1129 | PIDFF_FIND_FIELDS(set_condition, PID_SET_CONDITION, 1)) { |
1137 | printk(KERN_WARNING | 1130 | hid_warn(pidff->hid, "unknown condition effect layout\n"); |
1138 | "hid-pidff: unknown condition effect layout\n"); | ||
1139 | clear_bit(FF_SPRING, dev->ffbit); | 1131 | clear_bit(FF_SPRING, dev->ffbit); |
1140 | clear_bit(FF_DAMPER, dev->ffbit); | 1132 | clear_bit(FF_DAMPER, dev->ffbit); |
1141 | clear_bit(FF_FRICTION, dev->ffbit); | 1133 | clear_bit(FF_FRICTION, dev->ffbit); |
@@ -1144,8 +1136,7 @@ static int pidff_init_fields(struct pidff_device *pidff, struct input_dev *dev) | |||
1144 | 1136 | ||
1145 | if (test_bit(FF_PERIODIC, dev->ffbit) && | 1137 | if (test_bit(FF_PERIODIC, dev->ffbit) && |
1146 | PIDFF_FIND_FIELDS(set_periodic, PID_SET_PERIODIC, 1)) { | 1138 | PIDFF_FIND_FIELDS(set_periodic, PID_SET_PERIODIC, 1)) { |
1147 | printk(KERN_WARNING | 1139 | hid_warn(pidff->hid, "unknown periodic effect layout\n"); |
1148 | "hid-pidff: unknown periodic effect layout\n"); | ||
1149 | clear_bit(FF_PERIODIC, dev->ffbit); | 1140 | clear_bit(FF_PERIODIC, dev->ffbit); |
1150 | } | 1141 | } |
1151 | 1142 | ||
@@ -1184,12 +1175,12 @@ static void pidff_reset(struct pidff_device *pidff) | |||
1184 | if (pidff->pool[PID_SIMULTANEOUS_MAX].value) { | 1175 | if (pidff->pool[PID_SIMULTANEOUS_MAX].value) { |
1185 | while (pidff->pool[PID_SIMULTANEOUS_MAX].value[0] < 2) { | 1176 | while (pidff->pool[PID_SIMULTANEOUS_MAX].value[0] < 2) { |
1186 | if (i++ > 20) { | 1177 | if (i++ > 20) { |
1187 | printk(KERN_WARNING "hid-pidff: device reports " | 1178 | hid_warn(pidff->hid, |
1188 | "%d simultaneous effects\n", | 1179 | "device reports %d simultaneous effects\n", |
1189 | pidff->pool[PID_SIMULTANEOUS_MAX].value[0]); | 1180 | pidff->pool[PID_SIMULTANEOUS_MAX].value[0]); |
1190 | break; | 1181 | break; |
1191 | } | 1182 | } |
1192 | debug("pid_pool requested again"); | 1183 | hid_dbg(pidff->hid, "pid_pool requested again\n"); |
1193 | usbhid_submit_report(hid, pidff->reports[PID_POOL], | 1184 | usbhid_submit_report(hid, pidff->reports[PID_POOL], |
1194 | USB_DIR_IN); | 1185 | USB_DIR_IN); |
1195 | usbhid_wait_io(hid); | 1186 | usbhid_wait_io(hid); |
@@ -1215,7 +1206,7 @@ static int pidff_check_autocenter(struct pidff_device *pidff, | |||
1215 | 1206 | ||
1216 | error = pidff_request_effect_upload(pidff, 1); | 1207 | error = pidff_request_effect_upload(pidff, 1); |
1217 | if (error) { | 1208 | if (error) { |
1218 | printk(KERN_ERR "hid-pidff: upload request failed\n"); | 1209 | hid_err(pidff->hid, "upload request failed\n"); |
1219 | return error; | 1210 | return error; |
1220 | } | 1211 | } |
1221 | 1212 | ||
@@ -1224,8 +1215,8 @@ static int pidff_check_autocenter(struct pidff_device *pidff, | |||
1224 | pidff_autocenter(pidff, 0xffff); | 1215 | pidff_autocenter(pidff, 0xffff); |
1225 | set_bit(FF_AUTOCENTER, dev->ffbit); | 1216 | set_bit(FF_AUTOCENTER, dev->ffbit); |
1226 | } else { | 1217 | } else { |
1227 | printk(KERN_NOTICE "hid-pidff: " | 1218 | hid_notice(pidff->hid, |
1228 | "device has unknown autocenter control method\n"); | 1219 | "device has unknown autocenter control method\n"); |
1229 | } | 1220 | } |
1230 | 1221 | ||
1231 | pidff_erase_pid(pidff, | 1222 | pidff_erase_pid(pidff, |
@@ -1248,10 +1239,10 @@ int hid_pidff_init(struct hid_device *hid) | |||
1248 | int max_effects; | 1239 | int max_effects; |
1249 | int error; | 1240 | int error; |
1250 | 1241 | ||
1251 | debug("starting pid init"); | 1242 | hid_dbg(hid, "starting pid init\n"); |
1252 | 1243 | ||
1253 | if (list_empty(&hid->report_enum[HID_OUTPUT_REPORT].report_list)) { | 1244 | if (list_empty(&hid->report_enum[HID_OUTPUT_REPORT].report_list)) { |
1254 | debug("not a PID device, no output report"); | 1245 | hid_dbg(hid, "not a PID device, no output report\n"); |
1255 | return -ENODEV; | 1246 | return -ENODEV; |
1256 | } | 1247 | } |
1257 | 1248 | ||
@@ -1265,7 +1256,7 @@ int hid_pidff_init(struct hid_device *hid) | |||
1265 | pidff_find_reports(hid, HID_FEATURE_REPORT, pidff); | 1256 | pidff_find_reports(hid, HID_FEATURE_REPORT, pidff); |
1266 | 1257 | ||
1267 | if (!pidff_reports_ok(pidff)) { | 1258 | if (!pidff_reports_ok(pidff)) { |
1268 | debug("reports not ok, aborting"); | 1259 | hid_dbg(hid, "reports not ok, aborting\n"); |
1269 | error = -ENODEV; | 1260 | error = -ENODEV; |
1270 | goto fail; | 1261 | goto fail; |
1271 | } | 1262 | } |
@@ -1278,8 +1269,8 @@ int hid_pidff_init(struct hid_device *hid) | |||
1278 | 1269 | ||
1279 | if (test_bit(FF_GAIN, dev->ffbit)) { | 1270 | if (test_bit(FF_GAIN, dev->ffbit)) { |
1280 | pidff_set(&pidff->device_gain[PID_DEVICE_GAIN_FIELD], 0xffff); | 1271 | pidff_set(&pidff->device_gain[PID_DEVICE_GAIN_FIELD], 0xffff); |
1281 | usbhid_submit_report(pidff->hid, pidff->reports[PID_DEVICE_GAIN], | 1272 | usbhid_submit_report(hid, pidff->reports[PID_DEVICE_GAIN], |
1282 | USB_DIR_OUT); | 1273 | USB_DIR_OUT); |
1283 | } | 1274 | } |
1284 | 1275 | ||
1285 | error = pidff_check_autocenter(pidff, dev); | 1276 | error = pidff_check_autocenter(pidff, dev); |
@@ -1290,23 +1281,23 @@ int hid_pidff_init(struct hid_device *hid) | |||
1290 | pidff->block_load[PID_EFFECT_BLOCK_INDEX].field->logical_maximum - | 1281 | pidff->block_load[PID_EFFECT_BLOCK_INDEX].field->logical_maximum - |
1291 | pidff->block_load[PID_EFFECT_BLOCK_INDEX].field->logical_minimum + | 1282 | pidff->block_load[PID_EFFECT_BLOCK_INDEX].field->logical_minimum + |
1292 | 1; | 1283 | 1; |
1293 | debug("max effects is %d", max_effects); | 1284 | hid_dbg(hid, "max effects is %d\n", max_effects); |
1294 | 1285 | ||
1295 | if (max_effects > PID_EFFECTS_MAX) | 1286 | if (max_effects > PID_EFFECTS_MAX) |
1296 | max_effects = PID_EFFECTS_MAX; | 1287 | max_effects = PID_EFFECTS_MAX; |
1297 | 1288 | ||
1298 | if (pidff->pool[PID_SIMULTANEOUS_MAX].value) | 1289 | if (pidff->pool[PID_SIMULTANEOUS_MAX].value) |
1299 | debug("max simultaneous effects is %d", | 1290 | hid_dbg(hid, "max simultaneous effects is %d\n", |
1300 | pidff->pool[PID_SIMULTANEOUS_MAX].value[0]); | 1291 | pidff->pool[PID_SIMULTANEOUS_MAX].value[0]); |
1301 | 1292 | ||
1302 | if (pidff->pool[PID_RAM_POOL_SIZE].value) | 1293 | if (pidff->pool[PID_RAM_POOL_SIZE].value) |
1303 | debug("device memory size is %d bytes", | 1294 | hid_dbg(hid, "device memory size is %d bytes\n", |
1304 | pidff->pool[PID_RAM_POOL_SIZE].value[0]); | 1295 | pidff->pool[PID_RAM_POOL_SIZE].value[0]); |
1305 | 1296 | ||
1306 | if (pidff->pool[PID_DEVICE_MANAGED_POOL].value && | 1297 | if (pidff->pool[PID_DEVICE_MANAGED_POOL].value && |
1307 | pidff->pool[PID_DEVICE_MANAGED_POOL].value[0] == 0) { | 1298 | pidff->pool[PID_DEVICE_MANAGED_POOL].value[0] == 0) { |
1308 | printk(KERN_NOTICE "hid-pidff: " | 1299 | hid_notice(hid, |
1309 | "device does not support device managed pool\n"); | 1300 | "device does not support device managed pool\n"); |
1310 | goto fail; | 1301 | goto fail; |
1311 | } | 1302 | } |
1312 | 1303 | ||
@@ -1322,8 +1313,7 @@ int hid_pidff_init(struct hid_device *hid) | |||
1322 | ff->set_autocenter = pidff_set_autocenter; | 1313 | ff->set_autocenter = pidff_set_autocenter; |
1323 | ff->playback = pidff_playback; | 1314 | ff->playback = pidff_playback; |
1324 | 1315 | ||
1325 | printk(KERN_INFO "Force feedback for USB HID PID devices by " | 1316 | hid_info(dev, "Force feedback for USB HID PID devices by Anssi Hannula <anssi.hannula@gmail.com>\n"); |
1326 | "Anssi Hannula <anssi.hannula@gmail.com>\n"); | ||
1327 | 1317 | ||
1328 | return 0; | 1318 | return 0; |
1329 | 1319 | ||
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c index 2c185477eeb3..76b9a149c7df 100644 --- a/drivers/hid/usbhid/hid-quirks.c +++ b/drivers/hid/usbhid/hid-quirks.c | |||
@@ -85,7 +85,7 @@ static const struct hid_blacklist { | |||
85 | { USB_VENDOR_ID_PI_ENGINEERING, USB_DEVICE_ID_PI_ENGINEERING_VEC_USB_FOOTPEDAL, HID_QUIRK_HIDINPUT_FORCE }, | 85 | { USB_VENDOR_ID_PI_ENGINEERING, USB_DEVICE_ID_PI_ENGINEERING_VEC_USB_FOOTPEDAL, HID_QUIRK_HIDINPUT_FORCE }, |
86 | 86 | ||
87 | { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_MULTI_TOUCH, HID_QUIRK_MULTI_INPUT }, | 87 | { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_MULTI_TOUCH, HID_QUIRK_MULTI_INPUT }, |
88 | 88 | { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS, HID_QUIRK_MULTI_INPUT }, | |
89 | { 0, 0 } | 89 | { 0, 0 } |
90 | }; | 90 | }; |
91 | 91 | ||
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c index 984feb351a5a..af0a7c1002af 100644 --- a/drivers/hid/usbhid/hiddev.c +++ b/drivers/hid/usbhid/hiddev.c | |||
@@ -585,163 +585,168 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
585 | { | 585 | { |
586 | struct hiddev_list *list = file->private_data; | 586 | struct hiddev_list *list = file->private_data; |
587 | struct hiddev *hiddev = list->hiddev; | 587 | struct hiddev *hiddev = list->hiddev; |
588 | struct hid_device *hid = hiddev->hid; | 588 | struct hid_device *hid; |
589 | struct usb_device *dev; | ||
590 | struct hiddev_collection_info cinfo; | 589 | struct hiddev_collection_info cinfo; |
591 | struct hiddev_report_info rinfo; | 590 | struct hiddev_report_info rinfo; |
592 | struct hiddev_field_info finfo; | 591 | struct hiddev_field_info finfo; |
593 | struct hiddev_devinfo dinfo; | 592 | struct hiddev_devinfo dinfo; |
594 | struct hid_report *report; | 593 | struct hid_report *report; |
595 | struct hid_field *field; | 594 | struct hid_field *field; |
596 | struct usbhid_device *usbhid = hid->driver_data; | ||
597 | void __user *user_arg = (void __user *)arg; | 595 | void __user *user_arg = (void __user *)arg; |
598 | int i, r; | 596 | int i, r = -EINVAL; |
599 | 597 | ||
600 | /* Called without BKL by compat methods so no BKL taken */ | 598 | /* Called without BKL by compat methods so no BKL taken */ |
601 | 599 | ||
602 | /* FIXME: Who or what stop this racing with a disconnect ?? */ | 600 | mutex_lock(&hiddev->existancelock); |
603 | if (!hiddev->exist || !hid) | 601 | if (!hiddev->exist) { |
604 | return -EIO; | 602 | r = -ENODEV; |
603 | goto ret_unlock; | ||
604 | } | ||
605 | 605 | ||
606 | dev = hid_to_usb_dev(hid); | 606 | hid = hiddev->hid; |
607 | 607 | ||
608 | switch (cmd) { | 608 | switch (cmd) { |
609 | 609 | ||
610 | case HIDIOCGVERSION: | 610 | case HIDIOCGVERSION: |
611 | return put_user(HID_VERSION, (int __user *)arg); | 611 | r = put_user(HID_VERSION, (int __user *)arg) ? |
612 | -EFAULT : 0; | ||
613 | break; | ||
612 | 614 | ||
613 | case HIDIOCAPPLICATION: | 615 | case HIDIOCAPPLICATION: |
614 | if (arg < 0 || arg >= hid->maxapplication) | 616 | if (arg < 0 || arg >= hid->maxapplication) |
615 | return -EINVAL; | 617 | break; |
616 | 618 | ||
617 | for (i = 0; i < hid->maxcollection; i++) | 619 | for (i = 0; i < hid->maxcollection; i++) |
618 | if (hid->collection[i].type == | 620 | if (hid->collection[i].type == |
619 | HID_COLLECTION_APPLICATION && arg-- == 0) | 621 | HID_COLLECTION_APPLICATION && arg-- == 0) |
620 | break; | 622 | break; |
621 | 623 | ||
622 | if (i == hid->maxcollection) | 624 | if (i < hid->maxcollection) |
623 | return -EINVAL; | 625 | r = hid->collection[i].usage; |
624 | 626 | break; | |
625 | return hid->collection[i].usage; | ||
626 | 627 | ||
627 | case HIDIOCGDEVINFO: | 628 | case HIDIOCGDEVINFO: |
628 | dinfo.bustype = BUS_USB; | 629 | { |
629 | dinfo.busnum = dev->bus->busnum; | 630 | struct usb_device *dev = hid_to_usb_dev(hid); |
630 | dinfo.devnum = dev->devnum; | 631 | struct usbhid_device *usbhid = hid->driver_data; |
631 | dinfo.ifnum = usbhid->ifnum; | 632 | |
632 | dinfo.vendor = le16_to_cpu(dev->descriptor.idVendor); | 633 | dinfo.bustype = BUS_USB; |
633 | dinfo.product = le16_to_cpu(dev->descriptor.idProduct); | 634 | dinfo.busnum = dev->bus->busnum; |
634 | dinfo.version = le16_to_cpu(dev->descriptor.bcdDevice); | 635 | dinfo.devnum = dev->devnum; |
635 | dinfo.num_applications = hid->maxapplication; | 636 | dinfo.ifnum = usbhid->ifnum; |
636 | if (copy_to_user(user_arg, &dinfo, sizeof(dinfo))) | 637 | dinfo.vendor = le16_to_cpu(dev->descriptor.idVendor); |
637 | return -EFAULT; | 638 | dinfo.product = le16_to_cpu(dev->descriptor.idProduct); |
638 | 639 | dinfo.version = le16_to_cpu(dev->descriptor.bcdDevice); | |
639 | return 0; | 640 | dinfo.num_applications = hid->maxapplication; |
641 | |||
642 | r = copy_to_user(user_arg, &dinfo, sizeof(dinfo)) ? | ||
643 | -EFAULT : 0; | ||
644 | break; | ||
645 | } | ||
640 | 646 | ||
641 | case HIDIOCGFLAG: | 647 | case HIDIOCGFLAG: |
642 | if (put_user(list->flags, (int __user *)arg)) | 648 | r = put_user(list->flags, (int __user *)arg) ? |
643 | return -EFAULT; | 649 | -EFAULT : 0; |
644 | 650 | break; | |
645 | return 0; | ||
646 | 651 | ||
647 | case HIDIOCSFLAG: | 652 | case HIDIOCSFLAG: |
648 | { | 653 | { |
649 | int newflags; | 654 | int newflags; |
650 | if (get_user(newflags, (int __user *)arg)) | 655 | |
651 | return -EFAULT; | 656 | if (get_user(newflags, (int __user *)arg)) { |
657 | r = -EFAULT; | ||
658 | break; | ||
659 | } | ||
652 | 660 | ||
653 | if ((newflags & ~HIDDEV_FLAGS) != 0 || | 661 | if ((newflags & ~HIDDEV_FLAGS) != 0 || |
654 | ((newflags & HIDDEV_FLAG_REPORT) != 0 && | 662 | ((newflags & HIDDEV_FLAG_REPORT) != 0 && |
655 | (newflags & HIDDEV_FLAG_UREF) == 0)) | 663 | (newflags & HIDDEV_FLAG_UREF) == 0)) |
656 | return -EINVAL; | 664 | break; |
657 | 665 | ||
658 | list->flags = newflags; | 666 | list->flags = newflags; |
659 | 667 | ||
660 | return 0; | 668 | r = 0; |
669 | break; | ||
661 | } | 670 | } |
662 | 671 | ||
663 | case HIDIOCGSTRING: | 672 | case HIDIOCGSTRING: |
664 | mutex_lock(&hiddev->existancelock); | 673 | r = hiddev_ioctl_string(hiddev, cmd, user_arg); |
665 | if (hiddev->exist) | 674 | break; |
666 | r = hiddev_ioctl_string(hiddev, cmd, user_arg); | ||
667 | else | ||
668 | r = -ENODEV; | ||
669 | mutex_unlock(&hiddev->existancelock); | ||
670 | return r; | ||
671 | 675 | ||
672 | case HIDIOCINITREPORT: | 676 | case HIDIOCINITREPORT: |
673 | mutex_lock(&hiddev->existancelock); | ||
674 | if (!hiddev->exist) { | ||
675 | mutex_unlock(&hiddev->existancelock); | ||
676 | return -ENODEV; | ||
677 | } | ||
678 | usbhid_init_reports(hid); | 677 | usbhid_init_reports(hid); |
679 | mutex_unlock(&hiddev->existancelock); | 678 | r = 0; |
680 | 679 | break; | |
681 | return 0; | ||
682 | 680 | ||
683 | case HIDIOCGREPORT: | 681 | case HIDIOCGREPORT: |
684 | if (copy_from_user(&rinfo, user_arg, sizeof(rinfo))) | 682 | if (copy_from_user(&rinfo, user_arg, sizeof(rinfo))) { |
685 | return -EFAULT; | 683 | r = -EFAULT; |
684 | break; | ||
685 | } | ||
686 | 686 | ||
687 | if (rinfo.report_type == HID_REPORT_TYPE_OUTPUT) | 687 | if (rinfo.report_type == HID_REPORT_TYPE_OUTPUT) |
688 | return -EINVAL; | 688 | break; |
689 | 689 | ||
690 | if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL) | 690 | report = hiddev_lookup_report(hid, &rinfo); |
691 | return -EINVAL; | 691 | if (report == NULL) |
692 | break; | ||
692 | 693 | ||
693 | mutex_lock(&hiddev->existancelock); | 694 | usbhid_submit_report(hid, report, USB_DIR_IN); |
694 | if (hiddev->exist) { | 695 | usbhid_wait_io(hid); |
695 | usbhid_submit_report(hid, report, USB_DIR_IN); | ||
696 | usbhid_wait_io(hid); | ||
697 | } | ||
698 | mutex_unlock(&hiddev->existancelock); | ||
699 | 696 | ||
700 | return 0; | 697 | r = 0; |
698 | break; | ||
701 | 699 | ||
702 | case HIDIOCSREPORT: | 700 | case HIDIOCSREPORT: |
703 | if (copy_from_user(&rinfo, user_arg, sizeof(rinfo))) | 701 | if (copy_from_user(&rinfo, user_arg, sizeof(rinfo))) { |
704 | return -EFAULT; | 702 | r = -EFAULT; |
703 | break; | ||
704 | } | ||
705 | 705 | ||
706 | if (rinfo.report_type == HID_REPORT_TYPE_INPUT) | 706 | if (rinfo.report_type == HID_REPORT_TYPE_INPUT) |
707 | return -EINVAL; | 707 | break; |
708 | 708 | ||
709 | if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL) | 709 | report = hiddev_lookup_report(hid, &rinfo); |
710 | return -EINVAL; | 710 | if (report == NULL) |
711 | break; | ||
711 | 712 | ||
712 | mutex_lock(&hiddev->existancelock); | 713 | usbhid_submit_report(hid, report, USB_DIR_OUT); |
713 | if (hiddev->exist) { | 714 | usbhid_wait_io(hid); |
714 | usbhid_submit_report(hid, report, USB_DIR_OUT); | ||
715 | usbhid_wait_io(hid); | ||
716 | } | ||
717 | mutex_unlock(&hiddev->existancelock); | ||
718 | 715 | ||
719 | return 0; | 716 | r = 0; |
717 | break; | ||
720 | 718 | ||
721 | case HIDIOCGREPORTINFO: | 719 | case HIDIOCGREPORTINFO: |
722 | if (copy_from_user(&rinfo, user_arg, sizeof(rinfo))) | 720 | if (copy_from_user(&rinfo, user_arg, sizeof(rinfo))) { |
723 | return -EFAULT; | 721 | r = -EFAULT; |
722 | break; | ||
723 | } | ||
724 | 724 | ||
725 | if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL) | 725 | report = hiddev_lookup_report(hid, &rinfo); |
726 | return -EINVAL; | 726 | if (report == NULL) |
727 | break; | ||
727 | 728 | ||
728 | rinfo.num_fields = report->maxfield; | 729 | rinfo.num_fields = report->maxfield; |
729 | 730 | ||
730 | if (copy_to_user(user_arg, &rinfo, sizeof(rinfo))) | 731 | r = copy_to_user(user_arg, &rinfo, sizeof(rinfo)) ? |
731 | return -EFAULT; | 732 | -EFAULT : 0; |
732 | 733 | break; | |
733 | return 0; | ||
734 | 734 | ||
735 | case HIDIOCGFIELDINFO: | 735 | case HIDIOCGFIELDINFO: |
736 | if (copy_from_user(&finfo, user_arg, sizeof(finfo))) | 736 | if (copy_from_user(&finfo, user_arg, sizeof(finfo))) { |
737 | return -EFAULT; | 737 | r = -EFAULT; |
738 | break; | ||
739 | } | ||
740 | |||
738 | rinfo.report_type = finfo.report_type; | 741 | rinfo.report_type = finfo.report_type; |
739 | rinfo.report_id = finfo.report_id; | 742 | rinfo.report_id = finfo.report_id; |
740 | if ((report = hiddev_lookup_report(hid, &rinfo)) == NULL) | 743 | |
741 | return -EINVAL; | 744 | report = hiddev_lookup_report(hid, &rinfo); |
745 | if (report == NULL) | ||
746 | break; | ||
742 | 747 | ||
743 | if (finfo.field_index >= report->maxfield) | 748 | if (finfo.field_index >= report->maxfield) |
744 | return -EINVAL; | 749 | break; |
745 | 750 | ||
746 | field = report->field[finfo.field_index]; | 751 | field = report->field[finfo.field_index]; |
747 | memset(&finfo, 0, sizeof(finfo)); | 752 | memset(&finfo, 0, sizeof(finfo)); |
@@ -760,10 +765,9 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
760 | finfo.unit_exponent = field->unit_exponent; | 765 | finfo.unit_exponent = field->unit_exponent; |
761 | finfo.unit = field->unit; | 766 | finfo.unit = field->unit; |
762 | 767 | ||
763 | if (copy_to_user(user_arg, &finfo, sizeof(finfo))) | 768 | r = copy_to_user(user_arg, &finfo, sizeof(finfo)) ? |
764 | return -EFAULT; | 769 | -EFAULT : 0; |
765 | 770 | break; | |
766 | return 0; | ||
767 | 771 | ||
768 | case HIDIOCGUCODE: | 772 | case HIDIOCGUCODE: |
769 | /* fall through */ | 773 | /* fall through */ |
@@ -772,57 +776,66 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
772 | case HIDIOCGUSAGES: | 776 | case HIDIOCGUSAGES: |
773 | case HIDIOCSUSAGES: | 777 | case HIDIOCSUSAGES: |
774 | case HIDIOCGCOLLECTIONINDEX: | 778 | case HIDIOCGCOLLECTIONINDEX: |
775 | mutex_lock(&hiddev->existancelock); | 779 | r = hiddev_ioctl_usage(hiddev, cmd, user_arg); |
776 | if (hiddev->exist) | 780 | break; |
777 | r = hiddev_ioctl_usage(hiddev, cmd, user_arg); | ||
778 | else | ||
779 | r = -ENODEV; | ||
780 | mutex_unlock(&hiddev->existancelock); | ||
781 | return r; | ||
782 | 781 | ||
783 | case HIDIOCGCOLLECTIONINFO: | 782 | case HIDIOCGCOLLECTIONINFO: |
784 | if (copy_from_user(&cinfo, user_arg, sizeof(cinfo))) | 783 | if (copy_from_user(&cinfo, user_arg, sizeof(cinfo))) { |
785 | return -EFAULT; | 784 | r = -EFAULT; |
785 | break; | ||
786 | } | ||
786 | 787 | ||
787 | if (cinfo.index >= hid->maxcollection) | 788 | if (cinfo.index >= hid->maxcollection) |
788 | return -EINVAL; | 789 | break; |
789 | 790 | ||
790 | cinfo.type = hid->collection[cinfo.index].type; | 791 | cinfo.type = hid->collection[cinfo.index].type; |
791 | cinfo.usage = hid->collection[cinfo.index].usage; | 792 | cinfo.usage = hid->collection[cinfo.index].usage; |
792 | cinfo.level = hid->collection[cinfo.index].level; | 793 | cinfo.level = hid->collection[cinfo.index].level; |
793 | 794 | ||
794 | if (copy_to_user(user_arg, &cinfo, sizeof(cinfo))) | 795 | r = copy_to_user(user_arg, &cinfo, sizeof(cinfo)) ? |
795 | return -EFAULT; | 796 | -EFAULT : 0; |
796 | return 0; | 797 | break; |
797 | 798 | ||
798 | default: | 799 | default: |
799 | |||
800 | if (_IOC_TYPE(cmd) != 'H' || _IOC_DIR(cmd) != _IOC_READ) | 800 | if (_IOC_TYPE(cmd) != 'H' || _IOC_DIR(cmd) != _IOC_READ) |
801 | return -EINVAL; | 801 | break; |
802 | 802 | ||
803 | if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGNAME(0))) { | 803 | if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGNAME(0))) { |
804 | int len; | 804 | int len; |
805 | if (!hid->name) | 805 | |
806 | return 0; | 806 | if (!hid->name) { |
807 | r = 0; | ||
808 | break; | ||
809 | } | ||
810 | |||
807 | len = strlen(hid->name) + 1; | 811 | len = strlen(hid->name) + 1; |
808 | if (len > _IOC_SIZE(cmd)) | 812 | if (len > _IOC_SIZE(cmd)) |
809 | len = _IOC_SIZE(cmd); | 813 | len = _IOC_SIZE(cmd); |
810 | return copy_to_user(user_arg, hid->name, len) ? | 814 | r = copy_to_user(user_arg, hid->name, len) ? |
811 | -EFAULT : len; | 815 | -EFAULT : len; |
816 | break; | ||
812 | } | 817 | } |
813 | 818 | ||
814 | if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGPHYS(0))) { | 819 | if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGPHYS(0))) { |
815 | int len; | 820 | int len; |
816 | if (!hid->phys) | 821 | |
817 | return 0; | 822 | if (!hid->phys) { |
823 | r = 0; | ||
824 | break; | ||
825 | } | ||
826 | |||
818 | len = strlen(hid->phys) + 1; | 827 | len = strlen(hid->phys) + 1; |
819 | if (len > _IOC_SIZE(cmd)) | 828 | if (len > _IOC_SIZE(cmd)) |
820 | len = _IOC_SIZE(cmd); | 829 | len = _IOC_SIZE(cmd); |
821 | return copy_to_user(user_arg, hid->phys, len) ? | 830 | r = copy_to_user(user_arg, hid->phys, len) ? |
822 | -EFAULT : len; | 831 | -EFAULT : len; |
832 | break; | ||
823 | } | 833 | } |
824 | } | 834 | } |
825 | return -EINVAL; | 835 | |
836 | ret_unlock: | ||
837 | mutex_unlock(&hiddev->existancelock); | ||
838 | return r; | ||
826 | } | 839 | } |
827 | 840 | ||
828 | #ifdef CONFIG_COMPAT | 841 | #ifdef CONFIG_COMPAT |
@@ -892,7 +905,7 @@ int hiddev_connect(struct hid_device *hid, unsigned int force) | |||
892 | hiddev->exist = 1; | 905 | hiddev->exist = 1; |
893 | retval = usb_register_dev(usbhid->intf, &hiddev_class); | 906 | retval = usb_register_dev(usbhid->intf, &hiddev_class); |
894 | if (retval) { | 907 | if (retval) { |
895 | err_hid("Not able to get a minor for this device."); | 908 | hid_err(hid, "Not able to get a minor for this device\n"); |
896 | hid->hiddev = NULL; | 909 | hid->hiddev = NULL; |
897 | kfree(hiddev); | 910 | kfree(hiddev); |
898 | return -1; | 911 | return -1; |
diff --git a/drivers/hid/usbhid/usbhid.h b/drivers/hid/usbhid/usbhid.h index 89d2e847dcc6..1673cac93d77 100644 --- a/drivers/hid/usbhid/usbhid.h +++ b/drivers/hid/usbhid/usbhid.h | |||
@@ -95,7 +95,6 @@ struct usbhid_device { | |||
95 | unsigned long stop_retry; /* Time to give up, in jiffies */ | 95 | unsigned long stop_retry; /* Time to give up, in jiffies */ |
96 | unsigned int retry_delay; /* Delay length in ms */ | 96 | unsigned int retry_delay; /* Delay length in ms */ |
97 | struct work_struct reset_work; /* Task context for resets */ | 97 | struct work_struct reset_work; /* Task context for resets */ |
98 | struct work_struct restart_work; /* waking up for output to be done in a task */ | ||
99 | wait_queue_head_t wait; /* For sleeping */ | 98 | wait_queue_head_t wait; /* For sleeping */ |
100 | int ledcount; /* counting the number of active leds */ | 99 | int ledcount; /* counting the number of active leds */ |
101 | }; | 100 | }; |
diff --git a/drivers/hid/usbhid/usbkbd.c b/drivers/hid/usbhid/usbkbd.c index a948605564fb..065817329f03 100644 --- a/drivers/hid/usbhid/usbkbd.c +++ b/drivers/hid/usbhid/usbkbd.c | |||
@@ -24,6 +24,8 @@ | |||
24 | * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic | 24 | * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
28 | |||
27 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
28 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
29 | #include <linux/module.h> | 31 | #include <linux/module.h> |
@@ -104,16 +106,18 @@ static void usb_kbd_irq(struct urb *urb) | |||
104 | if (usb_kbd_keycode[kbd->old[i]]) | 106 | if (usb_kbd_keycode[kbd->old[i]]) |
105 | input_report_key(kbd->dev, usb_kbd_keycode[kbd->old[i]], 0); | 107 | input_report_key(kbd->dev, usb_kbd_keycode[kbd->old[i]], 0); |
106 | else | 108 | else |
107 | dev_info(&urb->dev->dev, | 109 | hid_info(urb->dev, |
108 | "Unknown key (scancode %#x) released.\n", kbd->old[i]); | 110 | "Unknown key (scancode %#x) released.\n", |
111 | kbd->old[i]); | ||
109 | } | 112 | } |
110 | 113 | ||
111 | if (kbd->new[i] > 3 && memscan(kbd->old + 2, kbd->new[i], 6) == kbd->old + 8) { | 114 | if (kbd->new[i] > 3 && memscan(kbd->old + 2, kbd->new[i], 6) == kbd->old + 8) { |
112 | if (usb_kbd_keycode[kbd->new[i]]) | 115 | if (usb_kbd_keycode[kbd->new[i]]) |
113 | input_report_key(kbd->dev, usb_kbd_keycode[kbd->new[i]], 1); | 116 | input_report_key(kbd->dev, usb_kbd_keycode[kbd->new[i]], 1); |
114 | else | 117 | else |
115 | dev_info(&urb->dev->dev, | 118 | hid_info(urb->dev, |
116 | "Unknown key (scancode %#x) released.\n", kbd->new[i]); | 119 | "Unknown key (scancode %#x) released.\n", |
120 | kbd->new[i]); | ||
117 | } | 121 | } |
118 | } | 122 | } |
119 | 123 | ||
@@ -124,9 +128,9 @@ static void usb_kbd_irq(struct urb *urb) | |||
124 | resubmit: | 128 | resubmit: |
125 | i = usb_submit_urb (urb, GFP_ATOMIC); | 129 | i = usb_submit_urb (urb, GFP_ATOMIC); |
126 | if (i) | 130 | if (i) |
127 | err_hid ("can't resubmit intr, %s-%s/input0, status %d", | 131 | hid_err(urb->dev, "can't resubmit intr, %s-%s/input0, status %d", |
128 | kbd->usbdev->bus->bus_name, | 132 | kbd->usbdev->bus->bus_name, |
129 | kbd->usbdev->devpath, i); | 133 | kbd->usbdev->devpath, i); |
130 | } | 134 | } |
131 | 135 | ||
132 | static int usb_kbd_event(struct input_dev *dev, unsigned int type, | 136 | static int usb_kbd_event(struct input_dev *dev, unsigned int type, |
@@ -150,7 +154,7 @@ static int usb_kbd_event(struct input_dev *dev, unsigned int type, | |||
150 | *(kbd->leds) = kbd->newleds; | 154 | *(kbd->leds) = kbd->newleds; |
151 | kbd->led->dev = kbd->usbdev; | 155 | kbd->led->dev = kbd->usbdev; |
152 | if (usb_submit_urb(kbd->led, GFP_ATOMIC)) | 156 | if (usb_submit_urb(kbd->led, GFP_ATOMIC)) |
153 | err_hid("usb_submit_urb(leds) failed"); | 157 | pr_err("usb_submit_urb(leds) failed\n"); |
154 | 158 | ||
155 | return 0; | 159 | return 0; |
156 | } | 160 | } |
@@ -160,7 +164,7 @@ static void usb_kbd_led(struct urb *urb) | |||
160 | struct usb_kbd *kbd = urb->context; | 164 | struct usb_kbd *kbd = urb->context; |
161 | 165 | ||
162 | if (urb->status) | 166 | if (urb->status) |
163 | dev_warn(&urb->dev->dev, "led urb status %d received\n", | 167 | hid_warn(urb->dev, "led urb status %d received\n", |
164 | urb->status); | 168 | urb->status); |
165 | 169 | ||
166 | if (*(kbd->leds) == kbd->newleds) | 170 | if (*(kbd->leds) == kbd->newleds) |
@@ -169,7 +173,7 @@ static void usb_kbd_led(struct urb *urb) | |||
169 | *(kbd->leds) = kbd->newleds; | 173 | *(kbd->leds) = kbd->newleds; |
170 | kbd->led->dev = kbd->usbdev; | 174 | kbd->led->dev = kbd->usbdev; |
171 | if (usb_submit_urb(kbd->led, GFP_ATOMIC)) | 175 | if (usb_submit_urb(kbd->led, GFP_ATOMIC)) |
172 | err_hid("usb_submit_urb(leds) failed"); | 176 | hid_err(urb->dev, "usb_submit_urb(leds) failed\n"); |
173 | } | 177 | } |
174 | 178 | ||
175 | static int usb_kbd_open(struct input_dev *dev) | 179 | static int usb_kbd_open(struct input_dev *dev) |
diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c index b95231763911..ee82851afe3e 100644 --- a/drivers/input/mouse/bcm5974.c +++ b/drivers/input/mouse/bcm5974.c | |||
@@ -55,6 +55,14 @@ | |||
55 | #define USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI 0x0236 | 55 | #define USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI 0x0236 |
56 | #define USB_DEVICE_ID_APPLE_WELLSPRING3_ISO 0x0237 | 56 | #define USB_DEVICE_ID_APPLE_WELLSPRING3_ISO 0x0237 |
57 | #define USB_DEVICE_ID_APPLE_WELLSPRING3_JIS 0x0238 | 57 | #define USB_DEVICE_ID_APPLE_WELLSPRING3_JIS 0x0238 |
58 | /* MacbookAir3,2 (unibody), aka wellspring5 */ | ||
59 | #define USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI 0x023f | ||
60 | #define USB_DEVICE_ID_APPLE_WELLSPRING4_ISO 0x0240 | ||
61 | #define USB_DEVICE_ID_APPLE_WELLSPRING4_JIS 0x0241 | ||
62 | /* MacbookAir3,1 (unibody), aka wellspring4 */ | ||
63 | #define USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI 0x0242 | ||
64 | #define USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO 0x0243 | ||
65 | #define USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS 0x0244 | ||
58 | 66 | ||
59 | #define BCM5974_DEVICE(prod) { \ | 67 | #define BCM5974_DEVICE(prod) { \ |
60 | .match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \ | 68 | .match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \ |
@@ -80,6 +88,14 @@ static const struct usb_device_id bcm5974_table[] = { | |||
80 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI), | 88 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI), |
81 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_ISO), | 89 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_ISO), |
82 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_JIS), | 90 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_JIS), |
91 | /* MacbookAir3,2 */ | ||
92 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI), | ||
93 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4_ISO), | ||
94 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4_JIS), | ||
95 | /* MacbookAir3,1 */ | ||
96 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI), | ||
97 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO), | ||
98 | BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS), | ||
83 | /* Terminating entry */ | 99 | /* Terminating entry */ |
84 | {} | 100 | {} |
85 | }; | 101 | }; |
@@ -234,6 +250,30 @@ static const struct bcm5974_config bcm5974_config_table[] = { | |||
234 | { DIM_X, DIM_X / SN_COORD, -4460, 5166 }, | 250 | { DIM_X, DIM_X / SN_COORD, -4460, 5166 }, |
235 | { DIM_Y, DIM_Y / SN_COORD, -75, 6700 } | 251 | { DIM_Y, DIM_Y / SN_COORD, -75, 6700 } |
236 | }, | 252 | }, |
253 | { | ||
254 | USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI, | ||
255 | USB_DEVICE_ID_APPLE_WELLSPRING4_ISO, | ||
256 | USB_DEVICE_ID_APPLE_WELLSPRING4_JIS, | ||
257 | HAS_INTEGRATED_BUTTON, | ||
258 | 0x84, sizeof(struct bt_data), | ||
259 | 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS, | ||
260 | { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 300 }, | ||
261 | { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 }, | ||
262 | { DIM_X, DIM_X / SN_COORD, -4620, 5140 }, | ||
263 | { DIM_Y, DIM_Y / SN_COORD, -150, 6600 } | ||
264 | }, | ||
265 | { | ||
266 | USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI, | ||
267 | USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO, | ||
268 | USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS, | ||
269 | HAS_INTEGRATED_BUTTON, | ||
270 | 0x84, sizeof(struct bt_data), | ||
271 | 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS, | ||
272 | { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 300 }, | ||
273 | { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 }, | ||
274 | { DIM_X, DIM_X / SN_COORD, -4616, 5112 }, | ||
275 | { DIM_Y, DIM_Y / SN_COORD, -142, 5234 } | ||
276 | }, | ||
237 | {} | 277 | {} |
238 | }; | 278 | }; |
239 | 279 | ||
diff --git a/include/linux/device.h b/include/linux/device.h index 45bc8c1669d2..d96af9701d60 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -197,6 +197,7 @@ struct class { | |||
197 | 197 | ||
198 | struct class_attribute *class_attrs; | 198 | struct class_attribute *class_attrs; |
199 | struct device_attribute *dev_attrs; | 199 | struct device_attribute *dev_attrs; |
200 | struct bin_attribute *dev_bin_attrs; | ||
200 | struct kobject *dev_kobj; | 201 | struct kobject *dev_kobj; |
201 | 202 | ||
202 | int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env); | 203 | int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env); |
diff --git a/include/linux/hid.h b/include/linux/hid.h index bb0f56f5c01e..20b9801f669b 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h | |||
@@ -820,6 +820,49 @@ static inline void hid_hw_stop(struct hid_device *hdev) | |||
820 | hdev->ll_driver->stop(hdev); | 820 | hdev->ll_driver->stop(hdev); |
821 | } | 821 | } |
822 | 822 | ||
823 | /** | ||
824 | * hid_hw_open - signal underlaying HW to start delivering events | ||
825 | * | ||
826 | * @hdev: hid device | ||
827 | * | ||
828 | * Tell underlying HW to start delivering events from the device. | ||
829 | * This function should be called sometime after successful call | ||
830 | * to hid_hiw_start(). | ||
831 | */ | ||
832 | static inline int __must_check hid_hw_open(struct hid_device *hdev) | ||
833 | { | ||
834 | return hdev->ll_driver->open(hdev); | ||
835 | } | ||
836 | |||
837 | /** | ||
838 | * hid_hw_close - signal underlaying HW to stop delivering events | ||
839 | * | ||
840 | * @hdev: hid device | ||
841 | * | ||
842 | * This function indicates that we are not interested in the events | ||
843 | * from this device anymore. Delivery of events may or may not stop, | ||
844 | * depending on the number of users still outstanding. | ||
845 | */ | ||
846 | static inline void hid_hw_close(struct hid_device *hdev) | ||
847 | { | ||
848 | hdev->ll_driver->close(hdev); | ||
849 | } | ||
850 | |||
851 | /** | ||
852 | * hid_hw_power - requests underlying HW to go into given power mode | ||
853 | * | ||
854 | * @hdev: hid device | ||
855 | * @level: requested power level (one of %PM_HINT_* defines) | ||
856 | * | ||
857 | * This function requests underlying hardware to enter requested power | ||
858 | * mode. | ||
859 | */ | ||
860 | |||
861 | static inline int hid_hw_power(struct hid_device *hdev, int level) | ||
862 | { | ||
863 | return hdev->ll_driver->power ? hdev->ll_driver->power(hdev, level) : 0; | ||
864 | } | ||
865 | |||
823 | void hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, | 866 | void hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size, |
824 | int interrupt); | 867 | int interrupt); |
825 | 868 | ||
@@ -838,12 +881,32 @@ int hid_pidff_init(struct hid_device *hid); | |||
838 | #define hid_pidff_init NULL | 881 | #define hid_pidff_init NULL |
839 | #endif | 882 | #endif |
840 | 883 | ||
841 | #define dbg_hid(format, arg...) if (hid_debug) \ | 884 | #define dbg_hid(format, arg...) \ |
842 | printk(KERN_DEBUG "%s: " format ,\ | 885 | do { \ |
843 | __FILE__ , ## arg) | 886 | if (hid_debug) \ |
844 | #define err_hid(format, arg...) printk(KERN_ERR "%s: " format "\n" , \ | 887 | printk(KERN_DEBUG "%s: " format, __FILE__, ##arg); \ |
845 | __FILE__ , ## arg) | 888 | } while (0) |
846 | #endif /* HID_FF */ | 889 | |
890 | #define hid_printk(level, hid, fmt, arg...) \ | ||
891 | dev_printk(level, &(hid)->dev, fmt, ##arg) | ||
892 | #define hid_emerg(hid, fmt, arg...) \ | ||
893 | dev_emerg(&(hid)->dev, fmt, ##arg) | ||
894 | #define hid_crit(hid, fmt, arg...) \ | ||
895 | dev_crit(&(hid)->dev, fmt, ##arg) | ||
896 | #define hid_alert(hid, fmt, arg...) \ | ||
897 | dev_alert(&(hid)->dev, fmt, ##arg) | ||
898 | #define hid_err(hid, fmt, arg...) \ | ||
899 | dev_err(&(hid)->dev, fmt, ##arg) | ||
900 | #define hid_notice(hid, fmt, arg...) \ | ||
901 | dev_notice(&(hid)->dev, fmt, ##arg) | ||
902 | #define hid_warn(hid, fmt, arg...) \ | ||
903 | dev_warn(&(hid)->dev, fmt, ##arg) | ||
904 | #define hid_info(hid, fmt, arg...) \ | ||
905 | dev_info(&(hid)->dev, fmt, ##arg) | ||
906 | #define hid_dbg(hid, fmt, arg...) \ | ||
907 | dev_dbg(&(hid)->dev, fmt, ##arg) | ||
908 | |||
909 | #endif /* __KERNEL__ */ | ||
847 | 910 | ||
848 | #endif | 911 | #endif |
849 | 912 | ||