-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
64 lines (50 loc) · 1.3 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// SPDX-License-Identifier: GPL-2.0
#include <linux/module.h>
#include <linux/pci.h>
#include "debug.h"
#include "pci_ids.h"
#include "device.h"
static struct gpu_device *gpu_dev = NULL;
static int find_pci_dev (
void
){
struct pci_dev *pci_dev = NULL;
const struct pci_device_id *match;
while (NULL != (pci_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev))) {
match = pci_match_id(pciidlist, pci_dev);
if (match) {
gpu_dev = gpu_device_create(pci_dev, match->driver_data);
if (IS_ERR_OR_NULL(gpu_dev)) {
gpu_dev = NULL;
LIGHTS_ERR("Failed to create the gpu device");
return -ENODEV;
}
return 0;
}
}
return -ENODEV;
}
static int __init aura_module_init (
void
){
int err = find_pci_dev();
if (err) {
LIGHTS_ERR("Failed to find a valid pci device");
return 0;
}
atombios_i2c_init(gpu_dev);
return 0;
}
static void __exit aura_module_exit (
void
){
if (gpu_dev){
atombios_i2c_fini(gpu_dev);
gpu_device_destroy(gpu_dev);
}
}
module_init(aura_module_init);
module_exit(aura_module_exit);
MODULE_AUTHOR("Owen Parry <[email protected]>");
MODULE_DESCRIPTION("ASUS AURA SMBus driver");
MODULE_LICENSE("GPL");