summaryrefslogtreecommitdiff
path: root/drivers/staging/spectra/ffsport.c
diff options
context:
space:
mode:
authorYong Wang <yong.y.wang@linux.intel.com>2010-11-17 22:08:28 +0800
committerGreg Kroah-Hartman <gregkh@suse.de>2010-11-17 13:14:14 -0800
commit6f5a416216fe2c39171326897e074d417df1082b (patch)
tree8bb220abd65cb00c3d15a7f692b677bac6612736 /drivers/staging/spectra/ffsport.c
parent237a1a1aef91ab654988cb459d783ac0ee09d2ea (diff)
downloadlinux-3.10-6f5a416216fe2c39171326897e074d417df1082b.tar.gz
linux-3.10-6f5a416216fe2c39171326897e074d417df1082b.tar.bz2
linux-3.10-6f5a416216fe2c39171326897e074d417df1082b.zip
staging: spectra: move all init logic into nand_pci_probe
Currently there are some driver initialization logic that is not part of nand_pci_probe function. This will result in that part of driver initialization code executing even on platforms without the corresponding hardware which is always dangerous. Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.com> Signed-off-by: Yong Wang <yong.y.wang@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/spectra/ffsport.c')
-rw-r--r--drivers/staging/spectra/ffsport.c56
1 files changed, 30 insertions, 26 deletions
diff --git a/drivers/staging/spectra/ffsport.c b/drivers/staging/spectra/ffsport.c
index c7932da03c5..c6b4a2d1685 100644
--- a/drivers/staging/spectra/ffsport.c
+++ b/drivers/staging/spectra/ffsport.c
@@ -729,34 +729,16 @@ static void create_sysfs_entry(struct device *dev)
}
*/
-static int GLOB_SBD_init(void)
+int register_spectra_ftl()
{
int i;
- /* Set debug output level (0~3) here. 3 is most verbose */
- printk(KERN_ALERT "Spectra: %s\n", GLOB_version);
-
- mutex_init(&spectra_lock);
-
- GLOB_SBD_majornum = register_blkdev(0, GLOB_SBD_NAME);
- if (GLOB_SBD_majornum <= 0) {
- printk(KERN_ERR "Unable to get the major %d for Spectra",
- GLOB_SBD_majornum);
- return -EBUSY;
- }
-
- if (PASS != GLOB_FTL_Flash_Init()) {
- printk(KERN_ERR "Spectra: Unable to Initialize Flash Device. "
- "Aborting\n");
- goto out_flash_register;
- }
-
/* create_sysfs_entry(&dev->dev); */
if (PASS != GLOB_FTL_IdentifyDevice(&IdentifyDeviceData)) {
printk(KERN_ERR "Spectra: Unable to Read Flash Device. "
"Aborting\n");
- goto out_flash_register;
+ return -ENOMEM;
} else {
nand_dbg_print(NAND_DBG_WARN, "In GLOB_SBD_init: "
"Num blocks=%d, pagesperblock=%d, "
@@ -775,24 +757,46 @@ static int GLOB_SBD_init(void)
}
printk(KERN_ALERT "Spectra: block table has been found.\n");
+ GLOB_SBD_majornum = register_blkdev(0, GLOB_SBD_NAME);
+ if (GLOB_SBD_majornum <= 0) {
+ printk(KERN_ERR "Unable to get the major %d for Spectra",
+ GLOB_SBD_majornum);
+ goto out_ftl_flash_register;
+ }
+
for (i = 0; i < NUM_DEVICES; i++)
if (SBD_setup_device(&nand_device[i], i) == -ENOMEM)
- goto out_ftl_flash_register;
+ goto out_blk_register;
nand_dbg_print(NAND_DBG_DEBUG,
"Spectra: module loaded with major number %d\n",
GLOB_SBD_majornum);
- return 0;
+ return PASS;
+out_blk_register:
+ unregister_blkdev(GLOB_SBD_majornum, GLOB_SBD_NAME);
out_ftl_flash_register:
GLOB_FTL_Cache_Release();
-out_flash_register:
- GLOB_FTL_Flash_Release();
- unregister_blkdev(GLOB_SBD_majornum, GLOB_SBD_NAME);
printk(KERN_ERR "Spectra: Module load failed.\n");
- return -ENOMEM;
+ return FAIL;
+}
+EXPORT_SYMBOL_GPL(register_spectra_ftl);
+
+static int GLOB_SBD_init(void)
+{
+ /* Set debug output level (0~3) here. 3 is most verbose */
+ printk(KERN_ALERT "Spectra: %s\n", GLOB_version);
+
+ mutex_init(&spectra_lock);
+
+ if (PASS != GLOB_FTL_Flash_Init()) {
+ printk(KERN_ERR "Spectra: Unable to Initialize Flash Device. "
+ "Aborting\n");
+ return -ENODEV;
+ }
+ return 0;
}
static void __exit GLOB_SBD_exit(void)