mirror of
https://github.com/wessel-novacustom/clevo-keyboard.git
synced 2024-11-15 03:34:01 +01:00
Code style, return type on same line, finally use scripts/Lindent
This commit is contained in:
parent
d319024029
commit
4d5998ea97
|
@ -49,7 +49,6 @@ static const struct kernel_param_ops param_ops_brightness_ops = {
|
||||||
.get = param_get_int,
|
.get = param_get_int,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Params Variables
|
// Params Variables
|
||||||
static uint param_color_left = KB_COLOR_DEFAULT;
|
static uint param_color_left = KB_COLOR_DEFAULT;
|
||||||
module_param_named(color_left, param_color_left, uint, S_IRUSR);
|
module_param_named(color_left, param_color_left, uint, S_IRUSR);
|
||||||
|
@ -118,72 +117,64 @@ static struct {
|
||||||
.key = 7,.value = 0xB0000000,.name = "WAVE"}
|
.key = 7,.value = 0xB0000000,.name = "WAVE"}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Sysfs Interface Methods
|
// Sysfs Interface Methods
|
||||||
// Sysfs Interface for the keyboard state (ON / OFF)
|
// Sysfs Interface for the keyboard state (ON / OFF)
|
||||||
static ssize_t
|
static ssize_t show_state_fs(struct device *child,
|
||||||
show_state_fs(struct device *child, struct device_attribute *attr, char *buffer)
|
struct device_attribute *attr, char *buffer)
|
||||||
{
|
{
|
||||||
return sprintf(buffer, "%d\n", keyboard.state);
|
return sprintf(buffer, "%d\n", keyboard.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sysfs Interface for the color of the left side (Color as hexvalue)
|
// Sysfs Interface for the color of the left side (Color as hexvalue)
|
||||||
static ssize_t
|
static ssize_t show_color_left_fs(struct device *child,
|
||||||
show_color_left_fs(struct device *child, struct device_attribute *attr,
|
struct device_attribute *attr, char *buffer)
|
||||||
char *buffer)
|
|
||||||
{
|
{
|
||||||
return sprintf(buffer, "%06x\n", keyboard.color.left);
|
return sprintf(buffer, "%06x\n", keyboard.color.left);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sysfs Interface for the color of the center (Color as hexvalue)
|
// Sysfs Interface for the color of the center (Color as hexvalue)
|
||||||
static ssize_t
|
static ssize_t show_color_center_fs(struct device *child,
|
||||||
show_color_center_fs(struct device *child, struct device_attribute *attr,
|
struct device_attribute *attr, char *buffer)
|
||||||
char *buffer)
|
|
||||||
{
|
{
|
||||||
return sprintf(buffer, "%06x\n", keyboard.color.center);
|
return sprintf(buffer, "%06x\n", keyboard.color.center);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sysfs Interface for the color of the right side (Color as hexvalue)
|
// Sysfs Interface for the color of the right side (Color as hexvalue)
|
||||||
static ssize_t
|
static ssize_t show_color_right_fs(struct device *child,
|
||||||
show_color_right_fs(struct device *child, struct device_attribute *attr,
|
struct device_attribute *attr, char *buffer)
|
||||||
char *buffer)
|
|
||||||
{
|
{
|
||||||
return sprintf(buffer, "%06x\n", keyboard.color.right);
|
return sprintf(buffer, "%06x\n", keyboard.color.right);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sysfs Interface for the color of the extra region (Color as hexvalue)
|
// Sysfs Interface for the color of the extra region (Color as hexvalue)
|
||||||
static ssize_t
|
static ssize_t show_color_extra_fs(struct device *child,
|
||||||
show_color_extra_fs(struct device *child, struct device_attribute *attr,
|
struct device_attribute *attr, char *buffer)
|
||||||
char *buffer)
|
|
||||||
{
|
{
|
||||||
return sprintf(buffer, "%06x\n", keyboard.color.extra);
|
return sprintf(buffer, "%06x\n", keyboard.color.extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sysfs Interface for the keyboard brightness (unsigned int)
|
// Sysfs Interface for the keyboard brightness (unsigned int)
|
||||||
static ssize_t
|
static ssize_t show_brightness_fs(struct device *child,
|
||||||
show_brightness_fs(struct device *child, struct device_attribute *attr,
|
struct device_attribute *attr, char *buffer)
|
||||||
char *buffer)
|
|
||||||
{
|
{
|
||||||
return sprintf(buffer, "%d\n", keyboard.brightness);
|
return sprintf(buffer, "%d\n", keyboard.brightness);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sysfs Interface for the keyboard mode
|
// Sysfs Interface for the keyboard mode
|
||||||
static ssize_t
|
static ssize_t show_mode_fs(struct device *child, struct device_attribute *attr,
|
||||||
show_mode_fs(struct device *child, struct device_attribute *attr, char *buffer)
|
char *buffer)
|
||||||
{
|
{
|
||||||
return sprintf(buffer, "%d\n", keyboard.mode);
|
return sprintf(buffer, "%d\n", keyboard.mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sysfs Interface for if the keyboard has extra region
|
// Sysfs Interface for if the keyboard has extra region
|
||||||
static ssize_t
|
static ssize_t show_hasextra_fs(struct device *child,
|
||||||
show_hasextra_fs(struct device *child, struct device_attribute *attr,
|
struct device_attribute *attr, char *buffer)
|
||||||
char *buffer)
|
|
||||||
{
|
{
|
||||||
return sprintf(buffer, "%d\n", keyboard.has_extra);
|
return sprintf(buffer, "%d\n", keyboard.has_extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int tuxedo_evaluate_wmi_method(u32 method_id, u32 arg, u32 * retval)
|
||||||
tuxedo_evaluate_wmi_method(u32 method_id, u32 arg, u32 * retval)
|
|
||||||
{
|
{
|
||||||
struct acpi_buffer in = { (acpi_size) sizeof(arg), &arg };
|
struct acpi_buffer in = { (acpi_size) sizeof(arg), &arg };
|
||||||
struct acpi_buffer out = { ACPI_ALLOCATE_BUFFER, NULL };
|
struct acpi_buffer out = { ACPI_ALLOCATE_BUFFER, NULL };
|
||||||
|
@ -224,17 +215,16 @@ tuxedo_evaluate_wmi_method(u32 method_id, u32 arg, u32 * retval)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void set_brightness(u8 brightness)
|
||||||
set_brightness(u8 brightness)
|
|
||||||
{
|
{
|
||||||
TUXEDO_INFO("Set brightness on %d", brightness);
|
TUXEDO_INFO("Set brightness on %d", brightness);
|
||||||
if (!tuxedo_evaluate_wmi_method(SET_KB_LED, 0xF4000000 | brightness, NULL)) {
|
if (!tuxedo_evaluate_wmi_method
|
||||||
|
(SET_KB_LED, 0xF4000000 | brightness, NULL)) {
|
||||||
keyboard.brightness = brightness;
|
keyboard.brightness = brightness;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void set_state(u8 state)
|
||||||
set_state(u8 state)
|
|
||||||
{
|
{
|
||||||
u32 cmd = 0xE0000000;
|
u32 cmd = 0xE0000000;
|
||||||
TUXEDO_INFO("Set keyboard state on: %d\n", state);
|
TUXEDO_INFO("Set keyboard state on: %d\n", state);
|
||||||
|
@ -250,8 +240,7 @@ set_state(u8 state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t set_state_fs(struct device *child, struct device_attribute *attr,
|
||||||
set_state_fs(struct device *child, struct device_attribute *attr,
|
|
||||||
const char *buffer, size_t size)
|
const char *buffer, size_t size)
|
||||||
{
|
{
|
||||||
unsigned int val;
|
unsigned int val;
|
||||||
|
@ -268,8 +257,7 @@ set_state_fs(struct device *child, struct device_attribute *attr,
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int set_color(u32 region, u32 color)
|
||||||
set_color(u32 region, u32 color)
|
|
||||||
{
|
{
|
||||||
u32 cset =
|
u32 cset =
|
||||||
((color & 0x0000FF) << 16) | ((color & 0xFF0000) >> 8) |
|
((color & 0x0000FF) << 16) | ((color & 0xFF0000) >> 8) |
|
||||||
|
@ -281,8 +269,7 @@ set_color(u32 region, u32 color)
|
||||||
return tuxedo_evaluate_wmi_method(SET_KB_LED, cmd, NULL);
|
return tuxedo_evaluate_wmi_method(SET_KB_LED, cmd, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int set_color_region(const char *buffer, size_t size, u32 region)
|
||||||
set_color_region(const char *buffer, size_t size, u32 region)
|
|
||||||
{
|
{
|
||||||
u32 val;
|
u32 val;
|
||||||
int ret = kstrtouint(buffer, 0, &val);
|
int ret = kstrtouint(buffer, 0, &val);
|
||||||
|
@ -311,37 +298,36 @@ set_color_region(const char *buffer, size_t size, u32 region)
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t set_color_left_fs(struct device *child,
|
||||||
set_color_left_fs(struct device *child, struct device_attribute *attr,
|
struct device_attribute *attr,
|
||||||
const char *buffer, size_t size)
|
const char *buffer, size_t size)
|
||||||
{
|
{
|
||||||
return set_color_region(buffer, size, REGION_LEFT);
|
return set_color_region(buffer, size, REGION_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t set_color_center_fs(struct device *child,
|
||||||
set_color_center_fs(struct device *child, struct device_attribute *attr,
|
struct device_attribute *attr,
|
||||||
const char *buffer, size_t size)
|
const char *buffer, size_t size)
|
||||||
{
|
{
|
||||||
return set_color_region(buffer, size, REGION_CENTER);
|
return set_color_region(buffer, size, REGION_CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t set_color_right_fs(struct device *child,
|
||||||
set_color_right_fs(struct device *child, struct device_attribute *attr,
|
struct device_attribute *attr,
|
||||||
const char *buffer, size_t size)
|
const char *buffer, size_t size)
|
||||||
{
|
{
|
||||||
return set_color_region(buffer, size, REGION_RIGHT);
|
return set_color_region(buffer, size, REGION_RIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t set_color_extra_fs(struct device *child,
|
||||||
set_color_extra_fs(struct device *child, struct device_attribute *attr,
|
struct device_attribute *attr,
|
||||||
const char *buffer, size_t size)
|
const char *buffer, size_t size)
|
||||||
{
|
{
|
||||||
return set_color_region(buffer, size, REGION_EXTRA);
|
return set_color_region(buffer, size, REGION_EXTRA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ssize_t set_brightness_fs(struct device *child,
|
||||||
static ssize_t
|
struct device_attribute *attr,
|
||||||
set_brightness_fs(struct device *child, struct device_attribute *attr,
|
|
||||||
const char *buffer, size_t size)
|
const char *buffer, size_t size)
|
||||||
{
|
{
|
||||||
unsigned int val;
|
unsigned int val;
|
||||||
|
@ -358,8 +344,7 @@ set_brightness_fs(struct device *child, struct device_attribute *attr,
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void set_mode(u8 mode)
|
||||||
set_mode(u8 mode)
|
|
||||||
{
|
{
|
||||||
TUXEDO_INFO("set_mode on %s", modes[mode].name);
|
TUXEDO_INFO("set_mode on %s", modes[mode].name);
|
||||||
|
|
||||||
|
@ -378,9 +363,7 @@ set_mode(u8 mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ssize_t set_mode_fs(struct device *child, struct device_attribute *attr,
|
||||||
static ssize_t
|
|
||||||
set_mode_fs(struct device *child, struct device_attribute *attr,
|
|
||||||
const char *buffer, size_t size)
|
const char *buffer, size_t size)
|
||||||
{
|
{
|
||||||
unsigned int val;
|
unsigned int val;
|
||||||
|
@ -396,8 +379,7 @@ set_mode_fs(struct device *child, struct device_attribute *attr,
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int mode_validator(const char *val, const struct kernel_param *kp)
|
||||||
mode_validator(const char *val, const struct kernel_param *kp)
|
|
||||||
{
|
{
|
||||||
int mode = 0;
|
int mode = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -410,8 +392,7 @@ mode_validator(const char *val, const struct kernel_param *kp)
|
||||||
return param_set_int(val, kp);
|
return param_set_int(val, kp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int brightness_validator(const char *val, const struct kernel_param *kp)
|
||||||
brightness_validator(const char *val, const struct kernel_param *kp)
|
|
||||||
{
|
{
|
||||||
int brightness = 0;
|
int brightness = 0;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -425,8 +406,7 @@ brightness_validator(const char *val, const struct kernel_param *kp)
|
||||||
return param_set_int(val, kp);
|
return param_set_int(val, kp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void tuxedo_wmi_notify(u32 value, void *context)
|
||||||
tuxedo_wmi_notify(u32 value, void *context)
|
|
||||||
{
|
{
|
||||||
u32 event;
|
u32 event;
|
||||||
|
|
||||||
|
@ -468,8 +448,7 @@ tuxedo_wmi_notify(u32 value, void *context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int tuxedo_wmi_probe(struct platform_device *dev)
|
||||||
tuxedo_wmi_probe(struct platform_device *dev)
|
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
|
@ -490,22 +469,19 @@ tuxedo_wmi_probe(struct platform_device *dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int tuxedo_wmi_remove(struct platform_device *dev)
|
||||||
tuxedo_wmi_remove(struct platform_device *dev)
|
|
||||||
{
|
{
|
||||||
wmi_remove_notify_handler(CLEVO_EVENT_GUID);
|
wmi_remove_notify_handler(CLEVO_EVENT_GUID);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int tuxedo_wmi_resume(struct platform_device *dev)
|
||||||
tuxedo_wmi_resume(struct platform_device *dev)
|
|
||||||
{
|
{
|
||||||
tuxedo_evaluate_wmi_method(GET_AP, 0, NULL);
|
tuxedo_evaluate_wmi_method(GET_AP, 0, NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static struct platform_driver tuxedo_platform_driver = {
|
static struct platform_driver tuxedo_platform_driver = {
|
||||||
.remove = tuxedo_wmi_remove,
|
.remove = tuxedo_wmi_remove,
|
||||||
.resume = tuxedo_wmi_resume,
|
.resume = tuxedo_wmi_resume,
|
||||||
|
@ -526,8 +502,7 @@ static DEVICE_ATTR(brightness, 0644, show_brightness_fs, set_brightness_fs);
|
||||||
static DEVICE_ATTR(mode, 0644, show_mode_fs, set_mode_fs);
|
static DEVICE_ATTR(mode, 0644, show_mode_fs, set_mode_fs);
|
||||||
static DEVICE_ATTR(extra, 0444, show_hasextra_fs, NULL);
|
static DEVICE_ATTR(extra, 0444, show_hasextra_fs, NULL);
|
||||||
|
|
||||||
static int __init
|
static int __init tuxedo_input_init(void)
|
||||||
tuxedo_input_init(void)
|
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
@ -558,8 +533,7 @@ tuxedo_input_init(void)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __exit
|
static void __exit tuxedo_input_exit(void)
|
||||||
tuxedo_input_exit(void)
|
|
||||||
{
|
{
|
||||||
if (unlikely(!tuxedo_input_device)) {
|
if (unlikely(!tuxedo_input_device)) {
|
||||||
return;
|
return;
|
||||||
|
@ -571,8 +545,7 @@ tuxedo_input_exit(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __init
|
static int __init tuxdeo_keyboard_init(void)
|
||||||
tuxdeo_keyboard_init(void)
|
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
@ -673,8 +646,7 @@ tuxdeo_keyboard_init(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __exit
|
static void __exit tuxdeo_keyboard_exit(void)
|
||||||
tuxdeo_keyboard_exit(void)
|
|
||||||
{
|
{
|
||||||
tuxedo_input_exit();
|
tuxedo_input_exit();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue