Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USBHID: don't recover device if suspend fails in system sleep

If suspend callback fails in system sleep context, usb core will
ignore the failure and let the system sleep go ahead further, so this
patch doesn't recover device under this situation, otherwise
may cause resume() confused.

Acked-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ming Lei and committed by
Greg Kroah-Hartman
37093b70 93e4f47f

+5 -9
+5 -9
drivers/hid/usbhid/hid-core.c
··· 1493 1493 { 1494 1494 struct hid_device *hid = usb_get_intfdata(intf); 1495 1495 struct usbhid_device *usbhid = hid->driver_data; 1496 - int status; 1496 + int status = 0; 1497 1497 bool driver_suspended = false; 1498 1498 1499 1499 if (PMSG_IS_AUTO(message)) { ··· 1520 1520 } 1521 1521 1522 1522 } else { 1523 - if (hid->driver && hid->driver->suspend) { 1523 + /* TODO: resume() might need to handle suspend failure */ 1524 + if (hid->driver && hid->driver->suspend) 1524 1525 status = hid->driver->suspend(hid, message); 1525 - if (status < 0) 1526 - return status; 1527 - } 1528 1526 driver_suspended = true; 1529 1527 spin_lock_irq(&usbhid->lock); 1530 1528 set_bit(HID_SUSPENDED, &usbhid->iofl); 1531 1529 spin_unlock_irq(&usbhid->lock); 1532 - if (usbhid_wait_io(hid) < 0) { 1530 + if (usbhid_wait_io(hid) < 0) 1533 1531 status = -EIO; 1534 - goto failed; 1535 - } 1536 1532 } 1537 1533 1538 1534 hid_cancel_delayed_stuff(usbhid); ··· 1540 1544 goto failed; 1541 1545 } 1542 1546 dev_dbg(&intf->dev, "suspend\n"); 1543 - return 0; 1547 + return status; 1544 1548 1545 1549 failed: 1546 1550 hid_resume_common(hid, driver_suspended);