staging: spectra: move all init logic into nand_pci_probe
PATCH 1/1 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 <[email protected]>
Signed-off-by Yong Wang <[email protected]>
--- drivers/staging/spectra/ffsport.c | 56 ++++++----- drivers/staging/spectra/ffsport.h | 1 + drivers/staging/spectra/flash.c | 4 +- drivers/staging/spectra/lld_nand.c | 177 +++++++++++++++++++----------------- 4 files changed, 127 insertions(+), 111 deletions(-)
drivers/staging/spectra/ffsport.c +30 -26
@@ -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)
drivers/staging/spectra/ffsport.h +1 -0
@@ -80,5 +80,6 @@ extern int nand_debug_level;extern int GLOB_Calc_Used_Bits (u32 n);extern u64 GLOB_u64_Div (u64 addr,u32 divisor);extern u64 GLOB_u64_Remainder (u64 addr,u32 divisor_type); +extern int register_spectra_ftl (void );#endif /* _FFSPORT_ */
drivers/staging/spectra/flash.c +1 -3
@@ -1258,9 +1258,7 @@ int GLOB_FTL_Flash_Init(void) g_SBDCmdIndex =0 ; -GLOB_LLD_Flash_Init (); - - status =GLOB_LLD_Read_Device_ID (); + status =GLOB_LLD_Flash_Init ();return status; }
drivers/staging/spectra/lld_nand.c +95 -82
212 lines not on this page · raw message
Signature · 1 line
1.5.5.1