VSF Documented
driver.h
Go to the documentation of this file.
1#ifndef __VSF_LINUX_DEVICE_DRIVER_H__
2#define __VSF_LINUX_DEVICE_DRIVER_H__
3
4#include <linux/types.h>
5#include <linux/module.h>
6#include <linux/pm.h>
7#include <linux/device/bus.h>
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13#define module_driver(__driver, __register, __unregister, ...) \
14static void __init __driver##_init(void) \
15{ \
16 __register(&(__driver) , ##__VA_ARGS__); \
17} \
18module_init(__driver##_init); \
19static void __exit __driver##_exit(void) \
20{ \
21 __unregister(&(__driver) , ##__VA_ARGS__); \
22} \
23module_exit(__driver##_exit);
24
25#define module_driver_init(__driver) \
26module_run_init(__driver##_init)
27
29 const char *name;
30 struct bus_type *bus;
31
32 struct module *owner;
33 const char *mod_name;
34
35 int (*probe)(struct device *dev);
36 int (*remove)(struct device *dev);
37 void (*shutdown)(struct device *dev);
38 int (*suspend)(struct device *dev);
39 int (*resume)(struct device *dev);
40};
41
42static inline int driver_match_device(const struct device_driver *drv, struct device *dev)
43{
44 return drv->bus->match ? drv->bus->match(dev, (struct device_driver *)drv) : 1;
45}
46
47extern int driver_register(struct device_driver *drv);
48extern void driver_unregister(struct device_driver *drv);
49extern int driver_probe_device(const struct device_driver *drv, struct device *dev);
50
51#ifdef __cplusplus
52}
53#endif
54
55#endif
void driver_unregister(struct device_driver *drv)
Definition vsf_linux_core.c:630
int driver_register(struct device_driver *drv)
Definition vsf_linux_core.c:614
int driver_probe_device(const struct device_driver *drv, struct device *dev)
Definition vsf_linux_core.c:644
Definition bus.h:15
int(* match)(struct device *dev, struct device_driver *drv)
Definition bus.h:20
Definition driver.h:28
int(* resume)(struct device *dev)
Definition driver.h:39
const char * mod_name
Definition driver.h:33
struct module * owner
Definition driver.h:32
int(* remove)(struct device *dev)
Definition driver.h:36
const char * name
Definition driver.h:29
struct bus_type * bus
Definition driver.h:30
int(* probe)(struct device *dev)
Definition driver.h:35
void(* shutdown)(struct device *dev)
Definition driver.h:37
int(* suspend)(struct device *dev)
Definition driver.h:38
Definition device.h:33
Definition module.h:46
Generated from commit: vsfteam/vsf@f33b89f