vio.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. /*
  2. * IBM PowerPC Virtual I/O Infrastructure Support.
  3. *
  4. * Copyright (c) 2003 IBM Corp.
  5. * Dave Engebretsen engebret@us.ibm.com
  6. * Santiago Leon santil@us.ibm.com
  7. * Hollis Blanchard <hollisb@us.ibm.com>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version
  12. * 2 of the License, or (at your option) any later version.
  13. */
  14. #include <linux/init.h>
  15. #include <linux/console.h>
  16. #include <linux/version.h>
  17. #include <linux/module.h>
  18. #include <linux/kobject.h>
  19. #include <linux/mm.h>
  20. #include <linux/dma-mapping.h>
  21. #include <asm/rtas.h>
  22. #include <asm/iommu.h>
  23. #include <asm/dma.h>
  24. #include <asm/ppcdebug.h>
  25. #include <asm/vio.h>
  26. #include <asm/hvcall.h>
  27. #include <asm/iSeries/vio.h>
  28. #include <asm/iSeries/HvTypes.h>
  29. #include <asm/iSeries/HvCallXm.h>
  30. #include <asm/iSeries/HvLpConfig.h>
  31. #define DBGENTER() pr_debug("%s entered\n", __FUNCTION__)
  32. extern struct subsystem devices_subsys; /* needed for vio_find_name() */
  33. static const struct vio_device_id *vio_match_device(
  34. const struct vio_device_id *, const struct vio_dev *);
  35. #ifdef CONFIG_PPC_PSERIES
  36. static struct iommu_table *vio_build_iommu_table(struct vio_dev *);
  37. static int vio_num_address_cells;
  38. #endif
  39. static struct vio_dev *vio_bus_device; /* fake "parent" device */
  40. #ifdef CONFIG_PPC_ISERIES
  41. static struct vio_dev *__init vio_register_device_iseries(char *type,
  42. uint32_t unit_num);
  43. static struct iommu_table veth_iommu_table;
  44. static struct iommu_table vio_iommu_table;
  45. static struct vio_dev _vio_dev = {
  46. .iommu_table = &vio_iommu_table,
  47. .dev.bus = &vio_bus_type
  48. };
  49. struct device *iSeries_vio_dev = &_vio_dev.dev;
  50. EXPORT_SYMBOL(iSeries_vio_dev);
  51. #define device_is_compatible(a, b) 1
  52. #endif
  53. /* convert from struct device to struct vio_dev and pass to driver.
  54. * dev->driver has already been set by generic code because vio_bus_match
  55. * succeeded. */
  56. static int vio_bus_probe(struct device *dev)
  57. {
  58. struct vio_dev *viodev = to_vio_dev(dev);
  59. struct vio_driver *viodrv = to_vio_driver(dev->driver);
  60. const struct vio_device_id *id;
  61. int error = -ENODEV;
  62. DBGENTER();
  63. if (!viodrv->probe)
  64. return error;
  65. id = vio_match_device(viodrv->id_table, viodev);
  66. if (id) {
  67. error = viodrv->probe(viodev, id);
  68. }
  69. return error;
  70. }
  71. /* convert from struct device to struct vio_dev and pass to driver. */
  72. static int vio_bus_remove(struct device *dev)
  73. {
  74. struct vio_dev *viodev = to_vio_dev(dev);
  75. struct vio_driver *viodrv = to_vio_driver(dev->driver);
  76. DBGENTER();
  77. if (viodrv->remove) {
  78. return viodrv->remove(viodev);
  79. }
  80. /* driver can't remove */
  81. return 1;
  82. }
  83. /**
  84. * vio_register_driver: - Register a new vio driver
  85. * @drv: The vio_driver structure to be registered.
  86. */
  87. int vio_register_driver(struct vio_driver *viodrv)
  88. {
  89. printk(KERN_DEBUG "%s: driver %s registering\n", __FUNCTION__,
  90. viodrv->name);
  91. /* fill in 'struct driver' fields */
  92. viodrv->driver.name = viodrv->name;
  93. viodrv->driver.bus = &vio_bus_type;
  94. viodrv->driver.probe = vio_bus_probe;
  95. viodrv->driver.remove = vio_bus_remove;
  96. return driver_register(&viodrv->driver);
  97. }
  98. EXPORT_SYMBOL(vio_register_driver);
  99. /**
  100. * vio_unregister_driver - Remove registration of vio driver.
  101. * @driver: The vio_driver struct to be removed form registration
  102. */
  103. void vio_unregister_driver(struct vio_driver *viodrv)
  104. {
  105. driver_unregister(&viodrv->driver);
  106. }
  107. EXPORT_SYMBOL(vio_unregister_driver);
  108. /**
  109. * vio_match_device: - Tell if a VIO device has a matching VIO device id structure.
  110. * @ids: array of VIO device id structures to search in
  111. * @dev: the VIO device structure to match against
  112. *
  113. * Used by a driver to check whether a VIO device present in the
  114. * system is in its list of supported devices. Returns the matching
  115. * vio_device_id structure or NULL if there is no match.
  116. */
  117. static const struct vio_device_id * vio_match_device(const struct vio_device_id *ids,
  118. const struct vio_dev *dev)
  119. {
  120. DBGENTER();
  121. while (ids->type) {
  122. if ((strncmp(dev->type, ids->type, strlen(ids->type)) == 0) &&
  123. device_is_compatible(dev->dev.platform_data, ids->compat))
  124. return ids;
  125. ids++;
  126. }
  127. return NULL;
  128. }
  129. #ifdef CONFIG_PPC_ISERIES
  130. void __init iommu_vio_init(void)
  131. {
  132. struct iommu_table *t;
  133. struct iommu_table_cb cb;
  134. unsigned long cbp;
  135. unsigned long itc_entries;
  136. cb.itc_busno = 255; /* Bus 255 is the virtual bus */
  137. cb.itc_virtbus = 0xff; /* Ask for virtual bus */
  138. cbp = virt_to_abs(&cb);
  139. HvCallXm_getTceTableParms(cbp);
  140. itc_entries = cb.itc_size * PAGE_SIZE / sizeof(union tce_entry);
  141. veth_iommu_table.it_size = itc_entries / 2;
  142. veth_iommu_table.it_busno = cb.itc_busno;
  143. veth_iommu_table.it_offset = cb.itc_offset;
  144. veth_iommu_table.it_index = cb.itc_index;
  145. veth_iommu_table.it_type = TCE_VB;
  146. veth_iommu_table.it_blocksize = 1;
  147. t = iommu_init_table(&veth_iommu_table);
  148. if (!t)
  149. printk("Virtual Bus VETH TCE table failed.\n");
  150. vio_iommu_table.it_size = itc_entries - veth_iommu_table.it_size;
  151. vio_iommu_table.it_busno = cb.itc_busno;
  152. vio_iommu_table.it_offset = cb.itc_offset +
  153. veth_iommu_table.it_size;
  154. vio_iommu_table.it_index = cb.itc_index;
  155. vio_iommu_table.it_type = TCE_VB;
  156. vio_iommu_table.it_blocksize = 1;
  157. t = iommu_init_table(&vio_iommu_table);
  158. if (!t)
  159. printk("Virtual Bus VIO TCE table failed.\n");
  160. }
  161. #endif
  162. #ifdef CONFIG_PPC_PSERIES
  163. static void probe_bus_pseries(void)
  164. {
  165. struct device_node *node_vroot, *of_node;
  166. node_vroot = find_devices("vdevice");
  167. if ((node_vroot == NULL) || (node_vroot->child == NULL))
  168. /* this machine doesn't do virtual IO, and that's ok */
  169. return;
  170. vio_num_address_cells = prom_n_addr_cells(node_vroot->child);
  171. /*
  172. * Create struct vio_devices for each virtual device in the device tree.
  173. * Drivers will associate with them later.
  174. */
  175. for (of_node = node_vroot->child; of_node != NULL;
  176. of_node = of_node->sibling) {
  177. printk(KERN_DEBUG "%s: processing %p\n", __FUNCTION__, of_node);
  178. vio_register_device_node(of_node);
  179. }
  180. }
  181. #endif
  182. #ifdef CONFIG_PPC_ISERIES
  183. static void probe_bus_iseries(void)
  184. {
  185. HvLpIndexMap vlan_map = HvLpConfig_getVirtualLanIndexMap();
  186. struct vio_dev *viodev;
  187. int i;
  188. /* there is only one of each of these */
  189. vio_register_device_iseries("viocons", 0);
  190. vio_register_device_iseries("vscsi", 0);
  191. vlan_map = HvLpConfig_getVirtualLanIndexMap();
  192. for (i = 0; i < HVMAXARCHITECTEDVIRTUALLANS; i++) {
  193. if ((vlan_map & (0x8000 >> i)) == 0)
  194. continue;
  195. viodev = vio_register_device_iseries("vlan", i);
  196. /* veth is special and has it own iommu_table */
  197. viodev->iommu_table = &veth_iommu_table;
  198. }
  199. for (i = 0; i < HVMAXARCHITECTEDVIRTUALDISKS; i++)
  200. vio_register_device_iseries("viodasd", i);
  201. for (i = 0; i < HVMAXARCHITECTEDVIRTUALCDROMS; i++)
  202. vio_register_device_iseries("viocd", i);
  203. for (i = 0; i < HVMAXARCHITECTEDVIRTUALTAPES; i++)
  204. vio_register_device_iseries("viotape", i);
  205. }
  206. #endif
  207. /**
  208. * vio_bus_init: - Initialize the virtual IO bus
  209. */
  210. static int __init vio_bus_init(void)
  211. {
  212. int err;
  213. err = bus_register(&vio_bus_type);
  214. if (err) {
  215. printk(KERN_ERR "failed to register VIO bus\n");
  216. return err;
  217. }
  218. /* the fake parent of all vio devices, just to give us a nice directory */
  219. vio_bus_device = kmalloc(sizeof(struct vio_dev), GFP_KERNEL);
  220. if (!vio_bus_device) {
  221. return 1;
  222. }
  223. memset(vio_bus_device, 0, sizeof(struct vio_dev));
  224. strcpy(vio_bus_device->dev.bus_id, "vio");
  225. err = device_register(&vio_bus_device->dev);
  226. if (err) {
  227. printk(KERN_WARNING "%s: device_register returned %i\n", __FUNCTION__,
  228. err);
  229. kfree(vio_bus_device);
  230. return err;
  231. }
  232. #ifdef CONFIG_PPC_PSERIES
  233. probe_bus_pseries();
  234. #endif
  235. #ifdef CONFIG_PPC_ISERIES
  236. probe_bus_iseries();
  237. #endif
  238. return 0;
  239. }
  240. __initcall(vio_bus_init);
  241. /* vio_dev refcount hit 0 */
  242. static void __devinit vio_dev_release(struct device *dev)
  243. {
  244. DBGENTER();
  245. #ifdef CONFIG_PPC_PSERIES
  246. /* XXX free TCE table */
  247. of_node_put(dev->platform_data);
  248. #endif
  249. kfree(to_vio_dev(dev));
  250. }
  251. #ifdef CONFIG_PPC_PSERIES
  252. static ssize_t viodev_show_devspec(struct device *dev, struct device_attribute *attr, char *buf)
  253. {
  254. struct device_node *of_node = dev->platform_data;
  255. return sprintf(buf, "%s\n", of_node->full_name);
  256. }
  257. DEVICE_ATTR(devspec, S_IRUSR | S_IRGRP | S_IROTH, viodev_show_devspec, NULL);
  258. #endif
  259. static ssize_t viodev_show_name(struct device *dev, struct device_attribute *attr, char *buf)
  260. {
  261. return sprintf(buf, "%s\n", to_vio_dev(dev)->name);
  262. }
  263. DEVICE_ATTR(name, S_IRUSR | S_IRGRP | S_IROTH, viodev_show_name, NULL);
  264. static struct vio_dev * __devinit vio_register_device_common(
  265. struct vio_dev *viodev, char *name, char *type,
  266. uint32_t unit_address, struct iommu_table *iommu_table)
  267. {
  268. DBGENTER();
  269. viodev->name = name;
  270. viodev->type = type;
  271. viodev->unit_address = unit_address;
  272. viodev->iommu_table = iommu_table;
  273. /* init generic 'struct device' fields: */
  274. viodev->dev.parent = &vio_bus_device->dev;
  275. viodev->dev.bus = &vio_bus_type;
  276. viodev->dev.release = vio_dev_release;
  277. /* register with generic device framework */
  278. if (device_register(&viodev->dev)) {
  279. printk(KERN_ERR "%s: failed to register device %s\n",
  280. __FUNCTION__, viodev->dev.bus_id);
  281. return NULL;
  282. }
  283. device_create_file(&viodev->dev, &dev_attr_name);
  284. return viodev;
  285. }
  286. #ifdef CONFIG_PPC_PSERIES
  287. /**
  288. * vio_register_device_node: - Register a new vio device.
  289. * @of_node: The OF node for this device.
  290. *
  291. * Creates and initializes a vio_dev structure from the data in
  292. * of_node (dev.platform_data) and adds it to the list of virtual devices.
  293. * Returns a pointer to the created vio_dev or NULL if node has
  294. * NULL device_type or compatible fields.
  295. */
  296. struct vio_dev * __devinit vio_register_device_node(struct device_node *of_node)
  297. {
  298. struct vio_dev *viodev;
  299. unsigned int *unit_address;
  300. unsigned int *irq_p;
  301. DBGENTER();
  302. /* we need the 'device_type' property, in order to match with drivers */
  303. if ((NULL == of_node->type)) {
  304. printk(KERN_WARNING
  305. "%s: node %s missing 'device_type'\n", __FUNCTION__,
  306. of_node->name ? of_node->name : "<unknown>");
  307. return NULL;
  308. }
  309. unit_address = (unsigned int *)get_property(of_node, "reg", NULL);
  310. if (!unit_address) {
  311. printk(KERN_WARNING "%s: node %s missing 'reg'\n", __FUNCTION__,
  312. of_node->name ? of_node->name : "<unknown>");
  313. return NULL;
  314. }
  315. /* allocate a vio_dev for this node */
  316. viodev = kmalloc(sizeof(struct vio_dev), GFP_KERNEL);
  317. if (!viodev) {
  318. return NULL;
  319. }
  320. memset(viodev, 0, sizeof(struct vio_dev));
  321. viodev->dev.platform_data = of_node_get(of_node);
  322. viodev->irq = NO_IRQ;
  323. irq_p = (unsigned int *)get_property(of_node, "interrupts", NULL);
  324. if (irq_p) {
  325. int virq = virt_irq_create_mapping(*irq_p);
  326. if (virq == NO_IRQ) {
  327. printk(KERN_ERR "Unable to allocate interrupt "
  328. "number for %s\n", of_node->full_name);
  329. } else
  330. viodev->irq = irq_offset_up(virq);
  331. }
  332. snprintf(viodev->dev.bus_id, BUS_ID_SIZE, "%x", *unit_address);
  333. /* register with generic device framework */
  334. if (vio_register_device_common(viodev, of_node->name, of_node->type,
  335. *unit_address, vio_build_iommu_table(viodev))
  336. == NULL) {
  337. /* XXX free TCE table */
  338. kfree(viodev);
  339. return NULL;
  340. }
  341. device_create_file(&viodev->dev, &dev_attr_devspec);
  342. return viodev;
  343. }
  344. EXPORT_SYMBOL(vio_register_device_node);
  345. #endif
  346. #ifdef CONFIG_PPC_ISERIES
  347. /**
  348. * vio_register_device: - Register a new vio device.
  349. * @voidev: The device to register.
  350. */
  351. static struct vio_dev *__init vio_register_device_iseries(char *type,
  352. uint32_t unit_num)
  353. {
  354. struct vio_dev *viodev;
  355. DBGENTER();
  356. /* allocate a vio_dev for this node */
  357. viodev = kmalloc(sizeof(struct vio_dev), GFP_KERNEL);
  358. if (!viodev)
  359. return NULL;
  360. memset(viodev, 0, sizeof(struct vio_dev));
  361. snprintf(viodev->dev.bus_id, BUS_ID_SIZE, "%s%d", type, unit_num);
  362. return vio_register_device_common(viodev, viodev->dev.bus_id, type,
  363. unit_num, &vio_iommu_table);
  364. }
  365. #endif
  366. void __devinit vio_unregister_device(struct vio_dev *viodev)
  367. {
  368. DBGENTER();
  369. #ifdef CONFIG_PPC_PSERIES
  370. device_remove_file(&viodev->dev, &dev_attr_devspec);
  371. #endif
  372. device_remove_file(&viodev->dev, &dev_attr_name);
  373. device_unregister(&viodev->dev);
  374. }
  375. EXPORT_SYMBOL(vio_unregister_device);
  376. #ifdef CONFIG_PPC_PSERIES
  377. /**
  378. * vio_get_attribute: - get attribute for virtual device
  379. * @vdev: The vio device to get property.
  380. * @which: The property/attribute to be extracted.
  381. * @length: Pointer to length of returned data size (unused if NULL).
  382. *
  383. * Calls prom.c's get_property() to return the value of the
  384. * attribute specified by the preprocessor constant @which
  385. */
  386. const void * vio_get_attribute(struct vio_dev *vdev, void* which, int* length)
  387. {
  388. return get_property(vdev->dev.platform_data, (char*)which, length);
  389. }
  390. EXPORT_SYMBOL(vio_get_attribute);
  391. /* vio_find_name() - internal because only vio.c knows how we formatted the
  392. * kobject name
  393. * XXX once vio_bus_type.devices is actually used as a kset in
  394. * drivers/base/bus.c, this function should be removed in favor of
  395. * "device_find(kobj_name, &vio_bus_type)"
  396. */
  397. static struct vio_dev *vio_find_name(const char *kobj_name)
  398. {
  399. struct kobject *found;
  400. found = kset_find_obj(&devices_subsys.kset, kobj_name);
  401. if (!found)
  402. return NULL;
  403. return to_vio_dev(container_of(found, struct device, kobj));
  404. }
  405. /**
  406. * vio_find_node - find an already-registered vio_dev
  407. * @vnode: device_node of the virtual device we're looking for
  408. */
  409. struct vio_dev *vio_find_node(struct device_node *vnode)
  410. {
  411. uint32_t *unit_address;
  412. char kobj_name[BUS_ID_SIZE];
  413. /* construct the kobject name from the device node */
  414. unit_address = (uint32_t *)get_property(vnode, "reg", NULL);
  415. if (!unit_address)
  416. return NULL;
  417. snprintf(kobj_name, BUS_ID_SIZE, "%x", *unit_address);
  418. return vio_find_name(kobj_name);
  419. }
  420. EXPORT_SYMBOL(vio_find_node);
  421. /**
  422. * vio_build_iommu_table: - gets the dma information from OF and builds the TCE tree.
  423. * @dev: the virtual device.
  424. *
  425. * Returns a pointer to the built tce tree, or NULL if it can't
  426. * find property.
  427. */
  428. static struct iommu_table * vio_build_iommu_table(struct vio_dev *dev)
  429. {
  430. unsigned int *dma_window;
  431. struct iommu_table *newTceTable;
  432. unsigned long offset;
  433. int dma_window_property_size;
  434. dma_window = (unsigned int *) get_property(dev->dev.platform_data, "ibm,my-dma-window", &dma_window_property_size);
  435. if(!dma_window) {
  436. return NULL;
  437. }
  438. newTceTable = (struct iommu_table *) kmalloc(sizeof(struct iommu_table), GFP_KERNEL);
  439. /* There should be some code to extract the phys-encoded offset
  440. using prom_n_addr_cells(). However, according to a comment
  441. on earlier versions, it's always zero, so we don't bother */
  442. offset = dma_window[1] >> PAGE_SHIFT;
  443. /* TCE table size - measured in tce entries */
  444. newTceTable->it_size = dma_window[4] >> PAGE_SHIFT;
  445. /* offset for VIO should always be 0 */
  446. newTceTable->it_offset = offset;
  447. newTceTable->it_busno = 0;
  448. newTceTable->it_index = (unsigned long)dma_window[0];
  449. newTceTable->it_type = TCE_VB;
  450. return iommu_init_table(newTceTable);
  451. }
  452. int vio_enable_interrupts(struct vio_dev *dev)
  453. {
  454. int rc = h_vio_signal(dev->unit_address, VIO_IRQ_ENABLE);
  455. if (rc != H_Success) {
  456. printk(KERN_ERR "vio: Error 0x%x enabling interrupts\n", rc);
  457. }
  458. return rc;
  459. }
  460. EXPORT_SYMBOL(vio_enable_interrupts);
  461. int vio_disable_interrupts(struct vio_dev *dev)
  462. {
  463. int rc = h_vio_signal(dev->unit_address, VIO_IRQ_DISABLE);
  464. if (rc != H_Success) {
  465. printk(KERN_ERR "vio: Error 0x%x disabling interrupts\n", rc);
  466. }
  467. return rc;
  468. }
  469. EXPORT_SYMBOL(vio_disable_interrupts);
  470. #endif
  471. static dma_addr_t vio_map_single(struct device *dev, void *vaddr,
  472. size_t size, enum dma_data_direction direction)
  473. {
  474. return iommu_map_single(to_vio_dev(dev)->iommu_table, vaddr, size,
  475. direction);
  476. }
  477. static void vio_unmap_single(struct device *dev, dma_addr_t dma_handle,
  478. size_t size, enum dma_data_direction direction)
  479. {
  480. iommu_unmap_single(to_vio_dev(dev)->iommu_table, dma_handle, size,
  481. direction);
  482. }
  483. static int vio_map_sg(struct device *dev, struct scatterlist *sglist,
  484. int nelems, enum dma_data_direction direction)
  485. {
  486. return iommu_map_sg(dev, to_vio_dev(dev)->iommu_table, sglist,
  487. nelems, direction);
  488. }
  489. static void vio_unmap_sg(struct device *dev, struct scatterlist *sglist,
  490. int nelems, enum dma_data_direction direction)
  491. {
  492. iommu_unmap_sg(to_vio_dev(dev)->iommu_table, sglist, nelems, direction);
  493. }
  494. static void *vio_alloc_coherent(struct device *dev, size_t size,
  495. dma_addr_t *dma_handle, unsigned int __nocast flag)
  496. {
  497. return iommu_alloc_coherent(to_vio_dev(dev)->iommu_table, size,
  498. dma_handle, flag);
  499. }
  500. static void vio_free_coherent(struct device *dev, size_t size,
  501. void *vaddr, dma_addr_t dma_handle)
  502. {
  503. iommu_free_coherent(to_vio_dev(dev)->iommu_table, size, vaddr,
  504. dma_handle);
  505. }
  506. static int vio_dma_supported(struct device *dev, u64 mask)
  507. {
  508. return 1;
  509. }
  510. struct dma_mapping_ops vio_dma_ops = {
  511. .alloc_coherent = vio_alloc_coherent,
  512. .free_coherent = vio_free_coherent,
  513. .map_single = vio_map_single,
  514. .unmap_single = vio_unmap_single,
  515. .map_sg = vio_map_sg,
  516. .unmap_sg = vio_unmap_sg,
  517. .dma_supported = vio_dma_supported,
  518. };
  519. static int vio_bus_match(struct device *dev, struct device_driver *drv)
  520. {
  521. const struct vio_dev *vio_dev = to_vio_dev(dev);
  522. struct vio_driver *vio_drv = to_vio_driver(drv);
  523. const struct vio_device_id *ids = vio_drv->id_table;
  524. const struct vio_device_id *found_id;
  525. DBGENTER();
  526. if (!ids)
  527. return 0;
  528. found_id = vio_match_device(ids, vio_dev);
  529. if (found_id)
  530. return 1;
  531. return 0;
  532. }
  533. struct bus_type vio_bus_type = {
  534. .name = "vio",
  535. .match = vio_bus_match,
  536. };
  537. EXPORT_SYMBOL(vio_bus_type);