vio.c 17 KB

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