Looks like the battery hijacked the wireless worker. That's not fair so
use a work queue per task.

Signed-off-by: Benjamin Tissoires <benjamin.tissoi...@redhat.com>
Acked-by: Ping Cheng <pi...@wacom.com>
Signed-off-by: Jiri Kosina <jkos...@suse.cz>
[aaron.sko...@wacom.com: Imported into input-wacom repository (d17d1f1)]
Signed-off-by: Aaron Armstrong Skomra <aaron.sko...@wacom.com>
[aaron.sko...@wacom.com: Backported from input-wacom repository (4f9aa64)]
Signed-off-by: Aaron Armstrong Skomra <aaron.sko...@wacom.com>
---
 2.6.38/wacom.h     | 21 ++++++++++++++++++---
 2.6.38/wacom_sys.c | 10 ++++++----
 2.6.38/wacom_wac.c | 13 +++++--------
 3.17/wacom.h       | 21 ++++++++++++++++++---
 3.17/wacom_sys.c   | 10 ++++++----
 3.17/wacom_wac.c   | 13 +++++--------
 3.7/wacom.h        | 21 ++++++++++++++++++---
 3.7/wacom_sys.c    | 10 ++++++----
 3.7/wacom_wac.c    | 13 +++++--------
 9 files changed, 87 insertions(+), 45 deletions(-)

diff --git a/2.6.38/wacom.h b/2.6.38/wacom.h
index 36dbf8a..d21d786 100644
--- a/2.6.38/wacom.h
+++ b/2.6.38/wacom.h
@@ -112,6 +112,11 @@ MODULE_LICENSE(DRIVER_LICENSE);
 #define USB_VENDOR_ID_WACOM    0x056a
 #define USB_VENDOR_ID_LENOVO   0x17ef
 
