Changeset 8e7c9fe in mainline for uspace/drv/root/virt/virt.c
- Timestamp:
- 2014-09-12T03:45:25Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c53b58e
- Parents:
- 3eb0c85 (diff), 105d8d6 (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 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/root/virt/virt.c
r3eb0c85 r8e7c9fe 28 28 29 29 /** 30 * @defgroup rootvirt Root device driver for virtual devices.30 * @defgroup virt Root device driver for virtual devices. 31 31 * @{ 32 32 */ … … 42 42 #include <ddf/log.h> 43 43 44 #define NAME " rootvirt"44 #define NAME "virt" 45 45 46 46 /** Virtual function entry */ … … 62 62 }; 63 63 64 static int rootvirt_dev_add(ddf_dev_t *dev);65 static int rootvirt_dev_remove(ddf_dev_t *dev);66 static int rootvirt_fun_online(ddf_fun_t *fun);67 static int rootvirt_fun_offline(ddf_fun_t *fun);68 69 static driver_ops_t rootvirt_ops = {70 .dev_add = & rootvirt_dev_add,71 .dev_remove = & rootvirt_dev_remove,72 .fun_online = & rootvirt_fun_online,73 .fun_offline = & rootvirt_fun_offline64 static int virt_dev_add(ddf_dev_t *dev); 65 static int virt_dev_remove(ddf_dev_t *dev); 66 static int virt_fun_online(ddf_fun_t *fun); 67 static int virt_fun_offline(ddf_fun_t *fun); 68 69 static driver_ops_t virt_ops = { 70 .dev_add = &virt_dev_add, 71 .dev_remove = &virt_dev_remove, 72 .fun_online = &virt_fun_online, 73 .fun_offline = &virt_fun_offline 74 74 }; 75 75 76 static driver_t rootvirt_driver = {76 static driver_t virt_driver = { 77 77 .name = NAME, 78 .driver_ops = & rootvirt_ops78 .driver_ops = &virt_ops 79 79 }; 80 80 … … 83 83 ddf_dev_t *dev; 84 84 list_t functions; 85 } rootvirt_t;85 } virt_t; 86 86 87 87 /* Function soft state */ … … 89 89 ddf_fun_t *fun; 90 90 link_t dev_link; 91 } rootvirt_fun_t;91 } virt_fun_t; 92 92 93 93 static int instances = 0; … … 100 100 * @return EOK on success or negative error code. 101 101 */ 102 static int rootvirt_add_fun(rootvirt_t *rootvirt, virtual_function_t *vfun)103 { 104 ddf_dev_t *vdev = rootvirt->dev;102 static int virt_add_fun(virt_t *virt, virtual_function_t *vfun) 103 { 104 ddf_dev_t *vdev = virt->dev; 105 105 ddf_fun_t *fun; 106 rootvirt_fun_t *rvfun;106 virt_fun_t *rvfun; 107 107 int rc; 108 108 … … 116 116 } 117 117 118 rvfun = ddf_fun_data_alloc(fun, sizeof( rootvirt_fun_t));118 rvfun = ddf_fun_data_alloc(fun, sizeof(virt_fun_t)); 119 119 if (rvfun == NULL) { 120 120 ddf_msg(LVL_ERROR, "Failed allocating soft state for %s.", … … 142 142 } 143 143 144 list_append(&rvfun->dev_link, & rootvirt->functions);144 list_append(&rvfun->dev_link, &virt->functions); 145 145 146 146 ddf_msg(LVL_NOTE, "Registered child device `%s'", vfun->name); … … 148 148 } 149 149 150 static int rootvirt_fun_remove(rootvirt_fun_t *rvfun)150 static int virt_fun_remove(virt_fun_t *rvfun) 151 151 { 152 152 int rc; 153 153 const char *name = ddf_fun_get_name(rvfun->fun); 154 154 155 ddf_msg(LVL_DEBUG, " rootvirt_fun_remove('%s')", name);155 ddf_msg(LVL_DEBUG, "virt_fun_remove('%s')", name); 156 156 rc = ddf_fun_offline(rvfun->fun); 157 157 if (rc != EOK) { … … 172 172 173 173 174 static int rootvirt_dev_add(ddf_dev_t *dev)175 { 176 rootvirt_t *rootvirt;174 static int virt_dev_add(ddf_dev_t *dev) 175 { 176 virt_t *virt; 177 177 178 178 /* … … 185 185 ddf_msg(LVL_DEBUG, "dev_add(handle=%d)", (int)ddf_dev_get_handle(dev)); 186 186 187 rootvirt = ddf_dev_data_alloc(dev, sizeof(rootvirt_t));188 if ( rootvirt == NULL)187 virt = ddf_dev_data_alloc(dev, sizeof(virt_t)); 188 if (virt == NULL) 189 189 return ENOMEM; 190 190 191 rootvirt->dev = dev;192 list_initialize(& rootvirt->functions);191 virt->dev = dev; 192 list_initialize(&virt->functions); 193 193 194 194 /* … … 198 198 virtual_function_t *vfun = virtual_functions; 199 199 while (vfun->name != NULL) { 200 (void) rootvirt_add_fun(rootvirt, vfun);200 (void) virt_add_fun(virt, vfun); 201 201 vfun++; 202 202 } … … 205 205 } 206 206 207 static int rootvirt_dev_remove(ddf_dev_t *dev)208 { 209 rootvirt_t *rootvirt = (rootvirt_t *)ddf_dev_data_get(dev);207 static int virt_dev_remove(ddf_dev_t *dev) 208 { 209 virt_t *virt = (virt_t *)ddf_dev_data_get(dev); 210 210 int rc; 211 211 212 while (!list_empty(& rootvirt->functions)) {213 rootvirt_fun_t *rvfun = list_get_instance(214 list_first(& rootvirt->functions), rootvirt_fun_t,212 while (!list_empty(&virt->functions)) { 213 virt_fun_t *rvfun = list_get_instance( 214 list_first(&virt->functions), virt_fun_t, 215 215 dev_link); 216 216 217 rc = rootvirt_fun_remove(rvfun);217 rc = virt_fun_remove(rvfun); 218 218 if (rc != EOK) 219 219 return rc; … … 224 224 } 225 225 226 static int rootvirt_fun_online(ddf_fun_t *fun)227 { 228 ddf_msg(LVL_DEBUG, " rootvirt_fun_online()");226 static int virt_fun_online(ddf_fun_t *fun) 227 { 228 ddf_msg(LVL_DEBUG, "virt_fun_online()"); 229 229 return ddf_fun_online(fun); 230 230 } 231 231 232 static int rootvirt_fun_offline(ddf_fun_t *fun)233 { 234 ddf_msg(LVL_DEBUG, " rootvirt_fun_offline()");232 static int virt_fun_offline(ddf_fun_t *fun) 233 { 234 ddf_msg(LVL_DEBUG, "virt_fun_offline()"); 235 235 return ddf_fun_offline(fun); 236 236 } … … 241 241 242 242 ddf_log_init(NAME); 243 return ddf_driver_main(& rootvirt_driver);243 return ddf_driver_main(&virt_driver); 244 244 } 245 245
Note:
See TracChangeset
for help on using the changeset viewer.