Skip to content

Commit 243e1b7

Browse files
andy-shevgregkh
authored andcommitted
driver core: platform: Unify the firmware node type check
OF and ACPI currently are using asymmetrical APIs to check for the firmware node type. Unify them by using is_*_node() against struct fwnode_handle pointer. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20231003142122.3072824-4-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 6136597 commit 243e1b7

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

drivers/base/platform.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -178,18 +178,19 @@ int platform_get_irq_optional(struct platform_device *dev, unsigned int num)
178178
ret = dev->archdata.irqs[num];
179179
goto out;
180180
#else
181+
struct fwnode_handle *fwnode = dev_fwnode(&dev->dev);
181182
struct resource *r;
182183

183-
if (IS_ENABLED(CONFIG_OF_IRQ) && dev->dev.of_node) {
184-
ret = of_irq_get(dev->dev.of_node, num);
184+
if (is_of_node(fwnode)) {
185+
ret = of_irq_get(to_of_node(fwnode), num);
185186
if (ret > 0 || ret == -EPROBE_DEFER)
186187
goto out;
187188
}
188189

189190
r = platform_get_resource(dev, IORESOURCE_IRQ, num);
190-
if (has_acpi_companion(&dev->dev)) {
191+
if (is_acpi_device_node(fwnode)) {
191192
if (r && r->flags & IORESOURCE_DISABLED) {
192-
ret = acpi_irq_get(ACPI_HANDLE(&dev->dev), num, r);
193+
ret = acpi_irq_get(ACPI_HANDLE_FWNODE(fwnode), num, r);
193194
if (ret)
194195
goto out;
195196
}
@@ -222,8 +223,8 @@ int platform_get_irq_optional(struct platform_device *dev, unsigned int num)
222223
* the device will only expose one IRQ, and this fallback
223224
* allows a common code path across either kind of resource.
224225
*/
225-
if (num == 0 && has_acpi_companion(&dev->dev)) {
226-
ret = acpi_dev_gpio_irq_get(ACPI_COMPANION(&dev->dev), num);
226+
if (num == 0 && is_acpi_device_node(fwnode)) {
227+
ret = acpi_dev_gpio_irq_get(to_acpi_device_node(fwnode), num);
227228
/* Our callers expect -ENXIO for missing IRQs. */
228229
if (ret >= 0 || ret == -EPROBE_DEFER)
229230
goto out;
@@ -312,7 +313,7 @@ static void devm_platform_get_irqs_affinity_release(struct device *dev,
312313
for (i = 0; i < ptr->count; i++) {
313314
irq_dispose_mapping(ptr->irq[i]);
314315

315-
if (has_acpi_companion(dev))
316+
if (is_acpi_device_node(dev_fwnode(dev)))
316317
platform_disable_acpi_irq(to_platform_device(dev), i);
317318
}
318319
}
@@ -1446,13 +1447,14 @@ static void platform_shutdown(struct device *_dev)
14461447
static int platform_dma_configure(struct device *dev)
14471448
{
14481449
struct platform_driver *drv = to_platform_driver(dev->driver);
1450+
struct fwnode_handle *fwnode = dev_fwnode(dev);
14491451
enum dev_dma_attr attr;
14501452
int ret = 0;
14511453

1452-
if (dev->of_node) {
1453-
ret = of_dma_configure(dev, dev->of_node, true);
1454-
} else if (has_acpi_companion(dev)) {
1455-
attr = acpi_get_dma_attr(to_acpi_device_node(dev->fwnode));
1454+
if (is_of_node(fwnode)) {
1455+
ret = of_dma_configure(dev, to_of_node(fwnode), true);
1456+
} else if (is_acpi_device_node(fwnode)) {
1457+
attr = acpi_get_dma_attr(to_acpi_device_node(fwnode));
14561458
ret = acpi_dma_configure(dev, attr);
14571459
}
14581460
if (ret || drv->driver_managed_dma)

0 commit comments

Comments
 (0)