+enum wacom_worker {
+       WACOM_WORKER_WIRELESS,
+       WACOM_WORKER_BATTERY,
+};
+
 struct wacom {
        dma_addr_t data_dma;
        struct usb_device *usbdev;
@@ -119,7 +124,8 @@ struct wacom {
        struct urb *irq;
        struct wacom_wac wacom_wac;
        struct mutex lock;
-       struct work_struct work;
+       struct work_struct wireless_work;
+       struct work_struct battery_work;
        bool open;
        char phys[32];
        struct wacom_led {
@@ -134,10 +140,19 @@ struct wacom {
        struct attribute_group remote_group[5];
 };
 
-static inline void wacom_schedule_work(struct wacom_wac *wacom_wac)
+static inline void wacom_schedule_work(struct wacom_wac *wacom_wac,
+                                      enum wacom_worker which)
 {
        struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
-       schedule_work(&wacom->work);
+
+       switch (which) {
+       case WACOM_WORKER_WIRELESS:
+               schedule_work(&wacom->wireless_work);
+               break;
+       case WACOM_WORKER_BATTERY:
+               schedule_work(&wacom->battery_work);
+               break;
+       }
 }
 
 extern const struct usb_device_id wacom_ids[];
diff --git a/2.6.38/wacom_sys.c b/2.6.38/wacom_sys.c
index 3cfe780..1f2a850 100644
--- a/2.6.38/wacom_sys.c
+++ b/2.6.38/wacom_sys.c
@@ -1492,7 +1492,7 @@ static void wacom_calculate_res(struct wacom_features 
*features)
 
 static void wacom_wireless_work(struct work_struct *work)
 {
-       struct wacom *wacom = container_of(work, struct wacom, work);
+       struct wacom *wacom = container_of(work, struct wacom, wireless_work);
        struct usb_device *usbdev = wacom->usbdev;
        struct wacom_wac *wacom_wac = &wacom->wacom_wac;
        struct wacom *wacom1, *wacom2;
@@ -1603,7 +1603,7 @@ fail:
 
 void wacom_battery_work(struct work_struct *work)
 {
-       struct wacom *wacom = container_of(work, struct wacom, work);
+       struct wacom *wacom = container_of(work, struct wacom, battery_work);
 
        if ((wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) &&
             !wacom->battery.dev) {
@@ -1660,7 +1660,8 @@ static int wacom_probe(struct usb_interface *intf, const 
struct usb_device_id *i
        wacom->usbdev = dev;
        wacom->intf = intf;
        mutex_init(&wacom->lock);
-       INIT_WORK(&wacom->work, wacom_wireless_work);
+       INIT_WORK(&wacom->wireless_work, wacom_wireless_work);
+       INIT_WORK(&wacom->battery_work, wacom_battery_work);
        usb_make_path(dev, wacom->phys, sizeof(wacom->phys));
        strlcat(wacom->phys, "/input0", sizeof(wacom->phys));
 
@@ -1755,7 +1756,8 @@ static void wacom_disconnect(struct usb_interface *intf)
        usb_set_intfdata(intf, NULL);
 
        usb_kill_urb(wacom->irq);
-       cancel_work_sync(&wacom->work);
+       cancel_work_sync(&wacom->wireless_work);
+       cancel_work_sync(&wacom->battery_work);
        kobject_put(wacom->remote_dir);
        wacom_destroy_leds(wacom);
        wacom_unregister_inputs(wacom);
diff --git a/2.6.38/wacom_wac.c b/2.6.38/wacom_wac.c
index 379bfdb..b131855 100644
--- a/2.6.38/wacom_wac.c
+++ b/2.6.38/wacom_wac.c
@@ -762,8 +762,7 @@ static int wacom_remote_irq(struct wacom_wac *wacom_wac, 
size_t len)
        if (!wacom->battery.dev &&
            !(features->quirks & WACOM_QUIRK_BATTERY)) {
                features->quirks |= WACOM_QUIRK_BATTERY;
-               INIT_WORK(&wacom->work, wacom_battery_work);
-               wacom_schedule_work(wacom_wac);
+               wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
        }
 
        wacom_notify_battery(wacom_wac, bat_percent, bat_charging, 1, 
bat_charging);
@@ -1572,7 +1571,7 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, 
size_t len)
                charging = !!(data[5] & 0x80);
                if (wacom->pid != pid) {
                        wacom->pid = pid;
-                       wacom_schedule_work(wacom);
+                       wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
                }
 
                if (w->battery.dev)
@@ -1581,7 +1580,7 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, 
size_t len)
        } else if (wacom->pid != 0) {
                /* disconnected while previously connected */
                wacom->pid = 0;
-               wacom_schedule_work(wacom);
+               wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
                wacom_notify_battery(wacom, 0, 0, 0, 0);
        }
 
@@ -1616,15 +1615,13 @@ static int wacom_status_irq(struct wacom_wac 
*wacom_wac, size_t len)
                if (!wacom->battery.dev &&
                    !(features->quirks & WACOM_QUIRK_BATTERY)) {
                        features->quirks |= WACOM_QUIRK_BATTERY;
-                       INIT_WORK(&wacom->work, wacom_battery_work);
-                       wacom_schedule_work(wacom_wac);
+                       wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
                }
        }
        else if ((features->quirks & WACOM_QUIRK_BATTERY) &&
                 wacom->battery.dev) {
                features->quirks &= ~WACOM_QUIRK_BATTERY;
-               INIT_WORK(&wacom->work, wacom_battery_work);
-               wacom_schedule_work(wacom_wac);
+               wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
                wacom_notify_battery(wacom_wac, 0, 0, 0, 0);
        }
        return 0;
diff --git a/3.17/wacom.h b/3.17/wacom.h
index 108a796..fc1eeae 100644
--- a/3.17/wacom.h
+++ b/3.17/wacom.h
@@ -119,13 +119,19 @@
 #define WACOM_POWERSUPPLY_DESC(ps) (ps)
 #endif
 
+enum wacom_worker {
+       WACOM_WORKER_WIRELESS,
+       WACOM_WORKER_BATTERY,
+};
+
 struct wacom {
        struct usb_device *usbdev;
        struct usb_interface *intf;
        struct wacom_wac wacom_wac;
        struct hid_device *hdev;
        struct mutex lock;
-       struct work_struct work;
+       struct work_struct wireless_work;
+       struct work_struct battery_work;
        struct wacom_led {
                u8 select[5]; /* status led selector (0..3) */
                u8 llv;       /* status led brightness no button (1..127) */
@@ -146,10 +152,19 @@ struct wacom {
        struct attribute_group remote_group[5];
 };
 
-static inline void wacom_schedule_work(struct wacom_wac *wacom_wac)
+static inline void wacom_schedule_work(struct wacom_wac *wacom_wac,
+                                      enum wacom_worker which)
 {
        struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
-       schedule_work(&wacom->work);
+
+       switch (which) {
+       case WACOM_WORKER_WIRELESS:
+               schedule_work(&wacom->wireless_work);
+               break;
+       case WACOM_WORKER_BATTERY:
+               schedule_work(&wacom->battery_work);
+               break;
+       }
 }
 
 extern const struct hid_device_id wacom_ids[];
diff --git a/3.17/wacom_sys.c b/3.17/wacom_sys.c
index ad492aa..c79a854 100644
--- a/3.17/wacom_sys.c
+++ b/3.17/wacom_sys.c
@@ -1561,7 +1561,7 @@ static void wacom_calculate_res(struct wacom_features 
*features)
 
 void wacom_battery_work(struct work_struct *work)
 {
-       struct wacom *wacom = container_of(work, struct wacom, work);
+       struct wacom *wacom = container_of(work, struct wacom, battery_work);
 
        if ((wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) &&
             !WACOM_POWERSUPPLY_DEVICE(wacom->battery)) {
@@ -1785,7 +1785,7 @@ fail_allocate_inputs:
 
 static void wacom_wireless_work(struct work_struct *work)
 {
-       struct wacom *wacom = container_of(work, struct wacom, work);
+       struct wacom *wacom = container_of(work, struct wacom, wireless_work);
        struct usb_device *usbdev = wacom->usbdev;
        struct wacom_wac *wacom_wac = &wacom->wacom_wac;
        struct hid_device *hdev1, *hdev2;
@@ -1913,7 +1913,8 @@ static int wacom_probe(struct hid_device *hdev,
        wacom->usbdev = dev;
        wacom->intf = intf;
        mutex_init(&wacom->lock);
-       INIT_WORK(&wacom->work, wacom_wireless_work);
+       INIT_WORK(&wacom->wireless_work, wacom_wireless_work);
+       INIT_WORK(&wacom->battery_work, wacom_battery_work);
 
        /* ask for the report descriptor to be loaded by HID */
        error = hid_parse(hdev);
@@ -1954,7 +1955,8 @@ static void wacom_remove(struct hid_device *hdev)
 
        hid_hw_stop(hdev);
 
-       cancel_work_sync(&wacom->work);
+       cancel_work_sync(&wacom->wireless_work);
+       cancel_work_sync(&wacom->battery_work);
        kobject_put(wacom->remote_dir);
        wacom_destroy_leds(wacom);
        wacom_clean_inputs(wacom);
diff --git a/3.17/wacom_wac.c b/3.17/wacom_wac.c
index 89cbe51..648355d 100644
--- a/3.17/wacom_wac.c
+++ b/3.17/wacom_wac.c
@@ -820,8 +820,7 @@ static int wacom_remote_irq(struct wacom_wac *wacom_wac, 
size_t len)
        if (!WACOM_POWERSUPPLY_DEVICE(wacom->battery) &&
            !(features->quirks & WACOM_QUIRK_BATTERY)) {
                features->quirks |= WACOM_QUIRK_BATTERY;
-               INIT_WORK(&wacom->work, wacom_battery_work);
-               wacom_schedule_work(wacom_wac);
+               wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
        }
 
        wacom_notify_battery(wacom_wac, bat_percent, bat_charging, 1,
@@ -2156,7 +2155,7 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, 
size_t len)
                charging = !!(data[5] & 0x80);
                if (wacom->pid != pid) {
                        wacom->pid = pid;
-                       wacom_schedule_work(wacom);
+                       wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
                }
 
                if (WACOM_POWERSUPPLY_DEVICE(w->battery))
@@ -2165,7 +2164,7 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, 
size_t len)
        } else if (wacom->pid != 0) {
                /* disconnected while previously connected */
                wacom->pid = 0;
-               wacom_schedule_work(wacom);
+               wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
                wacom_notify_battery(wacom, 0, 0, 0, 0);
        }
 
@@ -2200,15 +2199,13 @@ static int wacom_status_irq(struct wacom_wac 
*wacom_wac, size_t len)
                if (!WACOM_POWERSUPPLY_DEVICE(wacom->battery) &&
                    !(features->quirks & WACOM_QUIRK_BATTERY)) {
                        features->quirks |= WACOM_QUIRK_BATTERY;
-                       INIT_WORK(&wacom->work, wacom_battery_work);
-                       wacom_schedule_work(wacom_wac);
+                       wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
                }
        }
        else if ((features->quirks & WACOM_QUIRK_BATTERY) &&
                 WACOM_POWERSUPPLY_DEVICE(wacom->battery)) {
                features->quirks &= ~WACOM_QUIRK_BATTERY;
-               INIT_WORK(&wacom->work, wacom_battery_work);
-               wacom_schedule_work(wacom_wac);
+               wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
                wacom_notify_battery(wacom_wac, 0, 0, 0, 0);
        }
        return 0;
diff --git a/3.7/wacom.h b/3.7/wacom.h
index 05ef01a..fd039dd 100644
--- a/3.7/wacom.h
+++ b/3.7/wacom.h
@@ -108,6 +108,11 @@ MODULE_LICENSE(DRIVER_LICENSE);
 #define USB_VENDOR_ID_WACOM    0x056a
 #define USB_VENDOR_ID_LENOVO   0x17ef
 
+enum wacom_worker {
+       WACOM_WORKER_WIRELESS,
+       WACOM_WORKER_BATTERY,
+};
+
 struct wacom {
        dma_addr_t data_dma;
        struct usb_device *usbdev;
@@ -115,7 +120,8 @@ struct wacom {
        struct urb *irq;
        struct wacom_wac wacom_wac;
        struct mutex lock;
-       struct work_struct work;
+       struct work_struct wireless_work;
+       struct work_struct battery_work;
        bool open;
        char phys[32];
        struct wacom_led {
@@ -130,10 +136,19 @@ struct wacom {
        struct attribute_group remote_group[5];
 };
 
-static inline void wacom_schedule_work(struct wacom_wac *wacom_wac)
+static inline void wacom_schedule_work(struct wacom_wac *wacom_wac,
+                                      enum wacom_worker which)
 {
        struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
-       schedule_work(&wacom->work);
+
+       switch (which) {
+       case WACOM_WORKER_WIRELESS:
+               schedule_work(&wacom->wireless_work);
+               break;
+       case WACOM_WORKER_BATTERY:
+               schedule_work(&wacom->battery_work);
+               break;
+       }
 }
 
 extern const struct usb_device_id wacom_ids[];
diff --git a/3.7/wacom_sys.c b/3.7/wacom_sys.c
index 6a815bd..33b7ee7 100644
--- a/3.7/wacom_sys.c
+++ b/3.7/wacom_sys.c
@@ -1489,7 +1489,7 @@ static void wacom_calculate_res(struct wacom_features 
*features)
 
 static void wacom_wireless_work(struct work_struct *work)
 {
-       struct wacom *wacom = container_of(work, struct wacom, work);
+       struct wacom *wacom = container_of(work, struct wacom, wireless_work);
        struct usb_device *usbdev = wacom->usbdev;
        struct wacom_wac *wacom_wac = &wacom->wacom_wac;
        struct wacom *wacom1, *wacom2;
@@ -1600,7 +1600,7 @@ fail:
 
 void wacom_battery_work(struct work_struct *work)
 {
-       struct wacom *wacom = container_of(work, struct wacom, work);
+       struct wacom *wacom = container_of(work, struct wacom, battery_work);
 
        if ((wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) &&
             !wacom->battery.dev) {
@@ -1657,7 +1657,8 @@ static int wacom_probe(struct usb_interface *intf, const 
struct usb_device_id *i
        wacom->usbdev = dev;
        wacom->intf = intf;
        mutex_init(&wacom->lock);
-       INIT_WORK(&wacom->work, wacom_wireless_work);
+       INIT_WORK(&wacom->wireless_work, wacom_wireless_work);
+       INIT_WORK(&wacom->battery_work, wacom_battery_work);
        usb_make_path(dev, wacom->phys, sizeof(wacom->phys));
        strlcat(wacom->phys, "/input0", sizeof(wacom->phys));
 
@@ -1754,7 +1755,8 @@ static void wacom_disconnect(struct usb_interface *intf)
        usb_set_intfdata(intf, NULL);
 
        usb_kill_urb(wacom->irq);
-       cancel_work_sync(&wacom->work);
+       cancel_work_sync(&wacom->wireless_work);
+       cancel_work_sync(&wacom->battery_work);
        kobject_put(wacom->remote_dir);
        wacom_destroy_leds(wacom);
        wacom_unregister_inputs(wacom);
diff --git a/3.7/wacom_wac.c b/3.7/wacom_wac.c
index 2a9e173..5887561 100644
--- a/3.7/wacom_wac.c
+++ b/3.7/wacom_wac.c
@@ -763,8 +763,7 @@ static int wacom_remote_irq(struct wacom_wac *wacom_wac, 
size_t len)
        if (!wacom->battery.dev &&
            !(features->quirks & WACOM_QUIRK_BATTERY)) {
                features->quirks |= WACOM_QUIRK_BATTERY;
-               INIT_WORK(&wacom->work, wacom_battery_work);
-               wacom_schedule_work(wacom_wac);
+               wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
        }
 
        wacom_notify_battery(wacom_wac, bat_percent, bat_charging, 1,
@@ -1553,7 +1552,7 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, 
size_t len)
                charging = !!(data[5] & 0x80);
                if (wacom->pid != pid) {
                        wacom->pid = pid;
-                       wacom_schedule_work(wacom);
+                       wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
                }
 
                if (w->battery.dev)
@@ -1562,7 +1561,7 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, 
size_t len)
        } else if (wacom->pid != 0) {
                /* disconnected while previously connected */
                wacom->pid = 0;
-               wacom_schedule_work(wacom);
+               wacom_schedule_work(wacom, WACOM_WORKER_WIRELESS);
                wacom_notify_battery(wacom, 0, 0, 0, 0);
        }
 
@@ -1597,15 +1596,13 @@ static int wacom_status_irq(struct wacom_wac 
*wacom_wac, size_t len)
                if (!wacom->battery.dev &&
                    !(features->quirks & WACOM_QUIRK_BATTERY)) {
                        features->quirks |= WACOM_QUIRK_BATTERY;
-                       INIT_WORK(&wacom->work, wacom_battery_work);
-                       wacom_schedule_work(wacom_wac);
+                       wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
                }
        }
        else if ((features->quirks & WACOM_QUIRK_BATTERY) &&
                 wacom->battery.dev) {
                features->quirks &= ~WACOM_QUIRK_BATTERY;
-               INIT_WORK(&wacom->work, wacom_battery_work);
-               wacom_schedule_work(wacom_wac);
+               wacom_schedule_work(wacom_wac, WACOM_WORKER_BATTERY);
                wacom_notify_battery(wacom_wac, 0, 0, 0, 0);
        }
        return 0;
-- 
2.7.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to