From: Li Yang <leoli@freescale.com>
To: galak@kernel.crashing.org, linuxppc-dev@lists.ozlabs.org
Subject: [PATCH v3 5/5] fsl_msi: add removal path and probe failing path
Date: Thu, 22 Apr 2010 16:31:39 +0800 [thread overview]
Message-ID: <1271925099-29100-5-git-send-email-leoli@freescale.com> (raw)
In-Reply-To: <1271925099-29100-4-git-send-email-leoli@freescale.com>
Also cleanup the probe function.
Signed-off-by: Li Yang <leoli@freescale.com>
---
arch/powerpc/sysdev/fsl_msi.c | 36 ++++++++++++++++++++++++++++++------
arch/powerpc/sysdev/fsl_msi.h | 1 +
2 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/sysdev/fsl_msi.c b/arch/powerpc/sysdev/fsl_msi.c
index 7c442e2..025aa9b 100644
--- a/arch/powerpc/sysdev/fsl_msi.c
+++ b/arch/powerpc/sysdev/fsl_msi.c
@@ -249,6 +249,30 @@ unlock:
spin_unlock(&desc->lock);
}
+static int fsl_of_msi_remove(struct of_device *ofdev)
+{
+ struct fsl_msi *msi = ofdev->dev.platform_data;
+ int virq, i;
+ struct fsl_msi_cascade_data *cascade_data;
+
+ if (msi->list.prev != NULL)
+ list_del(&msi->list);
+ for (i = 0; i < NR_MSI_REG; i++) {
+ virq = msi->msi_virqs[i];
+ if (virq != NO_IRQ) {
+ cascade_data = get_irq_data(virq);
+ kfree(cascade_data);
+ irq_dispose_mapping(virq);
+ }
+ }
+ if (msi->bitmap.bitmap)
+ msi_bitmap_free(&msi->bitmap);
+ iounmap(msi->msi_regs);
+ kfree(msi);
+
+ return 0;
+}
+
static int __devinit fsl_of_msi_probe(struct of_device *dev,
const struct of_device_id *match)
{
@@ -268,9 +292,9 @@ static int __devinit fsl_of_msi_probe(struct of_device *dev,
msi = kzalloc(sizeof(struct fsl_msi), GFP_KERNEL);
if (!msi) {
dev_err(&dev->dev, "No memory for MSI structure\n");
- err = -ENOMEM;
- goto error_out;
+ return -ENOMEM;
}
+ dev->dev.platform_data = msi;
msi->irqhost = irq_alloc_host(dev->node, IRQ_HOST_MAP_LINEAR,
NR_MSI_IRQS, &fsl_msi_host_ops, 0);
@@ -327,9 +351,7 @@ static int __devinit fsl_of_msi_probe(struct of_device *dev,
offset = *p / IRQS_PER_MSI_REG;
count /= sizeof(u32);
- for (i = 0; i < count / 2; i++) {
- if (i > NR_MSI_REG)
- break;
+ for (i = 0; i < min(count / 2, NR_MSI_REG); i++) {
virt_msir = irq_of_parse_and_map(dev->node, i);
if (virt_msir != NO_IRQ) {
cascade_data = kzalloc(
@@ -341,6 +363,7 @@ static int __devinit fsl_of_msi_probe(struct of_device *dev,
err = -ENOMEM;
goto error_out;
}
+ msi->msi_virqs[i] = virt_msir;
cascade_data->index = i + offset;
cascade_data->msi_data = msi;
set_irq_data(virt_msir, (void *)cascade_data);
@@ -362,7 +385,7 @@ static int __devinit fsl_of_msi_probe(struct of_device *dev,
}
return 0;
error_out:
- kfree(msi);
+ fsl_of_msi_remove(dev);
return err;
}
@@ -392,6 +415,7 @@ static struct of_platform_driver fsl_of_msi_driver = {
.name = "fsl-msi",
.match_table = fsl_of_msi_ids,
.probe = fsl_of_msi_probe,
+ .remove = fsl_of_msi_remove,
};
static __init int fsl_of_msi_init(void)
diff --git a/arch/powerpc/sysdev/fsl_msi.h b/arch/powerpc/sysdev/fsl_msi.h
index 8fc5523..624580c 100644
--- a/arch/powerpc/sysdev/fsl_msi.h
+++ b/arch/powerpc/sysdev/fsl_msi.h
@@ -32,6 +32,7 @@ struct fsl_msi {
u32 msi_addr_hi;
void __iomem *msi_regs;
u32 feature;
+ int msi_virqs[NR_MSI_REG];
struct msi_bitmap bitmap;
--
1.6.6-rc1.GIT
next prev parent reply other threads:[~2010-04-22 7:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-22 8:31 [PATCH v3 1/5] fsl_msi: fix the conflict of virt_msir's chip_data Li Yang
2010-04-22 8:31 ` [PATCH v3 2/5] fsl_msi: enable msi allocation in all banks Li Yang
2010-04-22 8:31 ` [PATCH v3 3/5] fsl_msi: enable msi sharing through AMP OSes Li Yang
2010-04-22 8:31 ` [PATCH v3 4/5] mpc8572ds: change camp dtses for MSI sharing Li Yang
2010-04-22 8:31 ` Li Yang [this message]
2010-05-24 19:13 ` [PATCH v3 5/5] fsl_msi: add removal path and probe failing path Kumar Gala
2010-05-24 19:12 ` [PATCH v3 4/5] mpc8572ds: change camp dtses for MSI sharing Kumar Gala
2010-05-24 19:12 ` [PATCH v3 3/5] fsl_msi: enable msi sharing through AMP OSes Kumar Gala
2010-05-24 19:12 ` [PATCH v3 2/5] fsl_msi: enable msi allocation in all banks Kumar Gala
2010-05-24 19:12 ` [PATCH v3 1/5] fsl_msi: fix the conflict of virt_msir's chip_data Kumar Gala
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=1271925099-29100-5-git-send-email-leoli@freescale.com \
--to=leoli@freescale.com \
--cc=galak@kernel.crashing.org \
--cc=linuxppc-dev@lists.ozlabs.org \
/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