aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86
diff options
context:
space:
mode:
authorAzael Avalos <coproscefalo@gmail.com>2015-11-23 12:51:30 -0500
committerDarren Hart <dvhart@linux.intel.com>2016-01-19 18:49:21 -0500
commit65e3cf9c0f05877f76eefcb4f005944dc5379fbf (patch)
treea48e2553627b78a7d12d9e53e5b8da579e0ecaa7 /drivers/platform/x86
parent2fdde83443aa84b2a163dbcc5165f8139845b15e (diff)
toshiba_acpi: Fix keyboard backlight sysfs entries not being updated
Certain Toshiba models with the second generation keyboard backlight (type 2) do not generate the keyboard backlight changed event (0x92), and thus, the sysfs entries are never being updated. This patch adds a workquee and a global boolean variable to address the issue. For those models that do generate the event, the sysfs entries are being updated via the *notify function and the boolean is set to true to avoid a second call to update the entries. For those models that do not generate the event, the workquee is used to update the sysfs entries and also to emulate the event via netlink, to make userspace aware of such change. Signed-off-by: Azael Avalos <coproscefalo@gmail.com> Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Diffstat (limited to 'drivers/platform/x86')
-rw-r--r--drivers/platform/x86/toshiba_acpi.c47
1 files changed, 43 insertions, 4 deletions
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 5378e261e2dd..73833079bac8 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -208,6 +208,7 @@ struct toshiba_acpi_dev {
208 unsigned int sysfs_created:1; 208 unsigned int sysfs_created:1;
209 unsigned int special_functions; 209 unsigned int special_functions;
210 210
211 bool kbd_event_generated;
211 bool kbd_led_registered; 212 bool kbd_led_registered;
212 bool illumination_led_registered; 213 bool illumination_led_registered;
213 bool eco_led_registered; 214 bool eco_led_registered;
@@ -525,6 +526,7 @@ static void toshiba_kbd_illum_available(struct toshiba_acpi_dev *dev)
525 526
526 dev->kbd_illum_supported = 0; 527 dev->kbd_illum_supported = 0;
527 dev->kbd_led_registered = false; 528 dev->kbd_led_registered = false;
529 dev->kbd_event_generated = false;
528 530
529 if (!sci_open(dev)) 531 if (!sci_open(dev))
530 return; 532 return;
@@ -1642,6 +1644,11 @@ static const struct backlight_ops toshiba_backlight_data = {
1642 .update_status = set_lcd_status, 1644 .update_status = set_lcd_status,
1643}; 1645};
1644 1646
1647/* Keyboard backlight work */
1648static void toshiba_acpi_kbd_bl_work(struct work_struct *work);
1649
1650static DECLARE_WORK(kbd_bl_work, toshiba_acpi_kbd_bl_work);
1651
1645/* 1652/*
1646 * Sysfs files 1653 * Sysfs files
1647 */ 1654 */
@@ -1741,6 +1748,24 @@ static ssize_t kbd_backlight_mode_store(struct device *dev,
1741 return ret; 1748 return ret;
1742 1749
1743 toshiba->kbd_mode = mode; 1750 toshiba->kbd_mode = mode;
1751
1752 /*
1753 * Some laptop models with the second generation backlit
1754 * keyboard (type 2) do not generate the keyboard backlight
1755 * changed event (0x92), and thus, the driver will never update
1756 * the sysfs entries.
1757 *
1758 * The event is generated right when changing the keyboard
1759 * backlight mode and the *notify function will set the
1760 * kbd_event_generated to true.
1761 *
1762 * In case the event is not generated, schedule the keyboard
1763 * backlight work to update the sysfs entries and emulate the
1764 * event via genetlink.
1765 */
1766 if (toshiba->kbd_type == 2 &&
1767 !toshiba_acpi->kbd_event_generated)
1768 schedule_work(&kbd_bl_work);
1744 } 1769 }
1745 1770
1746 return count; 1771 return count;
@@ -2273,6 +2298,21 @@ static struct attribute_group toshiba_attr_group = {
2273 .attrs = toshiba_attributes, 2298 .attrs = toshiba_attributes,
2274}; 2299};
2275 2300
2301static void toshiba_acpi_kbd_bl_work(struct work_struct *work)
2302{
2303 struct acpi_device *acpi_dev = toshiba_acpi->acpi_dev;
2304
2305 /* Update the sysfs entries */
2306 if (sysfs_update_group(&acpi_dev->dev.kobj,
2307 &toshiba_attr_group))
2308 pr_err("Unable to update sysfs entries\n");
2309
2310 /* Emulate the keyboard backlight event */
2311 acpi_bus_generate_netlink_event(acpi_dev->pnp.device_class,
2312 dev_name(&acpi_dev->dev),
2313 0x92, 0);
2314}
2315
2276/* 2316/*
2277 * Misc device 2317 * Misc device
2278 */ 2318 */
@@ -2947,7 +2987,6 @@ error:
2947static void toshiba_acpi_notify(struct acpi_device *acpi_dev, u32 event) 2987static void toshiba_acpi_notify(struct acpi_device *acpi_dev, u32 event)
2948{ 2988{
2949 struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev); 2989 struct toshiba_acpi_dev *dev = acpi_driver_data(acpi_dev);
2950 int ret;
2951 2990
2952 switch (event) { 2991 switch (event) {
2953 case 0x80: /* Hotkeys and some system events */ 2992 case 0x80: /* Hotkeys and some system events */
@@ -2977,10 +3016,10 @@ static void toshiba_acpi_notify(struct acpi_device *acpi_dev, u32 event)
2977 pr_info("SATA power event received %x\n", event); 3016 pr_info("SATA power event received %x\n", event);
2978 break; 3017 break;
2979 case 0x92: /* Keyboard backlight mode changed */ 3018 case 0x92: /* Keyboard backlight mode changed */
3019 toshiba_acpi->kbd_event_generated = true;
2980 /* Update sysfs entries */ 3020 /* Update sysfs entries */
2981 ret = sysfs_update_group(&acpi_dev->dev.kobj, 3021 if (sysfs_update_group(&acpi_dev->dev.kobj,
2982 &toshiba_attr_group); 3022 &toshiba_attr_group))
2983 if (ret)
2984 pr_err("Unable to update sysfs entries\n"); 3023 pr_err("Unable to update sysfs entries\n");
2985 break; 3024 break;
2986 case 0x85: /* Unknown */ 3025 case 0x85: /* Unknown */