提交 a544c619 编写于 作者: B Benjamin Tissoires 提交者: Jiri Kosina

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: NBenjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: NJason Gerecke <jason.gerecke@wacom.com>
Signed-off-by: NJiri Kosina <jkosina@suse.cz>
上级 c0265a94
...@@ -166,6 +166,7 @@ struct wacom { ...@@ -166,6 +166,7 @@ struct wacom {
struct work_struct wireless_work; struct work_struct wireless_work;
struct work_struct battery_work; struct work_struct battery_work;
struct work_struct remote_work; struct work_struct remote_work;
struct delayed_work init_work;
struct wacom_remote *remote; struct wacom_remote *remote;
struct wacom_leds { struct wacom_leds {
struct wacom_group_leds *groups; struct wacom_group_leds *groups;
......
...@@ -497,11 +497,11 @@ static int wacom_bt_query_tablet_data(struct hid_device *hdev, u8 speed, ...@@ -497,11 +497,11 @@ static int wacom_bt_query_tablet_data(struct hid_device *hdev, u8 speed,
* from the tablet, it is necessary to switch the tablet out of this * from the tablet, it is necessary to switch the tablet out of this
* mode and into one which sends the full range of tablet data. * mode and into one which sends the full range of tablet data.
*/ */
static int wacom_query_tablet_data(struct hid_device *hdev, static int _wacom_query_tablet_data(struct wacom *wacom)
struct wacom_features *features)
{ {
struct wacom *wacom = hid_get_drvdata(hdev); struct hid_device *hdev = wacom->hdev;
struct wacom_wac *wacom_wac = &wacom->wacom_wac; struct wacom_wac *wacom_wac = &wacom->wacom_wac;
struct wacom_features *features = &wacom_wac->features;
if (hdev->bus == BUS_BLUETOOTH) if (hdev->bus == BUS_BLUETOOTH)
return wacom_bt_query_tablet_data(hdev, 1, features); return wacom_bt_query_tablet_data(hdev, 1, features);
...@@ -1437,11 +1437,23 @@ static int wacom_initialize_leds(struct wacom *wacom) ...@@ -1437,11 +1437,23 @@ static int wacom_initialize_leds(struct wacom *wacom)
"cannot create sysfs group err: %d\n", error); "cannot create sysfs group err: %d\n", error);
return error; return error;
} }
wacom_led_control(wacom);
return 0; return 0;
} }
static void wacom_init_work(struct work_struct *work)
{
struct wacom *wacom = container_of(work, struct wacom, init_work.work);
_wacom_query_tablet_data(wacom);
wacom_led_control(wacom);
}
static void wacom_query_tablet_data(struct wacom *wacom)
{
schedule_delayed_work(&wacom->init_work, msecs_to_jiffies(1000));
}
static enum power_supply_property wacom_battery_props[] = { static enum power_supply_property wacom_battery_props[] = {
POWER_SUPPLY_PROP_MODEL_NAME, POWER_SUPPLY_PROP_MODEL_NAME,
POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_PRESENT,
...@@ -2115,7 +2127,7 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless) ...@@ -2115,7 +2127,7 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
if (!wireless) { if (!wireless) {
/* Note that if query fails it is not a hard failure */ /* Note that if query fails it is not a hard failure */
wacom_query_tablet_data(hdev, features); wacom_query_tablet_data(wacom);
} }
/* touch only Bamboo doesn't support pen */ /* touch only Bamboo doesn't support pen */
...@@ -2447,6 +2459,7 @@ static int wacom_probe(struct hid_device *hdev, ...@@ -2447,6 +2459,7 @@ static int wacom_probe(struct hid_device *hdev,
wacom->usbdev = dev; wacom->usbdev = dev;
wacom->intf = intf; wacom->intf = intf;
mutex_init(&wacom->lock); mutex_init(&wacom->lock);
INIT_DELAYED_WORK(&wacom->init_work, wacom_init_work);
INIT_WORK(&wacom->wireless_work, wacom_wireless_work); INIT_WORK(&wacom->wireless_work, wacom_wireless_work);
INIT_WORK(&wacom->battery_work, wacom_battery_work); INIT_WORK(&wacom->battery_work, wacom_battery_work);
INIT_WORK(&wacom->remote_work, wacom_remote_work); INIT_WORK(&wacom->remote_work, wacom_remote_work);
...@@ -2488,6 +2501,7 @@ static void wacom_remove(struct hid_device *hdev) ...@@ -2488,6 +2501,7 @@ static void wacom_remove(struct hid_device *hdev)
hid_hw_stop(hdev); hid_hw_stop(hdev);
cancel_delayed_work_sync(&wacom->init_work);
cancel_work_sync(&wacom->wireless_work); cancel_work_sync(&wacom->wireless_work);
cancel_work_sync(&wacom->battery_work); cancel_work_sync(&wacom->battery_work);
cancel_work_sync(&wacom->remote_work); cancel_work_sync(&wacom->remote_work);
...@@ -2505,12 +2519,11 @@ static void wacom_remove(struct hid_device *hdev) ...@@ -2505,12 +2519,11 @@ static void wacom_remove(struct hid_device *hdev)
static int wacom_resume(struct hid_device *hdev) static int wacom_resume(struct hid_device *hdev)
{ {
struct wacom *wacom = hid_get_drvdata(hdev); struct wacom *wacom = hid_get_drvdata(hdev);
struct wacom_features *features = &wacom->wacom_wac.features;
mutex_lock(&wacom->lock); mutex_lock(&wacom->lock);
/* switch to wacom mode first */ /* switch to wacom mode first */
wacom_query_tablet_data(hdev, features); _wacom_query_tablet_data(wacom);
wacom_led_control(wacom); wacom_led_control(wacom);
mutex_unlock(&wacom->lock); mutex_unlock(&wacom->lock);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册