mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-28 04:03:23 -04:00
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>
This commit is contained in:
@@ -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[] = {
|
||||
|
||||
Reference in New Issue
Block a user