1
2
3
4
5
6
7
8
9
10
11
12#ifndef _SUNXI_RSB_H
13#define _SUNXI_RSB_H
14
15#include <linux/device.h>
16#include <linux/regmap.h>
17#include <linux/types.h>
18
19struct sunxi_rsb;
20
21
22
23
24
25
26
27
28struct sunxi_rsb_device {
29 struct device dev;
30 struct sunxi_rsb *rsb;
31 int irq;
32 u8 rtaddr;
33 u16 hwaddr;
34};
35
36static inline struct sunxi_rsb_device *to_sunxi_rsb_device(struct device *d)
37{
38 return container_of(d, struct sunxi_rsb_device, dev);
39}
40
41static inline void *sunxi_rsb_device_get_drvdata(const struct sunxi_rsb_device *rdev)
42{
43 return dev_get_drvdata(&rdev->dev);
44}
45
46static inline void sunxi_rsb_device_set_drvdata(struct sunxi_rsb_device *rdev,
47 void *data)
48{
49 dev_set_drvdata(&rdev->dev, data);
50}
51
52
53
54
55
56
57
58
59struct sunxi_rsb_driver {
60 struct device_driver driver;
61 int (*probe)(struct sunxi_rsb_device *rdev);
62 int (*remove)(struct sunxi_rsb_device *rdev);
63};
64
65static inline struct sunxi_rsb_driver *to_sunxi_rsb_driver(struct device_driver *d)
66{
67 return container_of(d, struct sunxi_rsb_driver, driver);
68}
69
70int sunxi_rsb_driver_register(struct sunxi_rsb_driver *rdrv);
71
72
73
74
75
76static inline void sunxi_rsb_driver_unregister(struct sunxi_rsb_driver *rdrv)
77{
78 if (rdrv)
79 driver_unregister(&rdrv->driver);
80}
81
82#define module_sunxi_rsb_driver(__sunxi_rsb_driver) \
83 module_driver(__sunxi_rsb_driver, sunxi_rsb_driver_register, \
84 sunxi_rsb_driver_unregister)
85
86struct regmap *__devm_regmap_init_sunxi_rsb(struct sunxi_rsb_device *rdev,
87 const struct regmap_config *config,
88 struct lock_class_key *lock_key,
89 const char *lock_name);
90
91
92
93
94
95
96
97
98
99
100
101#define devm_regmap_init_sunxi_rsb(rdev, config) \
102 __regmap_lockdep_wrapper(__devm_regmap_init_sunxi_rsb, #config, \
103 rdev, config)
104
105#endif
106