Cleanup
This commit is contained in:
parent
a5e9fc20c0
commit
4c070de0c8
2
dmi.c
2
dmi.c
|
|
@ -38,7 +38,7 @@ static int __init s76_dmi_matched(const struct dmi_system_id *id)
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct dmi_system_id s76_dmi_table[] __initdata = {
|
static struct dmi_system_id s76_dmi_table[] __initdata = {
|
||||||
DMI_TABLE("bonw13", kb_full_color_ops),
|
DMI_TABLE("bonw13", kb_full_color_with_extra_ops),
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
2
fan.c
2
fan.c
|
|
@ -19,6 +19,8 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//#define EXPERIMENTAL
|
||||||
|
|
||||||
#if S76_HAS_HWMON
|
#if S76_HAS_HWMON
|
||||||
struct s76_hwmon {
|
struct s76_hwmon {
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
|
|
|
||||||
84
input.c
84
input.c
|
|
@ -55,53 +55,7 @@ MODULE_PARM_DESC(poll_freq, "Set polling frequency");
|
||||||
|
|
||||||
static struct task_struct *s76_input_polling_task;
|
static struct task_struct *s76_input_polling_task;
|
||||||
|
|
||||||
static int s76_input_polling_thread(void *data) {
|
static void s76_input_airplane_key(void) {
|
||||||
S76_INFO("Polling thread started (PID: %i), polling at %i Hz\n",
|
|
||||||
current->pid, param_poll_freq);
|
|
||||||
|
|
||||||
while (!kthread_should_stop()) {
|
|
||||||
|
|
||||||
u8 byte;
|
|
||||||
|
|
||||||
ec_read(0xDB, &byte);
|
|
||||||
if (byte & 0x40) {
|
|
||||||
ec_write(0xDB, byte & ~0x40);
|
|
||||||
|
|
||||||
S76_INFO("Airplane-Mode Hotkey pressed (EC)\n");
|
|
||||||
|
|
||||||
mutex_lock(&s76_input_report_mutex);
|
|
||||||
|
|
||||||
input_report_key(s76_input_device, AIRPLANE_KEY, 1);
|
|
||||||
input_sync(s76_input_device);
|
|
||||||
|
|
||||||
input_report_key(s76_input_device, AIRPLANE_KEY, 0);
|
|
||||||
input_sync(s76_input_device);
|
|
||||||
|
|
||||||
S76_INFO("Led status: %d",
|
|
||||||
airplane_led_get(&airplane_led));
|
|
||||||
|
|
||||||
airplane_led_set(&airplane_led,
|
|
||||||
(airplane_led_get(&airplane_led) ? 0 : 1));
|
|
||||||
|
|
||||||
mutex_unlock(&s76_input_report_mutex);
|
|
||||||
}
|
|
||||||
msleep_interruptible(1000 / param_poll_freq);
|
|
||||||
}
|
|
||||||
|
|
||||||
S76_INFO("Polling thread exiting\n");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void airplane_wmi(void) {
|
|
||||||
S76_INFO("Airplane-Mode Hotkey pressed (WMI)\n");
|
|
||||||
|
|
||||||
if (s76_input_polling_task) {
|
|
||||||
S76_INFO("Stopping polling thread\n");
|
|
||||||
kthread_stop(s76_input_polling_task);
|
|
||||||
s76_input_polling_task = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
mutex_lock(&s76_input_report_mutex);
|
mutex_lock(&s76_input_report_mutex);
|
||||||
|
|
||||||
input_report_key(s76_input_device, AIRPLANE_KEY, 1);
|
input_report_key(s76_input_device, AIRPLANE_KEY, 1);
|
||||||
|
|
@ -113,6 +67,42 @@ static void airplane_wmi(void) {
|
||||||
mutex_unlock(&s76_input_report_mutex);
|
mutex_unlock(&s76_input_report_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int s76_input_polling_thread(void *data) {
|
||||||
|
S76_INFO("Polling thread started (PID: %i), polling at %i Hz\n",
|
||||||
|
current->pid, param_poll_freq);
|
||||||
|
|
||||||
|
while (!kthread_should_stop()) {
|
||||||
|
u8 byte;
|
||||||
|
|
||||||
|
ec_read(0xDB, &byte);
|
||||||
|
if (byte & 0x40) {
|
||||||
|
ec_write(0xDB, byte & ~0x40);
|
||||||
|
|
||||||
|
S76_INFO("Airplane-Mode Hotkey pressed (EC)\n");
|
||||||
|
|
||||||
|
s76_input_airplane_key();
|
||||||
|
}
|
||||||
|
|
||||||
|
msleep_interruptible(1000 / param_poll_freq);
|
||||||
|
}
|
||||||
|
|
||||||
|
S76_INFO("Polling thread exiting\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void s76_input_airplane_wmi(void) {
|
||||||
|
S76_INFO("Airplane-Mode Hotkey pressed (WMI)\n");
|
||||||
|
|
||||||
|
if (s76_input_polling_task) {
|
||||||
|
S76_INFO("Stopping polling thread\n");
|
||||||
|
kthread_stop(s76_input_polling_task);
|
||||||
|
s76_input_polling_task = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
s76_input_airplane_key();
|
||||||
|
}
|
||||||
|
|
||||||
static int s76_input_open(struct input_dev *dev)
|
static int s76_input_open(struct input_dev *dev)
|
||||||
{
|
{
|
||||||
s76_input_polling_task = kthread_run(
|
s76_input_polling_task = kthread_run(
|
||||||
|
|
|
||||||
1
kb.c
1
kb.c
|
|
@ -93,7 +93,6 @@ module_param_array_named(kb_color, param_kb_color, kb_color,
|
||||||
¶m_kb_color_num, S_IRUSR);
|
¶m_kb_color_num, S_IRUSR);
|
||||||
MODULE_PARM_DESC(kb_color, "Set the color(s) of the keyboard (sections)");
|
MODULE_PARM_DESC(kb_color, "Set the color(s) of the keyboard (sections)");
|
||||||
|
|
||||||
|
|
||||||
static int param_set_kb_brightness(const char *val,
|
static int param_set_kb_brightness(const char *val,
|
||||||
const struct kernel_param *kp)
|
const struct kernel_param *kp)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
16
led.c
16
led.c
|
|
@ -19,10 +19,6 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static bool param_led_invert;
|
|
||||||
module_param_named(led_invert, param_led_invert, bool, 0);
|
|
||||||
MODULE_PARM_DESC(led_invert, "Invert airplane mode LED state.");
|
|
||||||
|
|
||||||
static struct workqueue_struct *led_workqueue;
|
static struct workqueue_struct *led_workqueue;
|
||||||
|
|
||||||
static struct _led_work {
|
static struct _led_work {
|
||||||
|
|
@ -39,10 +35,7 @@ static void airplane_led_update(struct work_struct *work)
|
||||||
|
|
||||||
ec_read(0xD9, &byte);
|
ec_read(0xD9, &byte);
|
||||||
|
|
||||||
if (param_led_invert)
|
ec_write(0xD9, w->wk ? byte & ~0x40 : byte | 0x40);
|
||||||
ec_write(0xD9, w->wk ? byte & ~0x40 : byte | 0x40);
|
|
||||||
else
|
|
||||||
ec_write(0xD9, w->wk ? byte | 0x40 : byte & ~0x40);
|
|
||||||
|
|
||||||
/* wmbb 0x6C 1 (?) */
|
/* wmbb 0x6C 1 (?) */
|
||||||
}
|
}
|
||||||
|
|
@ -53,10 +46,7 @@ static enum led_brightness airplane_led_get(struct led_classdev *led_cdev)
|
||||||
|
|
||||||
ec_read(0xD9, &byte);
|
ec_read(0xD9, &byte);
|
||||||
|
|
||||||
if (param_led_invert)
|
return byte & 0x40 ? LED_OFF : LED_FULL;
|
||||||
return byte & 0x40 ? LED_OFF : LED_FULL;
|
|
||||||
else
|
|
||||||
return byte & 0x40 ? LED_FULL : LED_OFF;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* must not sleep */
|
/* must not sleep */
|
||||||
|
|
@ -80,8 +70,6 @@ static int __init s76_led_init(void)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
param_led_invert = TRUE;
|
|
||||||
|
|
||||||
led_workqueue = create_singlethread_workqueue("led_workqueue");
|
led_workqueue = create_singlethread_workqueue("led_workqueue");
|
||||||
if (unlikely(!led_workqueue))
|
if (unlikely(!led_workqueue))
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
|
||||||
50
system76.c
50
system76.c
|
|
@ -26,8 +26,6 @@
|
||||||
#define S76_DRIVER_NAME KBUILD_MODNAME
|
#define S76_DRIVER_NAME KBUILD_MODNAME
|
||||||
#define pr_fmt(fmt) S76_DRIVER_NAME ": " fmt
|
#define pr_fmt(fmt) S76_DRIVER_NAME ": " fmt
|
||||||
|
|
||||||
//#define EXPERIMENTAL
|
|
||||||
|
|
||||||
#include <linux/acpi.h>
|
#include <linux/acpi.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/dmi.h>
|
#include <linux/dmi.h>
|
||||||
|
|
@ -53,7 +51,6 @@
|
||||||
__func__, __LINE__, ##__VA_ARGS__)
|
__func__, __LINE__, ##__VA_ARGS__)
|
||||||
|
|
||||||
#define S76_EVENT_GUID "ABBC0F6B-8EA1-11D1-00A0-C90629100000"
|
#define S76_EVENT_GUID "ABBC0F6B-8EA1-11D1-00A0-C90629100000"
|
||||||
#define S76_EMAIL_GUID "ABBC0F6C-8EA1-11D1-00A0-C90629100000"
|
|
||||||
#define S76_GET_GUID "ABBC0F6D-8EA1-11D1-00A0-C90629100000"
|
#define S76_GET_GUID "ABBC0F6D-8EA1-11D1-00A0-C90629100000"
|
||||||
|
|
||||||
#define S76_HAS_HWMON (defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE)))
|
#define S76_HAS_HWMON (defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE)))
|
||||||
|
|
@ -139,32 +136,35 @@ static int __init s76_init(void)
|
||||||
platform_create_bundle(&s76_platform_driver,
|
platform_create_bundle(&s76_platform_driver,
|
||||||
s76_wmi_probe, NULL, 0, NULL, 0);
|
s76_wmi_probe, NULL, 0, NULL, 0);
|
||||||
|
|
||||||
if (unlikely(IS_ERR(s76_platform_device)))
|
if (unlikely(IS_ERR(s76_platform_device))) {
|
||||||
return PTR_ERR(s76_platform_device);
|
return PTR_ERR(s76_platform_device);
|
||||||
|
}
|
||||||
|
|
||||||
// err = s76_input_init();
|
err = s76_input_init();
|
||||||
// if (unlikely(err))
|
if (unlikely(err)) {
|
||||||
// S76_ERROR("Could not register input device\n");
|
S76_ERROR("Could not register input device\n");
|
||||||
|
}
|
||||||
|
|
||||||
err = s76_led_init();
|
err = s76_led_init();
|
||||||
if (unlikely(err))
|
if (unlikely(err)) {
|
||||||
S76_ERROR("Could not register LED device\n");
|
S76_ERROR("Could not register LED device\n");
|
||||||
|
}
|
||||||
|
|
||||||
if (device_create_file(&s76_platform_device->dev,
|
if (device_create_file(&s76_platform_device->dev, &dev_attr_kb_brightness) != 0) {
|
||||||
&dev_attr_kb_brightness) != 0)
|
|
||||||
S76_ERROR("Sysfs attribute creation failed for brightness\n");
|
S76_ERROR("Sysfs attribute creation failed for brightness\n");
|
||||||
|
}
|
||||||
|
|
||||||
if (device_create_file(&s76_platform_device->dev,
|
if (device_create_file(&s76_platform_device->dev, &dev_attr_kb_state) != 0) {
|
||||||
&dev_attr_kb_state) != 0)
|
|
||||||
S76_ERROR("Sysfs attribute creation failed for state\n");
|
S76_ERROR("Sysfs attribute creation failed for state\n");
|
||||||
|
}
|
||||||
|
|
||||||
if (device_create_file(&s76_platform_device->dev,
|
if (device_create_file(&s76_platform_device->dev, &dev_attr_kb_mode) != 0) {
|
||||||
&dev_attr_kb_mode) != 0)
|
|
||||||
S76_ERROR("Sysfs attribute creation failed for mode\n");
|
S76_ERROR("Sysfs attribute creation failed for mode\n");
|
||||||
|
}
|
||||||
|
|
||||||
if (device_create_file(&s76_platform_device->dev,
|
if (device_create_file(&s76_platform_device->dev, &dev_attr_kb_color) != 0) {
|
||||||
&dev_attr_kb_color) != 0)
|
|
||||||
S76_ERROR("Sysfs attribute creation failed for color\n");
|
S76_ERROR("Sysfs attribute creation failed for color\n");
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef S76_HAS_HWMON
|
#ifdef S76_HAS_HWMON
|
||||||
s76_hwmon_init(&s76_platform_device->dev);
|
s76_hwmon_init(&s76_platform_device->dev);
|
||||||
|
|
@ -175,17 +175,17 @@ static int __init s76_init(void)
|
||||||
|
|
||||||
static void __exit s76_exit(void)
|
static void __exit s76_exit(void)
|
||||||
{
|
{
|
||||||
s76_led_exit();
|
#ifdef S76_HAS_HWMON
|
||||||
// s76_input_exit();
|
s76_hwmon_fini(&s76_platform_device->dev);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef S76_HAS_HWMON
|
|
||||||
s76_hwmon_fini(&s76_platform_device->dev);
|
|
||||||
#endif
|
|
||||||
device_remove_file(&s76_platform_device->dev,
|
|
||||||
&dev_attr_kb_brightness);
|
|
||||||
device_remove_file(&s76_platform_device->dev, &dev_attr_kb_state);
|
|
||||||
device_remove_file(&s76_platform_device->dev, &dev_attr_kb_mode);
|
|
||||||
device_remove_file(&s76_platform_device->dev, &dev_attr_kb_color);
|
device_remove_file(&s76_platform_device->dev, &dev_attr_kb_color);
|
||||||
|
device_remove_file(&s76_platform_device->dev, &dev_attr_kb_mode);
|
||||||
|
device_remove_file(&s76_platform_device->dev, &dev_attr_kb_state);
|
||||||
|
device_remove_file(&s76_platform_device->dev, &dev_attr_kb_brightness);
|
||||||
|
|
||||||
|
s76_led_exit();
|
||||||
|
s76_input_exit();
|
||||||
|
|
||||||
platform_device_unregister(s76_platform_device);
|
platform_device_unregister(s76_platform_device);
|
||||||
platform_driver_unregister(&s76_platform_driver);
|
platform_driver_unregister(&s76_platform_driver);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue