aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/drivers/ubd_kern.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/um/drivers/ubd_kern.c')
-rw-r--r--arch/um/drivers/ubd_kern.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 962b8fb35f80..83189e188c3f 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -622,6 +622,14 @@ static int ubd_open_dev(struct ubd *ubd_dev)
622 return(err); 622 return(err);
623} 623}
624 624
625static void ubd_device_release(struct device *dev)
626{
627 struct ubd *ubd_dev = dev->driver_data;
628
629 blk_cleanup_queue(ubd_dev->queue);
630 *ubd_dev = ((struct ubd) DEFAULT_UBD);
631}
632
625static int ubd_disk_register(int major, u64 size, int unit, 633static int ubd_disk_register(int major, u64 size, int unit,
626 struct gendisk **disk_out) 634 struct gendisk **disk_out)
627{ 635{
@@ -644,6 +652,8 @@ static int ubd_disk_register(int major, u64 size, int unit,
644 if (major == MAJOR_NR) { 652 if (major == MAJOR_NR) {
645 ubd_devs[unit].pdev.id = unit; 653 ubd_devs[unit].pdev.id = unit;
646 ubd_devs[unit].pdev.name = DRIVER_NAME; 654 ubd_devs[unit].pdev.name = DRIVER_NAME;
655 ubd_devs[unit].pdev.dev.release = ubd_device_release;
656 ubd_devs[unit].pdev.dev.driver_data = &ubd_devs[unit];
647 platform_device_register(&ubd_devs[unit].pdev); 657 platform_device_register(&ubd_devs[unit].pdev);
648 disk->driverfs_dev = &ubd_devs[unit].pdev.dev; 658 disk->driverfs_dev = &ubd_devs[unit].pdev.dev;
649 } 659 }
@@ -787,7 +797,7 @@ static int ubd_id(char **str, int *start_out, int *end_out)
787 797
788static int ubd_remove(int n, char **error_out) 798static int ubd_remove(int n, char **error_out)
789{ 799{
790 struct gendisk *disk; 800 struct gendisk *disk = ubd_gendisk[n];
791 struct ubd *ubd_dev; 801 struct ubd *ubd_dev;
792 int err = -ENODEV; 802 int err = -ENODEV;
793 803
@@ -803,7 +813,6 @@ static int ubd_remove(int n, char **error_out)
803 if(ubd_dev->count > 0) 813 if(ubd_dev->count > 0)
804 goto out; 814 goto out;
805 815
806 disk = ubd_gendisk[n];
807 ubd_gendisk[n] = NULL; 816 ubd_gendisk[n] = NULL;
808 if(disk != NULL){ 817 if(disk != NULL){
809 del_gendisk(disk); 818 del_gendisk(disk);
@@ -816,10 +825,8 @@ static int ubd_remove(int n, char **error_out)
816 fake_gendisk[n] = NULL; 825 fake_gendisk[n] = NULL;
817 } 826 }
818 827
819 blk_cleanup_queue(ubd_dev->queue);
820 platform_device_unregister(&ubd_dev->pdev);
821 *ubd_dev = ((struct ubd) DEFAULT_UBD);
822 err = 0; 828 err = 0;
829 platform_device_unregister(&ubd_dev->pdev);
823out: 830out:
824 mutex_unlock(&ubd_lock); 831 mutex_unlock(&ubd_lock);
825 return err; 832 return err;