]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/kernel-video.git/blobdiff - drivers/input/tablet/wacom_sys.c
Input: wacom - fix wacom_set_report retry logic
[android-sdk/kernel-video.git] / drivers / input / tablet / wacom_sys.c
index 858ad446de91b338553d6577bb6d1ac886c1fbb5..aaf23aeae2ea428b4a26ea0cd99f20eeac32c964 100644 (file)
@@ -386,23 +386,40 @@ static int wacom_parse_hid(struct usb_interface *intf,
                                if (usage == WCM_DESKTOP) {
                                        if (finger) {
                                                features->device_type = BTN_TOOL_FINGER;
-                                               if (features->type == TABLETPC2FG) {
-                                                       /* need to reset back */
+
+                                               switch (features->type) {
+                                               case TABLETPC2FG:
                                                        features->pktlen = WACOM_PKGLEN_TPC2FG;
-                                               }
+                                                       break;
 
-                                               if (features->type == MTSCREEN || features->type == WACOM_24HDT)
+                                               case MTSCREEN:
+                                               case WACOM_24HDT:
                                                        features->pktlen = WACOM_PKGLEN_MTOUCH;
+                                                       break;
 
-                                               if (features->type == BAMBOO_PT) {
-                                                       /* need to reset back */
+                                               case MTTPC:
+                                                       features->pktlen = WACOM_PKGLEN_MTTPC;
+                                                       break;
+
+                                               case BAMBOO_PT:
                                                        features->pktlen = WACOM_PKGLEN_BBTOUCH;
+                                                       break;
+
+                                               default:
+                                                       features->pktlen = WACOM_PKGLEN_GRAPHIRE;
+                                                       break;
+                                               }
+
+                                               switch (features->type) {
+                                               case BAMBOO_PT:
                                                        features->x_phy =
                                                                get_unaligned_le16(&report[i + 5]);
                                                        features->x_max =
                                                                get_unaligned_le16(&report[i + 8]);
                                                        i += 15;
-                                               } else if (features->type == WACOM_24HDT) {
+                                                       break;
+
+                                               case WACOM_24HDT:
                                                        features->x_max =
                                                                get_unaligned_le16(&report[i + 3]);
                                                        features->x_phy =
@@ -410,7 +427,9 @@ static int wacom_parse_hid(struct usb_interface *intf,
                                                        features->unit = report[i - 1];
                                                        features->unitExpo = report[i - 3];
                                                        i += 12;
-                                               } else {
+                                                       break;
+
+                                               default:
                                                        features->x_max =
                                                                get_unaligned_le16(&report[i + 3]);
                                                        features->x_phy =
@@ -418,10 +437,11 @@ static int wacom_parse_hid(struct usb_interface *intf,
                                                        features->unit = report[i + 9];
                                                        features->unitExpo = report[i + 11];
                                                        i += 12;
+                                                       break;
                                                }
                                        } else if (pen) {
                                                /* penabled only accepts exact bytes of data */
-                                               if (features->type == TABLETPC2FG)
+                                               if (features->type >= TABLETPC)
                                                        features->pktlen = WACOM_PKGLEN_GRAPHIRE;
                                                features->device_type = BTN_TOOL_PEN;
                                                features->x_max =
@@ -434,32 +454,40 @@ static int wacom_parse_hid(struct usb_interface *intf,
                        case HID_USAGE_Y:
                                if (usage == WCM_DESKTOP) {
                                        if (finger) {
-                                               int type = features->type;
-
-                                               if (type == TABLETPC2FG || type == MTSCREEN) {
+                                               switch (features->type) {
+                                               case TABLETPC2FG:
+                                               case MTSCREEN:
+                                               case MTTPC:
                                                        features->y_max =
                                                                get_unaligned_le16(&report[i + 3]);
                                                        features->y_phy =
                                                                get_unaligned_le16(&report[i + 6]);
                                                        i += 7;
-                                               } else if (type == WACOM_24HDT) {
+                                                       break;
+
+                                               case WACOM_24HDT:
                                                        features->y_max =
                                                                get_unaligned_le16(&report[i + 3]);
                                                        features->y_phy =
                                                                get_unaligned_le16(&report[i - 2]);
                                                        i += 7;
-                                               } else if (type == BAMBOO_PT) {
+                                                       break;
+
+                                               case BAMBOO_PT:
                                                        features->y_phy =
                                                                get_unaligned_le16(&report[i + 3]);
                                                        features->y_max =
                                                                get_unaligned_le16(&report[i + 6]);
                                                        i += 12;
-                                               } else {
+                                                       break;
+
+                                               default:
                                                        features->y_max =
                                                                features->x_max;
                                                        features->y_phy =
                                                                get_unaligned_le16(&report[i + 3]);
                                                        i += 4;
+                                                       break;
                                                }
                                        } else if (pen) {
                                                features->y_max =
@@ -525,10 +553,10 @@ static int wacom_set_device_mode(struct usb_interface *intf, int report_id, int
        if (!rep_data)
                return error;
 
-       rep_data[0] = report_id;
-       rep_data[1] = mode;
-
        do {
+               rep_data[0] = report_id;
+               rep_data[1] = mode;
+
                error = wacom_set_report(intf, WAC_HID_FEATURE_REPORT,
                                         report_id, rep_data, length, 1);
                if (error >= 0)