Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7b199811 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

ACPI / driver core: Store an ACPI device pointer in struct acpi_dev_node



Modify struct acpi_dev_node to contain a pointer to struct acpi_device
associated with the given device object (that is, its ACPI companion
device) instead of an ACPI handle corresponding to it.  Introduce two
new macros for manipulating that pointer in a CONFIG_ACPI-safe way,
ACPI_COMPANION() and ACPI_COMPANION_SET(), and rework the
ACPI_HANDLE() macro to take the above changes into account.
Drop the ACPI_HANDLE_SET() macro entirely and rework its users to
use ACPI_COMPANION_SET() instead.  For some of them who used to
pass the result of acpi_get_child() directly to ACPI_HANDLE_SET()
introduce a helper routine acpi_preset_companion() doing an
equivalent thing.

The main motivation for doing this is that there are things
represented by struct acpi_device objects that don't have valid
ACPI handles (so called fixed ACPI hardware features, such as
power and sleep buttons) and we would like to create platform
device objects for them and "glue" them to their ACPI companions
in the usual way (which currently is impossible due to the
lack of valid ACPI handles).  However, there are more reasons
why it may be useful.

First, struct acpi_device pointers allow of much better type checking
than void pointers which are ACPI handles, so it should be more
difficult to write buggy code using modified struct acpi_dev_node
and the new macros.  Second, the change should help to reduce (over
time) the number of places in which the result of ACPI_HANDLE() is
passed to acpi_bus_get_device() in order to obtain a pointer to the
struct acpi_device associated with the given "physical" device,
because now that pointer is returned by ACPI_COMPANION() directly.
Finally, the change should make it easier to write generic code that
will build both for CONFIG_ACPI set and unset without adding explicit
compiler directives to it.

Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com> # on Haswell
Reviewed-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Aaron Lu <aaron.lu@intel.com> # for ATA and SDIO part
parent 2f466d33
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -1992,7 +1992,7 @@ sba_connect_bus(struct pci_bus *bus)
	if (PCI_CONTROLLER(bus)->iommu)
	if (PCI_CONTROLLER(bus)->iommu)
		return;
		return;


	handle = PCI_CONTROLLER(bus)->acpi_handle;
	handle = acpi_device_handle(PCI_CONTROLLER(bus)->companion);
	if (!handle)
	if (!handle)
		return;
		return;


+1 −1
Original line number Original line Diff line number Diff line
@@ -95,7 +95,7 @@ struct iospace_resource {
};
};


struct pci_controller {
struct pci_controller {
	void *acpi_handle;
	struct acpi_device *companion;
	void *iommu;
	void *iommu;
	int segment;
	int segment;
	int node;		/* nearest node with memory or -1 for global allocation */
	int node;		/* nearest node with memory or -1 for global allocation */
+3 −3
Original line number Original line Diff line number Diff line
@@ -436,9 +436,9 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
	if (!controller)
	if (!controller)
		return NULL;
		return NULL;


	controller->acpi_handle = device->handle;
	controller->companion = device;


	pxm = acpi_get_pxm(controller->acpi_handle);
	pxm = acpi_get_pxm(device->handle);
#ifdef CONFIG_NUMA
#ifdef CONFIG_NUMA
	if (pxm >= 0)
	if (pxm >= 0)
		controller->node = pxm_to_node(pxm);
		controller->node = pxm_to_node(pxm);
@@ -489,7 +489,7 @@ int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
{
{
	struct pci_controller *controller = bridge->bus->sysdata;
	struct pci_controller *controller = bridge->bus->sysdata;


	ACPI_HANDLE_SET(&bridge->dev, controller->acpi_handle);
	ACPI_COMPANION_SET(&bridge->dev, controller->companion);
	return 0;
	return 0;
}
}


+2 −2
Original line number Original line Diff line number Diff line
@@ -132,7 +132,7 @@ sn_get_bussoft_ptr(struct pci_bus *bus)
	struct acpi_resource_vendor_typed *vendor;
	struct acpi_resource_vendor_typed *vendor;




	handle = PCI_CONTROLLER(bus)->acpi_handle;
	handle = acpi_device_handle(PCI_CONTROLLER(bus)->companion);
	status = acpi_get_vendor_resource(handle, METHOD_NAME__CRS,
	status = acpi_get_vendor_resource(handle, METHOD_NAME__CRS,
					  &sn_uuid, &buffer);
					  &sn_uuid, &buffer);
	if (ACPI_FAILURE(status)) {
	if (ACPI_FAILURE(status)) {
@@ -360,7 +360,7 @@ sn_acpi_get_pcidev_info(struct pci_dev *dev, struct pcidev_info **pcidev_info,
	acpi_status status;
	acpi_status status;
	struct acpi_buffer name_buffer = { ACPI_ALLOCATE_BUFFER, NULL };
	struct acpi_buffer name_buffer = { ACPI_ALLOCATE_BUFFER, NULL };


	rootbus_handle = PCI_CONTROLLER(dev)->acpi_handle;
	rootbus_handle = acpi_device_handle(PCI_CONTROLLER(dev)->companion);
        status = acpi_evaluate_integer(rootbus_handle, METHOD_NAME__SEG, NULL,
        status = acpi_evaluate_integer(rootbus_handle, METHOD_NAME__SEG, NULL,
                                       &segment);
                                       &segment);
        if (ACPI_SUCCESS(status)) {
        if (ACPI_SUCCESS(status)) {
+1 −1
Original line number Original line Diff line number Diff line
@@ -15,7 +15,7 @@ struct pci_sysdata {
	int		domain;		/* PCI domain */
	int		domain;		/* PCI domain */
	int		node;		/* NUMA node */
	int		node;		/* NUMA node */
#ifdef CONFIG_ACPI
#ifdef CONFIG_ACPI
	void		*acpi;		/* ACPI-specific data */
	struct acpi_device *companion;	/* ACPI companion device */
#endif
#endif
#ifdef CONFIG_X86_64
#ifdef CONFIG_X86_64
	void		*iommu;		/* IOMMU private data */
	void		*iommu;		/* IOMMU private data */
Loading