aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/sd.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 638cff41d436..7a9d552f50e6 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1795,7 +1795,7 @@ static void sd_shutdown(struct device *dev)
1795 **/ 1795 **/
1796static int __init init_sd(void) 1796static int __init init_sd(void)
1797{ 1797{
1798 int majors = 0, i; 1798 int majors = 0, i, err;
1799 1799
1800 SCSI_LOG_HLQUEUE(3, printk("init_sd: sd driver entry point\n")); 1800 SCSI_LOG_HLQUEUE(3, printk("init_sd: sd driver entry point\n"));
1801 1801
@@ -1806,9 +1806,22 @@ static int __init init_sd(void)
1806 if (!majors) 1806 if (!majors)
1807 return -ENODEV; 1807 return -ENODEV;
1808 1808
1809 class_register(&sd_disk_class); 1809 err = class_register(&sd_disk_class);
1810 if (err)
1811 goto err_out;
1810 1812
1811 return scsi_register_driver(&sd_template.gendrv); 1813 err = scsi_register_driver(&sd_template.gendrv);
1814 if (err)
1815 goto err_out_class;
1816
1817 return 0;
1818
1819err_out_class:
1820 class_unregister(&sd_disk_class);
1821err_out:
1822 for (i = 0; i < SD_MAJORS; i++)
1823 unregister_blkdev(sd_major(i), "sd");
1824 return err;
1812} 1825}
1813 1826
1814/** 1827/**
@@ -1823,10 +1836,10 @@ static void __exit exit_sd(void)
1823 SCSI_LOG_HLQUEUE(3, printk("exit_sd: exiting sd driver\n")); 1836 SCSI_LOG_HLQUEUE(3, printk("exit_sd: exiting sd driver\n"));
1824 1837
1825 scsi_unregister_driver(&sd_template.gendrv); 1838 scsi_unregister_driver(&sd_template.gendrv);
1839 class_unregister(&sd_disk_class);
1840
1826 for (i = 0; i < SD_MAJORS; i++) 1841 for (i = 0; i < SD_MAJORS; i++)
1827 unregister_blkdev(sd_major(i), "sd"); 1842 unregister_blkdev(sd_major(i), "sd");
1828
1829 class_unregister(&sd_disk_class);
1830} 1843}
1831 1844
1832module_init(init_sd); 1845module_init(init_sd);