linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daeseok Youn <daeseok.youn@gmail.com>
To: lidza.louina@gmail.com, gregkh@linuxfoundation.org
Cc: markh@compro.net, dan.carpenter@oracle.com,
	driverdev-devel@linuxdriverproject.org,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: [PATCH 9/9] staging: dgap: introduce dgap_release_remap()
Date: Fri, 13 Jun 2014 16:44:11 +0900	[thread overview]
Message-ID: <20140613074411.GA31639@devel.8.8.4.4> (raw)

The dgap_found_board() did request some memory region and
call ioremap, these should be released and unmaped
when one of functions which are called after dgap_found_board()
in dgap_init_one() is failed.

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
---
 drivers/staging/dgap/dgap.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index e1347fb..5c8e622 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -77,6 +77,7 @@ static int dgap_init_pci(void);
 static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
 static void dgap_remove_one(struct pci_dev *dev);
 static int dgap_do_remap(struct board_t *brd);
+static void dgap_release_remap(struct board_t *brd);
 static irqreturn_t dgap_intr(int irq, void *voidbrd);
 
 static int dgap_tty_open(struct tty_struct *tty, struct file *file);
@@ -588,11 +589,11 @@ static int dgap_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	brd = dgap_board[dgap_numboards++];
 	rc = dgap_firmware_load(pdev, ent->driver_data, brd);
 	if (rc)
-		goto free_brd;
+		goto cleanup_brd;
 
 	rc = dgap_alloc_flipbuf(brd);
 	if (rc)
-		goto free_brd;
+		goto cleanup_brd;
 
 	rc = dgap_tty_register(brd);
 	if (rc)
@@ -626,7 +627,8 @@ unregister_tty:
 	dgap_tty_unregister(brd);
 free_flipbuf:
 	dgap_free_flipbuf(brd);
-free_brd:
+cleanup_brd:
+	dgap_release_remap(brd);
 	kfree(brd);
 	dgap_board[--dgap_numboards] = NULL;
 	return rc;
@@ -1034,6 +1036,12 @@ static int dgap_do_remap(struct board_t *brd)
 	return 0;
 }
 
+static void dgap_release_remap(struct board_t *brd)
+{
+	release_mem_region(brd->membase, 0x200000);
+	release_mem_region(brd->membase + PCI_IO_OFFSET, 0x200000);
+	iounmap(brd->re_map_membase);
+}
 /*****************************************************************************
 *
 * Function:
-- 
1.7.1


             reply	other threads:[~2014-06-13  7:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-13  7:44 Daeseok Youn [this message]
2014-06-13  8:33 ` [PATCH 9/9] staging: dgap: introduce dgap_release_remap() Dan Carpenter

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=20140613074411.GA31639@devel.8.8.4.4 \
    --to=daeseok.youn@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 \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).