--- zzzz-none-000/linux-4.9.276/drivers/usb/storage/usb.c 2021-07-20 14:21:16.000000000 +0000 +++ falcon-5530-750/linux-4.9.276/drivers/usb/storage/usb.c 2023-04-05 08:19:02.000000000 +0000 @@ -79,6 +79,9 @@ #define DRV_NAME "usb-storage" +/* == 20180328 AVM/VGJ - Include AVM USB Suspend functions == */ +#include "../core/usb.h" + /* Some informational data */ MODULE_AUTHOR("Matthew Dharm "); MODULE_DESCRIPTION("USB Mass Storage driver for Linux"); @@ -872,6 +875,10 @@ wake_up(&us->delay_wait); } + /* == 20171214 AVM/VGJ - Inc USB use counter -> prevents suspension + * Restore incremented counter to prevent suspension by default ==*/ + avm_usb_suspend_get_locked(us->pusb_dev); + /* * Prevent SCSI scanning (if it hasn't started yet) * or wait for the SCSI-scanning routine to stop. @@ -879,14 +886,25 @@ cancel_delayed_work_sync(&us->scan_dwork); /* Balance autopm calls if scanning was cancelled */ - if (test_bit(US_FLIDX_SCAN_PENDING, &us->dflags)) + if (test_bit(US_FLIDX_SCAN_PENDING, &us->dflags)) { usb_autopm_put_interface_no_suspend(us->pusb_intf); + /* == 20171214 AVM/VGJ - Dec USB use counter -> Driver was not yet probed ==*/ + avm_usb_suspend_put_locked(us->pusb_dev); + } + /* * Removing the host will perform an orderly shutdown: caches * synchronized, disks spun down, etc. */ + /* == 20171214 AVM/WKR - FIX: Prevent deadlock with suspend_put in invoke_transport() == */ +#if defined (CONFIG_AVM_USB_SUSPEND) + usb_unlock_device(us->pusb_dev); +#endif scsi_remove_host(host); +#if defined (CONFIG_AVM_USB_SUSPEND) + usb_lock_device(us->pusb_dev); +#endif /* * Prevent any new commands from being accepted and cut short @@ -941,6 +959,9 @@ /* Should we unbind if no devices were detected? */ usb_autopm_put_interface(us->pusb_intf); + /* == 20171214 AVM/VGJ - Dec USB use counter -> allows suspension + * Inc is done in usbcore to prevent suspension by default ==*/ + avm_usb_suspend_put(us->pusb_dev); clear_bit(US_FLIDX_SCAN_PENDING, &us->dflags); }