aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/ses.c
diff options
context:
space:
mode:
authorJames Bottomley <James.Bottomley@HansenPartnership.com>2009-07-31 20:41:22 -0400
committerJames Bottomley <James.Bottomley@suse.de>2009-08-22 18:52:13 -0400
commit43d8eb9cfd0aea93be32181c64e18191b69c211c (patch)
tree76725fe2ea080cb26c7503dbab8226181de1aa04 /drivers/scsi/ses.c
parent163f52b6cf3a639df6a72c7937e0eb88b20f1ef3 (diff)
[SCSI] ses: add support for enclosure component hot removal
Right at the moment, hot removal of a device within an enclosure does nothing (because the intf_remove only copes with enclosure removal not with component removal). Fix this by adding a function to remove the component. Also needed to fix the prototype of enclosure_remove_device, since we know the device we've removed but not the internal component number Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/scsi/ses.c')
-rw-r--r--drivers/scsi/ses.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index e1b8c828f03a..be593c8525b5 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -616,18 +616,26 @@ static int ses_remove(struct device *dev)
616 return 0; 616 return 0;
617} 617}
618 618
619static void ses_intf_remove(struct device *cdev, 619static void ses_intf_remove_component(struct scsi_device *sdev)
620 struct class_interface *intf) 620{
621 struct enclosure_device *edev, *prev = NULL;
622
623 while ((edev = enclosure_find(&sdev->host->shost_gendev, prev)) != NULL) {
624 prev = edev;
625 if (!enclosure_remove_device(edev, &sdev->sdev_gendev))
626 break;
627 }
628 if (edev)
629 put_device(&edev->edev);
630}
631
632static void ses_intf_remove_enclosure(struct scsi_device *sdev)
621{ 633{
622 struct scsi_device *sdev = to_scsi_device(cdev->parent);
623 struct enclosure_device *edev; 634 struct enclosure_device *edev;
624 struct ses_device *ses_dev; 635 struct ses_device *ses_dev;
625 636
626 if (!scsi_device_enclosure(sdev))
627 return;
628
629 /* exact match to this enclosure */ 637 /* exact match to this enclosure */
630 edev = enclosure_find(cdev->parent, NULL); 638 edev = enclosure_find(&sdev->sdev_gendev, NULL);
631 if (!edev) 639 if (!edev)
632 return; 640 return;
633 641
@@ -645,6 +653,17 @@ static void ses_intf_remove(struct device *cdev,
645 enclosure_unregister(edev); 653 enclosure_unregister(edev);
646} 654}
647 655
656static void ses_intf_remove(struct device *cdev,
657 struct class_interface *intf)
658{
659 struct scsi_device *sdev = to_scsi_device(cdev->parent);
660
661 if (!scsi_device_enclosure(sdev))
662 ses_intf_remove_component(sdev);
663 else
664 ses_intf_remove_enclosure(sdev);
665}
666
648static struct class_interface ses_interface = { 667static struct class_interface ses_interface = {
649 .add_dev = ses_intf_add, 668 .add_dev = ses_intf_add,
650 .remove_dev = ses_intf_remove, 669 .remove_dev = ses_intf_remove,