LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Giedrius Statkevičius" <giedrius.statkevicius@gmail.com>
To: lidza.louina@gmail.com, markh@compro.net
Cc: gregkh@linuxfoundation.org,
driverdev-devel@linuxdriverproject.org,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
dan.carpenter@oracle.com,
"Giedrius Statkevičius" <giedrius.statkevicius@gmail.com>
Subject: [PATCH v2] dgnc: Don't save boards in memory that have failed to initialize
Date: Mon, 9 Mar 2015 18:29:38 +0200 [thread overview]
Message-ID: <1425918578-10223-1-git-send-email-giedrius.statkevicius@gmail.com> (raw)
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>
---
v2: Remove "brd = dgnc_Board[dgnc_NumBoards];" line which I forgot to do
in the first version
drivers/staging/dgnc/dgnc_driver.c | 20 ++------------------
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(+), 32 deletions(-)
diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c
index fa1ee79..075727d 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -401,8 +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 = dgnc_Board[dgnc_NumBoards];
+ brd = kzalloc(sizeof(*brd), GFP_KERNEL);
if (!brd)
return -ENOMEM;
@@ -574,17 +573,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 +586,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 +615,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 +640,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 +698,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
next reply other threads:[~2015-03-09 16:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-09 16:29 Giedrius Statkevičius [this message]
2015-03-10 7:39 ` Dan Carpenter
2015-03-12 10:08 ` Greg KH
2015-03-12 10:20 ` Dan Carpenter
2015-03-12 16:14 ` Giedrius Statkevičius
2015-03-13 20:55 ` Mark Hounschell
2015-03-14 8:44 ` Greg KH
2015-03-15 12:07 ` Mark Hounschell
2015-03-15 16:38 ` Greg KH
2015-03-16 17:18 ` Mark Hounschell
2015-03-13 20:06 ` Giedrius Statkevičius
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1425918578-10223-1-git-send-email-giedrius.statkevicius@gmail.com \
--to=giedrius.statkevicius@gmail.com \
--cc=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=driverdev-devel@linuxdriverproject.org \
--cc=gregkh@linuxfoundation.org \
--cc=lidza.louina@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=markh@compro.net \
--subject='Re: [PATCH v2] dgnc: Don'\''t save boards in memory that have failed to initialize' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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).