*
* ChangeLog:
* Aug.18, 2020 Kenneth Chan <kenneth.t.chan@gmail.com>
+ * fix sticky_key init bug
* fix naming of platform files for consistency with other
* modules
* split MODULE_AUTHOR() by one author per macro call
struct pcc_acpi {
acpi_handle handle;
unsigned long num_sifr;
- int sticky_mode;
+ int sticky_key;
u32 *sinf;
struct acpi_device *device;
struct input_dev *input_dev;
if (!acpi_pcc_retrieve_biosdata(pcc))
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,
{
struct acpi_device *acpi = to_acpi_device(dev);
struct pcc_acpi *pcc = acpi_driver_data(acpi);
- int val;
+ int err, val;
- if (count && sscanf(buf, "%i", &val) == 1 &&
- (val == 0 || val == 1)) {
+ err = kstrtoint(buf, 0, &val);
+ if (err)
+ return err;
+ if (val == 0 || val == 1) {
acpi_pcc_write_sset(pcc, SINF_STICKY_KEY, val);
- pcc->sticky_mode = val;
+ pcc->sticky_key = val;
}
return count;
if (!pcc)
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
/* read the initial brightness setting from the hardware */
pcc->backlight->props.brightness = pcc->sinf[SINF_AC_CUR_BRIGHT];
- /* read the initial sticky key mode from the hardware */
- pcc->sticky_mode = pcc->sinf[SINF_STICKY_KEY];
+ /* Reset initial sticky key mode since the hardware register state is not consistent */
+ acpi_pcc_write_sset(pcc, SINF_STICKY_KEY, 0);
+ pcc->sticky_key = 0;
/* add sysfs attributes */
result = sysfs_create_group(&device->dev.kobj, &pcc_attr_group);