• Dmitry Torokhov's avatar
    HID: hiddev: fix mess in hiddev_open() · 18a1b06e
    Dmitry Torokhov authored
    The open method of hiddev handler fails to bring the device out of
    autosuspend state as was promised in 0361a28d, as it actually has 2
    blocks that try to start the transport (call hid_hw_open()) with both
    being guarded by the "open" counter, so the 2nd block is never executed as
    the first block increments the counter so it is never at 0 when we check
    it for the second block.
    
    Additionally hiddev_open() was leaving counter incremented on errors,
    causing the device to never be reopened properly if there was ever an
    error.
    
    Let's fix all of this by factoring out code that creates client structure
    and powers up the device into a separate function that is being called
    from usbhid_open() with the "existancelock" being held.
    
    Fixes: 0361a28d ("HID: autosuspend support for USB HID")
    Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
    18a1b06e
hiddev.c 22.1 KB