aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/skd_main.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>2013-11-05 06:37:02 -0500
committerJens Axboe <axboe@kernel.dk>2013-11-08 11:10:30 -0500
commitb8df6647c248db457f1c2fb4f0f6350beaf16f9e (patch)
treeabe07e5b81ddf74d9f48eec03995a3524001713a /drivers/block/skd_main.c
parentfbed149ab328b72f501a3344ab4f20f712c63392 (diff)
skd: register block device only if some devices are present
Register block device in skd_pci_probe() instead of in skd_init() so it is registered only if some devices are present (currently it is always registered when the driver is loaded). Please note that this change depends on the fact that register_blkdev(0, ...) never returns 0. Cc: Akhil Bhansali <abhansali@stec-inc.com> Cc: Jeff Moyer <jmoyer@redhat.com> Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block/skd_main.c')
-rw-r--r--drivers/block/skd_main.c33
1 files changed, 12 insertions, 21 deletions
diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
index 99d5d1251c45..9ff34be89f99 100644
--- a/drivers/block/skd_main.c
+++ b/drivers/block/skd_main.c
@@ -4899,6 +4899,14 @@ static int skd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
4899 } 4899 }
4900 } 4900 }
4901 4901
4902 if (!skd_major) {
4903 rc = register_blkdev(0, DRV_NAME);
4904 if (rc < 0)
4905 goto err_out_regions;
4906 BUG_ON(!rc);
4907 skd_major = rc;
4908 }
4909
4902 skdev = skd_construct(pdev); 4910 skdev = skd_construct(pdev);
4903 if (skdev == NULL) { 4911 if (skdev == NULL) {
4904 rc = -ENOMEM; 4912 rc = -ENOMEM;
@@ -5396,8 +5404,6 @@ static void skd_log_skreq(struct skd_device *skdev,
5396 5404
5397static int __init skd_init(void) 5405static int __init skd_init(void)
5398{ 5406{
5399 int rc = -ENOMEM;
5400
5401 pr_info(PFX " v%s-b%s loaded\n", DRV_VERSION, DRV_BUILD_ID); 5407 pr_info(PFX " v%s-b%s loaded\n", DRV_VERSION, DRV_BUILD_ID);
5402 5408
5403 switch (skd_isr_type) { 5409 switch (skd_isr_type) {
@@ -5448,24 +5454,7 @@ static int __init skd_init(void)
5448 skd_max_pass_thru = SKD_N_SPECIAL_CONTEXT; 5454 skd_max_pass_thru = SKD_N_SPECIAL_CONTEXT;
5449 } 5455 }
5450 5456
5451 /* Obtain major device number. */ 5457 return pci_register_driver(&skd_driver);
5452 rc = register_blkdev(0, DRV_NAME);
5453 if (rc < 0)
5454 goto err_register_blkdev;
5455
5456 skd_major = rc;
5457
5458 rc = pci_register_driver(&skd_driver);
5459 if (rc < 0)
5460 goto err_pci_register_driver;
5461
5462 return rc;
5463
5464err_pci_register_driver:
5465 unregister_blkdev(skd_major, DRV_NAME);
5466
5467err_register_blkdev:
5468 return rc;
5469} 5458}
5470 5459
5471static void __exit skd_exit(void) 5460static void __exit skd_exit(void)
@@ -5473,7 +5462,9 @@ static void __exit skd_exit(void)
5473 pr_info(PFX " v%s-b%s unloading\n", DRV_VERSION, DRV_BUILD_ID); 5462 pr_info(PFX " v%s-b%s unloading\n", DRV_VERSION, DRV_BUILD_ID);
5474 5463
5475 pci_unregister_driver(&skd_driver); 5464 pci_unregister_driver(&skd_driver);
5476 unregister_blkdev(skd_major, DRV_NAME); 5465
5466 if (skd_major)
5467 unregister_blkdev(skd_major, DRV_NAME);
5477} 5468}
5478 5469
5479module_init(skd_init); 5470module_init(skd_init);