dgnc: Don't save boards in memory that have failed to initialize
PATCH 1/1 dgnc: Don't save boards in memory that have failed to initialize
Remove BOARD_FAILED and don't save dgnc_boards which failed to initialize.
Assign the result of kzalloc() to brd in dgnc_found_board() and only put it in the dgnc_Board[] if it successfully initializes. Also, remove BOARD_FAILED enum and all ifs that check for it. Finally, remove one final place where state was set to BOARD_FAILED which was even redundant before this patch.
--- drivers/staging/dgnc/dgnc_driver.c | 19 ++----------------- drivers/staging/dgnc/dgnc_driver.h | 3 +-- drivers/staging/dgnc/dgnc_mgmt.c | 5 +---- drivers/staging/dgnc/dgnc_tty.c | 8 -------- 4 files changed, 4 insertions(+), 31 deletions(-)
drivers/staging/dgnc/dgnc_driver.c +2 -17
@@ -401,7 +401,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)unsigned long flags;/* get the board structure and prep it */ - dgnc_Board[dgnc_NumBoards] =kzalloc (sizeof (*brd),GFP_KERNEL ); + brd =kzalloc (sizeof (*brd),GFP_KERNEL ); brd = dgnc_Board[dgnc_NumBoards];if (!brd)
@@ -574,17 +574,12 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)if (rc <0 ) {dgnc_tty_uninit (brd);pr_err (DRVSTR ": Can't register tty devices (%d)\n" , rc); - brd->state =BOARD_FAILED ; - brd->dpastatus =BD_NOFEP ; goto failed; } rc =dgnc_finalize_board_init (brd);if (rc <0 ) {pr_err (DRVSTR ": Can't finalize board init (%d)\n" , rc); - brd->state =BOARD_FAILED ; - brd->dpastatus =BD_NOFEP ; - goto failed; }
@@ -592,9 +587,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)if (rc <0 ) {dgnc_tty_uninit (brd);pr_err (DRVSTR ": Can't init tty devices (%d)\n" , rc); - brd->state =BOARD_FAILED ; - brd->dpastatus =BD_NOFEP ; - goto failed; }
@@ -624,6 +616,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id) brd->flipbuf =kzalloc (MYFLIPLEN ,GFP_KERNEL );wake_up_interruptible (&brd->state_wait); + dgnc_Board[dgnc_NumBoards] = brd;return 0 ;
@@ -648,8 +641,6 @@ static int dgnc_finalize_board_init(struct dgnc_board *brd)if (rc) {dev_err (&brd->pdev->dev,"Failed to hook IRQ %d\n" , brd->irq); - brd->state =BOARD_FAILED ; - brd->dpastatus =BD_NOFEP ; rc = -ENODEV ; } }
@@ -708,12 +699,6 @@ static void dgnc_poll_handler(ulong dummy)spin_lock_irqsave (&brd->bd_lock, flags); -/* If board is in a failed state, don't bother scheduling a tasklet */ -if (brd->state ==BOARD_FAILED ) { -spin_unlock_irqrestore (&brd->bd_lock, flags); -continue ; - } -/* Schedule a poll helper task */ tasklet_schedule (&brd->helper_tasklet);
drivers/staging/dgnc/dgnc_driver.h +1 -2
@@ -107,8 +107,7 @@ enum {* All the possible states the board can be while booting up. */ enum { -BOARD_FAILED =0 , -BOARD_FOUND , +BOARD_FOUND =0 ,BOARD_READY };
drivers/staging/dgnc/dgnc_mgmt.c +1 -4
@@ -168,10 +168,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) di.info_ioport =0 ; di.info_physaddr = (ulong ) dgnc_Board[brd]->membase; di.info_physsize = (ulong ) dgnc_Board[brd]->membase - dgnc_Board[brd]->membase_end; -if (dgnc_Board[brd]->state !=BOARD_FAILED ) - di.info_nports = dgnc_Board[brd]->nasync; -else - di.info_nports =0 ; + di.info_nports = dgnc_Board[brd]->nasync;spin_unlock_irqrestore (&dgnc_Board[brd]->bd_lock, flags);
drivers/staging/dgnc/dgnc_tty.c +0 -8
@@ -1253,14 +1253,6 @@ static int dgnc_block_til_ready(struct tty_struct *tty, struct file *file, struc sleep_on_un_flags =0 ; -/* -* If board has failed somehow during our sleep, bail with error. -*/ -if (ch->ch_bd->state ==BOARD_FAILED ) { - retval = -ENXIO ; -break ; - } -/* If tty was hung up, break out of loop and set error. */ if (tty_hung_up_p (file)) { retval = -EAGAIN ;
Signature · 1 line
2.3.2
Quoted 22 lines · Giedrius Statkevičius
Remove
BOARD_FAILEDand don't savedgnc_boardswhich failed to initialize.Assign the result of
kzalloc()to brd indgnc_found_board()and only put it in the dgnc_Board[] if it successfully initializes. Also, removeBOARD_FAILEDenum and all ifs that check for it. Finally, remove one final place where state was set toBOARD_FAILEDwhich was even redundant before this patch.Signed-off-by Giedrius Statkevičius <[email protected]>--- drivers/staging/dgnc/dgnc_driver.c | 19 ++----------------- drivers/staging/dgnc/dgnc_driver.h | 3 +-- drivers/staging/dgnc/dgnc_mgmt.c | 5 +---- drivers/staging/dgnc/dgnc_tty.c | 8 -------- 4 files changed, 4 insertions(+), 31 deletions(-)drivers/staging/dgnc/dgnc_driver.c +0
-0
drivers/staging/dgnc/dgnc_driver.c static int dgnc_found_board(struct pci_dev *pdev, int id) · line 405
Quoted 6 lines
drivers/staging/dgnc/dgnc_driver.c +1
-1@@ -401,7 +401,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)unsigned long flags;/* get the board structure and prep it */ - dgnc_Board[dgnc_NumBoards] =kzalloc (sizeof (*brd),GFP_KERNEL ); + brd =kzalloc (sizeof (*brd),GFP_KERNEL ); brd = dgnc_Board[dgnc_NumBoards];
err, forgot to remove this here. Posting v2.