Commit 903f4fed authored by Alan Stern's avatar Alan Stern Committed by James Bottomley

[SCSI] fix callers of scsi_remove_device() who already hold the scan muted

This patch (as544) adds a private entry point to scsi_remove_device, for
use when callers already own the scan_mutex.  The appropriate callers are
modified to use the new entry point.
Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent e517d313
...@@ -124,6 +124,7 @@ extern void scsi_sysfs_unregister(void); ...@@ -124,6 +124,7 @@ extern void scsi_sysfs_unregister(void);
extern void scsi_sysfs_device_initialize(struct scsi_device *); extern void scsi_sysfs_device_initialize(struct scsi_device *);
extern int scsi_sysfs_target_initialize(struct scsi_device *); extern int scsi_sysfs_target_initialize(struct scsi_device *);
extern struct scsi_transport_template blank_transport_template; extern struct scsi_transport_template blank_transport_template;
extern void __scsi_remove_device(struct scsi_device *);
extern struct bus_type scsi_bus_type; extern struct bus_type scsi_bus_type;
......
...@@ -653,7 +653,7 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev) ...@@ -653,7 +653,7 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
error = attr_add(&sdev->sdev_gendev, error = attr_add(&sdev->sdev_gendev,
sdev->host->hostt->sdev_attrs[i]); sdev->host->hostt->sdev_attrs[i]);
if (error) { if (error) {
scsi_remove_device(sdev); __scsi_remove_device(sdev);
goto out; goto out;
} }
} }
...@@ -667,7 +667,7 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev) ...@@ -667,7 +667,7 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
scsi_sysfs_sdev_attrs[i]); scsi_sysfs_sdev_attrs[i]);
error = device_create_file(&sdev->sdev_gendev, attr); error = device_create_file(&sdev->sdev_gendev, attr);
if (error) { if (error) {
scsi_remove_device(sdev); __scsi_remove_device(sdev);
goto out; goto out;
} }
} }
...@@ -687,17 +687,10 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev) ...@@ -687,17 +687,10 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
return error; return error;
} }
/** void __scsi_remove_device(struct scsi_device *sdev)
* scsi_remove_device - unregister a device from the scsi bus
* @sdev: scsi_device to unregister
**/
void scsi_remove_device(struct scsi_device *sdev)
{ {
struct Scsi_Host *shost = sdev->host;
down(&shost->scan_mutex);
if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0) if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0)
goto out; return;
class_device_unregister(&sdev->sdev_classdev); class_device_unregister(&sdev->sdev_classdev);
device_del(&sdev->sdev_gendev); device_del(&sdev->sdev_gendev);
...@@ -706,8 +699,17 @@ void scsi_remove_device(struct scsi_device *sdev) ...@@ -706,8 +699,17 @@ void scsi_remove_device(struct scsi_device *sdev)
sdev->host->hostt->slave_destroy(sdev); sdev->host->hostt->slave_destroy(sdev);
transport_unregister_device(&sdev->sdev_gendev); transport_unregister_device(&sdev->sdev_gendev);
put_device(&sdev->sdev_gendev); put_device(&sdev->sdev_gendev);
out: }
up(&shost->scan_mutex);
/**
* scsi_remove_device - unregister a device from the scsi bus
* @sdev: scsi_device to unregister
**/
void scsi_remove_device(struct scsi_device *sdev)
{
down(&sdev->host->scan_mutex);
__scsi_remove_device(sdev);
up(&sdev->host->scan_mutex);
} }
EXPORT_SYMBOL(scsi_remove_device); EXPORT_SYMBOL(scsi_remove_device);
......
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