Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /* Copyright(c) 2021 Intel Corporation. All rights reserved. */
0003 
0004 #include <linux/platform_device.h>
0005 #include <linux/device.h>
0006 #include <linux/acpi.h>
0007 #include <cxl.h>
0008 #include "test/mock.h"
0009 
0010 struct acpi_device *to_cxl_host_bridge(struct device *host, struct device *dev)
0011 {
0012     int index;
0013     struct acpi_device *adev, *found = NULL;
0014     struct cxl_mock_ops *ops = get_cxl_mock_ops(&index);
0015 
0016     if (ops && ops->is_mock_bridge(dev)) {
0017         found = ACPI_COMPANION(dev);
0018         goto out;
0019     }
0020 
0021     if (dev->bus == &platform_bus_type)
0022         goto out;
0023 
0024     adev = to_acpi_device(dev);
0025     if (!acpi_pci_find_root(adev->handle))
0026         goto out;
0027 
0028     if (strcmp(acpi_device_hid(adev), "ACPI0016") == 0) {
0029         found = adev;
0030         dev_dbg(host, "found host bridge %s\n", dev_name(&adev->dev));
0031     }
0032 out:
0033     put_cxl_mock_ops(index);
0034     return found;
0035 }