xref: /openbmc/linux/drivers/hid/hid-vivaldi.c (revision 7b0364ea)
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * HID support for Vivaldi Keyboard
4  *
5  * Copyright 2020 Google LLC.
6  * Author: Sean O'Brien <seobrien@chromium.org>
7  */
8 
9 #include <linux/device.h>
10 #include <linux/hid.h>
11 #include <linux/input/vivaldi-fmap.h>
12 #include <linux/kernel.h>
13 #include <linux/module.h>
14 
15 #include "hid-vivaldi-common.h"
16 
17 static int vivaldi_probe(struct hid_device *hdev,
18 			 const struct hid_device_id *id)
19 {
20 	struct vivaldi_data *drvdata;
21 	int ret;
22 
23 	drvdata = devm_kzalloc(&hdev->dev, sizeof(*drvdata), GFP_KERNEL);
24 	if (!drvdata)
25 		return -ENOMEM;
26 
27 	hid_set_drvdata(hdev, drvdata);
28 
29 	ret = hid_parse(hdev);
30 	if (ret)
31 		return ret;
32 
33 	return hid_hw_start(hdev, HID_CONNECT_DEFAULT);
34 }
35 
36 static const struct hid_device_id vivaldi_table[] = {
37 	{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_VIVALDI, HID_ANY_ID, HID_ANY_ID) },
38 	{ }
39 };
40 
41 MODULE_DEVICE_TABLE(hid, vivaldi_table);
42 
43 static struct hid_driver hid_vivaldi = {
44 	.name = "hid-vivaldi",
45 	.id_table = vivaldi_table,
46 	.probe = vivaldi_probe,
47 	.feature_mapping = vivaldi_feature_mapping,
48 	.input_configured = vivaldi_input_configured,
49 };
50 
51 module_hid_driver(hid_vivaldi);
52 
53 MODULE_AUTHOR("Sean O'Brien");
54 MODULE_DESCRIPTION("HID vivaldi driver");
55 MODULE_LICENSE("GPL");
56