From 4d57e59887e298408aa7f1ebaa452ad64ec8b2dc Mon Sep 17 00:00:00 2001 From: Richard Sailer Date: Fri, 31 May 2019 21:50:52 +0200 Subject: [PATCH] Move module parameter handling from .h to .c file Other compilation units (CUs) including this header file do not need module parameter handling. It's specific to our CU. Header files are meant to communicate/interface with outside CUs --- src/tuxedo_keyboard.c | 45 +++++++++++++++++++++++++++++++++++++++++++ src/tuxedo_keyboard.h | 44 ------------------------------------------ 2 files changed, 45 insertions(+), 44 deletions(-) diff --git a/src/tuxedo_keyboard.c b/src/tuxedo_keyboard.c index 8271c11..8297d88 100644 --- a/src/tuxedo_keyboard.c +++ b/src/tuxedo_keyboard.c @@ -36,6 +36,51 @@ MODULE_VERSION("1.0.0"); struct platform_device *tuxedo_platform_device; static struct input_dev *tuxedo_input_device; +// Param Validators +static int mode_validator(const char *val, const struct kernel_param *kp); +static const struct kernel_param_ops param_ops_mode_ops = { + .set = mode_validator, + .get = param_get_int, +}; + +static int brightness_validator(const char *val, const struct kernel_param *kp); +static const struct kernel_param_ops param_ops_brightness_ops = { + .set = brightness_validator, + .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); +MODULE_PARM_DESC(color_left, "Color for the Left Section"); + +static uint param_color_center = KB_COLOR_DEFAULT; +module_param_named(color_center, param_color_center, uint, S_IRUSR); +MODULE_PARM_DESC(color_center, "Color for the Center Section"); + +static uint param_color_right = KB_COLOR_DEFAULT; +module_param_named(color_right, param_color_right, uint, S_IRUSR); +MODULE_PARM_DESC(color_right, "Color for the Right Right"); + +static uint param_color_extra = KB_COLOR_DEFAULT; +module_param_named(color_extra, param_color_extra, uint, S_IRUSR); +MODULE_PARM_DESC(color_extra, "Color for the Extra Section"); + +static ushort param_mode = DEFAULT_MODE; +module_param_cb(mode, ¶m_ops_mode_ops, ¶m_mode, S_IRUSR); +MODULE_PARM_DESC(mode, "Set the mode"); + +static ushort param_brightness = BRIGHTNESS_DEFAULT; +module_param_cb(brightness, ¶m_ops_brightness_ops, ¶m_brightness, + S_IRUSR); +MODULE_PARM_DESC(brightness, "Set the Keyboard Brightness"); + +static bool param_state = true; +module_param_named(state, param_state, bool, S_IRUSR); +MODULE_PARM_DESC(state, + "Set the State of the Keyboard TRUE = ON | FALSE = OFF"); + // Init and Exit methods static int __init tuxdeo_keyboard_init(void); static void __exit tuxdeo_keyboard_exit(void); diff --git a/src/tuxedo_keyboard.h b/src/tuxedo_keyboard.h index ad57e3f..597cb12 100644 --- a/src/tuxedo_keyboard.h +++ b/src/tuxedo_keyboard.h @@ -80,50 +80,6 @@ -// Param Validators -static int mode_validator(const char *val, const struct kernel_param *kp); -static const struct kernel_param_ops param_ops_mode_ops = { - .set = mode_validator, - .get = param_get_int, -}; - -static int brightness_validator(const char *val, const struct kernel_param *kp); -static const struct kernel_param_ops param_ops_brightness_ops = { - .set = brightness_validator, - .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); -MODULE_PARM_DESC(color_left, "Color for the Left Section"); - -static uint param_color_center = KB_COLOR_DEFAULT; -module_param_named(color_center, param_color_center, uint, S_IRUSR); -MODULE_PARM_DESC(color_center, "Color for the Center Section"); - -static uint param_color_right = KB_COLOR_DEFAULT; -module_param_named(color_right, param_color_right, uint, S_IRUSR); -MODULE_PARM_DESC(color_right, "Color for the Right Right"); - -static uint param_color_extra = KB_COLOR_DEFAULT; -module_param_named(color_extra, param_color_extra, uint, S_IRUSR); -MODULE_PARM_DESC(color_extra, "Color for the Extra Section"); - -static ushort param_mode = DEFAULT_MODE; -module_param_cb(mode, ¶m_ops_mode_ops, ¶m_mode, S_IRUSR); -MODULE_PARM_DESC(mode, "Set the mode"); - -static ushort param_brightness = BRIGHTNESS_DEFAULT; -module_param_cb(brightness, ¶m_ops_brightness_ops, ¶m_brightness, - S_IRUSR); -MODULE_PARM_DESC(brightness, "Set the Keyboard Brightness"); - -static bool param_state = true; -module_param_named(state, param_state, bool, S_IRUSR); -MODULE_PARM_DESC(state, - "Set the State of the Keyboard TRUE = ON | FALSE = OFF"); - // Sysfs device Attributes 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);