Beispiel #1
0
static acpi_status acpi_run_hpx(struct pci_dev *dev, acpi_handle handle,
				const struct hotplug_program_ops *hp_ops)
{
	acpi_status status;
	struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
	union acpi_object *package, *record, *fields;
	struct hpp_type0 hpx0;
	struct hpp_type1 hpx1;
	struct hpp_type2 hpx2;
	u32 type;
	int i;

	status = acpi_evaluate_object(handle, "_HPX", NULL, &buffer);
	if (ACPI_FAILURE(status))
		return status;

	package = (union acpi_object *)buffer.pointer;
	if (package->type != ACPI_TYPE_PACKAGE) {
		status = AE_ERROR;
		goto exit;
	}

	for (i = 0; i < package->package.count; i++) {
		record = &package->package.elements[i];
		if (record->type != ACPI_TYPE_PACKAGE) {
			status = AE_ERROR;
			goto exit;
		}

		fields = record->package.elements;
		if (fields[0].type != ACPI_TYPE_INTEGER ||
		    fields[1].type != ACPI_TYPE_INTEGER) {
			status = AE_ERROR;
			goto exit;
		}

		type = fields[0].integer.value;
		switch (type) {
		case 0:
			memset(&hpx0, 0, sizeof(hpx0));
			status = decode_type0_hpx_record(record, &hpx0);
			if (ACPI_FAILURE(status))
				goto exit;
			hp_ops->program_type0(dev, &hpx0);
			break;
		case 1:
			memset(&hpx1, 0, sizeof(hpx1));
			status = decode_type1_hpx_record(record, &hpx1);
			if (ACPI_FAILURE(status))
				goto exit;
			hp_ops->program_type1(dev, &hpx1);
			break;
		case 2:
			memset(&hpx2, 0, sizeof(hpx2));
			status = decode_type2_hpx_record(record, &hpx2);
			if (ACPI_FAILURE(status))
				goto exit;
			hp_ops->program_type2(dev, &hpx2);
			break;
		case 3:
			status = program_type3_hpx_record(dev, record, hp_ops);
			if (ACPI_FAILURE(status))
				goto exit;
			break;
		default:
			pr_err("%s: Type %d record not supported\n",
			       __func__, type);
			status = AE_ERROR;
			goto exit;
		}
	}
 exit:
	kfree(buffer.pointer);
	return status;
}
Beispiel #2
0
static acpi_status
acpi_run_hpx(acpi_handle handle, struct hotplug_params *hpx)
{
    acpi_status status;
    struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
    union acpi_object *package, *record, *fields;
    u32 type;
    int i;

    /* Clear the return buffer with zeros */
    memset(hpx, 0, sizeof(struct hotplug_params));

    status = acpi_evaluate_object(handle, "_HPX", NULL, &buffer);
    if (ACPI_FAILURE(status))
        return status;

    package = (union acpi_object *)buffer.pointer;
    if (package->type != ACPI_TYPE_PACKAGE) {
        status = AE_ERROR;
        goto exit;
    }

    for (i = 0; i < package->package.count; i++) {
        record = &package->package.elements[i];
        if (record->type != ACPI_TYPE_PACKAGE) {
            status = AE_ERROR;
            goto exit;
        }

        fields = record->package.elements;
        if (fields[0].type != ACPI_TYPE_INTEGER ||
            fields[1].type != ACPI_TYPE_INTEGER) {
            status = AE_ERROR;
            goto exit;
        }

        type = fields[0].integer.value;
        switch (type) {
        case 0:
            status = decode_type0_hpx_record(record, hpx);
            if (ACPI_FAILURE(status))
                goto exit;
            break;
        case 1:
            status = decode_type1_hpx_record(record, hpx);
            if (ACPI_FAILURE(status))
                goto exit;
            break;
        case 2:
            status = decode_type2_hpx_record(record, hpx);
            if (ACPI_FAILURE(status))
                goto exit;
            break;
        default:
            printk(KERN_ERR "%s: Type %d record not supported\n",
                   __func__, type);
            status = AE_ERROR;
            goto exit;
        }
    }
 exit:
    kfree(buffer.pointer);
    return status;
}