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

Commit 038d7b59 authored by Hanjun Guo's avatar Hanjun Guo Committed by Rafael J. Wysocki
Browse files

ACPI / processor: Return specific error value when mapping lapic id



Usually, 0 is returned for success in int-returning functions and
negative value are returned on failure, but in processor_core.c, some
function return 1 for success and 0 for failure which causes confusion
to happen sometimes, so modify the functions in question to follow the
common convention..

Signed-off-by: default avatarHanjun Guo <hanjun.guo@linaro.org>
[rjw: Changelog]
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent b981513f
Loading
Loading
Loading
Loading
+13 −13
Original line number Original line Diff line number Diff line
@@ -45,13 +45,13 @@ static int map_lapic_id(struct acpi_subtable_header *entry,
		(struct acpi_madt_local_apic *)entry;
		(struct acpi_madt_local_apic *)entry;


	if (!(lapic->lapic_flags & ACPI_MADT_ENABLED))
	if (!(lapic->lapic_flags & ACPI_MADT_ENABLED))
		return 0;
		return -ENODEV;


	if (lapic->processor_id != acpi_id)
	if (lapic->processor_id != acpi_id)
		return 0;
		return -EINVAL;


	*apic_id = lapic->id;
	*apic_id = lapic->id;
	return 1;
	return 0;
}
}


static int map_x2apic_id(struct acpi_subtable_header *entry,
static int map_x2apic_id(struct acpi_subtable_header *entry,
@@ -61,14 +61,14 @@ static int map_x2apic_id(struct acpi_subtable_header *entry,
		(struct acpi_madt_local_x2apic *)entry;
		(struct acpi_madt_local_x2apic *)entry;


	if (!(apic->lapic_flags & ACPI_MADT_ENABLED))
	if (!(apic->lapic_flags & ACPI_MADT_ENABLED))
		return 0;
		return -ENODEV;


	if (device_declaration && (apic->uid == acpi_id)) {
	if (device_declaration && (apic->uid == acpi_id)) {
		*apic_id = apic->local_apic_id;
		*apic_id = apic->local_apic_id;
		return 1;
		return 0;
	}
	}


	return 0;
	return -EINVAL;
}
}


static int map_lsapic_id(struct acpi_subtable_header *entry,
static int map_lsapic_id(struct acpi_subtable_header *entry,
@@ -78,16 +78,16 @@ static int map_lsapic_id(struct acpi_subtable_header *entry,
		(struct acpi_madt_local_sapic *)entry;
		(struct acpi_madt_local_sapic *)entry;


	if (!(lsapic->lapic_flags & ACPI_MADT_ENABLED))
	if (!(lsapic->lapic_flags & ACPI_MADT_ENABLED))
		return 0;
		return -ENODEV;


	if (device_declaration) {
	if (device_declaration) {
		if ((entry->length < 16) || (lsapic->uid != acpi_id))
		if ((entry->length < 16) || (lsapic->uid != acpi_id))
			return 0;
			return -EINVAL;
	} else if (lsapic->processor_id != acpi_id)
	} else if (lsapic->processor_id != acpi_id)
		return 0;
		return -EINVAL;


	*apic_id = (lsapic->id << 8) | lsapic->eid;
	*apic_id = (lsapic->id << 8) | lsapic->eid;
	return 1;
	return 0;
}
}


static int map_madt_entry(int type, u32 acpi_id)
static int map_madt_entry(int type, u32 acpi_id)
@@ -117,13 +117,13 @@ static int map_madt_entry(int type, u32 acpi_id)
		struct acpi_subtable_header *header =
		struct acpi_subtable_header *header =
			(struct acpi_subtable_header *)entry;
			(struct acpi_subtable_header *)entry;
		if (header->type == ACPI_MADT_TYPE_LOCAL_APIC) {
		if (header->type == ACPI_MADT_TYPE_LOCAL_APIC) {
			if (map_lapic_id(header, acpi_id, &apic_id))
			if (!map_lapic_id(header, acpi_id, &apic_id))
				break;
				break;
		} else if (header->type == ACPI_MADT_TYPE_LOCAL_X2APIC) {
		} else if (header->type == ACPI_MADT_TYPE_LOCAL_X2APIC) {
			if (map_x2apic_id(header, type, acpi_id, &apic_id))
			if (!map_x2apic_id(header, type, acpi_id, &apic_id))
				break;
				break;
		} else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) {
		} else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) {
			if (map_lsapic_id(header, type, acpi_id, &apic_id))
			if (!map_lsapic_id(header, type, acpi_id, &apic_id))
				break;
				break;
		}
		}
		entry += header->length;
		entry += header->length;