10_lightning_node_pro_led: First working binded module
This commit is contained in:
parent
a407e656b6
commit
96c00a0dcc
5 changed files with 62 additions and 89 deletions
9
10_lightning_node_pro_led/Makefile
Normal file
9
10_lightning_node_pro_led/Makefile
Normal file
|
@ -0,0 +1,9 @@
|
|||
MODULE_NAME = lightning_node_pro_led
|
||||
|
||||
obj-m += $(MODULE_NAME).o
|
||||
|
||||
all:
|
||||
make -C $(LINUX_MODULES_FOLDER)/build M=$(PWD) modules
|
||||
|
||||
clean:
|
||||
make -C $(LINUX_MODULES_FOLDER)/build M=$(PWD) clean
|
19
10_lightning_node_pro_led/README.md
Normal file
19
10_lightning_node_pro_led/README.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
## Tips
|
||||
|
||||
1. Get info about device
|
||||
|
||||
```console
|
||||
$ lsusb -v -d <vendor_id>:<product_id>
|
||||
```
|
||||
|
||||
2. Check if device is attached to driver
|
||||
|
||||
```console
|
||||
$ ls /sys/bus/<bus_type>/drivers/<driver_name>
|
||||
```
|
||||
|
||||
If is attached to driver, it appear here.
|
||||
|
||||
## Usefull links
|
||||
|
||||
- https://github.com/torvalds/linux/blob/master/drivers/hid/hid-led.c
|
40
10_lightning_node_pro_led/lightning_node_pro_led.c
Normal file
40
10_lightning_node_pro_led/lightning_node_pro_led.c
Normal file
|
@ -0,0 +1,40 @@
|
|||
#include <linux/init.h>
|
||||
#include <linux/hid.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
#define USB_VENDOR_ID_CORSAIR 0x1b1c
|
||||
#define USB_DEVICE_ID_LIGHTNING_NODE_PRO 0x0c0b
|
||||
|
||||
static int lightning_node_pro_led_probe(struct hid_device *hdev,
|
||||
const struct hid_device_id *id)
|
||||
{
|
||||
pr_info("Détection USB pour Lightning Node Pro\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void lightning_node_pro_led_remove(struct hid_device *dev)
|
||||
{
|
||||
pr_info("Retrait USB pour Lightning Node Pro\n");
|
||||
}
|
||||
|
||||
static struct hid_device_id lightning_node_pro_led_table[] = {
|
||||
{ HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR,
|
||||
USB_DEVICE_ID_LIGHTNING_NODE_PRO) },
|
||||
{} /* Entrée de terminaison */
|
||||
};
|
||||
MODULE_DEVICE_TABLE(hid, lightning_node_pro_led_table);
|
||||
|
||||
static struct hid_driver lightning_node_pro_led_driver = {
|
||||
.name = "lightning-node-pro",
|
||||
.id_table = lightning_node_pro_led_table,
|
||||
.probe = lightning_node_pro_led_probe,
|
||||
.remove = lightning_node_pro_led_remove,
|
||||
};
|
||||
|
||||
module_hid_driver(lightning_node_pro_led_driver);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("Florian RICHER <florian.richer@protonmail.com>");
|
||||
MODULE_DESCRIPTION("Un module noyau pour utiliser le Lightning Node Pro LED");
|
||||
MODULE_VERSION("1.0");
|
Loading…
Add table
Add a link
Reference in a new issue