aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/platform.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base/platform.c')
-rw-r--r--drivers/base/platform.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 5f837f2e4f41..dab0a5abc391 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -147,7 +147,20 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
147 irqd_set_trigger_type(irqd, r->flags & IORESOURCE_BITS); 147 irqd_set_trigger_type(irqd, r->flags & IORESOURCE_BITS);
148 } 148 }
149 149
150 return r ? r->start : -ENXIO; 150 if (r)
151 return r->start;
152
153 /*
154 * For the index 0 interrupt, allow falling back to GpioInt
155 * resources. While a device could have both Interrupt and GpioInt
156 * resources, making this fallback ambiguous, in many common cases
157 * the device will only expose one IRQ, and this fallback
158 * allows a common code path across either kind of resource.
159 */
160 if (num == 0 && has_acpi_companion(&dev->dev))
161 return acpi_dev_gpio_irq_get(ACPI_COMPANION(&dev->dev), num);
162
163 return -ENXIO;
151#endif 164#endif
152} 165}
153EXPORT_SYMBOL_GPL(platform_get_irq); 166EXPORT_SYMBOL_GPL(platform_get_irq);
@@ -528,10 +541,12 @@ struct platform_device *platform_device_register_full(
528 541
529 pdev = platform_device_alloc(pdevinfo->name, pdevinfo->id); 542 pdev = platform_device_alloc(pdevinfo->name, pdevinfo->id);
530 if (!pdev) 543 if (!pdev)
531 goto err_alloc; 544 return ERR_PTR(-ENOMEM);
532 545
533 pdev->dev.parent = pdevinfo->parent; 546 pdev->dev.parent = pdevinfo->parent;
534 pdev->dev.fwnode = pdevinfo->fwnode; 547 pdev->dev.fwnode = pdevinfo->fwnode;
548 pdev->dev.of_node = of_node_get(to_of_node(pdev->dev.fwnode));
549 pdev->dev.of_node_reused = pdevinfo->of_node_reused;
535 550
536 if (pdevinfo->dma_mask) { 551 if (pdevinfo->dma_mask) {
537 /* 552 /*
@@ -573,8 +588,6 @@ struct platform_device *platform_device_register_full(
573err: 588err:
574 ACPI_COMPANION_SET(&pdev->dev, NULL); 589 ACPI_COMPANION_SET(&pdev->dev, NULL);
575 kfree(pdev->dev.dma_mask); 590 kfree(pdev->dev.dma_mask);
576
577err_alloc:
578 platform_device_put(pdev); 591 platform_device_put(pdev);
579 return ERR_PTR(ret); 592 return ERR_PTR(ret);
580 } 593 }