visorbus_main.c 38 KB

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