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