summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRosen Penev <rosenp@gmail.com>2026-07-27 12:46:04 -0700
committerJassi Brar <jassisinghbrar@gmail.com>2026-08-15 15:41:13 -0500
commit3ccffcc3672af5fc2f5809d349f26d2be8d318a3 (patch)
treef85aa8218a976abef2061b247c896496cf86400a
parent66c7bcad72430a02c860521031350b84b31ad9a8 (diff)
downloadlinux-3ccffcc3672af5fc2f5809d349f26d2be8d318a3.tar.gz
linux-3ccffcc3672af5fc2f5809d349f26d2be8d318a3.zip
mailbox: bcm2835: use platform_get_irq and simplify probe
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> Signed-off-by: Jassi Brar <jassisinghbrar@gmail.com>
-rw-r--r--drivers/mailbox/bcm2835-mailbox.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/drivers/mailbox/bcm2835-mailbox.c b/drivers/mailbox/bcm2835-mailbox.c
index 5af1e434c71c..0ca75c378a60 100644
--- a/drivers/mailbox/bcm2835-mailbox.c
+++ b/drivers/mailbox/bcm2835-mailbox.c
@@ -136,25 +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);
+ mbox->regs = regs;
- ret = devm_request_irq(dev, irq_of_parse_and_map(dev->of_node, 0),
- bcm2835_mbox_irq, IRQF_NO_SUSPEND, dev_name(dev),
- mbox);
+ ret = devm_request_irq(dev, irq, bcm2835_mbox_irq,
+ IRQF_NO_SUSPEND, dev_name(dev), mbox);
if (ret)
- return -ENODEV;
-
- mbox->regs = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(mbox->regs)) {
- ret = PTR_ERR(mbox->regs);
return ret;
- }
mbox->controller.txdone_poll = true;
mbox->controller.txpoll_period = 5;
@@ -167,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[] = {