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,
|
||||
};
|
||||
|
||||
|
||||
// Params Variables
|
||||
static uint param_color_left = KB_COLOR_DEFAULT;
|
||||
module_param_named(color_left, param_color_left, uint, S_IRUSR);
|
||||
|
@ -118,74 +117,66 @@ static struct {
|
|||
.key = 7,.value = 0xB0000000,.name = "WAVE"}
|
||||
};
|
||||
|
||||
|
||||
// Sysfs Interface Methods
|
||||
// Sysfs Interface for the keyboard state (ON / OFF)
|
||||
static ssize_t
|
||||
show_state_fs(struct device *child, struct device_attribute *attr, char *buffer)
|
||||
static ssize_t show_state_fs(struct device *child,
|
||||
struct device_attribute *attr, char *buffer)
|
||||
{
|
||||
return sprintf(buffer, "%d\n", keyboard.state);
|
||||
}
|
||||
|
||||
// Sysfs Interface for the color of the left side (Color as hexvalue)
|
||||
static ssize_t
|
||||
show_color_left_fs(struct device *child, struct device_attribute *attr,
|
||||
char *buffer)
|
||||
static ssize_t show_color_left_fs(struct device *child,
|
||||
struct device_attribute *attr, char *buffer)
|
||||
{
|
||||
return sprintf(buffer, "%06x\n", keyboard.color.left);
|
||||
}
|
||||
|
||||
// Sysfs Interface for the color of the center (Color as hexvalue)
|
||||
static ssize_t
|
||||
show_color_center_fs(struct device *child, struct device_attribute *attr,
|
||||
char *buffer)
|
||||
static ssize_t show_color_center_fs(struct device *child,
|
||||
struct device_attribute *attr, char *buffer)
|
||||
{
|
||||
return sprintf(buffer, "%06x\n", keyboard.color.center);
|
||||
}
|
||||
|
||||
// Sysfs Interface for the color of the right side (Color as hexvalue)
|
||||
static ssize_t
|
||||
show_color_right_fs(struct device *child, struct device_attribute *attr,
|
||||
char *buffer)
|
||||
static ssize_t show_color_right_fs(struct device *child,
|
||||
struct device_attribute *attr, char *buffer)
|
||||
{
|
||||
return sprintf(buffer, "%06x\n", keyboard.color.right);
|
||||
}
|
||||
|
||||
// Sysfs Interface for the color of the extra region (Color as hexvalue)
|
||||
static ssize_t
|
||||
show_color_extra_fs(struct device *child, struct device_attribute *attr,
|
||||
char *buffer)
|
||||
static ssize_t show_color_extra_fs(struct device *child,
|
||||
struct device_attribute *attr, char *buffer)
|
||||
{
|
||||
return sprintf(buffer, "%06x\n", keyboard.color.extra);
|
||||
}
|
||||
|
||||
// Sysfs Interface for the keyboard brightness (unsigned int)
|
||||
static ssize_t
|
||||
show_brightness_fs(struct device *child, struct device_attribute *attr,
|
||||
char *buffer)
|
||||
static ssize_t show_brightness_fs(struct device *child,
|
||||
struct device_attribute *attr, char *buffer)
|
||||
{
|
||||
return sprintf(buffer, "%d\n", keyboard.brightness);
|
||||
}
|
||||
|
||||
// Sysfs Interface for the keyboard mode
|
||||
static ssize_t
|
||||
show_mode_fs(struct device *child, struct device_attribute *attr, char *buffer)
|
||||
static ssize_t show_mode_fs(struct device *child, struct device_attribute *attr,
|
||||
char *buffer)
|
||||
{
|
||||
return sprintf(buffer, "%d\n", keyboard.mode);
|
||||
}
|
||||
|
||||
// Sysfs Interface for if the keyboard has extra region
|
||||
static ssize_t
|
||||
show_hasextra_fs(struct device *child, struct device_attribute *attr,
|
||||
char *buffer)
|
||||
static ssize_t show_hasextra_fs(struct device *child,
|
||||
struct device_attribute *attr, char *buffer)
|
||||
{
|
||||
return sprintf(buffer, "%d\n", keyboard.has_extra);
|
||||
}
|
||||
|
||||
static int
|
||||
tuxedo_evaluate_wmi_method(u32 method_id, u32 arg, u32 * retval)
|
||||
static int 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 };
|
||||
union acpi_object *obj;
|
||||
acpi_status status;
|
||||
|
@ -201,7 +192,7 @@ tuxedo_evaluate_wmi_method(u32 method_id, u32 arg, u32 * retval)
|
|||
goto exit;
|
||||
}
|
||||
|
||||
obj = (union acpi_object *) out.pointer;
|
||||
obj = (union acpi_object *)out.pointer;
|
||||
if (obj && obj->type == ACPI_TYPE_INTEGER) {
|
||||
tmp = (u32) obj->integer.value;
|
||||
} else {
|
||||
|
@ -216,7 +207,7 @@ tuxedo_evaluate_wmi_method(u32 method_id, u32 arg, u32 * retval)
|
|||
|
||||
kfree(obj);
|
||||
|
||||
exit:
|
||||
exit:
|
||||
if (unlikely(ACPI_FAILURE(status))) {
|
||||
return -EIO;
|
||||
}
|
||||
|
@ -224,17 +215,16 @@ tuxedo_evaluate_wmi_method(u32 method_id, u32 arg, u32 * retval)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
set_brightness(u8 brightness)
|
||||
static void set_brightness(u8 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;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_state(u8 state)
|
||||
static void set_state(u8 state)
|
||||
{
|
||||
u32 cmd = 0xE0000000;
|
||||
TUXEDO_INFO("Set keyboard state on: %d\n", state);
|
||||
|
@ -250,8 +240,7 @@ set_state(u8 state)
|
|||
}
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
set_state_fs(struct device *child, struct device_attribute *attr,
|
||||
static ssize_t set_state_fs(struct device *child, struct device_attribute *attr,
|
||||
const char *buffer, size_t size)
|
||||
{
|
||||
unsigned int val;
|
||||
|
@ -268,8 +257,7 @@ set_state_fs(struct device *child, struct device_attribute *attr,
|
|||
return size;
|
||||
}
|
||||
|
||||
static int
|
||||
set_color(u32 region, u32 color)
|
||||
static int set_color(u32 region, u32 color)
|
||||
{
|
||||
u32 cset =
|
||||
((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);
|
||||
}
|
||||
|
||||
static int
|
||||
set_color_region(const char *buffer, size_t size, u32 region)
|
||||
static int set_color_region(const char *buffer, size_t size, u32 region)
|
||||
{
|
||||
u32 val;
|
||||
int ret = kstrtouint(buffer, 0, &val);
|
||||
|
@ -311,37 +298,36 @@ set_color_region(const char *buffer, size_t size, u32 region)
|
|||
return size;
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
set_color_left_fs(struct device *child, struct device_attribute *attr,
|
||||
static ssize_t set_color_left_fs(struct device *child,
|
||||
struct device_attribute *attr,
|
||||
const char *buffer, size_t size)
|
||||
{
|
||||
return set_color_region(buffer, size, REGION_LEFT);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
set_color_center_fs(struct device *child, struct device_attribute *attr,
|
||||
static ssize_t set_color_center_fs(struct device *child,
|
||||
struct device_attribute *attr,
|
||||
const char *buffer, size_t size)
|
||||
{
|
||||
return set_color_region(buffer, size, REGION_CENTER);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
set_color_right_fs(struct device *child, struct device_attribute *attr,
|
||||
static ssize_t set_color_right_fs(struct device *child,
|
||||
struct device_attribute *attr,
|
||||
const char *buffer, size_t size)
|
||||
{
|
||||
return set_color_region(buffer, size, REGION_RIGHT);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
set_color_extra_fs(struct device *child, struct device_attribute *attr,
|
||||
static ssize_t set_color_extra_fs(struct device *child,
|
||||
struct device_attribute *attr,
|
||||
const char *buffer, size_t size)
|
||||
{
|
||||
return set_color_region(buffer, size, REGION_EXTRA);
|
||||
}
|
||||
|
||||
|
||||
static ssize_t
|
||||
set_brightness_fs(struct device *child, struct device_attribute *attr,
|
||||
static ssize_t set_brightness_fs(struct device *child,
|
||||
struct device_attribute *attr,
|
||||
const char *buffer, size_t size)
|
||||
{
|
||||
unsigned int val;
|
||||
|
@ -358,8 +344,7 @@ set_brightness_fs(struct device *child, struct device_attribute *attr,
|
|||
return size;
|
||||
}
|
||||
|
||||
static void
|
||||
set_mode(u8 mode)
|
||||
static void set_mode(u8 mode)
|
||||
{
|
||||
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)
|
||||
{
|
||||
unsigned int val;
|
||||
|
@ -396,8 +379,7 @@ set_mode_fs(struct device *child, struct device_attribute *attr,
|
|||
return size;
|
||||
}
|
||||
|
||||
static int
|
||||
mode_validator(const char *val, const struct kernel_param *kp)
|
||||
static int mode_validator(const char *val, const struct kernel_param *kp)
|
||||
{
|
||||
int mode = 0;
|
||||
int ret;
|
||||
|
@ -410,8 +392,7 @@ mode_validator(const char *val, const struct kernel_param *kp)
|
|||
return param_set_int(val, kp);
|
||||
}
|
||||
|
||||
static int
|
||||
brightness_validator(const char *val, const struct kernel_param *kp)
|
||||
static int brightness_validator(const char *val, const struct kernel_param *kp)
|
||||
{
|
||||
int brightness = 0;
|
||||
int ret;
|
||||
|
@ -425,8 +406,7 @@ brightness_validator(const char *val, const struct kernel_param *kp)
|
|||
return param_set_int(val, kp);
|
||||
}
|
||||
|
||||
static void
|
||||
tuxedo_wmi_notify(u32 value, void *context)
|
||||
static void tuxedo_wmi_notify(u32 value, void *context)
|
||||
{
|
||||
u32 event;
|
||||
|
||||
|
@ -468,8 +448,7 @@ tuxedo_wmi_notify(u32 value, void *context)
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
tuxedo_wmi_probe(struct platform_device *dev)
|
||||
static int tuxedo_wmi_probe(struct platform_device *dev)
|
||||
{
|
||||
int status;
|
||||
|
||||
|
@ -490,22 +469,19 @@ tuxedo_wmi_probe(struct platform_device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
tuxedo_wmi_remove(struct platform_device *dev)
|
||||
static int tuxedo_wmi_remove(struct platform_device *dev)
|
||||
{
|
||||
wmi_remove_notify_handler(CLEVO_EVENT_GUID);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
tuxedo_wmi_resume(struct platform_device *dev)
|
||||
static int tuxedo_wmi_resume(struct platform_device *dev)
|
||||
{
|
||||
tuxedo_evaluate_wmi_method(GET_AP, 0, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static struct platform_driver tuxedo_platform_driver = {
|
||||
.remove = tuxedo_wmi_remove,
|
||||
.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(extra, 0444, show_hasextra_fs, NULL);
|
||||
|
||||
static int __init
|
||||
tuxedo_input_init(void)
|
||||
static int __init tuxedo_input_init(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
|
@ -552,14 +527,13 @@ tuxedo_input_init(void)
|
|||
|
||||
return 0;
|
||||
|
||||
err_free_input_device:
|
||||
err_free_input_device:
|
||||
input_free_device(tuxedo_input_device);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static void __exit
|
||||
tuxedo_input_exit(void)
|
||||
static void __exit tuxedo_input_exit(void)
|
||||
{
|
||||
if (unlikely(!tuxedo_input_device)) {
|
||||
return;
|
||||
|
@ -571,8 +545,7 @@ tuxedo_input_exit(void)
|
|||
}
|
||||
}
|
||||
|
||||
static int __init
|
||||
tuxdeo_keyboard_init(void)
|
||||
static int __init tuxdeo_keyboard_init(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
|
@ -673,8 +646,7 @@ tuxdeo_keyboard_init(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void __exit
|
||||
tuxdeo_keyboard_exit(void)
|
||||
static void __exit tuxdeo_keyboard_exit(void)
|
||||
{
|
||||
tuxedo_input_exit();
|
||||
|
||||
|
|
Loading…
Reference in a new issue