Changeset ad7a6c9 in mainline for uspace/drv/rootvirt/rootvirt.c
- Timestamp:
- 2011-03-30T13:10:24Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4ae90f9
- Parents:
- 6e50466 (diff), d6b81941 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/rootvirt/rootvirt.c
r6e50466 rad7a6c9 39 39 #include <errno.h> 40 40 #include <str_error.h> 41 #include <d river.h>41 #include <ddf/driver.h> 42 42 43 43 #define NAME "rootvirt" 44 44 45 /** Virtual device entry.*/45 /** Virtual function entry */ 46 46 typedef struct { 47 /** Device name.*/47 /** Function name */ 48 48 const char *name; 49 /** Device match id.*/49 /** Function match ID */ 50 50 const char *match_id; 51 } virtual_ device_t;51 } virtual_function_t; 52 52 53 /** List of existing virtual devices.*/54 virtual_ device_t virtual_devices[] = {53 /** List of existing virtual functions */ 54 virtual_function_t virtual_functions[] = { 55 55 #include "devices.def" 56 /* Terminating item .*/56 /* Terminating item */ 57 57 { 58 58 .name = NULL, … … 61 61 }; 62 62 63 static int add_device(device_t *dev);63 static int rootvirt_add_device(ddf_dev_t *dev); 64 64 65 65 static driver_ops_t rootvirt_ops = { 66 .add_device = & add_device66 .add_device = &rootvirt_add_device 67 67 }; 68 68 … … 72 72 }; 73 73 74 /** Add childdevice.74 /** Add function to the virtual device. 75 75 * 76 * @param parent Parent device.77 * @param v irt_dev Virtual device to add.78 * @return Error code.76 * @param vdev The virtual device 77 * @param vfun Virtual function description 78 * @return EOK on success or negative error code. 79 79 */ 80 static int add_child(device_t *parent, virtual_device_t *virt_dev)80 static int rootvirt_add_fun(ddf_dev_t *vdev, virtual_function_t *vfun) 81 81 { 82 printf(NAME ": registering child device `%s' (match \"%s\")\n",83 virt_dev->name, virt_dev->match_id);82 ddf_fun_t *fun; 83 int rc; 84 84 85 int rc = child_device_register_wrapper(parent, virt_dev->name,86 v irt_dev->match_id, 10);85 printf(NAME ": registering function `%s' (match \"%s\")\n", 86 vfun->name, vfun->match_id); 87 87 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)); 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; 94 92 } 95 93 96 return rc; 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; 97 112 } 98 113 99 static int add_device(device_t *dev)114 static int rootvirt_add_device(ddf_dev_t *dev) 100 115 { 101 116 static int instances = 0; … … 109 124 } 110 125 111 printf(NAME ": add_device(name=\"%s\", handle=%d)\n", 112 dev->name, (int)dev->handle); 113 126 printf(NAME ": add_device(handle=%d)\n", (int)dev->handle); 127 114 128 /* 115 * Go through all virtual devices and try to add them.129 * Go through all virtual functions and try to add them. 116 130 * We silently ignore failures. 117 131 */ 118 virtual_ device_t *virt_dev = virtual_devices;119 while (v irt_dev->name != NULL) {120 (void) add_child(dev, virt_dev);121 v irt_dev++;132 virtual_function_t *vfun = virtual_functions; 133 while (vfun->name != NULL) { 134 (void) rootvirt_add_fun(dev, vfun); 135 vfun++; 122 136 } 123 137 … … 128 142 { 129 143 printf(NAME ": HelenOS virtual devices root driver\n"); 130 return d river_main(&rootvirt_driver);144 return ddf_driver_main(&rootvirt_driver); 131 145 } 132 146
Note:
See TracChangeset
for help on using the changeset viewer.