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

Commit 5f765b8d authored by Len Brown's avatar Len Brown
Browse files

Pull acpi_device_handle_cleanup into release branch

parents b197ba3c d07a8577
Loading
Loading
Loading
Loading
+6 −8
Original line number Original line Diff line number Diff line
@@ -65,7 +65,7 @@ static struct acpi_driver acpi_ac_driver = {
};
};


struct acpi_ac {
struct acpi_ac {
	acpi_handle handle;
	struct acpi_device * device;
	unsigned long state;
	unsigned long state;
};
};


@@ -88,7 +88,7 @@ static int acpi_ac_get_state(struct acpi_ac *ac)
	if (!ac)
	if (!ac)
		return -EINVAL;
		return -EINVAL;


	status = acpi_evaluate_integer(ac->handle, "_PSR", NULL, &ac->state);
	status = acpi_evaluate_integer(ac->device->handle, "_PSR", NULL, &ac->state);
	if (ACPI_FAILURE(status)) {
	if (ACPI_FAILURE(status)) {
		ACPI_EXCEPTION((AE_INFO, status, "Error reading AC Adapter state"));
		ACPI_EXCEPTION((AE_INFO, status, "Error reading AC Adapter state"));
		ac->state = ACPI_AC_STATUS_UNKNOWN;
		ac->state = ACPI_AC_STATUS_UNKNOWN;
@@ -191,9 +191,7 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
	if (!ac)
	if (!ac)
		return;
		return;


	if (acpi_bus_get_device(ac->handle, &device))
	device = ac->device;
		return;

	switch (event) {
	switch (event) {
	case ACPI_AC_NOTIFY_STATUS:
	case ACPI_AC_NOTIFY_STATUS:
		acpi_ac_get_state(ac);
		acpi_ac_get_state(ac);
@@ -223,7 +221,7 @@ static int acpi_ac_add(struct acpi_device *device)
		return -ENOMEM;
		return -ENOMEM;
	memset(ac, 0, sizeof(struct acpi_ac));
	memset(ac, 0, sizeof(struct acpi_ac));


	ac->handle = device->handle;
	ac->device = device;
	strcpy(acpi_device_name(device), ACPI_AC_DEVICE_NAME);
	strcpy(acpi_device_name(device), ACPI_AC_DEVICE_NAME);
	strcpy(acpi_device_class(device), ACPI_AC_CLASS);
	strcpy(acpi_device_class(device), ACPI_AC_CLASS);
	acpi_driver_data(device) = ac;
	acpi_driver_data(device) = ac;
@@ -236,7 +234,7 @@ static int acpi_ac_add(struct acpi_device *device)
	if (result)
	if (result)
		goto end;
		goto end;


	status = acpi_install_notify_handler(ac->handle,
	status = acpi_install_notify_handler(device->handle,
					     ACPI_DEVICE_NOTIFY, acpi_ac_notify,
					     ACPI_DEVICE_NOTIFY, acpi_ac_notify,
					     ac);
					     ac);
	if (ACPI_FAILURE(status)) {
	if (ACPI_FAILURE(status)) {
@@ -268,7 +266,7 @@ static int acpi_ac_remove(struct acpi_device *device, int type)


	ac = (struct acpi_ac *)acpi_driver_data(device);
	ac = (struct acpi_ac *)acpi_driver_data(device);


	status = acpi_remove_notify_handler(ac->handle,
	status = acpi_remove_notify_handler(device->handle,
					    ACPI_DEVICE_NOTIFY, acpi_ac_notify);
					    ACPI_DEVICE_NOTIFY, acpi_ac_notify);


	acpi_ac_remove_fs(device);
	acpi_ac_remove_fs(device);
+7 −7
Original line number Original line Diff line number Diff line
@@ -80,7 +80,7 @@ struct acpi_memory_info {
};
};


struct acpi_memory_device {
struct acpi_memory_device {
	acpi_handle handle;
	struct acpi_device * device;
	unsigned int state;	/* State of the memory device */
	unsigned int state;	/* State of the memory device */
	struct list_head res_list;
	struct list_head res_list;
};
};
@@ -129,7 +129,7 @@ acpi_memory_get_device_resources(struct acpi_memory_device *mem_device)
	struct acpi_memory_info *info, *n;
	struct acpi_memory_info *info, *n;




	status = acpi_walk_resources(mem_device->handle, METHOD_NAME__CRS,
	status = acpi_walk_resources(mem_device->device->handle, METHOD_NAME__CRS,
				     acpi_memory_get_resource, mem_device);
				     acpi_memory_get_resource, mem_device);
	if (ACPI_FAILURE(status)) {
	if (ACPI_FAILURE(status)) {
		list_for_each_entry_safe(info, n, &mem_device->res_list, list)
		list_for_each_entry_safe(info, n, &mem_device->res_list, list)
@@ -192,7 +192,7 @@ static int acpi_memory_check_device(struct acpi_memory_device *mem_device)




	/* Get device present/absent information from the _STA */
	/* Get device present/absent information from the _STA */
	if (ACPI_FAILURE(acpi_evaluate_integer(mem_device->handle, "_STA",
	if (ACPI_FAILURE(acpi_evaluate_integer(mem_device->device->handle, "_STA",
					       NULL, &current_status)))
					       NULL, &current_status)))
		return -ENODEV;
		return -ENODEV;
	/*
	/*
@@ -222,7 +222,7 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
		return result;
		return result;
	}
	}


	node = acpi_get_node(mem_device->handle);
	node = acpi_get_node(mem_device->device->handle);
	/*
	/*
	 * Tell the VM there is more memory here...
	 * Tell the VM there is more memory here...
	 * Note: Assume that this function returns zero on success
	 * Note: Assume that this function returns zero on success
@@ -269,7 +269,7 @@ static int acpi_memory_powerdown_device(struct acpi_memory_device *mem_device)
	arg_list.pointer = &arg;
	arg_list.pointer = &arg;
	arg.type = ACPI_TYPE_INTEGER;
	arg.type = ACPI_TYPE_INTEGER;
	arg.integer.value = 1;
	arg.integer.value = 1;
	status = acpi_evaluate_object(mem_device->handle,
	status = acpi_evaluate_object(mem_device->device->handle,
				      "_EJ0", &arg_list, NULL);
				      "_EJ0", &arg_list, NULL);
	/* Return on _EJ0 failure */
	/* Return on _EJ0 failure */
	if (ACPI_FAILURE(status)) {
	if (ACPI_FAILURE(status)) {
@@ -278,7 +278,7 @@ static int acpi_memory_powerdown_device(struct acpi_memory_device *mem_device)
	}
	}


	/* Evalute _STA to check if the device is disabled */
	/* Evalute _STA to check if the device is disabled */
	status = acpi_evaluate_integer(mem_device->handle, "_STA",
	status = acpi_evaluate_integer(mem_device->device->handle, "_STA",
				       NULL, &current_status);
				       NULL, &current_status);
	if (ACPI_FAILURE(status))
	if (ACPI_FAILURE(status))
		return -ENODEV;
		return -ENODEV;
@@ -398,7 +398,7 @@ static int acpi_memory_device_add(struct acpi_device *device)
	memset(mem_device, 0, sizeof(struct acpi_memory_device));
	memset(mem_device, 0, sizeof(struct acpi_memory_device));


	INIT_LIST_HEAD(&mem_device->res_list);
	INIT_LIST_HEAD(&mem_device->res_list);
	mem_device->handle = device->handle;
	mem_device->device = device;
	sprintf(acpi_device_name(device), "%s", ACPI_MEMORY_DEVICE_NAME);
	sprintf(acpi_device_name(device), "%s", ACPI_MEMORY_DEVICE_NAME);
	sprintf(acpi_device_class(device), "%s", ACPI_MEMORY_DEVICE_CLASS);
	sprintf(acpi_device_class(device), "%s", ACPI_MEMORY_DEVICE_CLASS);
	acpi_driver_data(device) = mem_device;
	acpi_driver_data(device) = mem_device;
+10 −13
Original line number Original line Diff line number Diff line
@@ -108,7 +108,7 @@ struct acpi_battery_trips {
};
};


struct acpi_battery {
struct acpi_battery {
	acpi_handle handle;
	struct acpi_device * device;
	struct acpi_battery_flags flags;
	struct acpi_battery_flags flags;
	struct acpi_battery_trips trips;
	struct acpi_battery_trips trips;
	unsigned long alarm;
	unsigned long alarm;
@@ -138,7 +138,7 @@ acpi_battery_get_info(struct acpi_battery *battery,


	/* Evalute _BIF */
	/* Evalute _BIF */


	status = acpi_evaluate_object(battery->handle, "_BIF", NULL, &buffer);
	status = acpi_evaluate_object(battery->device->handle, "_BIF", NULL, &buffer);
	if (ACPI_FAILURE(status)) {
	if (ACPI_FAILURE(status)) {
		ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF"));
		ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF"));
		return -ENODEV;
		return -ENODEV;
@@ -198,7 +198,7 @@ acpi_battery_get_status(struct acpi_battery *battery,


	/* Evalute _BST */
	/* Evalute _BST */


	status = acpi_evaluate_object(battery->handle, "_BST", NULL, &buffer);
	status = acpi_evaluate_object(battery->device->handle, "_BST", NULL, &buffer);
	if (ACPI_FAILURE(status)) {
	if (ACPI_FAILURE(status)) {
		ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BST"));
		ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BST"));
		return -ENODEV;
		return -ENODEV;
@@ -255,7 +255,7 @@ acpi_battery_set_alarm(struct acpi_battery *battery, unsigned long alarm)


	arg0.integer.value = alarm;
	arg0.integer.value = alarm;


	status = acpi_evaluate_object(battery->handle, "_BTP", &arg_list, NULL);
	status = acpi_evaluate_object(battery->device->handle, "_BTP", &arg_list, NULL);
	if (ACPI_FAILURE(status))
	if (ACPI_FAILURE(status))
		return -ENODEV;
		return -ENODEV;


@@ -278,9 +278,7 @@ static int acpi_battery_check(struct acpi_battery *battery)
	if (!battery)
	if (!battery)
		return -EINVAL;
		return -EINVAL;


	result = acpi_bus_get_device(battery->handle, &device);
	device = battery->device;
	if (result)
		return result;


	result = acpi_bus_get_status(device);
	result = acpi_bus_get_status(device);
	if (result)
	if (result)
@@ -305,7 +303,7 @@ static int acpi_battery_check(struct acpi_battery *battery)


		/* See if alarms are supported, and if so, set default */
		/* See if alarms are supported, and if so, set default */


		status = acpi_get_handle(battery->handle, "_BTP", &handle);
		status = acpi_get_handle(battery->device->handle, "_BTP", &handle);
		if (ACPI_SUCCESS(status)) {
		if (ACPI_SUCCESS(status)) {
			battery->flags.alarm = 1;
			battery->flags.alarm = 1;
			acpi_battery_set_alarm(battery, battery->trips.warning);
			acpi_battery_set_alarm(battery, battery->trips.warning);
@@ -662,8 +660,7 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
	if (!battery)
	if (!battery)
		return;
		return;


	if (acpi_bus_get_device(handle, &device))
	device = battery->device;
		return;


	switch (event) {
	switch (event) {
	case ACPI_BATTERY_NOTIFY_STATUS:
	case ACPI_BATTERY_NOTIFY_STATUS:
@@ -695,7 +692,7 @@ static int acpi_battery_add(struct acpi_device *device)
		return -ENOMEM;
		return -ENOMEM;
	memset(battery, 0, sizeof(struct acpi_battery));
	memset(battery, 0, sizeof(struct acpi_battery));


	battery->handle = device->handle;
	battery->device = device;
	strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
	strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
	strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
	strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
	acpi_driver_data(device) = battery;
	acpi_driver_data(device) = battery;
@@ -708,7 +705,7 @@ static int acpi_battery_add(struct acpi_device *device)
	if (result)
	if (result)
		goto end;
		goto end;


	status = acpi_install_notify_handler(battery->handle,
	status = acpi_install_notify_handler(device->handle,
					     ACPI_DEVICE_NOTIFY,
					     ACPI_DEVICE_NOTIFY,
					     acpi_battery_notify, battery);
					     acpi_battery_notify, battery);
	if (ACPI_FAILURE(status)) {
	if (ACPI_FAILURE(status)) {
@@ -740,7 +737,7 @@ static int acpi_battery_remove(struct acpi_device *device, int type)


	battery = (struct acpi_battery *)acpi_driver_data(device);
	battery = (struct acpi_battery *)acpi_driver_data(device);


	status = acpi_remove_notify_handler(battery->handle,
	status = acpi_remove_notify_handler(device->handle,
					    ACPI_DEVICE_NOTIFY,
					    ACPI_DEVICE_NOTIFY,
					    acpi_battery_notify);
					    acpi_battery_notify);


+4 −6
Original line number Original line Diff line number Diff line
@@ -82,7 +82,6 @@ static struct acpi_driver acpi_button_driver = {
};
};


struct acpi_button {
struct acpi_button {
	acpi_handle handle;
	struct acpi_device *device;	/* Fixed button kludge */
	struct acpi_device *device;	/* Fixed button kludge */
	u8 type;
	u8 type;
	unsigned long pushed;
	unsigned long pushed;
@@ -137,7 +136,7 @@ static int acpi_button_state_seq_show(struct seq_file *seq, void *offset)
	if (!button || !button->device)
	if (!button || !button->device)
		return 0;
		return 0;


	status = acpi_evaluate_integer(button->handle, "_LID", NULL, &state);
	status = acpi_evaluate_integer(button->device->handle, "_LID", NULL, &state);
	if (ACPI_FAILURE(status)) {
	if (ACPI_FAILURE(status)) {
		seq_printf(seq, "state:      unsupported\n");
		seq_printf(seq, "state:      unsupported\n");
	} else {
	} else {
@@ -282,7 +281,7 @@ static acpi_status acpi_button_notify_fixed(void *data)
	if (!button)
	if (!button)
		return AE_BAD_PARAMETER;
		return AE_BAD_PARAMETER;


	acpi_button_notify(button->handle, ACPI_BUTTON_NOTIFY_STATUS, button);
	acpi_button_notify(button->device->handle, ACPI_BUTTON_NOTIFY_STATUS, button);


	return AE_OK;
	return AE_OK;
}
}
@@ -303,7 +302,6 @@ static int acpi_button_add(struct acpi_device *device)
	memset(button, 0, sizeof(struct acpi_button));
	memset(button, 0, sizeof(struct acpi_button));


	button->device = device;
	button->device = device;
	button->handle = device->handle;
	acpi_driver_data(device) = button;
	acpi_driver_data(device) = button;


	/*
	/*
@@ -362,7 +360,7 @@ static int acpi_button_add(struct acpi_device *device)
						     button);
						     button);
		break;
		break;
	default:
	default:
		status = acpi_install_notify_handler(button->handle,
		status = acpi_install_notify_handler(device->handle,
						     ACPI_DEVICE_NOTIFY,
						     ACPI_DEVICE_NOTIFY,
						     acpi_button_notify,
						     acpi_button_notify,
						     button);
						     button);
@@ -420,7 +418,7 @@ static int acpi_button_remove(struct acpi_device *device, int type)
						    acpi_button_notify_fixed);
						    acpi_button_notify_fixed);
		break;
		break;
	default:
	default:
		status = acpi_remove_notify_handler(button->handle,
		status = acpi_remove_notify_handler(device->handle,
						    ACPI_DEVICE_NOTIFY,
						    ACPI_DEVICE_NOTIFY,
						    acpi_button_notify);
						    acpi_button_notify);
		break;
		break;
+5 −5
Original line number Original line Diff line number Diff line
@@ -64,7 +64,7 @@ static struct acpi_driver acpi_fan_driver = {
};
};


struct acpi_fan {
struct acpi_fan {
	acpi_handle handle;
	struct acpi_device * device;
};
};


/* --------------------------------------------------------------------------
/* --------------------------------------------------------------------------
@@ -80,7 +80,7 @@ static int acpi_fan_read_state(struct seq_file *seq, void *offset)




	if (fan) {
	if (fan) {
		if (acpi_bus_get_power(fan->handle, &state))
		if (acpi_bus_get_power(fan->device->handle, &state))
			seq_printf(seq, "status:                  ERROR\n");
			seq_printf(seq, "status:                  ERROR\n");
		else
		else
			seq_printf(seq, "status:                  %s\n",
			seq_printf(seq, "status:                  %s\n",
@@ -112,7 +112,7 @@ acpi_fan_write_state(struct file *file, const char __user * buffer,


	state_string[count] = '\0';
	state_string[count] = '\0';


	result = acpi_bus_set_power(fan->handle,
	result = acpi_bus_set_power(fan->device->handle,
				    simple_strtoul(state_string, NULL, 0));
				    simple_strtoul(state_string, NULL, 0));
	if (result)
	if (result)
		return result;
		return result;
@@ -191,12 +191,12 @@ static int acpi_fan_add(struct acpi_device *device)
		return -ENOMEM;
		return -ENOMEM;
	memset(fan, 0, sizeof(struct acpi_fan));
	memset(fan, 0, sizeof(struct acpi_fan));


	fan->handle = device->handle;
	fan->device = device;
	strcpy(acpi_device_name(device), "Fan");
	strcpy(acpi_device_name(device), "Fan");
	strcpy(acpi_device_class(device), ACPI_FAN_CLASS);
	strcpy(acpi_device_class(device), ACPI_FAN_CLASS);
	acpi_driver_data(device) = fan;
	acpi_driver_data(device) = fan;


	result = acpi_bus_get_power(fan->handle, &state);
	result = acpi_bus_get_power(device->handle, &state);
	if (result) {
	if (result) {
		printk(KERN_ERR PREFIX "Reading power state\n");
		printk(KERN_ERR PREFIX "Reading power state\n");
		goto end;
		goto end;
Loading