From: Roel Kluin <roel.kluin@gmail.com>
To: Olof Johansson <olof@lixom.net>
Cc: linuxppc-dev@ozlabs.org
Subject: Re: [PATCH] [POWERPC] pasemi: ioremap/iounmap balance and failure handling
Date: Sat, 13 Dec 2008 20:15:17 +0100 [thread overview]
Message-ID: <494409C5.1050308@gmail.com> (raw)
In-Reply-To: <4943E6B5.6010501@gmail.com>
Roel Kluin wrote:
> map_onedev can return NULL, so catch that. Also iounmap if DMA controller can't be
> found.
I think there may also be a problem with pasemi_mac_init_module(): if
pci_register_driver() fails, then iob_regs won't get iounmapped.
maybe something like the totally untested patch below?
diff --git a/arch/powerpc/include/asm/pasemi_dma.h b/arch/powerpc/include/asm/pasemi_dma.h
index 19fd793..7256a2c 100644
--- a/arch/powerpc/include/asm/pasemi_dma.h
+++ b/arch/powerpc/include/asm/pasemi_dma.h
@@ -535,4 +535,7 @@ extern void pasemi_dma_free_fun(int fun);
/* Initialize the library, must be called before any other functions */
extern int pasemi_dma_init(void);
+/* Clean up the library */
+extern void pasemi_dma_exit(void);
+
#endif /* ASM_PASEMI_DMA_H */
diff --git a/arch/powerpc/platforms/pasemi/dma_lib.c b/arch/powerpc/platforms/pasemi/dma_lib.c
index 217af32..fc0e1f9 100644
--- a/arch/powerpc/platforms/pasemi/dma_lib.c
+++ b/arch/powerpc/platforms/pasemi/dma_lib.c
@@ -534,14 +534,21 @@ int pasemi_dma_init(void)
err = -ENODEV;
goto out;
}
+
iob_regs = map_onedev(iob_pdev, 0);
+ if (iob_regs == NULL) {
+ BUG();
+ printk(KERN_WARNING "Can't ioremap I/O Bridge registers\n");
+ err = -ENODEV;
+ goto out;
+ }
dma_pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa007, NULL);
if (!dma_pdev) {
BUG();
printk(KERN_WARNING "Can't find DMA controller\n");
err = -ENODEV;
- goto out;
+ goto out_unmap;
}
dma_regs = map_onedev(dma_pdev, 0);
base_hw_irq = virq_to_hw(dma_pdev->irq);
@@ -624,9 +631,19 @@ int pasemi_dma_init(void)
printk(KERN_INFO "PA Semi PWRficient DMA library initialized "
"(%d tx, %d rx channels)\n", num_txch, num_rxch);
+ goto out;
+
+out_unmap:
+ iounmap(iob_regs);
out:
spin_unlock(&init_lock);
return err;
}
EXPORT_SYMBOL(pasemi_dma_init);
+
+void pasemi_dma_exit(void)
+{
+ iounmap(iob_regs);
+}
+
diff --git a/drivers/net/pasemi_mac.c b/drivers/net/pasemi_mac.c
index edc0fd5..0897fa0 100644
--- a/drivers/net/pasemi_mac.c
+++ b/drivers/net/pasemi_mac.c
@@ -1919,7 +1919,11 @@ int pasemi_mac_init_module(void)
if (err)
return err;
- return pci_register_driver(&pasemi_mac_driver);
+ err = pci_register_driver(&pasemi_mac_driver);
+ if (err)
+ pasemi_dma_exit();
+
+ return err;
}
module_init(pasemi_mac_init_module);
next prev parent reply other threads:[~2008-12-13 19:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-13 16:45 [PATCH] [POWERPC] pasemi: ioremap/iounmap balance and failure handling Roel Kluin
2008-12-13 19:15 ` Roel Kluin [this message]
2008-12-13 21:13 ` Olof Johansson
2008-12-16 10:52 ` Roel Kluin
2009-01-07 0:50 ` Benjamin Herrenschmidt
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=494409C5.1050308@gmail.com \
--to=roel.kluin@gmail.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=olof@lixom.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.