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

Commit 859ac9a4 authored by Bjorn Helgaas's avatar Bjorn Helgaas Committed by Len Brown
Browse files

ACPI: identify device tree root by null parent pointer, not ACPI_BUS_TYPE



We can identify the root of the ACPI device tree by the fact that it
has no parent.  This is simpler than passing around ACPI_BUS_TYPE_SYSTEM
and will help remove special treatment of the device tree root.

Currently, we add the root by hand with ACPI_BUS_TYPE_SYSTEM.  If we
traverse the tree treating the root as just another device and use
acpi_get_type(), the root shows up as ACPI_TYPE_DEVICE.

Signed-off-by: default avatarBjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent adc08e20
Loading
Loading
Loading
Loading
+13 −7
Original line number Original line Diff line number Diff line
@@ -22,6 +22,8 @@ extern struct acpi_device *acpi_root;
#define ACPI_BUS_HID			"LNXSYBUS"
#define ACPI_BUS_HID			"LNXSYBUS"
#define ACPI_BUS_DEVICE_NAME		"System Bus"
#define ACPI_BUS_DEVICE_NAME		"System Bus"


#define ACPI_IS_ROOT_DEVICE(device)    (!(device)->parent)

static LIST_HEAD(acpi_device_list);
static LIST_HEAD(acpi_device_list);
static LIST_HEAD(acpi_bus_id_list);
static LIST_HEAD(acpi_bus_id_list);
DEFINE_MUTEX(acpi_device_lock);
DEFINE_MUTEX(acpi_device_lock);
@@ -955,10 +957,12 @@ static void acpi_device_get_busid(struct acpi_device *device)
	 * The device's Bus ID is simply the object name.
	 * The device's Bus ID is simply the object name.
	 * TBD: Shouldn't this value be unique (within the ACPI namespace)?
	 * TBD: Shouldn't this value be unique (within the ACPI namespace)?
	 */
	 */
	switch (device->device_type) {
	if (ACPI_IS_ROOT_DEVICE(device)) {
	case ACPI_BUS_TYPE_SYSTEM:
		strcpy(device->pnp.bus_id, "ACPI");
		strcpy(device->pnp.bus_id, "ACPI");
		break;
		return;
	}

	switch (device->device_type) {
	case ACPI_BUS_TYPE_POWER_BUTTON:
	case ACPI_BUS_TYPE_POWER_BUTTON:
		strcpy(device->pnp.bus_id, "PWRF");
		strcpy(device->pnp.bus_id, "PWRF");
		break;
		break;
@@ -1093,6 +1097,11 @@ static void acpi_device_set_id(struct acpi_device *device)


	switch (device->device_type) {
	switch (device->device_type) {
	case ACPI_BUS_TYPE_DEVICE:
	case ACPI_BUS_TYPE_DEVICE:
		if (ACPI_IS_ROOT_DEVICE(device)) {
			hid = ACPI_SYSTEM_HID;
			break;
		}

		status = acpi_get_object_info(device->handle, &info);
		status = acpi_get_object_info(device->handle, &info);
		if (ACPI_FAILURE(status)) {
		if (ACPI_FAILURE(status)) {
			printk(KERN_ERR PREFIX "%s: Error reading device info\n", __func__);
			printk(KERN_ERR PREFIX "%s: Error reading device info\n", __func__);
@@ -1129,9 +1138,6 @@ static void acpi_device_set_id(struct acpi_device *device)
	case ACPI_BUS_TYPE_PROCESSOR:
	case ACPI_BUS_TYPE_PROCESSOR:
		hid = ACPI_PROCESSOR_OBJECT_HID;
		hid = ACPI_PROCESSOR_OBJECT_HID;
		break;
		break;
	case ACPI_BUS_TYPE_SYSTEM:
		hid = ACPI_SYSTEM_HID;
		break;
	case ACPI_BUS_TYPE_THERMAL:
	case ACPI_BUS_TYPE_THERMAL:
		hid = ACPI_THERMAL_HID;
		hid = ACPI_THERMAL_HID;
		break;
		break;
@@ -1643,7 +1649,7 @@ int __init acpi_scan_init(void)
	 * Create the root device in the bus's device tree
	 * Create the root device in the bus's device tree
	 */
	 */
	result = acpi_add_single_object(&acpi_root, ACPI_ROOT_OBJECT,
	result = acpi_add_single_object(&acpi_root, ACPI_ROOT_OBJECT,
					ACPI_BUS_TYPE_SYSTEM, &ops);
					ACPI_BUS_TYPE_DEVICE, &ops);
	if (result)
	if (result)
		goto Done;
		goto Done;


+0 −1
Original line number Original line Diff line number Diff line
@@ -70,7 +70,6 @@ enum acpi_bus_device_type {
	ACPI_BUS_TYPE_POWER,
	ACPI_BUS_TYPE_POWER,
	ACPI_BUS_TYPE_PROCESSOR,
	ACPI_BUS_TYPE_PROCESSOR,
	ACPI_BUS_TYPE_THERMAL,
	ACPI_BUS_TYPE_THERMAL,
	ACPI_BUS_TYPE_SYSTEM,
	ACPI_BUS_TYPE_POWER_BUTTON,
	ACPI_BUS_TYPE_POWER_BUTTON,
	ACPI_BUS_TYPE_SLEEP_BUTTON,
	ACPI_BUS_TYPE_SLEEP_BUTTON,
	ACPI_BUS_DEVICE_TYPE_COUNT
	ACPI_BUS_DEVICE_TYPE_COUNT