Skip to content

Commit a544c61

Browse files
bentissJiri Kosina
authored andcommitted
HID: wacom: do not attempt to switch mode while in probe
The Intuos Pro seems to not like when we set the features right after being powered up. Instead of waiting during probe, we can schedule the switch mode and LED control in a deferred worker so that we don't have the 5 secs of delay from USB when the device is not accessible. The USB timeout delays were really a pain because if you happen to unplug the tablet while it is still waiting, you are just adding 5 second timeouts to the USB stack. Which means that a new plug of the same tablet will also gets delayed, and will also attempt to access the hardware while in .probe(). So the tablet doesn't appear in the dmesg, the user unplug/replug it to make it appearing... and so on so forth. Really, this is for the best :) Signed-off-by: Benjamin Tissoires <[email protected]> Acked-by: Jason Gerecke <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent c0265a9 commit a544c61

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

drivers/hid/wacom.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ struct wacom {
166166
struct work_struct wireless_work;
167167
struct work_struct battery_work;
168168
struct work_struct remote_work;
169+
struct delayed_work init_work;
169170
struct wacom_remote *remote;
170171
struct wacom_leds {
171172
struct wacom_group_leds *groups;

drivers/hid/wacom_sys.c

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -497,11 +497,11 @@ static int wacom_bt_query_tablet_data(struct hid_device *hdev, u8 speed,
497497
* from the tablet, it is necessary to switch the tablet out of this
498498
* mode and into one which sends the full range of tablet data.
499499
*/
500-
static int wacom_query_tablet_data(struct hid_device *hdev,
501-
struct wacom_features *features)
500+
static int _wacom_query_tablet_data(struct wacom *wacom)
502501
{
503-
struct wacom *wacom = hid_get_drvdata(hdev);
502+
struct hid_device *hdev = wacom->hdev;
504503
struct wacom_wac *wacom_wac = &wacom->wacom_wac;
504+
struct wacom_features *features = &wacom_wac->features;
505505

506506
if (hdev->bus == BUS_BLUETOOTH)
507507
return wacom_bt_query_tablet_data(hdev, 1, features);
@@ -1437,11 +1437,23 @@ static int wacom_initialize_leds(struct wacom *wacom)
14371437
"cannot create sysfs group err: %d\n", error);
14381438
return error;
14391439
}
1440-
wacom_led_control(wacom);
14411440

14421441
return 0;
14431442
}
14441443

1444+
static void wacom_init_work(struct work_struct *work)
1445+
{
1446+
struct wacom *wacom = container_of(work, struct wacom, init_work.work);
1447+
1448+
_wacom_query_tablet_data(wacom);
1449+
wacom_led_control(wacom);
1450+
}
1451+
1452+
static void wacom_query_tablet_data(struct wacom *wacom)
1453+
{
1454+
schedule_delayed_work(&wacom->init_work, msecs_to_jiffies(1000));
1455+
}
1456+
14451457
static enum power_supply_property wacom_battery_props[] = {
14461458
POWER_SUPPLY_PROP_MODEL_NAME,
14471459
POWER_SUPPLY_PROP_PRESENT,
@@ -2115,7 +2127,7 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
21152127

21162128
if (!wireless) {
21172129
/* Note that if query fails it is not a hard failure */
2118-
wacom_query_tablet_data(hdev, features);
2130+
wacom_query_tablet_data(wacom);
21192131
}
21202132

21212133
/* touch only Bamboo doesn't support pen */
@@ -2447,6 +2459,7 @@ static int wacom_probe(struct hid_device *hdev,
24472459
wacom->usbdev = dev;
24482460
wacom->intf = intf;
24492461
mutex_init(&wacom->lock);
2462+
INIT_DELAYED_WORK(&wacom->init_work, wacom_init_work);
24502463
INIT_WORK(&wacom->wireless_work, wacom_wireless_work);
24512464
INIT_WORK(&wacom->battery_work, wacom_battery_work);
24522465
INIT_WORK(&wacom->remote_work, wacom_remote_work);
@@ -2488,6 +2501,7 @@ static void wacom_remove(struct hid_device *hdev)
24882501

24892502
hid_hw_stop(hdev);
24902503

2504+
cancel_delayed_work_sync(&wacom->init_work);
24912505
cancel_work_sync(&wacom->wireless_work);
24922506
cancel_work_sync(&wacom->battery_work);
24932507
cancel_work_sync(&wacom->remote_work);
@@ -2505,12 +2519,11 @@ static void wacom_remove(struct hid_device *hdev)
25052519
static int wacom_resume(struct hid_device *hdev)
25062520
{
25072521
struct wacom *wacom = hid_get_drvdata(hdev);
2508-
struct wacom_features *features = &wacom->wacom_wac.features;
25092522

25102523
mutex_lock(&wacom->lock);
25112524

25122525
/* switch to wacom mode first */
2513-
wacom_query_tablet_data(hdev, features);
2526+
_wacom_query_tablet_data(wacom);
25142527
wacom_led_control(wacom);
25152528

25162529
mutex_unlock(&wacom->lock);

0 commit comments

Comments
 (0)