HID: wacom: Handle failing HID_DG_CONTACTMAX requests
[linux-2.6-block.git] / drivers / hid / wacom_sys.c
index 157aa7aa1067a4b2cff7c527594c58af6da89a3b..eea18a6cbdc701490fb4908ff0740de61bd5c888 100644 (file)
@@ -35,7 +35,11 @@ static int wacom_get_report(struct hid_device *hdev, u8 type, u8 *buf,
        do {
                retval = hid_hw_raw_request(hdev, buf[0], buf, size, type,
                                HID_REQ_GET_REPORT);
-       } while ((retval == -ETIMEDOUT || retval == -EPIPE) && --retries);
+       } while ((retval == -ETIMEDOUT || retval == -EAGAIN) && --retries);
+
+       if (retval < 0)
+               hid_err(hdev, "wacom_get_report: ran out of retries "
+                       "(last error = %d)\n", retval);
 
        return retval;
 }
@@ -48,7 +52,11 @@ static int wacom_set_report(struct hid_device *hdev, u8 type, u8 *buf,
        do {
                retval = hid_hw_raw_request(hdev, buf[0], buf, size, type,
                                HID_REQ_SET_REPORT);
-       } while ((retval == -ETIMEDOUT || retval == -EPIPE) && --retries);
+       } while ((retval == -ETIMEDOUT || retval == -EAGAIN) && --retries);
+
+       if (retval < 0)
+               hid_err(hdev, "wacom_set_report: ran out of retries "
+                       "(last error = %d)\n", retval);
 
        return retval;
 }
@@ -117,9 +125,16 @@ static void wacom_feature_mapping(struct hid_device *hdev,
                                break;
                        data[0] = field->report->id;
                        ret = wacom_get_report(hdev, HID_FEATURE_REPORT,
-                                               data, 2, 0);
-                       if (ret == 2)
+                                               data, 2, WAC_CMD_RETRIES);
+                       if (ret == 2) {
                                features->touch_max = data[1];
+                       } else {
+                               features->touch_max = 16;
+                               hid_warn(hdev, "wacom_feature_mapping: "
+                                        "could not get HID_DG_CONTACTMAX, "
+                                        "defaulting to %d\n",
+                                         features->touch_max);
+                       }
                        kfree(data);
                }
                break;
@@ -1528,8 +1543,14 @@ static int wacom_probe(struct hid_device *hdev,
        wacom_setup_device_quirks(wacom);
 
        if (!features->device_type && features->type != WIRELESS) {
+               error = features->type == HID_GENERIC ? -ENODEV : 0;
+
                dev_warn(&hdev->dev, "Unknown device_type for '%s'. %s.",
-                        hdev->name, "Assuming pen");
+                        hdev->name,
+                        error ? "Ignoring" : "Assuming pen");
+
+               if (error)
+                       goto fail_shared_data;
 
                features->device_type = BTN_TOOL_PEN;
        }