aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
authorAntonio Ospite <ao2@ao2.it>2015-02-16 12:12:22 -0500
committerJiri Kosina <jkosina@suse.cz>2015-02-18 15:36:12 -0500
commita85d67b545e9c1e178ecdb159cfa59a45405c22a (patch)
tree667083aca540ef42635d093cc0258aab76ddede2 /drivers/hid
parent29b691a894f3964b26b8179423a45591fc071eea (diff)
HID: sony: Don't use magic numbers in sixaxis_set_operational_usb()
Remove the magic numbers used in sixaxis_set_operational_usb(): - use the already defined SIXAXIS_REPORT_0xF2_SIZE; - define and use SIXAXIS_REPORT_0xF5_SIZE; - set the dummy buffer size to accommodate any report that is going to be requested. Signed-off-by: Antonio Ospite <ao2@ao2.it> Acked-by: Frank Praznik <frank.praznik@oh.rr.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/hid-sony.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 4d6376cac0bd..64f2f51e6698 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -803,6 +803,7 @@ union sixaxis_output_report_01 {
803#define DS4_REPORT_0x11_SIZE 78 803#define DS4_REPORT_0x11_SIZE 78
804#define DS4_REPORT_0x81_SIZE 7 804#define DS4_REPORT_0x81_SIZE 7
805#define SIXAXIS_REPORT_0xF2_SIZE 17 805#define SIXAXIS_REPORT_0xF2_SIZE 17
806#define SIXAXIS_REPORT_0xF5_SIZE 8
806 807
807static spinlock_t sony_dev_list_lock; 808static spinlock_t sony_dev_list_lock;
808static LIST_HEAD(sony_device_list); 809static LIST_HEAD(sony_device_list);
@@ -1131,13 +1132,15 @@ static void sony_input_configured(struct hid_device *hdev,
1131static int sixaxis_set_operational_usb(struct hid_device *hdev) 1132static int sixaxis_set_operational_usb(struct hid_device *hdev)
1132{ 1133{
1133 int ret; 1134 int ret;
1134 char *buf = kmalloc(18, GFP_KERNEL); 1135 const int buf_size =
1136 max(SIXAXIS_REPORT_0xF2_SIZE, SIXAXIS_REPORT_0xF5_SIZE);
1137 char *buf = kmalloc(buf_size, GFP_KERNEL);
1135 1138
1136 if (!buf) 1139 if (!buf)
1137 return -ENOMEM; 1140 return -ENOMEM;
1138 1141
1139 ret = hid_hw_raw_request(hdev, 0xf2, buf, 17, HID_FEATURE_REPORT, 1142 ret = hid_hw_raw_request(hdev, 0xf2, buf, SIXAXIS_REPORT_0xF2_SIZE,
1140 HID_REQ_GET_REPORT); 1143 HID_FEATURE_REPORT, HID_REQ_GET_REPORT);
1141 1144
1142 if (ret < 0) { 1145 if (ret < 0) {
1143 hid_err(hdev, "can't set operational mode: step 1\n"); 1146 hid_err(hdev, "can't set operational mode: step 1\n");
@@ -1148,8 +1151,8 @@ static int sixaxis_set_operational_usb(struct hid_device *hdev)
1148 * Some compatible controllers like the Speedlink Strike FX and 1151 * Some compatible controllers like the Speedlink Strike FX and
1149 * Gasia need another query plus an USB interrupt to get operational. 1152 * Gasia need another query plus an USB interrupt to get operational.
1150 */ 1153 */
1151 ret = hid_hw_raw_request(hdev, 0xf5, buf, 8, HID_FEATURE_REPORT, 1154 ret = hid_hw_raw_request(hdev, 0xf5, buf, SIXAXIS_REPORT_0xF5_SIZE,
1152 HID_REQ_GET_REPORT); 1155 HID_FEATURE_REPORT, HID_REQ_GET_REPORT);
1153 1156
1154 if (ret < 0) { 1157 if (ret < 0) {
1155 hid_err(hdev, "can't set operational mode: step 2\n"); 1158 hid_err(hdev, "can't set operational mode: step 2\n");