Add empty new driver

This commit is contained in:
Christoffer Sandberg 2020-05-29 16:20:02 +02:00
parent e74a3404a7
commit 3bb71064ae
No known key found for this signature in database
GPG key ID: BF563F71B6C7A96D
3 changed files with 87 additions and 11 deletions

View file

@ -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 <linux/module.h>
#include <linux/kernel.h>
@ -30,6 +29,7 @@
#include <linux/input/sparse-keymap.h>
#include "tuxedo_keyboard_common.h"
#include "clevo_keyboard.h"
#include "uniwill_keyboard.h"
MODULE_AUTHOR("TUXEDO Computers GmbH <tux@tuxedocomputers.com>");
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) {

View file

@ -20,6 +20,7 @@
#ifndef TUXEDO_KEYBOARD_COMMON_H
#define TUXEDO_KEYBOARD_COMMON_H
#include <linux/module.h>
#include <linux/input/sparse-keymap.h>
/* :::: 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;

63
src/uniwill_keyboard.h Normal file
View file

@ -0,0 +1,63 @@
/*
* uniwill_keyboard.h
*
* Copyright (C) 2018-2020 TUXEDO Computers GmbH <tux@tuxedocomputers.com>
*
* 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,
};