This source file includes following definitions.
- rcar_fcp_get
- rcar_fcp_put
- rcar_fcp_get_device
- rcar_fcp_enable
- rcar_fcp_disable
- rcar_fcp_probe
- rcar_fcp_remove
1
2
3
4
5
6
7
8
9
10 #include <linux/device.h>
11 #include <linux/list.h>
12 #include <linux/module.h>
13 #include <linux/mod_devicetable.h>
14 #include <linux/mutex.h>
15 #include <linux/platform_device.h>
16 #include <linux/pm_runtime.h>
17 #include <linux/slab.h>
18
19 #include <media/rcar-fcp.h>
20
21 struct rcar_fcp_device {
22 struct list_head list;
23 struct device *dev;
24 };
25
26 static LIST_HEAD(fcp_devices);
27 static DEFINE_MUTEX(fcp_lock);
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 struct rcar_fcp_device *rcar_fcp_get(const struct device_node *np)
44 {
45 struct rcar_fcp_device *fcp;
46
47 mutex_lock(&fcp_lock);
48
49 list_for_each_entry(fcp, &fcp_devices, list) {
50 if (fcp->dev->of_node != np)
51 continue;
52
53 get_device(fcp->dev);
54 goto done;
55 }
56
57 fcp = ERR_PTR(-EPROBE_DEFER);
58
59 done:
60 mutex_unlock(&fcp_lock);
61 return fcp;
62 }
63 EXPORT_SYMBOL_GPL(rcar_fcp_get);
64
65
66
67
68
69
70
71 void rcar_fcp_put(struct rcar_fcp_device *fcp)
72 {
73 if (fcp)
74 put_device(fcp->dev);
75 }
76 EXPORT_SYMBOL_GPL(rcar_fcp_put);
77
78 struct device *rcar_fcp_get_device(struct rcar_fcp_device *fcp)
79 {
80 return fcp->dev;
81 }
82 EXPORT_SYMBOL_GPL(rcar_fcp_get_device);
83
84
85
86
87
88
89
90
91
92
93
94
95
96 int rcar_fcp_enable(struct rcar_fcp_device *fcp)
97 {
98 int ret;
99
100 if (!fcp)
101 return 0;
102
103 ret = pm_runtime_get_sync(fcp->dev);
104 if (ret < 0)
105 return ret;
106
107 return 0;
108 }
109 EXPORT_SYMBOL_GPL(rcar_fcp_enable);
110
111
112
113
114
115
116
117
118 void rcar_fcp_disable(struct rcar_fcp_device *fcp)
119 {
120 if (fcp)
121 pm_runtime_put(fcp->dev);
122 }
123 EXPORT_SYMBOL_GPL(rcar_fcp_disable);
124
125
126
127
128
129 static int rcar_fcp_probe(struct platform_device *pdev)
130 {
131 struct rcar_fcp_device *fcp;
132
133 fcp = devm_kzalloc(&pdev->dev, sizeof(*fcp), GFP_KERNEL);
134 if (fcp == NULL)
135 return -ENOMEM;
136
137 fcp->dev = &pdev->dev;
138
139 pm_runtime_enable(&pdev->dev);
140
141 mutex_lock(&fcp_lock);
142 list_add_tail(&fcp->list, &fcp_devices);
143 mutex_unlock(&fcp_lock);
144
145 platform_set_drvdata(pdev, fcp);
146
147 return 0;
148 }
149
150 static int rcar_fcp_remove(struct platform_device *pdev)
151 {
152 struct rcar_fcp_device *fcp = platform_get_drvdata(pdev);
153
154 mutex_lock(&fcp_lock);
155 list_del(&fcp->list);
156 mutex_unlock(&fcp_lock);
157
158 pm_runtime_disable(&pdev->dev);
159
160 return 0;
161 }
162
163 static const struct of_device_id rcar_fcp_of_match[] = {
164 { .compatible = "renesas,fcpf" },
165 { .compatible = "renesas,fcpv" },
166 { },
167 };
168 MODULE_DEVICE_TABLE(of, rcar_fcp_of_match);
169
170 static struct platform_driver rcar_fcp_platform_driver = {
171 .probe = rcar_fcp_probe,
172 .remove = rcar_fcp_remove,
173 .driver = {
174 .name = "rcar-fcp",
175 .of_match_table = rcar_fcp_of_match,
176 .suppress_bind_attrs = true,
177 },
178 };
179
180 module_platform_driver(rcar_fcp_platform_driver);
181
182 MODULE_ALIAS("rcar-fcp");
183 MODULE_AUTHOR("Laurent Pinchart <laurent.pinchart@ideasonboard.com>");
184 MODULE_DESCRIPTION("Renesas FCP Driver");
185 MODULE_LICENSE("GPL");