Changes in uspace/drv/rootvirt/rootvirt.c [af6b5157:6f9e7fea] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/rootvirt/rootvirt.c
raf6b5157 r6f9e7fea 39 39 #include <errno.h> 40 40 #include <str_error.h> 41 #include <d df/driver.h>41 #include <driver.h> 42 42 43 43 #define NAME "rootvirt" 44 44 45 /** Virtual function entry*/45 /** Virtual device entry. */ 46 46 typedef struct { 47 /** Function name*/47 /** Device name. */ 48 48 const char *name; 49 /** Function match ID*/49 /** Device match id. */ 50 50 const char *match_id; 51 } virtual_ function_t;51 } virtual_device_t; 52 52 53 /** List of existing virtual functions*/54 virtual_ function_t virtual_functions[] = {53 /** List of existing virtual devices. */ 54 virtual_device_t virtual_devices[] = { 55 55 #include "devices.def" 56 /* Terminating item */56 /* Terminating item. */ 57 57 { 58 58 .name = NULL, … … 61 61 }; 62 62 63 static int rootvirt_add_device(ddf_dev_t *dev);63 static int add_device(device_t *dev); 64 64 65 65 static driver_ops_t rootvirt_ops = { 66 .add_device = & rootvirt_add_device66 .add_device = &add_device 67 67 }; 68 68 … … 72 72 }; 73 73 74 /** Add function to the virtualdevice.74 /** Add child device. 75 75 * 76 * @param vdev The virtual device77 * @param v fun Virtual function description78 * @return EOK on success or negative error code.76 * @param parent Parent device. 77 * @param virt_dev Virtual device to add. 78 * @return Error code. 79 79 */ 80 static int rootvirt_add_fun(ddf_dev_t *vdev, virtual_function_t *vfun)80 static int add_child(device_t *parent, virtual_device_t *virt_dev) 81 81 { 82 ddf_fun_t *fun;83 int rc;82 printf(NAME ": registering child device `%s' (match \"%s\")\n", 83 virt_dev->name, virt_dev->match_id); 84 84 85 printf(NAME ": registering function `%s' (match \"%s\")\n",86 v fun->name, vfun->match_id);85 int rc = child_device_register_wrapper(parent, virt_dev->name, 86 virt_dev->match_id, 10); 87 87 88 fun = ddf_fun_create(vdev, fun_inner, vfun->name); 89 if (fun == NULL) { 90 printf(NAME ": error creating function %s\n", vfun->name); 91 return ENOMEM; 88 if (rc == EOK) { 89 printf(NAME ": registered child device `%s'\n", 90 virt_dev->name); 91 } else { 92 printf(NAME ": failed to register child device `%s': %s\n", 93 virt_dev->name, str_error(rc)); 92 94 } 93 95 94 rc = ddf_fun_add_match_id(fun, vfun->match_id, 10); 95 if (rc != EOK) { 96 printf(NAME ": error adding match IDs to function %s\n", 97 vfun->name); 98 ddf_fun_destroy(fun); 99 return rc; 100 } 101 102 rc = ddf_fun_bind(fun); 103 if (rc != EOK) { 104 printf(NAME ": error binding function %s: %s\n", vfun->name, 105 str_error(rc)); 106 ddf_fun_destroy(fun); 107 return rc; 108 } 109 110 printf(NAME ": registered child device `%s'\n", vfun->name); 111 return EOK; 96 return rc; 112 97 } 113 98 114 static int rootvirt_add_device(ddf_dev_t *dev)99 static int add_device(device_t *dev) 115 100 { 116 101 static int instances = 0; … … 124 109 } 125 110 126 printf(NAME ": add_device(handle=%d)\n", (int)dev->handle); 127 111 printf(NAME ": add_device(name=\"%s\", handle=%d)\n", 112 dev->name, dev->handle); 113 128 114 /* 129 * Go through all virtual functions and try to add them.115 * Go through all virtual devices and try to add them. 130 116 * We silently ignore failures. 131 117 */ 132 virtual_ function_t *vfun = virtual_functions;133 while (v fun->name != NULL) {134 (void) rootvirt_add_fun(dev, vfun);135 v fun++;118 virtual_device_t *virt_dev = virtual_devices; 119 while (virt_dev->name != NULL) { 120 (void) add_child(dev, virt_dev); 121 virt_dev++; 136 122 } 137 123 … … 142 128 { 143 129 printf(NAME ": HelenOS virtual devices root driver\n"); 144 return d df_driver_main(&rootvirt_driver);130 return driver_main(&rootvirt_driver); 145 131 } 146 132
Note:
See TracChangeset
for help on using the changeset viewer.