aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/scsi_sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/scsi_sysfs.c')
-rw-r--r--drivers/scsi/scsi_sysfs.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index dae59d1da07a..b8052d5206cc 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -653,7 +653,7 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
653 error = attr_add(&sdev->sdev_gendev, 653 error = attr_add(&sdev->sdev_gendev,
654 sdev->host->hostt->sdev_attrs[i]); 654 sdev->host->hostt->sdev_attrs[i]);
655 if (error) { 655 if (error) {
656 scsi_remove_device(sdev); 656 __scsi_remove_device(sdev);
657 goto out; 657 goto out;
658 } 658 }
659 } 659 }
@@ -667,7 +667,7 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
667 scsi_sysfs_sdev_attrs[i]); 667 scsi_sysfs_sdev_attrs[i]);
668 error = device_create_file(&sdev->sdev_gendev, attr); 668 error = device_create_file(&sdev->sdev_gendev, attr);
669 if (error) { 669 if (error) {
670 scsi_remove_device(sdev); 670 __scsi_remove_device(sdev);
671 goto out; 671 goto out;
672 } 672 }
673 } 673 }
@@ -687,17 +687,10 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
687 return error; 687 return error;
688} 688}
689 689
690/** 690void __scsi_remove_device(struct scsi_device *sdev)
691 * scsi_remove_device - unregister a device from the scsi bus
692 * @sdev: scsi_device to unregister
693 **/
694void scsi_remove_device(struct scsi_device *sdev)
695{ 691{
696 struct Scsi_Host *shost = sdev->host;
697
698 down(&shost->scan_mutex);
699 if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0) 692 if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0)
700 goto out; 693 return;
701 694
702 class_device_unregister(&sdev->sdev_classdev); 695 class_device_unregister(&sdev->sdev_classdev);
703 device_del(&sdev->sdev_gendev); 696 device_del(&sdev->sdev_gendev);
@@ -706,8 +699,17 @@ void scsi_remove_device(struct scsi_device *sdev)
706 sdev->host->hostt->slave_destroy(sdev); 699 sdev->host->hostt->slave_destroy(sdev);
707 transport_unregister_device(&sdev->sdev_gendev); 700 transport_unregister_device(&sdev->sdev_gendev);
708 put_device(&sdev->sdev_gendev); 701 put_device(&sdev->sdev_gendev);
709out: 702}
710 up(&shost->scan_mutex); 703
704/**
705 * scsi_remove_device - unregister a device from the scsi bus
706 * @sdev: scsi_device to unregister
707 **/
708void scsi_remove_device(struct scsi_device *sdev)
709{
710 down(&sdev->host->scan_mutex);
711 __scsi_remove_device(sdev);
712 up(&sdev->host->scan_mutex);
711} 713}
712EXPORT_SYMBOL(scsi_remove_device); 714EXPORT_SYMBOL(scsi_remove_device);
713 715