LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] dgnc: Don't save boards in memory that have failed to initialize
@ 2015-03-09 15:27 Giedrius Statkevičius
  2015-03-09 16:18 ` Giedrius Statkevičius
  0 siblings, 1 reply; 2+ messages in thread
From: Giedrius Statkevičius @ 2015-03-09 15:27 UTC (permalink / raw)
  To: lidza.louina, markh
  Cc: gregkh, driverdev-devel, devel, linux-kernel, dan.carpenter,
	Giedrius Statkevičius

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.

Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@gmail.com>
---
 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(-)

diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c
index fa1ee79..c73dc1f 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -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);
 
diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h
index 734bdc2..9f0d97b 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -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
 };
 
diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c
index 5544a8e..8c3a1bf 100644
--- a/drivers/staging/dgnc/dgnc_mgmt.c
+++ b/drivers/staging/dgnc/dgnc_mgmt.c
@@ -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);
 
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index 8179342..570eb7e 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -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;
-- 
2.3.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] dgnc: Don't save boards in memory that have failed to initialize
  2015-03-09 15:27 [PATCH] dgnc: Don't save boards in memory that have failed to initialize Giedrius Statkevičius
@ 2015-03-09 16:18 ` Giedrius Statkevičius
  0 siblings, 0 replies; 2+ messages in thread
From: Giedrius Statkevičius @ 2015-03-09 16:18 UTC (permalink / raw)
  To: lidza.louina, markh
  Cc: gregkh, driverdev-devel, devel, linux-kernel, dan.carpenter

On 2015.03.09 17:27, Giedrius Statkevičius wrote:
> 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.
> 
> Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@gmail.com>
> ---
>  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(-)
> 
> diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c
> index fa1ee79..c73dc1f 100644
> --- a/drivers/staging/dgnc/dgnc_driver.c
> +++ b/drivers/staging/dgnc/dgnc_driver.c
> @@ -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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-03-09 16:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-09 15:27 [PATCH] dgnc: Don't save boards in memory that have failed to initialize Giedrius Statkevičius
2015-03-09 16:18 ` Giedrius Statkevičius

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).