Commit 00856351 authored by Kenneth Chan's avatar Kenneth Chan Committed by Hans de Goede

platform/x86: panasonic-laptop: Fix sticky key init bug

The return value of the sticky key on some models (e.g. CF-W5) do not
reflect its state. How to retrieve its state from firmware is unknown.
The safest bet is to reset it at module init and store its state in
pcc struct.
Signed-off-by: default avatarKenneth Chan <kenneth.t.chan@gmail.com>
Link: https://lore.kernel.org/r/20200821181433.17653-6-kenneth.t.chan@gmail.comSigned-off-by: default avatarHans de Goede <hdegoede@redhat.com>
parent 80373ad0
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
* *
* ChangeLog: * ChangeLog:
* Aug.18, 2020 Kenneth Chan <kenneth.t.chan@gmail.com> * Aug.18, 2020 Kenneth Chan <kenneth.t.chan@gmail.com>
* fix sticky_key init bug
* fix naming of platform files for consistency with other * fix naming of platform files for consistency with other
* modules * modules
* split MODULE_AUTHOR() by one author per macro call * split MODULE_AUTHOR() by one author per macro call
...@@ -218,7 +219,7 @@ static const struct key_entry panasonic_keymap[] = { ...@@ -218,7 +219,7 @@ static const struct key_entry panasonic_keymap[] = {
struct pcc_acpi { struct pcc_acpi {
acpi_handle handle; acpi_handle handle;
unsigned long num_sifr; unsigned long num_sifr;
int sticky_mode; int sticky_key;
u32 *sinf; u32 *sinf;
struct acpi_device *device; struct acpi_device *device;
struct input_dev *input_dev; struct input_dev *input_dev;
...@@ -491,7 +492,7 @@ static ssize_t sticky_key_show(struct device *dev, struct device_attribute *attr ...@@ -491,7 +492,7 @@ static ssize_t sticky_key_show(struct device *dev, struct device_attribute *attr
if (!acpi_pcc_retrieve_biosdata(pcc)) if (!acpi_pcc_retrieve_biosdata(pcc))
return -EIO; return -EIO;
return snprintf(buf, PAGE_SIZE, "%u\n", pcc->sinf[SINF_STICKY_KEY]); return snprintf(buf, PAGE_SIZE, "%u\n", pcc->sticky_key);
} }
static ssize_t sticky_key_store(struct device *dev, struct device_attribute *attr, static ssize_t sticky_key_store(struct device *dev, struct device_attribute *attr,
...@@ -499,12 +500,14 @@ static ssize_t sticky_key_store(struct device *dev, struct device_attribute *att ...@@ -499,12 +500,14 @@ static ssize_t sticky_key_store(struct device *dev, struct device_attribute *att
{ {
struct acpi_device *acpi = to_acpi_device(dev); struct acpi_device *acpi = to_acpi_device(dev);
struct pcc_acpi *pcc = acpi_driver_data(acpi); struct pcc_acpi *pcc = acpi_driver_data(acpi);
int val; int err, val;
if (count && sscanf(buf, "%i", &val) == 1 && err = kstrtoint(buf, 0, &val);
(val == 0 || val == 1)) { if (err)
return err;
if (val == 0 || val == 1) {
acpi_pcc_write_sset(pcc, SINF_STICKY_KEY, val); acpi_pcc_write_sset(pcc, SINF_STICKY_KEY, val);
pcc->sticky_mode = val; pcc->sticky_key = val;
} }
return count; return count;
...@@ -687,7 +690,9 @@ static int acpi_pcc_hotkey_resume(struct device *dev) ...@@ -687,7 +690,9 @@ static int acpi_pcc_hotkey_resume(struct device *dev)
if (!pcc) if (!pcc)
return -EINVAL; return -EINVAL;
return acpi_pcc_write_sset(pcc, SINF_STICKY_KEY, pcc->sticky_mode); acpi_pcc_write_sset(pcc, SINF_STICKY_KEY, pcc->sticky_key);
return 0;
} }
#endif #endif
...@@ -751,8 +756,9 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device) ...@@ -751,8 +756,9 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device)
/* read the initial brightness setting from the hardware */ /* read the initial brightness setting from the hardware */
pcc->backlight->props.brightness = pcc->sinf[SINF_AC_CUR_BRIGHT]; pcc->backlight->props.brightness = pcc->sinf[SINF_AC_CUR_BRIGHT];
/* read the initial sticky key mode from the hardware */ /* Reset initial sticky key mode since the hardware register state is not consistent */
pcc->sticky_mode = pcc->sinf[SINF_STICKY_KEY]; acpi_pcc_write_sset(pcc, SINF_STICKY_KEY, 0);
pcc->sticky_key = 0;
/* add sysfs attributes */ /* add sysfs attributes */
result = sysfs_create_group(&device->dev.kobj, &pcc_attr_group); result = sysfs_create_group(&device->dev.kobj, &pcc_attr_group);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment