Commit a094760b authored by Heiner Kallweit's avatar Heiner Kallweit Committed by Greg Kroah-Hartman

usb: storage: fix runtime pm issue in usb_stor_probe2

Since commit 71723f95 "PM / runtime: print error when activating a
child to unactive parent" I see the following error message:

scsi host2: usb-storage 1-3:1.0
scsi host2: runtime PM trying to activate child device host2 but parent
	    (1-3:1.0) is not active

Digging into it it seems to be related to the problem described in the
commit message for cd998ded "i2c: designware: Prevent runtime
suspend during adapter registration" as scsi_add_host also calls
device_add and after the call to device_add the parent device is
suspended.

Fix this by using the approach from the mentioned commit and getting
the runtime pm reference before calling scsi_add_host.
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 833415a3
...@@ -1070,17 +1070,17 @@ int usb_stor_probe2(struct us_data *us) ...@@ -1070,17 +1070,17 @@ int usb_stor_probe2(struct us_data *us)
result = usb_stor_acquire_resources(us); result = usb_stor_acquire_resources(us);
if (result) if (result)
goto BadDevice; goto BadDevice;
usb_autopm_get_interface_no_resume(us->pusb_intf);
snprintf(us->scsi_name, sizeof(us->scsi_name), "usb-storage %s", snprintf(us->scsi_name, sizeof(us->scsi_name), "usb-storage %s",
dev_name(&us->pusb_intf->dev)); dev_name(&us->pusb_intf->dev));
result = scsi_add_host(us_to_host(us), dev); result = scsi_add_host(us_to_host(us), dev);
if (result) { if (result) {
dev_warn(dev, dev_warn(dev,
"Unable to add the scsi host\n"); "Unable to add the scsi host\n");
goto BadDevice; goto HostAddErr;
} }
/* Submit the delayed_work for SCSI-device scanning */ /* Submit the delayed_work for SCSI-device scanning */
usb_autopm_get_interface_no_resume(us->pusb_intf);
set_bit(US_FLIDX_SCAN_PENDING, &us->dflags); set_bit(US_FLIDX_SCAN_PENDING, &us->dflags);
if (delay_use > 0) if (delay_use > 0)
...@@ -1090,6 +1090,8 @@ int usb_stor_probe2(struct us_data *us) ...@@ -1090,6 +1090,8 @@ int usb_stor_probe2(struct us_data *us)
return 0; return 0;
/* We come here if there are any problems */ /* We come here if there are any problems */
HostAddErr:
usb_autopm_put_interface_no_suspend(us->pusb_intf);
BadDevice: BadDevice:
usb_stor_dbg(us, "storage_probe() failed\n"); usb_stor_dbg(us, "storage_probe() failed\n");
release_everything(us); release_everything(us);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment