* [PATCH] mailbox: bcm2835: use platform_get_irq and simplify probe
@ 2026-07-27 19:46 Rosen Penev
0 siblings, 0 replies; only message in thread
From: Rosen Penev @ 2026-07-27 19:46 UTC (permalink / raw)
To: linux-kernel
Cc: Jassi Brar, Florian Fainelli,
Broadcom internal kernel review list, Ray Jui, Scott Branden,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE,
moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE
Replace irq_of_parse_and_map() with platform_get_irq() for the mailbox
interrupt lookup, and move IRQ and MMIO resource acquisition to the top
of the probe function before any memory allocation.
Simplify error handling throughout: use direct return of platform_get_irq
and PTR_ERR values, remove the redundant platform_set_drvdata and
dev_info log, and inline the final return.
Assisted-by: Opencode:Big-Pickle
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/mailbox/bcm2835-mailbox.c | 37 +++++++++++++------------------
1 file changed, 16 insertions(+), 21 deletions(-)
diff --git a/drivers/mailbox/bcm2835-mailbox.c b/drivers/mailbox/bcm2835-mailbox.c
index ea12fb8d2401..0ca75c378a60 100644
--- a/drivers/mailbox/bcm2835-mailbox.c
+++ b/drivers/mailbox/bcm2835-mailbox.c
@@ -136,28 +136,30 @@ static struct mbox_chan *bcm2835_mbox_index_xlate(struct mbox_controller *mbox,
static int bcm2835_mbox_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
+ void __iomem *regs;
int ret = 0;
+ int irq;
struct bcm2835_mbox *mbox;
+ irq = platform_get_irq(pdev, 0);
+ if (irq < 0)
+ return irq;
+
+ regs = devm_platform_ioremap_resource(pdev, 0);
+ if (IS_ERR(regs))
+ return PTR_ERR(regs);
+
mbox = devm_kzalloc(dev, sizeof(*mbox), GFP_KERNEL);
if (mbox == NULL)
return -ENOMEM;
- spin_lock_init(&mbox->lock);
- ret = devm_request_irq(dev, irq_of_parse_and_map(dev->of_node, 0),
- bcm2835_mbox_irq, IRQF_NO_SUSPEND, dev_name(dev),
- mbox);
- if (ret) {
- dev_err(dev, "Failed to register a mailbox IRQ handler: %d\n",
- ret);
- return -ENODEV;
- }
+ spin_lock_init(&mbox->lock);
+ mbox->regs = regs;
- mbox->regs = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(mbox->regs)) {
- ret = PTR_ERR(mbox->regs);
+ ret = devm_request_irq(dev, irq, bcm2835_mbox_irq,
+ IRQF_NO_SUSPEND, dev_name(dev), mbox);
+ if (ret)
return ret;
- }
mbox->controller.txdone_poll = true;
mbox->controller.txpoll_period = 5;
@@ -170,14 +172,7 @@ static int bcm2835_mbox_probe(struct platform_device *pdev)
if (!mbox->controller.chans)
return -ENOMEM;
- ret = devm_mbox_controller_register(dev, &mbox->controller);
- if (ret)
- return ret;
-
- platform_set_drvdata(pdev, mbox);
- dev_info(dev, "mailbox enabled\n");
-
- return ret;
+ return devm_mbox_controller_register(dev, &mbox->controller);
}
static const struct of_device_id bcm2835_mbox_of_match[] = {
--
2.55.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-07-27 19:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-27 19:46 [PATCH] mailbox: bcm2835: use platform_get_irq and simplify probe Rosen Penev
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.