From 3bb71064ae6a1e52f0568c930117f87a6d7ce79e Mon Sep 17 00:00:00 2001 From: Christoffer Sandberg Date: Fri, 29 May 2020 16:20:02 +0200 Subject: [PATCH] Add empty new driver --- src/tuxedo_keyboard.c | 30 ++++++++++------- src/tuxedo_keyboard_common.h | 5 +++ src/uniwill_keyboard.h | 63 ++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 11 deletions(-) create mode 100644 src/uniwill_keyboard.h diff --git a/src/tuxedo_keyboard.c b/src/tuxedo_keyboard.c index eec7d8f..e780cba 100644 --- a/src/tuxedo_keyboard.c +++ b/src/tuxedo_keyboard.c @@ -18,8 +18,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#define DRIVER_NAME "tuxedo_keyboard" -#define pr_fmt(fmt) DRIVER_NAME ": " fmt +#define pr_fmt(fmt) "tuxedo_keyboard" ": " fmt #include #include @@ -30,6 +29,7 @@ #include #include "tuxedo_keyboard_common.h" #include "clevo_keyboard.h" +#include "uniwill_keyboard.h" MODULE_AUTHOR("TUXEDO Computers GmbH "); MODULE_DESCRIPTION("TUXEDO Computers keyboard & keyboard backlight Driver"); @@ -39,6 +39,11 @@ MODULE_VERSION("2.0.4"); MODULE_ALIAS("wmi:" CLEVO_EVENT_GUID); MODULE_ALIAS("wmi:" CLEVO_GET_GUID); +static struct tuxedo_keyboard_driver *driver_list[] = { + &clevo_keyboard_driver, + &uniwill_keyboard_driver +}; + static int tuxedo_input_init(const struct key_entry key_map[]) { int err; @@ -90,24 +95,27 @@ static void __exit tuxedo_input_exit(void) static int __init tuxdeo_keyboard_init(void) { - int err; - + int i, err; + int num_drivers = sizeof(driver_list) / sizeof(*driver_list); TUXEDO_INFO("Model '%s' found\n", dmi_get_system_info(DMI_PRODUCT_NAME)); // Attempt to load each available driver // Associated probe decides if it fits // Driver from first successful probe is used - tuxedo_platform_device = - platform_create_bundle(clevo_keyboard_driver.platform_driver, - clevo_keyboard_driver.probe, NULL, 0, - NULL, 0); - if (IS_ERR(tuxedo_platform_device)) { + i = 0; + while (IS_ERR_OR_NULL(tuxedo_platform_device) && i < num_drivers) { + current_driver = driver_list[i]; + tuxedo_platform_device = platform_create_bundle( + current_driver->platform_driver, + current_driver->probe, NULL, 0, NULL, 0); + ++i; + } + + if (IS_ERR_OR_NULL(tuxedo_platform_device)) { TUXEDO_ERROR("No matching hardware found\n"); return -ENODEV; - } else { - current_driver = &clevo_keyboard_driver; } if (current_driver->key_map != NULL) { diff --git a/src/tuxedo_keyboard_common.h b/src/tuxedo_keyboard_common.h index cb75d0b..950db5f 100644 --- a/src/tuxedo_keyboard_common.h +++ b/src/tuxedo_keyboard_common.h @@ -20,6 +20,7 @@ #ifndef TUXEDO_KEYBOARD_COMMON_H #define TUXEDO_KEYBOARD_COMMON_H +#include #include /* :::: Module specific Constants and simple Macros :::: */ @@ -28,6 +29,10 @@ #define TUXEDO_ERROR(fmt, ...) __TUXEDO_PR(err, fmt, ##__VA_ARGS__) #define TUXEDO_DEBUG(fmt, ...) __TUXEDO_PR(debug, "[%s:%u] " fmt, __func__, __LINE__, ##__VA_ARGS__) +#ifndef DRIVER_NAME +#define DRIVER_NAME "tuxedo_keyboard" +#endif + struct tuxedo_keyboard_driver { // Platform driver provided by driver struct platform_driver *platform_driver; diff --git a/src/uniwill_keyboard.h b/src/uniwill_keyboard.h new file mode 100644 index 0000000..0b77252 --- /dev/null +++ b/src/uniwill_keyboard.h @@ -0,0 +1,63 @@ +/* +* uniwill_keyboard.h +* +* Copyright (C) 2018-2020 TUXEDO Computers GmbH +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +#include "tuxedo_keyboard_common.h" + +struct tuxedo_keyboard_driver uniwill_keyboard_driver; + +static struct key_entry uniwill_wmi_keymap[] = { + { KE_END, 0 } +}; + +static int uniwill_keyboard_probe(struct platform_device *dev) +{ + return -ENODEV; +} + +static int uniwill_keyboard_remove(struct platform_device *dev) +{ + return 0; +} + +static int uniwill_keyboard_suspend(struct platform_device *dev, pm_message_t state) +{ + return 0; +} + +static int uniwill_keyboard_resume(struct platform_device *dev) +{ + return 0; +} + +static struct platform_driver platform_driver_uniwill = { + .remove = uniwill_keyboard_remove, + .suspend = uniwill_keyboard_suspend, + .resume = uniwill_keyboard_resume, + .driver = + { + .name = DRIVER_NAME, + .owner = THIS_MODULE, + }, +}; + +struct tuxedo_keyboard_driver uniwill_keyboard_driver = { + .platform_driver = &platform_driver_uniwill, + .probe = uniwill_keyboard_probe, + .key_map = uniwill_wmi_keymap, +};