Blame view
drivers/visorbus/visorbus_main.c
38.3 KB
b79c0f4f5 staging: unisys: ... |
1 |
// SPDX-License-Identifier: GPL-2.0 |
060b293b9 staging: unisys: ... |
2 |
/* |
6f14cc18f staging: unisys: ... |
3 |
* Copyright � 2010 - 2015 UNISYS CORPORATION |
3703987cd staging: unisys: ... |
4 |
* All rights reserved. |
3703987cd staging: unisys: ... |
5 |
*/ |
b71d87b74 staging: unisys: ... |
6 |
#include <linux/ctype.h> |
8217becc1 staging: unisys: ... |
7 |
#include <linux/debugfs.h> |
eb6eb1e14 staging: unisys: ... |
8 9 |
#include <linux/module.h> #include <linux/slab.h> |
93d3ad90c drivers: visorbus... |
10 |
#include <linux/visorbus.h> |
3703987cd staging: unisys: ... |
11 |
#include <linux/uuid.h> |
c79b28f73 staging: unisys: ... |
12 |
#include "visorbus_private.h" |
4b78000ec staging: unisys: ... |
13 |
|
b32c5cb84 staging: unisys: ... |
14 |
static const guid_t visor_vbus_channel_guid = VISOR_VBUS_CHANNEL_GUID; |
060b293b9 staging: unisys: ... |
15 |
/* Display string that is guaranteed to be no longer the 99 characters */ |
38d56c2fa staging: unisys: ... |
16 |
#define LINESIZE 99 |
ffcdb1012 staging: unisys: ... |
17 |
#define POLLJIFFIES_NORMALCHANNEL 10 |
3703987cd staging: unisys: ... |
18 |
|
060b293b9 staging: unisys: ... |
19 20 |
/* stores whether bus_registration was successful */ static bool initialized; |
8217becc1 staging: unisys: ... |
21 |
static struct dentry *visorbus_debugfs_dir; |
6155a3cf1 staging: unisys: ... |
22 |
|
3fd1b3b68 staging: unisys: ... |
23 |
/* |
59fd2c8bd drivers, staging,... |
24 25 26 27 28 29 30 31 |
* DEVICE type attributes * * The modalias file will contain the guid of the device. */ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf) { struct visor_device *vdev; |
b32c5cb84 staging: unisys: ... |
32 |
const guid_t *guid; |
59fd2c8bd drivers, staging,... |
33 34 |
vdev = to_visor_device(dev); |
b32c5cb84 staging: unisys: ... |
35 36 37 |
guid = visorchannel_get_guid(vdev->visorchannel); return sprintf(buf, "visorbus:%pUl ", guid); |
59fd2c8bd drivers, staging,... |
38 39 40 41 42 43 44 |
} static DEVICE_ATTR_RO(modalias); static struct attribute *visorbus_dev_attrs[] = { &dev_attr_modalias.attr, NULL, }; |
aa5ebdeb5 staging: unisys: ... |
45 |
ATTRIBUTE_GROUPS(visorbus_dev); |
59fd2c8bd drivers, staging,... |
46 |
|
3703987cd staging: unisys: ... |
47 |
/* filled in with info about parent chipset driver when we register with it */ |
55c71ebaf staging: unisys: ... |
48 |
static struct visor_vbus_deviceinfo chipset_driverinfo; |
3703987cd staging: unisys: ... |
49 |
/* filled in with info about this driver, wrt it servicing client busses */ |
55c71ebaf staging: unisys: ... |
50 |
static struct visor_vbus_deviceinfo clientbus_driverinfo; |
3703987cd staging: unisys: ... |
51 |
|
3fd1b3b68 staging: unisys: ... |
52 |
/* list of visor_device structs, linked via .list_all */ |
3703987cd staging: unisys: ... |
53 |
static LIST_HEAD(list_all_bus_instances); |
3fd1b3b68 staging: unisys: ... |
54 |
/* list of visor_device structs, linked via .list_all */ |
3703987cd staging: unisys: ... |
55 |
static LIST_HEAD(list_all_device_instances); |
403043c4e staging: unisys: ... |
56 57 58 59 60 61 |
/* * Generic function useful for validating any type of channel when it is * received by the client that will be accessing the channel. * Note that <logCtx> is only needed for callers in the EFI environment, and * is used to pass the EFI_DIAG_CAPTURE_PROTOCOL needed to log messages. */ |
5f50a34a5 staging: unisys: ... |
62 63 64 |
int visor_check_channel(struct channel_header *ch, struct device *dev, const guid_t *expected_guid, char *chname, u64 expected_min_bytes, u32 expected_version, |
403043c4e staging: unisys: ... |
65 66 |
u64 expected_signature) { |
b32c5cb84 staging: unisys: ... |
67 |
if (!guid_is_null(expected_guid)) { |
403043c4e staging: unisys: ... |
68 |
/* caller wants us to verify type GUID */ |
b32c5cb84 staging: unisys: ... |
69 |
if (!guid_equal(&ch->chtype, expected_guid)) { |
e25201d66 staging: unisys: ... |
70 71 72 73 |
dev_err(dev, "Channel mismatch on channel=%s(%pUL) field=type expected=%pUL actual=%pUL ", chname, expected_guid, expected_guid, &ch->chtype); |
403043c4e staging: unisys: ... |
74 75 76 77 78 79 |
return 0; } } /* verify channel size */ if (expected_min_bytes > 0) { if (ch->size < expected_min_bytes) { |
e25201d66 staging: unisys: ... |
80 81 82 83 84 |
dev_err(dev, "Channel mismatch on channel=%s(%pUL) field=size expected=0x%-8.8Lx actual=0x%-8.8Lx ", chname, expected_guid, (unsigned long long)expected_min_bytes, ch->size); |
403043c4e staging: unisys: ... |
85 86 87 88 89 90 |
return 0; } } /* verify channel version */ if (expected_version > 0) { if (ch->version_id != expected_version) { |
e25201d66 staging: unisys: ... |
91 92 93 94 95 |
dev_err(dev, "Channel mismatch on channel=%s(%pUL) field=version expected=0x%-8.8lx actual=0x%-8.8x ", chname, expected_guid, (unsigned long)expected_version, ch->version_id); |
403043c4e staging: unisys: ... |
96 97 98 99 100 101 |
return 0; } } /* verify channel signature */ if (expected_signature > 0) { if (ch->signature != expected_signature) { |
e25201d66 staging: unisys: ... |
102 103 104 105 |
dev_err(dev, "Channel mismatch on channel=%s(%pUL) field=signature expected=0x%-8.8Lx actual=0x%-8.8Lx ", chname, expected_guid, expected_signature, ch->signature); |
403043c4e staging: unisys: ... |
106 107 108 109 110 |
return 0; } } return 1; } |
403043c4e staging: unisys: ... |
111 |
|
baf9b7054 staging: unisys: ... |
112 |
static int visorbus_uevent(struct device *xdev, struct kobj_uevent_env *env) |
3703987cd staging: unisys: ... |
113 |
{ |
59fd2c8bd drivers, staging,... |
114 |
struct visor_device *dev; |
b32c5cb84 staging: unisys: ... |
115 |
const guid_t *guid; |
59fd2c8bd drivers, staging,... |
116 117 |
dev = to_visor_device(xdev); |
b32c5cb84 staging: unisys: ... |
118 |
guid = visorchannel_get_guid(dev->visorchannel); |
b32c5cb84 staging: unisys: ... |
119 |
return add_uevent_var(env, "MODALIAS=visorbus:%pUl", guid); |
3703987cd staging: unisys: ... |
120 |
} |
b84be59a5 staging: unisys: ... |
121 |
/* |
3fd1b3b68 staging: unisys: ... |
122 123 124 125 126 127 128 |
* visorbus_match() - called automatically upon adding a visor_device * (device_add), or adding a visor_driver * (visorbus_register_visor_driver) * @xdev: struct device for the device being matched * @xdrv: struct device_driver for driver to match device against * * Return: 1 iff the provided driver can control the specified device |
3703987cd staging: unisys: ... |
129 |
*/ |
baf9b7054 staging: unisys: ... |
130 |
static int visorbus_match(struct device *xdev, struct device_driver *xdrv) |
3703987cd staging: unisys: ... |
131 |
{ |
b32c5cb84 staging: unisys: ... |
132 |
const guid_t *channel_type; |
3703987cd staging: unisys: ... |
133 134 135 |
int i; struct visor_device *dev; struct visor_driver *drv; |
cb3b5dccc staging: unisys: ... |
136 |
struct visorchannel *chan; |
3703987cd staging: unisys: ... |
137 138 |
dev = to_visor_device(xdev); |
b32c5cb84 staging: unisys: ... |
139 |
channel_type = visorchannel_get_guid(dev->visorchannel); |
d4e8a22e8 staging: unisys: ... |
140 |
drv = to_visor_driver(xdrv); |
cb3b5dccc staging: unisys: ... |
141 |
chan = dev->visorchannel; |
3703987cd staging: unisys: ... |
142 |
if (!drv->channel_types) |
8e33f48c9 staging: unisys: ... |
143 |
return 0; |
425eaf47e staging: unisys: ... |
144 |
for (i = 0; !guid_is_null(&drv->channel_types[i].guid); i++) |
cb3b5dccc staging: unisys: ... |
145 146 147 148 149 150 151 152 |
if (guid_equal(&drv->channel_types[i].guid, channel_type) && visor_check_channel(visorchannel_get_header(chan), xdev, &drv->channel_types[i].guid, (char *)drv->channel_types[i].name, drv->channel_types[i].min_bytes, drv->channel_types[i].version, VISOR_CHANNEL_SIGNATURE)) |
8e33f48c9 staging: unisys: ... |
153 |
return i + 1; |
8e33f48c9 staging: unisys: ... |
154 |
return 0; |
3703987cd staging: unisys: ... |
155 |
} |
7993b40cd staging: unisys: ... |
156 157 |
/* * This describes the TYPE of bus. |
060b293b9 staging: unisys: ... |
158 |
* (Don't confuse this with an INSTANCE of the bus.) |
7993b40cd staging: unisys: ... |
159 |
*/ |
69a4d1e75 staging: unisys: ... |
160 |
static struct bus_type visorbus_type = { |
7993b40cd staging: unisys: ... |
161 162 163 164 |
.name = "visorbus", .match = visorbus_match, .uevent = visorbus_uevent, .dev_groups = visorbus_dev_groups, |
7993b40cd staging: unisys: ... |
165 |
}; |
69a4d1e75 staging: unisys: ... |
166 167 168 169 |
struct visor_busdev { u32 bus_no; u32 dev_no; }; |
418e3ea15 bus_find_device: ... |
170 |
static int match_visorbus_dev_by_id(struct device *dev, const void *data) |
69a4d1e75 staging: unisys: ... |
171 172 |
{ struct visor_device *vdev = to_visor_device(dev); |
418e3ea15 bus_find_device: ... |
173 |
const struct visor_busdev *id = data; |
69a4d1e75 staging: unisys: ... |
174 |
|
614b083d7 staging: unisys: ... |
175 176 |
if (vdev->chipset_bus_no == id->bus_no && vdev->chipset_dev_no == id->dev_no) |
69a4d1e75 staging: unisys: ... |
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
return 1; return 0; } struct visor_device *visorbus_get_device_by_id(u32 bus_no, u32 dev_no, struct visor_device *from) { struct device *dev; struct device *dev_start = NULL; struct visor_busdev id = { .bus_no = bus_no, .dev_no = dev_no }; if (from) dev_start = &from->device; dev = bus_find_device(&visorbus_type, dev_start, (void *)&id, match_visorbus_dev_by_id); if (!dev) return NULL; return to_visor_device(dev); } |
b84be59a5 staging: unisys: ... |
199 |
/* |
ce4617ef9 staging: unisys: ... |
200 201 202 |
* visorbus_release_busdevice() - called when device_unregister() is called for * the bus device instance, after all other tasks * involved with destroying the dev are complete |
3fd1b3b68 staging: unisys: ... |
203 |
* @xdev: struct device for the bus being released |
3703987cd staging: unisys: ... |
204 |
*/ |
baf9b7054 staging: unisys: ... |
205 |
static void visorbus_release_busdevice(struct device *xdev) |
3703987cd staging: unisys: ... |
206 |
{ |
343506bf0 staging: unisys: ... |
207 |
struct visor_device *dev = dev_get_drvdata(xdev); |
3703987cd staging: unisys: ... |
208 |
|
1c218004a staging: unisys: ... |
209 |
debugfs_remove(dev->debugfs_bus_info); |
8217becc1 staging: unisys: ... |
210 |
debugfs_remove_recursive(dev->debugfs_dir); |
ae54a2879 staging: unisys: ... |
211 |
visorchannel_destroy(dev->visorchannel); |
343506bf0 staging: unisys: ... |
212 |
kfree(dev); |
3703987cd staging: unisys: ... |
213 |
} |
b84be59a5 staging: unisys: ... |
214 |
/* |
3fd1b3b68 staging: unisys: ... |
215 216 217 |
* visorbus_release_device() - called when device_unregister() is called for * each child device instance * @xdev: struct device for the visor device being released |
3703987cd staging: unisys: ... |
218 |
*/ |
baf9b7054 staging: unisys: ... |
219 |
static void visorbus_release_device(struct device *xdev) |
3703987cd staging: unisys: ... |
220 221 |
{ struct visor_device *dev = to_visor_device(xdev); |
d72e1a1c4 staging: unisys: ... |
222 |
visorchannel_destroy(dev->visorchannel); |
3703987cd staging: unisys: ... |
223 224 |
kfree(dev); } |
3fd1b3b68 staging: unisys: ... |
225 |
/* |
7915a3c45 staging: unisys: ... |
226 |
* BUS specific channel attributes to appear under |
3fd1b3b68 staging: unisys: ... |
227 228 |
* /sys/bus/visorbus<x>/dev<y>/channel */ |
795731627 staging: unisys: ... |
229 230 |
static ssize_t physaddr_show(struct device *dev, struct device_attribute *attr, char *buf) |
826b6a0f8 staging: unisys: ... |
231 |
{ |
795731627 staging: unisys: ... |
232 |
struct visor_device *vdev = to_visor_device(dev); |
7a41385e6 staging: unisys: ... |
233 234 235 |
return sprintf(buf, "0x%llx ", visorchannel_get_physaddr(vdev->visorchannel)); |
826b6a0f8 staging: unisys: ... |
236 |
} |
a25280b31 staging: unisys: ... |
237 |
static DEVICE_ATTR_RO(physaddr); |
826b6a0f8 staging: unisys: ... |
238 |
|
795731627 staging: unisys: ... |
239 240 |
static ssize_t nbytes_show(struct device *dev, struct device_attribute *attr, char *buf) |
826b6a0f8 staging: unisys: ... |
241 |
{ |
795731627 staging: unisys: ... |
242 |
struct visor_device *vdev = to_visor_device(dev); |
7a41385e6 staging: unisys: ... |
243 244 |
return sprintf(buf, "0x%lx ", |
da56cb048 staging: unisys: ... |
245 |
visorchannel_get_nbytes(vdev->visorchannel)); |
826b6a0f8 staging: unisys: ... |
246 |
} |
a25280b31 staging: unisys: ... |
247 |
static DEVICE_ATTR_RO(nbytes); |
826b6a0f8 staging: unisys: ... |
248 |
|
795731627 staging: unisys: ... |
249 250 251 252 |
static ssize_t clientpartition_show(struct device *dev, struct device_attribute *attr, char *buf) { struct visor_device *vdev = to_visor_device(dev); |
7a41385e6 staging: unisys: ... |
253 254 255 |
return sprintf(buf, "0x%llx ", visorchannel_get_clientpartition(vdev->visorchannel)); |
826b6a0f8 staging: unisys: ... |
256 |
} |
a25280b31 staging: unisys: ... |
257 |
static DEVICE_ATTR_RO(clientpartition); |
826b6a0f8 staging: unisys: ... |
258 |
|
795731627 staging: unisys: ... |
259 260 |
static ssize_t typeguid_show(struct device *dev, struct device_attribute *attr, char *buf) |
826b6a0f8 staging: unisys: ... |
261 |
{ |
795731627 staging: unisys: ... |
262 |
struct visor_device *vdev = to_visor_device(dev); |
38d56c2fa staging: unisys: ... |
263 |
char typeid[LINESIZE]; |
826b6a0f8 staging: unisys: ... |
264 |
|
7a41385e6 staging: unisys: ... |
265 266 267 |
return sprintf(buf, "%s ", visorchannel_id(vdev->visorchannel, typeid)); |
826b6a0f8 staging: unisys: ... |
268 |
} |
a25280b31 staging: unisys: ... |
269 |
static DEVICE_ATTR_RO(typeguid); |
826b6a0f8 staging: unisys: ... |
270 |
|
795731627 staging: unisys: ... |
271 272 |
static ssize_t zoneguid_show(struct device *dev, struct device_attribute *attr, char *buf) |
826b6a0f8 staging: unisys: ... |
273 |
{ |
795731627 staging: unisys: ... |
274 |
struct visor_device *vdev = to_visor_device(dev); |
38d56c2fa staging: unisys: ... |
275 |
char zoneid[LINESIZE]; |
826b6a0f8 staging: unisys: ... |
276 |
|
7a41385e6 staging: unisys: ... |
277 278 279 |
return sprintf(buf, "%s ", visorchannel_zoneid(vdev->visorchannel, zoneid)); |
826b6a0f8 staging: unisys: ... |
280 |
} |
a25280b31 staging: unisys: ... |
281 |
static DEVICE_ATTR_RO(zoneguid); |
826b6a0f8 staging: unisys: ... |
282 |
|
795731627 staging: unisys: ... |
283 284 |
static ssize_t typename_show(struct device *dev, struct device_attribute *attr, char *buf) |
826b6a0f8 staging: unisys: ... |
285 286 |
{ int i = 0; |
795731627 staging: unisys: ... |
287 288 |
struct bus_type *xbus = dev->bus; struct device_driver *xdrv = dev->driver; |
826b6a0f8 staging: unisys: ... |
289 |
struct visor_driver *drv = NULL; |
a3276bf32 staging: unisys: ... |
290 |
if (!xdrv) |
826b6a0f8 staging: unisys: ... |
291 |
return 0; |
795731627 staging: unisys: ... |
292 |
i = xbus->match(dev, xdrv); |
826b6a0f8 staging: unisys: ... |
293 294 295 |
if (!i) return 0; drv = to_visor_driver(xdrv); |
7a41385e6 staging: unisys: ... |
296 297 |
return sprintf(buf, "%s ", drv->channel_types[i - 1].name); |
826b6a0f8 staging: unisys: ... |
298 |
} |
795731627 staging: unisys: ... |
299 |
static DEVICE_ATTR_RO(typename); |
795731627 staging: unisys: ... |
300 301 |
static struct attribute *channel_attrs[] = { |
b372fee1d staging: unisys: ... |
302 303 304 305 306 307 308 |
&dev_attr_physaddr.attr, &dev_attr_nbytes.attr, &dev_attr_clientpartition.attr, &dev_attr_typeguid.attr, &dev_attr_zoneguid.attr, &dev_attr_typename.attr, NULL |
826b6a0f8 staging: unisys: ... |
309 |
}; |
aa5ebdeb5 staging: unisys: ... |
310 |
ATTRIBUTE_GROUPS(channel); |
826b6a0f8 staging: unisys: ... |
311 |
|
3fd1b3b68 staging: unisys: ... |
312 313 |
/* * BUS instance attributes |
3703987cd staging: unisys: ... |
314 315 |
* * define & implement display of bus attributes under |
3fd1b3b68 staging: unisys: ... |
316 |
* /sys/bus/visorbus/devices/visorbus<n>. |
3703987cd staging: unisys: ... |
317 |
*/ |
d181dd037 staging: unisys: ... |
318 |
static ssize_t partition_handle_show(struct device *dev, |
5f50a34a5 staging: unisys: ... |
319 |
struct device_attribute *attr, char *buf) |
7b9de71bd staging: unisys: ... |
320 |
{ |
5ecbd5d46 staging: unisys: ... |
321 322 |
struct visor_device *vdev = to_visor_device(dev); u64 handle = visorchannel_get_clientpartition(vdev->visorchannel); |
3703987cd staging: unisys: ... |
323 |
|
7a41385e6 staging: unisys: ... |
324 325 |
return sprintf(buf, "0x%llx ", handle); |
3703987cd staging: unisys: ... |
326 |
} |
a25280b31 staging: unisys: ... |
327 |
static DEVICE_ATTR_RO(partition_handle); |
3703987cd staging: unisys: ... |
328 |
|
d181dd037 staging: unisys: ... |
329 |
static ssize_t partition_guid_show(struct device *dev, |
5f50a34a5 staging: unisys: ... |
330 |
struct device_attribute *attr, char *buf) |
7b9de71bd staging: unisys: ... |
331 |
{ |
5ecbd5d46 staging: unisys: ... |
332 |
struct visor_device *vdev = to_visor_device(dev); |
3703987cd staging: unisys: ... |
333 |
|
b32c5cb84 staging: unisys: ... |
334 335 |
return sprintf(buf, "{%pUb} ", &vdev->partition_guid); |
3703987cd staging: unisys: ... |
336 |
} |
a25280b31 staging: unisys: ... |
337 |
static DEVICE_ATTR_RO(partition_guid); |
3703987cd staging: unisys: ... |
338 |
|
d181dd037 staging: unisys: ... |
339 |
static ssize_t partition_name_show(struct device *dev, |
5f50a34a5 staging: unisys: ... |
340 |
struct device_attribute *attr, char *buf) |
7b9de71bd staging: unisys: ... |
341 |
{ |
5ecbd5d46 staging: unisys: ... |
342 |
struct visor_device *vdev = to_visor_device(dev); |
3703987cd staging: unisys: ... |
343 |
|
7a41385e6 staging: unisys: ... |
344 345 |
return sprintf(buf, "%s ", vdev->name); |
3703987cd staging: unisys: ... |
346 |
} |
a25280b31 staging: unisys: ... |
347 |
static DEVICE_ATTR_RO(partition_name); |
3703987cd staging: unisys: ... |
348 |
|
d181dd037 staging: unisys: ... |
349 |
static ssize_t channel_addr_show(struct device *dev, |
5f50a34a5 staging: unisys: ... |
350 |
struct device_attribute *attr, char *buf) |
7b9de71bd staging: unisys: ... |
351 |
{ |
5ecbd5d46 staging: unisys: ... |
352 353 |
struct visor_device *vdev = to_visor_device(dev); u64 addr = visorchannel_get_physaddr(vdev->visorchannel); |
3703987cd staging: unisys: ... |
354 |
|
7a41385e6 staging: unisys: ... |
355 356 |
return sprintf(buf, "0x%llx ", addr); |
3703987cd staging: unisys: ... |
357 |
} |
a25280b31 staging: unisys: ... |
358 |
static DEVICE_ATTR_RO(channel_addr); |
3703987cd staging: unisys: ... |
359 |
|
d181dd037 staging: unisys: ... |
360 |
static ssize_t channel_bytes_show(struct device *dev, |
5f50a34a5 staging: unisys: ... |
361 |
struct device_attribute *attr, char *buf) |
7b9de71bd staging: unisys: ... |
362 |
{ |
5ecbd5d46 staging: unisys: ... |
363 364 |
struct visor_device *vdev = to_visor_device(dev); u64 nbytes = visorchannel_get_nbytes(vdev->visorchannel); |
3703987cd staging: unisys: ... |
365 |
|
7a41385e6 staging: unisys: ... |
366 367 |
return sprintf(buf, "0x%llx ", nbytes); |
3703987cd staging: unisys: ... |
368 |
} |
a25280b31 staging: unisys: ... |
369 |
static DEVICE_ATTR_RO(channel_bytes); |
3703987cd staging: unisys: ... |
370 |
|
d181dd037 staging: unisys: ... |
371 |
static ssize_t channel_id_show(struct device *dev, |
5f50a34a5 staging: unisys: ... |
372 |
struct device_attribute *attr, char *buf) |
7b9de71bd staging: unisys: ... |
373 |
{ |
5ecbd5d46 staging: unisys: ... |
374 |
struct visor_device *vdev = to_visor_device(dev); |
3703987cd staging: unisys: ... |
375 |
int len = 0; |
bf8d0e947 staging: unisys: ... |
376 377 378 379 |
visorchannel_id(vdev->visorchannel, buf); len = strlen(buf); buf[len++] = ' '; |
3703987cd staging: unisys: ... |
380 381 |
return len; } |
a25280b31 staging: unisys: ... |
382 |
static DEVICE_ATTR_RO(channel_id); |
3703987cd staging: unisys: ... |
383 |
|
aa5ebdeb5 staging: unisys: ... |
384 |
static struct attribute *visorbus_attrs[] = { |
b372fee1d staging: unisys: ... |
385 386 387 388 389 390 391 |
&dev_attr_partition_handle.attr, &dev_attr_partition_guid.attr, &dev_attr_partition_name.attr, &dev_attr_channel_addr.attr, &dev_attr_channel_bytes.attr, &dev_attr_channel_id.attr, NULL |
d181dd037 staging: unisys: ... |
392 |
}; |
3703987cd staging: unisys: ... |
393 |
|
aa5ebdeb5 staging: unisys: ... |
394 |
ATTRIBUTE_GROUPS(visorbus); |
3703987cd staging: unisys: ... |
395 |
|
8217becc1 staging: unisys: ... |
396 397 398 399 400 401 |
/* * BUS debugfs entries * * define & implement display of debugfs attributes under * /sys/kernel/debug/visorbus/visorbus<n>. */ |
d4e8a22e8 staging: unisys: ... |
402 |
|
738561a80 staging: unisys: ... |
403 |
/* |
55c71ebaf staging: unisys: ... |
404 |
* vbuschannel_print_devinfo() - format a struct visor_vbus_deviceinfo |
738561a80 staging: unisys: ... |
405 |
* and write it to a seq_file |
55c71ebaf staging: unisys: ... |
406 |
* @devinfo: the struct visor_vbus_deviceinfo to format |
738561a80 staging: unisys: ... |
407 408 409 410 411 412 |
* @seq: seq_file to write to * @devix: the device index to be included in the output data, or -1 if no * device index is to be included * * Reads @devInfo, and writes it in human-readable notation to @seq. */ |
baf9b7054 staging: unisys: ... |
413 414 |
static void vbuschannel_print_devinfo(struct visor_vbus_deviceinfo *devinfo, struct seq_file *seq, int devix) |
738561a80 staging: unisys: ... |
415 |
{ |
060b293b9 staging: unisys: ... |
416 |
/* uninitialized vbus device entry */ |
738561a80 staging: unisys: ... |
417 |
if (!isprint(devinfo->devtype[0])) |
060b293b9 staging: unisys: ... |
418 |
return; |
738561a80 staging: unisys: ... |
419 420 421 422 423 |
if (devix >= 0) seq_printf(seq, "[%d]", devix); else /* vbus device entry is for bus or chipset */ seq_puts(seq, " "); |
738561a80 staging: unisys: ... |
424 425 426 427 428 429 430 431 432 433 434 435 |
/* * Note: because the s-Par back-end is free to scribble in this area, * we never assume '\0'-termination. */ seq_printf(seq, "%-*.*s ", (int)sizeof(devinfo->devtype), (int)sizeof(devinfo->devtype), devinfo->devtype); seq_printf(seq, "%-*.*s ", (int)sizeof(devinfo->drvname), (int)sizeof(devinfo->drvname), devinfo->drvname); seq_printf(seq, "%.*s ", (int)sizeof(devinfo->infostrs), devinfo->infostrs); } |
8217becc1 staging: unisys: ... |
436 |
|
1c218004a staging: unisys: ... |
437 |
static int bus_info_debugfs_show(struct seq_file *seq, void *v) |
8217becc1 staging: unisys: ... |
438 |
{ |
d4e8a22e8 staging: unisys: ... |
439 |
int i = 0; |
8217becc1 staging: unisys: ... |
440 |
unsigned long off; |
55c71ebaf staging: unisys: ... |
441 |
struct visor_vbus_deviceinfo dev_info; |
d4e8a22e8 staging: unisys: ... |
442 443 |
struct visor_device *vdev = seq->private; struct visorchannel *channel = vdev->visorchannel; |
8217becc1 staging: unisys: ... |
444 445 446 447 448 |
if (!channel) return 0; seq_printf(seq, |
453ca1938 staging: unisys: ... |
449 450 |
"Client device/driver info for %s partition (vbus #%u): ", |
8217becc1 staging: unisys: ... |
451 452 453 |
((vdev->name) ? (char *)(vdev->name) : ""), vdev->chipset_bus_no); if (visorchannel_read(channel, |
55c71ebaf staging: unisys: ... |
454 |
offsetof(struct visor_vbus_channel, chp_info), |
8217becc1 staging: unisys: ... |
455 456 457 |
&dev_info, sizeof(dev_info)) >= 0) vbuschannel_print_devinfo(&dev_info, seq, -1); if (visorchannel_read(channel, |
55c71ebaf staging: unisys: ... |
458 |
offsetof(struct visor_vbus_channel, bus_info), |
8217becc1 staging: unisys: ... |
459 460 |
&dev_info, sizeof(dev_info)) >= 0) vbuschannel_print_devinfo(&dev_info, seq, -1); |
d4e8a22e8 staging: unisys: ... |
461 |
|
55c71ebaf staging: unisys: ... |
462 |
off = offsetof(struct visor_vbus_channel, dev_info); |
8217becc1 staging: unisys: ... |
463 464 465 466 467 468 469 |
while (off + sizeof(dev_info) <= visorchannel_get_nbytes(channel)) { if (visorchannel_read(channel, off, &dev_info, sizeof(dev_info)) >= 0) vbuschannel_print_devinfo(&dev_info, seq, i); off += sizeof(dev_info); i++; } |
8217becc1 staging: unisys: ... |
470 471 |
return 0; } |
1c218004a staging: unisys: ... |
472 |
static int bus_info_debugfs_open(struct inode *inode, struct file *file) |
8217becc1 staging: unisys: ... |
473 |
{ |
1c218004a staging: unisys: ... |
474 |
return single_open(file, bus_info_debugfs_show, inode->i_private); |
8217becc1 staging: unisys: ... |
475 |
} |
1c218004a staging: unisys: ... |
476 |
static const struct file_operations bus_info_debugfs_fops = { |
8217becc1 staging: unisys: ... |
477 |
.owner = THIS_MODULE, |
1c218004a staging: unisys: ... |
478 |
.open = bus_info_debugfs_open, |
8217becc1 staging: unisys: ... |
479 480 481 482 |
.read = seq_read, .llseek = seq_lseek, .release = single_release, }; |
e99e88a9d treewide: setup_t... |
483 |
static void dev_periodic_work(struct timer_list *t) |
3703987cd staging: unisys: ... |
484 |
{ |
e99e88a9d treewide: setup_t... |
485 |
struct visor_device *dev = from_timer(dev, t, timer); |
3703987cd staging: unisys: ... |
486 |
struct visor_driver *drv = to_visor_driver(dev->device.driver); |
396e36c9a staging: unisys: ... |
487 |
drv->channel_interrupt(dev); |
9ebab6495 staging: unisys: ... |
488 |
mod_timer(&dev->timer, jiffies + POLLJIFFIES_NORMALCHANNEL); |
3703987cd staging: unisys: ... |
489 |
} |
baf9b7054 staging: unisys: ... |
490 |
static int dev_start_periodic_work(struct visor_device *dev) |
3703987cd staging: unisys: ... |
491 |
{ |
9ebab6495 staging: unisys: ... |
492 |
if (dev->being_removed || dev->timer_active) |
b90194d9b staging: unisys: ... |
493 |
return -EINVAL; |
4e95347b1 staging: unisys: ... |
494 |
|
3703987cd staging: unisys: ... |
495 496 |
/* now up by at least 2 */ get_device(&dev->device); |
9ebab6495 staging: unisys: ... |
497 498 499 |
dev->timer.expires = jiffies + POLLJIFFIES_NORMALCHANNEL; add_timer(&dev->timer); dev->timer_active = true; |
b90194d9b staging: unisys: ... |
500 |
return 0; |
3703987cd staging: unisys: ... |
501 |
} |
baf9b7054 staging: unisys: ... |
502 |
static void dev_stop_periodic_work(struct visor_device *dev) |
3703987cd staging: unisys: ... |
503 |
{ |
9ebab6495 staging: unisys: ... |
504 505 |
if (!dev->timer_active) return; |
4e95347b1 staging: unisys: ... |
506 |
|
9ebab6495 staging: unisys: ... |
507 508 509 |
del_timer_sync(&dev->timer); dev->timer_active = false; put_device(&dev->device); |
3703987cd staging: unisys: ... |
510 |
} |
b84be59a5 staging: unisys: ... |
511 |
/* |
3fd1b3b68 staging: unisys: ... |
512 513 514 515 516 517 518 519 |
* visordriver_remove_device() - handle visor device going away * @xdev: struct device for the visor device being removed * * This is called when device_unregister() is called for each child device * instance, to notify the appropriate visorbus function driver that the device * is going away, and to decrease the reference count of the device. * * Return: 0 iff successful |
3703987cd staging: unisys: ... |
520 |
*/ |
baf9b7054 staging: unisys: ... |
521 |
static int visordriver_remove_device(struct device *xdev) |
3703987cd staging: unisys: ... |
522 |
{ |
7f91228d3 staging: unisys: ... |
523 524 |
struct visor_device *dev = to_visor_device(xdev); struct visor_driver *drv = to_visor_driver(xdev->driver); |
d4e8a22e8 staging: unisys: ... |
525 |
|
d505855e5 staging: unisys: ... |
526 |
mutex_lock(&dev->visordriver_callback_lock); |
779d0752b staging: unisys: ... |
527 |
dev->being_removed = true; |
c2d00b218 staging: unisys: ... |
528 |
drv->remove(dev); |
d505855e5 staging: unisys: ... |
529 |
mutex_unlock(&dev->visordriver_callback_lock); |
d4e8a22e8 staging: unisys: ... |
530 |
dev_stop_periodic_work(dev); |
3703987cd staging: unisys: ... |
531 |
put_device(&dev->device); |
df7f46e83 staging: unisys: ... |
532 |
return 0; |
3703987cd staging: unisys: ... |
533 |
} |
060b293b9 staging: unisys: ... |
534 |
/* |
3fd1b3b68 staging: unisys: ... |
535 536 537 538 539 |
* visorbus_unregister_visor_driver() - unregisters the provided driver * @drv: the driver to unregister * * A visor function driver calls this function to unregister the driver, * i.e., within its module_exit function. |
3703987cd staging: unisys: ... |
540 |
*/ |
baf9b7054 staging: unisys: ... |
541 |
void visorbus_unregister_visor_driver(struct visor_driver *drv) |
3703987cd staging: unisys: ... |
542 |
{ |
3703987cd staging: unisys: ... |
543 544 545 |
driver_unregister(&drv->driver); } EXPORT_SYMBOL_GPL(visorbus_unregister_visor_driver); |
060b293b9 staging: unisys: ... |
546 |
/* |
3fd1b3b68 staging: unisys: ... |
547 548 549 550 551 552 553 |
* visorbus_read_channel() - reads from the designated channel into * the provided buffer * @dev: the device whose channel is read from * @offset: the offset into the channel at which reading starts * @dest: the destination buffer that is written into from the channel * @nbytes: the number of bytes to read from the channel * |
7915a3c45 staging: unisys: ... |
554 |
* If receiving a message, use the visorchannel_signalremove() function instead. |
3fd1b3b68 staging: unisys: ... |
555 556 557 |
* * Return: integer indicating success (zero) or failure (non-zero) */ |
baf9b7054 staging: unisys: ... |
558 559 |
int visorbus_read_channel(struct visor_device *dev, unsigned long offset, void *dest, unsigned long nbytes) |
3703987cd staging: unisys: ... |
560 561 562 563 |
{ return visorchannel_read(dev->visorchannel, offset, dest, nbytes); } EXPORT_SYMBOL_GPL(visorbus_read_channel); |
060b293b9 staging: unisys: ... |
564 |
/* |
3fd1b3b68 staging: unisys: ... |
565 566 567 568 569 570 571 |
* visorbus_write_channel() - writes the provided buffer into the designated * channel * @dev: the device whose channel is written to * @offset: the offset into the channel at which writing starts * @src: the source buffer that is written into the channel * @nbytes: the number of bytes to write into the channel * |
7915a3c45 staging: unisys: ... |
572 |
* If sending a message, use the visorchannel_signalinsert() function instead. |
3fd1b3b68 staging: unisys: ... |
573 574 575 |
* * Return: integer indicating success (zero) or failure (non-zero) */ |
baf9b7054 staging: unisys: ... |
576 577 |
int visorbus_write_channel(struct visor_device *dev, unsigned long offset, void *src, unsigned long nbytes) |
3703987cd staging: unisys: ... |
578 579 580 581 |
{ return visorchannel_write(dev->visorchannel, offset, src, nbytes); } EXPORT_SYMBOL_GPL(visorbus_write_channel); |
060b293b9 staging: unisys: ... |
582 |
/* |
3fd1b3b68 staging: unisys: ... |
583 584 585 586 587 588 |
* visorbus_enable_channel_interrupts() - enables interrupts on the * designated device * @dev: the device on which to enable interrupts * * Currently we don't yet have a real interrupt, so for now we just call the * interrupt function periodically via a timer. |
3703987cd staging: unisys: ... |
589 |
*/ |
baf9b7054 staging: unisys: ... |
590 |
int visorbus_enable_channel_interrupts(struct visor_device *dev) |
3703987cd staging: unisys: ... |
591 |
{ |
396e36c9a staging: unisys: ... |
592 593 594 595 596 |
struct visor_driver *drv = to_visor_driver(dev->device.driver); if (!drv->channel_interrupt) { dev_err(&dev->device, "%s no interrupt function! ", __func__); |
5dca9b294 staging: unisys: ... |
597 |
return -ENOENT; |
396e36c9a staging: unisys: ... |
598 |
} |
5dca9b294 staging: unisys: ... |
599 |
return dev_start_periodic_work(dev); |
3703987cd staging: unisys: ... |
600 601 |
} EXPORT_SYMBOL_GPL(visorbus_enable_channel_interrupts); |
060b293b9 staging: unisys: ... |
602 |
/* |
3fd1b3b68 staging: unisys: ... |
603 604 605 606 |
* visorbus_disable_channel_interrupts() - disables interrupts on the * designated device * @dev: the device on which to disable interrupts */ |
baf9b7054 staging: unisys: ... |
607 |
void visorbus_disable_channel_interrupts(struct visor_device *dev) |
3703987cd staging: unisys: ... |
608 609 610 611 |
{ dev_stop_periodic_work(dev); } EXPORT_SYMBOL_GPL(visorbus_disable_channel_interrupts); |
b84be59a5 staging: unisys: ... |
612 |
/* |
3fd1b3b68 staging: unisys: ... |
613 614 615 616 617 618 619 |
* create_visor_device() - create visor device as a result of receiving the * controlvm device_create message for a new device * @dev: a freshly-zeroed struct visor_device, containing only filled-in values * for chipset_bus_no and chipset_dev_no, that will be initialized * * This is how everything starts from the device end. * This function is called when a channel first appears via a ControlVM |
7915a3c45 staging: unisys: ... |
620 621 622 623 624 |
* message. In response, this function allocates a visor_device to correspond * to the new channel, and attempts to connect it the appropriate * driver. If * the appropriate driver is found, the visor_driver.probe() function for that * driver will be called, and will be passed the new * visor_device that we * just created. |
3703987cd staging: unisys: ... |
625 |
* |
3fd1b3b68 staging: unisys: ... |
626 627 628 |
* It's ok if the appropriate driver is not yet loaded, because in that case * the new device struct will just stick around in the bus' list of devices. * When the appropriate driver calls visorbus_register_visor_driver(), the |
7915a3c45 staging: unisys: ... |
629 |
* visor_driver.probe() for the new driver will be called with the new device. |
3fd1b3b68 staging: unisys: ... |
630 631 632 |
* * Return: 0 if successful, otherwise the negative value returned by * device_add() indicating the reason for failure |
3703987cd staging: unisys: ... |
633 |
*/ |
51c0f81cc staging: unisys: ... |
634 |
int create_visor_device(struct visor_device *dev) |
3703987cd staging: unisys: ... |
635 |
{ |
0b2acf34f staging: unisys: ... |
636 |
int err; |
a298bc0b5 staging: unisys: ... |
637 638 |
u32 chipset_bus_no = dev->chipset_bus_no; u32 chipset_dev_no = dev->chipset_dev_no; |
3703987cd staging: unisys: ... |
639 |
|
d505855e5 staging: unisys: ... |
640 |
mutex_init(&dev->visordriver_callback_lock); |
3703987cd staging: unisys: ... |
641 |
dev->device.bus = &visorbus_type; |
aa5ebdeb5 staging: unisys: ... |
642 |
dev->device.groups = channel_groups; |
3703987cd staging: unisys: ... |
643 644 645 646 |
device_initialize(&dev->device); dev->device.release = visorbus_release_device; /* keep a reference just for us (now 2) */ get_device(&dev->device); |
e99e88a9d treewide: setup_t... |
647 |
timer_setup(&dev->timer, dev_periodic_work, 0); |
3fd1b3b68 staging: unisys: ... |
648 |
/* |
7915a3c45 staging: unisys: ... |
649 650 651 |
* bus_id must be a unique name with respect to this bus TYPE (NOT bus * instance). That's why we need to include the bus number within the * name. |
3703987cd staging: unisys: ... |
652 |
*/ |
e0d210ae5 staging: unisys: ... |
653 654 655 656 |
err = dev_set_name(&dev->device, "vbus%u:dev%u", chipset_bus_no, chipset_dev_no); if (err) goto err_put; |
3fd1b3b68 staging: unisys: ... |
657 658 |
/* * device_add does this: |
3703987cd staging: unisys: ... |
659 660 661 662 663 664 665 666 667 668 669 |
* bus_add_device(dev) * ->device_attach(dev) * ->for each driver drv registered on the bus that dev is on * if (dev.drv) ** device already has a driver ** * ** not sure we could ever get here... ** * else * if (bus.match(dev,drv)) [visorbus_match] * dev.drv = drv * if (!drv.probe(dev)) [visordriver_probe_device] * dev.drv = NULL * |
7915a3c45 staging: unisys: ... |
670 671 672 |
* Note that device_add does NOT fail if no driver failed to claim the * device. The device will be linked onto bus_type.klist_devices * regardless (use bus_for_each_dev). |
3703987cd staging: unisys: ... |
673 |
*/ |
0b2acf34f staging: unisys: ... |
674 |
err = device_add(&dev->device); |
ebdc1b883 staging: unisys: ... |
675 |
if (err < 0) |
0b2acf34f staging: unisys: ... |
676 |
goto err_put; |
a298bc0b5 staging: unisys: ... |
677 |
list_add_tail(&dev->list_all, &list_all_device_instances); |
51c0f81cc staging: unisys: ... |
678 679 |
dev->state.created = 1; visorbus_response(dev, err, CONTROLVM_DEVICE_CREATE); |
060b293b9 staging: unisys: ... |
680 681 |
/* success: reference kept via unmatched get_device() */ return 0; |
3703987cd staging: unisys: ... |
682 |
|
0b2acf34f staging: unisys: ... |
683 |
err_put: |
a298bc0b5 staging: unisys: ... |
684 |
put_device(&dev->device); |
ebdc1b883 staging: unisys: ... |
685 686 |
dev_err(&dev->device, "Creating visor device failed. %d ", err); |
0b2acf34f staging: unisys: ... |
687 |
return err; |
3703987cd staging: unisys: ... |
688 |
} |
b74856b41 staging: unisys: ... |
689 |
void remove_visor_device(struct visor_device *dev) |
3703987cd staging: unisys: ... |
690 691 |
{ list_del(&dev->list_all); |
3703987cd staging: unisys: ... |
692 |
put_device(&dev->device); |
fd9e450cf staging: unisys: ... |
693 694 |
if (dev->pending_msg_hdr) visorbus_response(dev, 0, CONTROLVM_DEVICE_DESTROY); |
3703987cd staging: unisys: ... |
695 696 |
device_unregister(&dev->device); } |
baf9b7054 staging: unisys: ... |
697 |
static int get_vbus_header_info(struct visorchannel *chan, |
e25201d66 staging: unisys: ... |
698 |
struct device *dev, |
baf9b7054 staging: unisys: ... |
699 |
struct visor_vbus_headerinfo *hdr_info) |
3703987cd staging: unisys: ... |
700 |
{ |
711c67f4e staging: unisys: ... |
701 |
int err; |
315dfc84d staging: unisys: ... |
702 |
if (!visor_check_channel(visorchannel_get_header(chan), |
e25201d66 staging: unisys: ... |
703 |
dev, |
b32c5cb84 staging: unisys: ... |
704 |
&visor_vbus_channel_guid, |
315dfc84d staging: unisys: ... |
705 706 707 |
"vbus", sizeof(struct visor_vbus_channel), VISOR_VBUS_CHANNEL_VERSIONID, |
e9b9275c3 staging: unisys: ... |
708 |
VISOR_CHANNEL_SIGNATURE)) |
f748f64f0 staging: unisys: ... |
709 |
return -EINVAL; |
711c67f4e staging: unisys: ... |
710 711 712 713 |
err = visorchannel_read(chan, sizeof(struct channel_header), hdr_info, sizeof(*hdr_info)); if (err < 0) return err; |
55c71ebaf staging: unisys: ... |
714 |
if (hdr_info->struct_bytes < sizeof(struct visor_vbus_headerinfo)) |
f748f64f0 staging: unisys: ... |
715 |
return -EINVAL; |
3703987cd staging: unisys: ... |
716 |
if (hdr_info->device_info_struct_bytes < |
55c71ebaf staging: unisys: ... |
717 |
sizeof(struct visor_vbus_deviceinfo)) |
f748f64f0 staging: unisys: ... |
718 |
return -EINVAL; |
f748f64f0 staging: unisys: ... |
719 |
return 0; |
3703987cd staging: unisys: ... |
720 |
} |
b84be59a5 staging: unisys: ... |
721 |
/* |
3fd1b3b68 staging: unisys: ... |
722 |
* write_vbus_chp_info() - write the contents of <info> to the struct |
55c71ebaf staging: unisys: ... |
723 |
* visor_vbus_channel.chp_info |
3fd1b3b68 staging: unisys: ... |
724 725 726 727 728 729 |
* @chan: indentifies the s-Par channel that will be updated * @hdr_info: used to find appropriate channel offset to write data * @info: contains the information to write * * Writes chipset info into the channel memory to be used for diagnostic * purposes. |
ff13cf37f staging: unisys: ... |
730 |
* |
3fd1b3b68 staging: unisys: ... |
731 |
* Returns no value since this is debug information and not needed for |
ff13cf37f staging: unisys: ... |
732 |
* device functionality. |
481178950 staging: unisys: ... |
733 |
*/ |
baf9b7054 staging: unisys: ... |
734 735 736 |
static void write_vbus_chp_info(struct visorchannel *chan, struct visor_vbus_headerinfo *hdr_info, struct visor_vbus_deviceinfo *info) |
3703987cd staging: unisys: ... |
737 |
{ |
5d1a7fd75 staging: unisys: ... |
738 |
int off; |
3703987cd staging: unisys: ... |
739 740 |
if (hdr_info->chp_info_offset == 0) |
ff13cf37f staging: unisys: ... |
741 |
return; |
3703987cd staging: unisys: ... |
742 |
|
5d1a7fd75 staging: unisys: ... |
743 |
off = sizeof(struct channel_header) + hdr_info->chp_info_offset; |
ff13cf37f staging: unisys: ... |
744 |
visorchannel_write(chan, off, info, sizeof(*info)); |
3703987cd staging: unisys: ... |
745 |
} |
b84be59a5 staging: unisys: ... |
746 |
/* |
3fd1b3b68 staging: unisys: ... |
747 |
* write_vbus_bus_info() - write the contents of <info> to the struct |
55c71ebaf staging: unisys: ... |
748 |
* visor_vbus_channel.bus_info |
3fd1b3b68 staging: unisys: ... |
749 750 751 752 753 754 |
* @chan: indentifies the s-Par channel that will be updated * @hdr_info: used to find appropriate channel offset to write data * @info: contains the information to write * * Writes bus info into the channel memory to be used for diagnostic * purposes. |
ff13cf37f staging: unisys: ... |
755 |
* |
3fd1b3b68 staging: unisys: ... |
756 |
* Returns no value since this is debug information and not needed for |
ff13cf37f staging: unisys: ... |
757 |
* device functionality. |
481178950 staging: unisys: ... |
758 |
*/ |
baf9b7054 staging: unisys: ... |
759 760 761 |
static void write_vbus_bus_info(struct visorchannel *chan, struct visor_vbus_headerinfo *hdr_info, struct visor_vbus_deviceinfo *info) |
3703987cd staging: unisys: ... |
762 |
{ |
5d1a7fd75 staging: unisys: ... |
763 |
int off; |
3703987cd staging: unisys: ... |
764 765 |
if (hdr_info->bus_info_offset == 0) |
ff13cf37f staging: unisys: ... |
766 |
return; |
4e95347b1 staging: unisys: ... |
767 |
|
5d1a7fd75 staging: unisys: ... |
768 |
off = sizeof(struct channel_header) + hdr_info->bus_info_offset; |
ff13cf37f staging: unisys: ... |
769 |
visorchannel_write(chan, off, info, sizeof(*info)); |
3703987cd staging: unisys: ... |
770 |
} |
b84be59a5 staging: unisys: ... |
771 |
/* |
3fd1b3b68 staging: unisys: ... |
772 |
* write_vbus_dev_info() - write the contents of <info> to the struct |
55c71ebaf staging: unisys: ... |
773 |
* visor_vbus_channel.dev_info[<devix>] |
3fd1b3b68 staging: unisys: ... |
774 775 776 777 |
* @chan: indentifies the s-Par channel that will be updated * @hdr_info: used to find appropriate channel offset to write data * @info: contains the information to write * @devix: the relative device number (0..n-1) of the device on the bus |
ff13cf37f staging: unisys: ... |
778 |
* |
3fd1b3b68 staging: unisys: ... |
779 780 781 782 |
* Writes device info into the channel memory to be used for diagnostic * purposes. * * Returns no value since this is debug information and not needed for |
ff13cf37f staging: unisys: ... |
783 |
* device functionality. |
3703987cd staging: unisys: ... |
784 |
*/ |
baf9b7054 staging: unisys: ... |
785 786 787 788 |
static void write_vbus_dev_info(struct visorchannel *chan, struct visor_vbus_headerinfo *hdr_info, struct visor_vbus_deviceinfo *info, unsigned int devix) |
3703987cd staging: unisys: ... |
789 |
{ |
5d1a7fd75 staging: unisys: ... |
790 |
int off; |
3703987cd staging: unisys: ... |
791 792 |
if (hdr_info->dev_info_offset == 0) |
ff13cf37f staging: unisys: ... |
793 |
return; |
5d1a7fd75 staging: unisys: ... |
794 795 |
off = (sizeof(struct channel_header) + hdr_info->dev_info_offset) + (hdr_info->device_info_struct_bytes * devix); |
ff13cf37f staging: unisys: ... |
796 |
visorchannel_write(chan, off, info, sizeof(*info)); |
3703987cd staging: unisys: ... |
797 |
} |
b5577d79e staging: unisys: ... |
798 |
static void bus_device_info_init( |
55c71ebaf staging: unisys: ... |
799 |
struct visor_vbus_deviceinfo *bus_device_info_ptr, |
b5577d79e staging: unisys: ... |
800 801 |
const char *dev_type, const char *drv_name) { |
55c71ebaf staging: unisys: ... |
802 |
memset(bus_device_info_ptr, 0, sizeof(struct visor_vbus_deviceinfo)); |
b5577d79e staging: unisys: ... |
803 804 805 806 807 808 809 810 811 812 |
snprintf(bus_device_info_ptr->devtype, sizeof(bus_device_info_ptr->devtype), "%s", (dev_type) ? dev_type : "unknownType"); snprintf(bus_device_info_ptr->drvname, sizeof(bus_device_info_ptr->drvname), "%s", (drv_name) ? drv_name : "unknownDriver"); snprintf(bus_device_info_ptr->infostrs, sizeof(bus_device_info_ptr->infostrs), "kernel ver. %s", utsname()->release); } |
b84be59a5 staging: unisys: ... |
813 |
/* |
e3b2ed666 staging: unisys: ... |
814 815 816 817 |
* publish_vbus_dev_info() - for a child device just created on a client bus, * fill in information about the driver that is * controlling this device into the appropriate slot * within the vbus channel of the bus instance |
3fd1b3b68 staging: unisys: ... |
818 |
* @visordev: struct visor_device for the desired device |
3703987cd staging: unisys: ... |
819 |
*/ |
e3b2ed666 staging: unisys: ... |
820 |
static void publish_vbus_dev_info(struct visor_device *visordev) |
3703987cd staging: unisys: ... |
821 822 |
{ int i; |
d32517e39 staging: unisys: ... |
823 |
struct visor_device *bdev; |
3703987cd staging: unisys: ... |
824 |
struct visor_driver *visordrv; |
f7a34ff7c staging: unisys: ... |
825 826 |
u32 bus_no = visordev->chipset_bus_no; u32 dev_no = visordev->chipset_dev_no; |
55c71ebaf staging: unisys: ... |
827 |
struct visor_vbus_deviceinfo dev_info; |
3703987cd staging: unisys: ... |
828 |
const char *chan_type_name = NULL; |
55c71ebaf staging: unisys: ... |
829 |
struct visor_vbus_headerinfo *hdr_info; |
3703987cd staging: unisys: ... |
830 831 |
if (!visordev->device.driver) |
216c3e2c1 staging: unisys: ... |
832 |
return; |
d32517e39 staging: unisys: ... |
833 834 835 |
bdev = visorbus_get_device_by_id(bus_no, BUS_ROOT_DEVICE, NULL); if (!bdev) return; |
55c71ebaf staging: unisys: ... |
836 |
hdr_info = (struct visor_vbus_headerinfo *)bdev->vbus_hdr_info; |
5990b39e2 staging: unisys: ... |
837 838 |
if (!hdr_info) return; |
d32517e39 staging: unisys: ... |
839 |
visordrv = to_visor_driver(visordev->device.driver); |
3703987cd staging: unisys: ... |
840 |
|
3fd1b3b68 staging: unisys: ... |
841 842 |
/* * Within the list of device types (by GUID) that the driver |
3703987cd staging: unisys: ... |
843 844 845 846 847 |
* says it supports, find out which one of those types matches * the type of this device, so that we can include the device * type name */ for (i = 0; visordrv->channel_types[i].name; i++) { |
5d48942c1 staging: unisys: ... |
848 849 |
if (guid_equal(&visordrv->channel_types[i].guid, &visordev->channel_type_guid)) { |
3703987cd staging: unisys: ... |
850 851 852 853 |
chan_type_name = visordrv->channel_types[i].name; break; } } |
e82ed633e staging: unisys: ... |
854 |
bus_device_info_init(&dev_info, chan_type_name, visordrv->name); |
d32517e39 staging: unisys: ... |
855 |
write_vbus_dev_info(bdev->visorchannel, hdr_info, &dev_info, dev_no); |
d32517e39 staging: unisys: ... |
856 857 858 |
write_vbus_chp_info(bdev->visorchannel, hdr_info, &chipset_driverinfo); write_vbus_bus_info(bdev->visorchannel, hdr_info, &clientbus_driverinfo); |
3703987cd staging: unisys: ... |
859 |
} |
b84be59a5 staging: unisys: ... |
860 |
/* |
7a0ee6948 staging: unisys: ... |
861 862 863 864 865 866 867 868 869 870 871 872 873 874 |
* visordriver_probe_device() - handle new visor device coming online * @xdev: struct device for the visor device being probed * * This is called automatically upon adding a visor_device (device_add), or * adding a visor_driver (visorbus_register_visor_driver), but only after * visorbus_match() has returned 1 to indicate a successful match between * driver and device. * * If successful, a reference to the device will be held onto via get_device(). * * Return: 0 if successful, meaning the function driver's probe() function * was successful with this device, otherwise a negative errno * value indicating failure reason */ |
baf9b7054 staging: unisys: ... |
875 |
static int visordriver_probe_device(struct device *xdev) |
7a0ee6948 staging: unisys: ... |
876 |
{ |
61f38f9a4 staging: unisys: ... |
877 |
int err; |
7f91228d3 staging: unisys: ... |
878 879 |
struct visor_driver *drv = to_visor_driver(xdev->driver); struct visor_device *dev = to_visor_device(xdev); |
7a0ee6948 staging: unisys: ... |
880 881 882 |
mutex_lock(&dev->visordriver_callback_lock); dev->being_removed = false; |
61f38f9a4 staging: unisys: ... |
883 884 885 886 |
err = drv->probe(dev); if (err) { mutex_unlock(&dev->visordriver_callback_lock); return err; |
7a0ee6948 staging: unisys: ... |
887 |
} |
61f38f9a4 staging: unisys: ... |
888 889 890 |
/* success: reference kept via unmatched get_device() */ get_device(&dev->device); publish_vbus_dev_info(dev); |
7a0ee6948 staging: unisys: ... |
891 |
mutex_unlock(&dev->visordriver_callback_lock); |
61f38f9a4 staging: unisys: ... |
892 |
return 0; |
7a0ee6948 staging: unisys: ... |
893 |
} |
060b293b9 staging: unisys: ... |
894 |
/* |
7915a3c45 staging: unisys: ... |
895 896 |
* visorbus_register_visor_driver() - registers the provided visor driver for * handling one or more visor device |
7a0ee6948 staging: unisys: ... |
897 898 899 |
* types (channel_types) * @drv: the driver to register * |
7915a3c45 staging: unisys: ... |
900 901 |
* A visor function driver calls this function to register the driver. The * caller MUST fill in the following fields within the #drv structure: |
7a0ee6948 staging: unisys: ... |
902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 |
* name, version, owner, channel_types, probe, remove * * Here's how the whole Linux bus / driver / device model works. * * At system start-up, the visorbus kernel module is loaded, which registers * visorbus_type as a bus type, using bus_register(). * * All kernel modules that support particular device types on a * visorbus bus are loaded. Each of these kernel modules calls * visorbus_register_visor_driver() in their init functions, passing a * visor_driver struct. visorbus_register_visor_driver() in turn calls * register_driver(&visor_driver.driver). This .driver member is * initialized with generic methods (like probe), whose sole responsibility * is to act as a broker for the real methods, which are within the * visor_driver struct. (This is the way the subclass behavior is * implemented, since visor_driver is essentially a subclass of the * generic driver.) Whenever a driver_register() happens, core bus code in * the kernel does (see device_attach() in drivers/base/dd.c): * * for each dev associated with the bus (the bus that driver is on) that * does not yet have a driver * if bus.match(dev,newdriver) == yes_matched ** .match specified * ** during bus_register(). * newdriver.probe(dev) ** for visor drivers, this will call * ** the generic driver.probe implemented in visorbus.c, * ** which in turn calls the probe specified within the * ** struct visor_driver (which was specified by the * ** actual device driver as part of * ** visorbus_register_visor_driver()). * * The above dance also happens when a new device appears. * So the question is, how are devices created within the system? * Basically, just call device_add(dev). See pci_bus_add_devices(). * pci_scan_device() shows an example of how to build a device struct. It * returns the newly-created struct to pci_scan_single_device(), who adds it * to the list of devices at PCIBUS.devices. That list of devices is what * is traversed by pci_bus_add_devices(). * * Return: integer indicating success (zero) or failure (non-zero) */ int visorbus_register_visor_driver(struct visor_driver *drv) { |
060b293b9 staging: unisys: ... |
944 |
/* can't register on a nonexistent bus */ |
b0512faf6 staging: unisys: ... |
945 |
if (!initialized) |
060b293b9 staging: unisys: ... |
946 |
return -ENODEV; |
c2d00b218 staging: unisys: ... |
947 |
if (!drv->probe) |
3459e83a1 staging: unisys: ... |
948 |
return -EINVAL; |
c2d00b218 staging: unisys: ... |
949 |
if (!drv->remove) |
3459e83a1 staging: unisys: ... |
950 |
return -EINVAL; |
c2d00b218 staging: unisys: ... |
951 |
if (!drv->pause) |
3459e83a1 staging: unisys: ... |
952 |
return -EINVAL; |
c2d00b218 staging: unisys: ... |
953 |
if (!drv->resume) |
3459e83a1 staging: unisys: ... |
954 |
return -EINVAL; |
c2d00b218 staging: unisys: ... |
955 |
|
7a0ee6948 staging: unisys: ... |
956 957 958 959 960 |
drv->driver.name = drv->name; drv->driver.bus = &visorbus_type; drv->driver.probe = visordriver_probe_device; drv->driver.remove = visordriver_remove_device; drv->driver.owner = drv->owner; |
7a0ee6948 staging: unisys: ... |
961 962 963 964 965 966 967 968 969 970 971 972 |
/* * driver_register does this: * bus_add_driver(drv) * ->if (drv.bus) ** (bus_type) ** * driver_attach(drv) * for each dev with bus type of drv.bus * if (!dev.drv) ** no driver assigned yet ** * if (bus.match(dev,drv)) [visorbus_match] * dev.drv = drv * if (!drv.probe(dev)) [visordriver_probe_device] * dev.drv = NULL */ |
293deb2c0 staging: unisys: ... |
973 |
return driver_register(&drv->driver); |
7a0ee6948 staging: unisys: ... |
974 975 |
} EXPORT_SYMBOL_GPL(visorbus_register_visor_driver); |
b84be59a5 staging: unisys: ... |
976 |
/* |
9e78fd35d staging: unisys: ... |
977 |
* visorbus_create_instance() - create a device instance for the visorbus itself |
3fd1b3b68 staging: unisys: ... |
978 979 980 981 |
* @dev: struct visor_device indicating the bus instance * * Return: 0 for success, otherwise negative errno value indicating reason for * failure |
3703987cd staging: unisys: ... |
982 |
*/ |
fdf5b9ac3 staging: unisys: ... |
983 |
int visorbus_create_instance(struct visor_device *dev) |
3703987cd staging: unisys: ... |
984 |
{ |
d32517e39 staging: unisys: ... |
985 |
int id = dev->chipset_bus_no; |
8217becc1 staging: unisys: ... |
986 |
int err; |
55c71ebaf staging: unisys: ... |
987 |
struct visor_vbus_headerinfo *hdr_info; |
3703987cd staging: unisys: ... |
988 |
|
7726f8135 staging: unisys: ... |
989 |
hdr_info = kzalloc(sizeof(*hdr_info), GFP_KERNEL); |
c2c667d6b staging: unisys: ... |
990 991 |
if (!hdr_info) return -ENOMEM; |
343506bf0 staging: unisys: ... |
992 993 994 995 |
dev_set_name(&dev->device, "visorbus%d", id); dev->device.bus = &visorbus_type; dev->device.groups = visorbus_groups; dev->device.release = visorbus_release_busdevice; |
8217becc1 staging: unisys: ... |
996 997 |
dev->debugfs_dir = debugfs_create_dir(dev_name(&dev->device), visorbus_debugfs_dir); |
1c218004a staging: unisys: ... |
998 999 1000 |
dev->debugfs_bus_info = debugfs_create_file("client_bus_info", 0440, dev->debugfs_dir, dev, &bus_info_debugfs_fops); |
362f87f31 staging: unisys: ... |
1001 |
dev_set_drvdata(&dev->device, dev); |
e25201d66 staging: unisys: ... |
1002 |
err = get_vbus_header_info(dev->visorchannel, &dev->device, hdr_info); |
362f87f31 staging: unisys: ... |
1003 |
if (err < 0) |
8217becc1 staging: unisys: ... |
1004 |
goto err_debugfs_dir; |
362f87f31 staging: unisys: ... |
1005 |
err = device_register(&dev->device); |
450333f10 staging: unisys: ... |
1006 |
if (err < 0) |
362f87f31 staging: unisys: ... |
1007 |
goto err_debugfs_dir; |
343506bf0 staging: unisys: ... |
1008 |
list_add_tail(&dev->list_all, &list_all_bus_instances); |
fdf5b9ac3 staging: unisys: ... |
1009 |
dev->state.created = 1; |
362f87f31 staging: unisys: ... |
1010 |
dev->vbus_hdr_info = (void *)hdr_info; |
9f1d28fa2 staging: unisys; ... |
1011 1012 |
write_vbus_chp_info(dev->visorchannel, hdr_info, &chipset_driverinfo); write_vbus_bus_info(dev->visorchannel, hdr_info, &clientbus_driverinfo); |
fdf5b9ac3 staging: unisys: ... |
1013 |
visorbus_response(dev, err, CONTROLVM_BUS_CREATE); |
362f87f31 staging: unisys: ... |
1014 |
return 0; |
8217becc1 staging: unisys: ... |
1015 1016 1017 |
err_debugfs_dir: debugfs_remove_recursive(dev->debugfs_dir); |
8217becc1 staging: unisys: ... |
1018 |
kfree(hdr_info); |
23d01c425 staging: unisys: ... |
1019 1020 |
dev_err(&dev->device, "%s failed: %d ", __func__, err); |
8217becc1 staging: unisys: ... |
1021 |
return err; |
3703987cd staging: unisys: ... |
1022 |
} |
b84be59a5 staging: unisys: ... |
1023 |
/* |
9e78fd35d staging: unisys: ... |
1024 |
* visorbus_remove_instance() - remove a device instance for the visorbus itself |
3fd1b3b68 staging: unisys: ... |
1025 |
* @dev: struct visor_device indentifying the bus to remove |
3703987cd staging: unisys: ... |
1026 |
*/ |
a7093ba16 staging: unisys: ... |
1027 |
void visorbus_remove_instance(struct visor_device *dev) |
3703987cd staging: unisys: ... |
1028 |
{ |
3fd1b3b68 staging: unisys: ... |
1029 1030 |
/* * Note that this will result in the release method for |
343506bf0 staging: unisys: ... |
1031 |
* dev->dev being called, which will call |
3703987cd staging: unisys: ... |
1032 1033 1034 1035 1036 |
* visorbus_release_busdevice(). This has something to do with * the put_device() done in device_unregister(), but I have never * successfully been able to trace thru the code to see where/how * release() gets called. But I know it does. */ |
343506bf0 staging: unisys: ... |
1037 1038 |
kfree(dev->vbus_hdr_info); list_del(&dev->list_all); |
ae54a2879 staging: unisys: ... |
1039 1040 |
if (dev->pending_msg_hdr) visorbus_response(dev, 0, CONTROLVM_BUS_DESTROY); |
343506bf0 staging: unisys: ... |
1041 |
device_unregister(&dev->device); |
3703987cd staging: unisys: ... |
1042 |
} |
b84be59a5 staging: unisys: ... |
1043 |
/* |
9e78fd35d staging: unisys: ... |
1044 |
* remove_all_visor_devices() - remove all child visorbus device instances |
3703987cd staging: unisys: ... |
1045 |
*/ |
baf9b7054 staging: unisys: ... |
1046 |
static void remove_all_visor_devices(void) |
3703987cd staging: unisys: ... |
1047 1048 1049 1050 |
{ struct list_head *listentry, *listtmp; list_for_each_safe(listentry, listtmp, &list_all_device_instances) { |
17e4bddad staging: unisys: ... |
1051 1052 1053 |
struct visor_device *dev; dev = list_entry(listentry, struct visor_device, list_all); |
3703987cd staging: unisys: ... |
1054 1055 1056 |
remove_visor_device(dev); } } |
b84be59a5 staging: unisys: ... |
1057 |
/* |
3fd1b3b68 staging: unisys: ... |
1058 1059 1060 1061 1062 1063 1064 |
* pause_state_change_complete() - the callback function to be called by a * visorbus function driver when a * pending "pause device" operation has * completed * @dev: struct visor_device identifying the paused device * @status: 0 iff the pause state change completed successfully, otherwise * a negative errno value indicating the reason for failure |
3703987cd staging: unisys: ... |
1065 |
*/ |
baf9b7054 staging: unisys: ... |
1066 |
static void pause_state_change_complete(struct visor_device *dev, int status) |
3703987cd staging: unisys: ... |
1067 1068 |
{ if (!dev->pausing) |
216c3e2c1 staging: unisys: ... |
1069 |
return; |
3703987cd staging: unisys: ... |
1070 |
|
779d0752b staging: unisys: ... |
1071 |
dev->pausing = false; |
722e73d55 staging: unisys: ... |
1072 1073 |
visorbus_device_changestate_response(dev, status, segment_state_standby); |
3703987cd staging: unisys: ... |
1074 |
} |
b84be59a5 staging: unisys: ... |
1075 |
/* |
3fd1b3b68 staging: unisys: ... |
1076 1077 1078 1079 1080 1081 1082 |
* resume_state_change_complete() - the callback function to be called by a * visorbus function driver when a * pending "resume device" operation has * completed * @dev: struct visor_device identifying the resumed device * @status: 0 iff the resume state change completed successfully, otherwise * a negative errno value indicating the reason for failure |
3703987cd staging: unisys: ... |
1083 |
*/ |
baf9b7054 staging: unisys: ... |
1084 |
static void resume_state_change_complete(struct visor_device *dev, int status) |
3703987cd staging: unisys: ... |
1085 1086 |
{ if (!dev->resuming) |
216c3e2c1 staging: unisys: ... |
1087 |
return; |
3703987cd staging: unisys: ... |
1088 |
|
779d0752b staging: unisys: ... |
1089 |
dev->resuming = false; |
3fd1b3b68 staging: unisys: ... |
1090 1091 |
/* * Notify the chipset driver that the resume is complete, |
3703987cd staging: unisys: ... |
1092 |
* which will presumably want to send some sort of response to |
481178950 staging: unisys: ... |
1093 1094 |
* the initiator. */ |
722e73d55 staging: unisys: ... |
1095 1096 |
visorbus_device_changestate_response(dev, status, segment_state_running); |
3703987cd staging: unisys: ... |
1097 |
} |
b84be59a5 staging: unisys: ... |
1098 |
/* |
451072e3f staging: unisys: ... |
1099 1100 |
* visorchipset_initiate_device_pause_resume() - start a pause or resume * operation for a visor device |
3fd1b3b68 staging: unisys: ... |
1101 1102 1103 1104 1105 1106 1107 |
* @dev: struct visor_device identifying the device being paused or resumed * @is_pause: true to indicate pause operation, false to indicate resume * * Tell the subordinate function driver for a specific device to pause * or resume that device. Success/failure result is returned asynchronously * via a callback function; see pause_state_change_complete() and * resume_state_change_complete(). |
3703987cd staging: unisys: ... |
1108 |
*/ |
baf9b7054 staging: unisys: ... |
1109 1110 |
static int visorchipset_initiate_device_pause_resume(struct visor_device *dev, bool is_pause) |
3703987cd staging: unisys: ... |
1111 |
{ |
15d9ce9d3 staging: unisys: ... |
1112 |
int err; |
473659df5 staging: unisys: ... |
1113 |
struct visor_driver *drv; |
3703987cd staging: unisys: ... |
1114 |
|
68f4f7665 staging: unisys: ... |
1115 1116 1117 |
/* If no driver associated with the device nothing to pause/resume */ if (!dev->device.driver) return 0; |
15d9ce9d3 staging: unisys: ... |
1118 1119 |
if (dev->pausing || dev->resuming) return -EBUSY; |
3703987cd staging: unisys: ... |
1120 |
|
68f4f7665 staging: unisys: ... |
1121 |
drv = to_visor_driver(dev->device.driver); |
3703987cd staging: unisys: ... |
1122 |
if (is_pause) { |
779d0752b staging: unisys: ... |
1123 |
dev->pausing = true; |
15d9ce9d3 staging: unisys: ... |
1124 |
err = drv->pause(dev, pause_state_change_complete); |
3703987cd staging: unisys: ... |
1125 |
} else { |
060b293b9 staging: unisys: ... |
1126 1127 1128 |
/* * The vbus_dev_info structure in the channel was been cleared, * make sure it is valid. |
481178950 staging: unisys: ... |
1129 |
*/ |
e3b2ed666 staging: unisys: ... |
1130 |
publish_vbus_dev_info(dev); |
779d0752b staging: unisys: ... |
1131 |
dev->resuming = true; |
15d9ce9d3 staging: unisys: ... |
1132 |
err = drv->resume(dev, resume_state_change_complete); |
3703987cd staging: unisys: ... |
1133 |
} |
15d9ce9d3 staging: unisys: ... |
1134 |
return err; |
3703987cd staging: unisys: ... |
1135 |
} |
060b293b9 staging: unisys: ... |
1136 |
/* |
c0b44136c staging: unisys: ... |
1137 |
* visorchipset_device_pause() - start a pause operation for a visor device |
3fd1b3b68 staging: unisys: ... |
1138 1139 1140 1141 1142 1143 |
* @dev_info: struct visor_device identifying the device being paused * * Tell the subordinate function driver for a specific device to pause * that device. Success/failure result is returned asynchronously * via a callback function; see pause_state_change_complete(). */ |
baf9b7054 staging: unisys: ... |
1144 |
int visorchipset_device_pause(struct visor_device *dev_info) |
3703987cd staging: unisys: ... |
1145 |
{ |
15d9ce9d3 staging: unisys: ... |
1146 |
int err; |
451072e3f staging: unisys: ... |
1147 |
err = visorchipset_initiate_device_pause_resume(dev_info, true); |
15d9ce9d3 staging: unisys: ... |
1148 1149 |
if (err < 0) { dev_info->pausing = false; |
b4a8e6ae1 staging: unisys: ... |
1150 |
return err; |
15d9ce9d3 staging: unisys: ... |
1151 |
} |
b4a8e6ae1 staging: unisys: ... |
1152 |
return 0; |
3703987cd staging: unisys: ... |
1153 |
} |
060b293b9 staging: unisys: ... |
1154 |
/* |
c0b44136c staging: unisys: ... |
1155 |
* visorchipset_device_resume() - start a resume operation for a visor device |
3fd1b3b68 staging: unisys: ... |
1156 1157 1158 1159 1160 1161 |
* @dev_info: struct visor_device identifying the device being resumed * * Tell the subordinate function driver for a specific device to resume * that device. Success/failure result is returned asynchronously * via a callback function; see resume_state_change_complete(). */ |
baf9b7054 staging: unisys: ... |
1162 |
int visorchipset_device_resume(struct visor_device *dev_info) |
3703987cd staging: unisys: ... |
1163 |
{ |
15d9ce9d3 staging: unisys: ... |
1164 |
int err; |
451072e3f staging: unisys: ... |
1165 |
err = visorchipset_initiate_device_pause_resume(dev_info, false); |
15d9ce9d3 staging: unisys: ... |
1166 |
if (err < 0) { |
15d9ce9d3 staging: unisys: ... |
1167 |
dev_info->resuming = false; |
b4a8e6ae1 staging: unisys: ... |
1168 |
return err; |
15d9ce9d3 staging: unisys: ... |
1169 |
} |
b4a8e6ae1 staging: unisys: ... |
1170 |
return 0; |
3703987cd staging: unisys: ... |
1171 |
} |
baf9b7054 staging: unisys: ... |
1172 |
int visorbus_init(void) |
3703987cd staging: unisys: ... |
1173 |
{ |
78af1aef6 staging: unisys: ... |
1174 |
int err; |
3703987cd staging: unisys: ... |
1175 |
|
8217becc1 staging: unisys: ... |
1176 |
visorbus_debugfs_dir = debugfs_create_dir("visorbus", NULL); |
e82ed633e staging: unisys: ... |
1177 |
bus_device_info_init(&clientbus_driverinfo, "clientbus", "visorbus"); |
5b6f9b95f staging: unisys: ... |
1178 |
err = bus_register(&visorbus_type); |
804aab3be staging: unisys: ... |
1179 1180 |
if (err < 0) return err; |
b0512faf6 staging: unisys: ... |
1181 |
initialized = true; |
e82ed633e staging: unisys: ... |
1182 |
bus_device_info_init(&chipset_driverinfo, "chipset", "visorchipset"); |
78af1aef6 staging: unisys: ... |
1183 |
return 0; |
3703987cd staging: unisys: ... |
1184 |
} |
baf9b7054 staging: unisys: ... |
1185 |
void visorbus_exit(void) |
3703987cd staging: unisys: ... |
1186 1187 |
{ struct list_head *listentry, *listtmp; |
3703987cd staging: unisys: ... |
1188 |
remove_all_visor_devices(); |
3703987cd staging: unisys: ... |
1189 |
list_for_each_safe(listentry, listtmp, &list_all_bus_instances) { |
17e4bddad staging: unisys: ... |
1190 1191 1192 |
struct visor_device *dev; dev = list_entry(listentry, struct visor_device, list_all); |
9e78fd35d staging: unisys: ... |
1193 |
visorbus_remove_instance(dev); |
3703987cd staging: unisys: ... |
1194 |
} |
5b6f9b95f staging: unisys: ... |
1195 |
bus_unregister(&visorbus_type); |
b0512faf6 staging: unisys: ... |
1196 |
initialized = false; |
8217becc1 staging: unisys: ... |
1197 |
debugfs_remove_recursive(visorbus_debugfs_dir); |
3703987cd staging: unisys: ... |
1198 |
} |