Code style, return type on same line, finally use scripts/Lindent

This commit is contained in:
Richard Sailer 2019-06-04 19:32:30 +02:00
parent d319024029
commit 4d5998ea97

View file

@ -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);
@ -73,13 +72,13 @@ MODULE_PARM_DESC(mode, "Set the mode");
static ushort param_brightness = BRIGHTNESS_DEFAULT; static ushort param_brightness = BRIGHTNESS_DEFAULT;
module_param_cb(brightness, &param_ops_brightness_ops, &param_brightness, module_param_cb(brightness, &param_ops_brightness_ops, &param_brightness,
S_IRUSR); S_IRUSR);
MODULE_PARM_DESC(brightness, "Set the Keyboard Brightness"); MODULE_PARM_DESC(brightness, "Set the Keyboard Brightness");
static bool param_state = true; static bool param_state = true;
module_param_named(state, param_state, bool, S_IRUSR); module_param_named(state, param_state, bool, S_IRUSR);
MODULE_PARM_DESC(state, MODULE_PARM_DESC(state,
"Set the State of the Keyboard TRUE = ON | FALSE = OFF"); "Set the State of the Keyboard TRUE = ON | FALSE = OFF");
// Keyboard struct // Keyboard struct
static struct { static struct {
@ -99,7 +98,7 @@ static struct {
.has_extra = 0,.mode = DEFAULT_MODE,.state = 1,.brightness = .has_extra = 0,.mode = DEFAULT_MODE,.state = 1,.brightness =
BRIGHTNESS_DEFAULT,.color = { BRIGHTNESS_DEFAULT,.color = {
.left = KB_COLOR_DEFAULT,.center = KB_COLOR_DEFAULT,.right = .left = KB_COLOR_DEFAULT,.center = KB_COLOR_DEFAULT,.right =
KB_COLOR_DEFAULT,.extra = KB_COLOR_DEFAULT,} KB_COLOR_DEFAULT,.extra = KB_COLOR_DEFAULT,}
}; };
static struct { static struct {
@ -107,7 +106,7 @@ static struct {
u32 value; u32 value;
const char *const name; const char *const name;
} modes[] = { } modes[] = {
{ {
.key = 0,.value = 0,.name = "CUSTOM"}, { .key = 0,.value = 0,.name = "CUSTOM"}, {
.key = 1,.value = 0x1002a000,.name = "BREATHE"}, { .key = 1,.value = 0x1002a000,.name = "BREATHE"}, {
.key = 2,.value = 0x33010000,.name = "CYCLE"}, { .key = 2,.value = 0x33010000,.name = "CYCLE"}, {
@ -118,74 +117,66 @@ 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 };
union acpi_object *obj; union acpi_object *obj;
acpi_status status; acpi_status status;
@ -201,7 +192,7 @@ tuxedo_evaluate_wmi_method(u32 method_id, u32 arg, u32 * retval)
goto exit; goto exit;
} }
obj = (union acpi_object *) out.pointer; obj = (union acpi_object *)out.pointer;
if (obj && obj->type == ACPI_TYPE_INTEGER) { if (obj && obj->type == ACPI_TYPE_INTEGER) {
tmp = (u32) obj->integer.value; tmp = (u32) obj->integer.value;
} else { } else {
@ -216,7 +207,7 @@ tuxedo_evaluate_wmi_method(u32 method_id, u32 arg, u32 * retval)
kfree(obj); kfree(obj);
exit: exit:
if (unlikely(ACPI_FAILURE(status))) { if (unlikely(ACPI_FAILURE(status))) {
return -EIO; return -EIO;
} }
@ -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,9 +240,8 @@ 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;
int ret = kstrtouint(buffer, 0, &val); int ret = kstrtouint(buffer, 0, &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,38 +298,37 @@ 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;
// hier unsigned? // hier unsigned?
@ -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,10 +363,8 @@ set_mode(u8 mode)
} }
} }
static ssize_t set_mode_fs(struct device *child, struct device_attribute *attr,
static ssize_t const char *buffer, size_t size)
set_mode_fs(struct device *child, struct device_attribute *attr,
const char *buffer, size_t size)
{ {
unsigned int val; unsigned int val;
int ret = kstrtouint(buffer, 0, &val); int ret = kstrtouint(buffer, 0, &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;
@ -456,7 +436,7 @@ tuxedo_wmi_notify(u32 value, void *context)
case WMI_CODE_NEXT_MODE: case WMI_CODE_NEXT_MODE:
set_mode((keyboard.mode + 1) > set_mode((keyboard.mode + 1) >
(ARRAY_SIZE(modes) - 1) ? 0 : (keyboard.mode + 1)); (ARRAY_SIZE(modes) - 1) ? 0 : (keyboard.mode + 1));
break; break;
case WMI_CODE_TOGGLE_STATE: case WMI_CODE_TOGGLE_STATE:
@ -468,20 +448,19 @@ 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;
status = status =
wmi_install_notify_handler(CLEVO_EVENT_GUID, tuxedo_wmi_notify, wmi_install_notify_handler(CLEVO_EVENT_GUID, tuxedo_wmi_notify,
NULL); NULL);
// neuer name? // neuer name?
TUXEDO_DEBUG("clevo_xsm_wmi_probe status: (%0#6x)", status); TUXEDO_DEBUG("clevo_xsm_wmi_probe status: (%0#6x)", status);
if (unlikely(ACPI_FAILURE(status))) { if (unlikely(ACPI_FAILURE(status))) {
TUXEDO_ERROR("Could not register WMI notify handler (%0#6x)\n", TUXEDO_ERROR("Could not register WMI notify handler (%0#6x)\n",
status); status);
return -EIO; return -EIO;
} }
@ -490,44 +469,40 @@ 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,
.driver = { .driver = {
.name = DRIVER_NAME, .name = DRIVER_NAME,
.owner = THIS_MODULE, .owner = THIS_MODULE,
}, },
}; };
// Sysfs device Attributes // Sysfs device Attributes
static DEVICE_ATTR(state, 0644, show_state_fs, set_state_fs); static DEVICE_ATTR(state, 0644, show_state_fs, set_state_fs);
static DEVICE_ATTR(color_left, 0644, show_color_left_fs, set_color_left_fs); static DEVICE_ATTR(color_left, 0644, show_color_left_fs, set_color_left_fs);
static DEVICE_ATTR(color_center, 0644, show_color_center_fs, static DEVICE_ATTR(color_center, 0644, show_color_center_fs,
set_color_center_fs); set_color_center_fs);
static DEVICE_ATTR(color_right, 0644, show_color_right_fs, set_color_right_fs); static DEVICE_ATTR(color_right, 0644, show_color_right_fs, set_color_right_fs);
static DEVICE_ATTR(color_extra, 0644, show_color_extra_fs, set_color_extra_fs); static DEVICE_ATTR(color_extra, 0644, show_color_extra_fs, set_color_extra_fs);
static DEVICE_ATTR(brightness, 0644, show_brightness_fs, set_brightness_fs); 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;
@ -552,14 +527,13 @@ tuxedo_input_init(void)
return 0; return 0;
err_free_input_device: err_free_input_device:
input_free_device(tuxedo_input_device); input_free_device(tuxedo_input_device);
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;
@ -587,11 +560,11 @@ tuxdeo_keyboard_init(void)
} }
TUXEDO_INFO("Model '%s' found\n", TUXEDO_INFO("Model '%s' found\n",
dmi_get_system_info(DMI_PRODUCT_NAME)); dmi_get_system_info(DMI_PRODUCT_NAME));
tuxedo_platform_device = tuxedo_platform_device =
platform_create_bundle(&tuxedo_platform_driver, tuxedo_wmi_probe, platform_create_bundle(&tuxedo_platform_driver, tuxedo_wmi_probe,
NULL, 0, NULL, 0); NULL, 0, NULL, 0);
if (unlikely(IS_ERR(tuxedo_platform_device))) { if (unlikely(IS_ERR(tuxedo_platform_device))) {
TUXEDO_ERROR("Can not init Platform driver"); TUXEDO_ERROR("Can not init Platform driver");
return PTR_ERR(tuxedo_platform_device); return PTR_ERR(tuxedo_platform_device);
@ -673,15 +646,14 @@ 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();
device_remove_file(&tuxedo_platform_device->dev, &dev_attr_state); device_remove_file(&tuxedo_platform_device->dev, &dev_attr_state);
device_remove_file(&tuxedo_platform_device->dev, &dev_attr_color_left); device_remove_file(&tuxedo_platform_device->dev, &dev_attr_color_left);
device_remove_file(&tuxedo_platform_device->dev, device_remove_file(&tuxedo_platform_device->dev,
&dev_attr_color_center); &dev_attr_color_center);
device_remove_file(&tuxedo_platform_device->dev, &dev_attr_color_right); device_remove_file(&tuxedo_platform_device->dev, &dev_attr_color_right);
device_remove_file(&tuxedo_platform_device->dev, &dev_attr_extra); device_remove_file(&tuxedo_platform_device->dev, &dev_attr_extra);
device_remove_file(&tuxedo_platform_device->dev, &dev_attr_mode); device_remove_file(&tuxedo_platform_device->dev, &dev_attr_mode);
@ -689,7 +661,7 @@ tuxdeo_keyboard_exit(void)
if (keyboard.has_extra == 1) { if (keyboard.has_extra == 1) {
device_remove_file(&tuxedo_platform_device->dev, device_remove_file(&tuxedo_platform_device->dev,
&dev_attr_color_extra); &dev_attr_color_extra);
} }
platform_device_unregister(tuxedo_platform_device); platform_device_unregister(tuxedo_platform_device);