platform/x86: lenovo-yogabook: Stop checking adev->power.state

lenovo-yogabook-wmi: controls the power-state itself and stores
this in data->flags so there is no need to poke inside ACPI device
internals.

This is a preparation patch for making lenovo-yogabook-wmi also work
on the Android version of the Yoga Book 1 which does not have a WMI
interface to deal with toggling the keyboard half between
touch-keyboard and wacom-digitizer mode.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20230430165807.472798-12-hdegoede@redhat.com
This commit is contained in:
Hans de Goede 2023-04-30 18:57:59 +02:00
parent 01d126ff33
commit 9acf236e95

View file

@ -50,13 +50,11 @@ static int yogabook_wmi_set_kbd_backlight(struct yogabook_wmi *data,
union acpi_object param;
acpi_status status;
if (data->kbd_adev->power.state != ACPI_STATE_D0) {
dev_warn(data->dev, "keyboard touchscreen not in D0, cannot set brightness\n");
return -ENXIO;
}
dev_dbg(data->dev, "Set KBLC level to %u\n", level);
/* Ensure keyboard touchpad is on before we call KBLC() */
acpi_device_set_power(data->kbd_adev, ACPI_STATE_D0);
input.count = 1;
input.pointer = &param;
@ -181,7 +179,7 @@ static int kbd_brightness_set(struct led_classdev *cdev,
data->brightness = value;
if (data->kbd_adev->power.state != ACPI_STATE_D0)
if (!test_bit(YB_KBD_IS_ON, &data->flags))
return 0;
return yogabook_wmi_set_kbd_backlight(data, data->brightness);
@ -353,11 +351,8 @@ static int yogabook_resume(struct device *dev)
{
struct yogabook_wmi *data = dev_get_drvdata(dev);
if (test_bit(YB_KBD_IS_ON, &data->flags)) {
/* Ensure keyboard touchpad is on before we call KBLC() */
acpi_device_set_power(data->kbd_adev, ACPI_STATE_D0);
if (test_bit(YB_KBD_IS_ON, &data->flags))
yogabook_wmi_set_kbd_backlight(data, data->brightness);
}
clear_bit(YB_SUSPENDED, &data->flags);