Changeset 8b655705 in mainline for uspace/drv/rootvirt/rootvirt.c
- Timestamp:
- 2011-04-15T19:38:07Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9dd730d1
- Parents:
- 6b9e85b (diff), b2fb47f (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
r6b9e85b r8b655705 39 39 #include <errno.h> 40 40 #include <str_error.h> 41 #include <driver.h> 41 #include <ddf/driver.h> 42 #include <ddf/log.h> 42 43 43 44 #define NAME "rootvirt" 44 45 45 /** Virtual device entry.*/46 /** Virtual function entry */ 46 47 typedef struct { 47 /** Device name.*/48 /** Function name */ 48 49 const char *name; 49 /** Device match id.*/50 /** Function match ID */ 50 51 const char *match_id; 51 } virtual_ device_t;52 } virtual_function_t; 52 53 53 /** List of existing virtual devices.*/54 virtual_ device_t virtual_devices[] = {54 /** List of existing virtual functions */ 55 virtual_function_t virtual_functions[] = { 55 56 #include "devices.def" 56 /* Terminating item .*/57 /* Terminating item */ 57 58 { 58 59 .name = NULL, … … 61 62 }; 62 63 63 static int add_device(device_t *dev);64 static int rootvirt_add_device(ddf_dev_t *dev); 64 65 65 66 static driver_ops_t rootvirt_ops = { 66 .add_device = & add_device67 .add_device = &rootvirt_add_device 67 68 }; 68 69 … … 72 73 }; 73 74 74 /** Add childdevice.75 /** Add function to the virtual device. 75 76 * 76 * @param parent Parent device.77 * @param v irt_dev Virtual device to add.78 * @return Error code.77 * @param vdev The virtual device 78 * @param vfun Virtual function description 79 * @return EOK on success or negative error code. 79 80 */ 80 static int add_child(device_t *parent, virtual_device_t *virt_dev)81 static int rootvirt_add_fun(ddf_dev_t *vdev, virtual_function_t *vfun) 81 82 { 82 printf(NAME ": registering child device `%s' (match \"%s\")\n",83 virt_dev->name, virt_dev->match_id);83 ddf_fun_t *fun; 84 int rc; 84 85 85 int rc = child_device_register_wrapper(parent, virt_dev->name,86 v irt_dev->match_id, 10);86 ddf_msg(LVL_DEBUG, "Registering function `%s' (match \"%s\")", 87 vfun->name, vfun->match_id); 87 88 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)); 89 fun = ddf_fun_create(vdev, fun_inner, vfun->name); 90 if (fun == NULL) { 91 ddf_msg(LVL_ERROR, "Failed creating function %s", vfun->name); 92 return ENOMEM; 94 93 } 95 94 96 return rc; 95 rc = ddf_fun_add_match_id(fun, vfun->match_id, 10); 96 if (rc != EOK) { 97 ddf_msg(LVL_ERROR, "Failed adding match IDs to function %s", 98 vfun->name); 99 ddf_fun_destroy(fun); 100 return rc; 101 } 102 103 rc = ddf_fun_bind(fun); 104 if (rc != EOK) { 105 ddf_msg(LVL_ERROR, "Failed binding function %s: %s", 106 vfun->name, str_error(rc)); 107 ddf_fun_destroy(fun); 108 return rc; 109 } 110 111 ddf_msg(LVL_NOTE, "Registered child device `%s'", vfun->name); 112 return EOK; 97 113 } 98 114 99 static int add_device(device_t *dev)115 static int rootvirt_add_device(ddf_dev_t *dev) 100 116 { 101 117 static int instances = 0; … … 109 125 } 110 126 111 printf(NAME ": add_device(name=\"%s\", handle=%d)\n", 112 dev->name, (int)dev->handle); 113 127 ddf_msg(LVL_DEBUG, "add_device(handle=%d)", (int)dev->handle); 128 114 129 /* 115 * Go through all virtual devices and try to add them.130 * Go through all virtual functions and try to add them. 116 131 * We silently ignore failures. 117 132 */ 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++;133 virtual_function_t *vfun = virtual_functions; 134 while (vfun->name != NULL) { 135 (void) rootvirt_add_fun(dev, vfun); 136 vfun++; 122 137 } 123 138 … … 128 143 { 129 144 printf(NAME ": HelenOS virtual devices root driver\n"); 130 return driver_main(&rootvirt_driver); 145 146 ddf_log_init(NAME, LVL_ERROR); 147 return ddf_driver_main(&rootvirt_driver); 131 148 } 132 149
Note:
See TracChangeset
for help on using the changeset viewer.