Changes in uspace/srv/devman/main.c [38b3baf:c6c389ed] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/main.c
r38b3baf rc6c389ed 66 66 static driver_t *devman_driver_register(void) 67 67 { 68 ipc_call_t icall; 69 ipc_callid_t iid; 70 driver_t *driver = NULL; 71 68 72 printf(NAME ": devman_driver_register \n"); 69 73 70 ipc_call_t icall; 71 ipc_callid_t iid = async_get_call(&icall); 72 driver_t *driver = NULL; 73 74 iid = async_get_call(&icall); 74 75 if (IPC_GET_METHOD(icall) != DEVMAN_DRIVER_REGISTER) { 75 76 ipc_answer_0(iid, EREFUSED); … … 85 86 return NULL; 86 87 } 88 87 89 printf(NAME ": the %s driver is trying to register by the service.\n", 88 90 drv_name); … … 91 93 driver = find_driver(&drivers_list, drv_name); 92 94 93 if ( NULL == driver) {95 if (driver == NULL) { 94 96 printf(NAME ": no driver named %s was found.\n", drv_name); 95 97 free(drv_name); … … 146 148 } 147 149 148 if ( NULL == match_id) {150 if (match_id == NULL) { 149 151 printf(NAME ": ERROR: devman_receive_match_id - failed to " 150 152 "allocate match id.\n"); … … 160 162 rc = async_data_write_accept((void **) &match_id_str, true, 0, 0, 0, 0); 161 163 match_id->id = match_id_str; 162 if ( EOK != rc) {164 if (rc != EOK) { 163 165 delete_match_id(match_id); 164 166 printf(NAME ": devman_receive_match_id - failed to receive " … … 181 183 * @return Zero on success, negative error code otherwise. 182 184 */ 183 static int 184 devman_receive_match_ids(ipcarg_t match_count,match_id_list_t *match_ids)185 static int devman_receive_match_ids(ipcarg_t match_count, 186 match_id_list_t *match_ids) 185 187 { 186 188 int ret = EOK; … … 205 207 206 208 fibril_rwlock_write_lock(&tree->rwlock); 207 node_t *parent = 208 209 if ( NULL == parent) {209 node_t *parent = find_dev_node_no_lock(&device_tree, parent_handle); 210 211 if (parent == NULL) { 210 212 fibril_rwlock_write_unlock(&tree->rwlock); 211 213 ipc_answer_0(callid, ENOENT); 212 214 return; 213 } 215 } 214 216 215 217 char *dev_name = NULL; 216 218 int rc = async_data_write_accept((void **)&dev_name, true, 0, 0, 0, 0); 217 if ( EOK != rc) {219 if (rc != EOK) { 218 220 fibril_rwlock_write_unlock(&tree->rwlock); 219 221 ipc_answer_0(callid, rc); … … 227 229 ipc_answer_0(callid, ENOMEM); 228 230 return; 229 } 231 } 232 230 233 fibril_rwlock_write_unlock(&tree->rwlock); 231 234 … … 245 248 /* Create devmap path and name for the device. */ 246 249 char *devmap_pathname = NULL; 250 247 251 asprintf(&devmap_pathname, "%s/%s%c%s", DEVMAP_CLASS_NAMESPACE, 248 252 cli->dev_class->name, DEVMAP_SEPARATOR, cli->dev_name); 249 if ( NULL == devmap_pathname)253 if (devmap_pathname == NULL) 250 254 return; 251 255 … … 279 283 280 284 node_t *dev = find_dev_node(&device_tree, handle); 281 if ( NULL == dev) {285 if (dev == NULL) { 282 286 ipc_answer_0(callid, ENOENT); 283 287 return; … … 318 322 319 323 driver_t *driver = devman_driver_register(); 320 if ( NULL == driver)324 if (driver == NULL) 321 325 return; 322 326 … … 373 377 free(pathname); 374 378 375 if ( NULL == dev) {379 if (dev == NULL) { 376 380 ipc_answer_0(iid, ENOENT); 377 381 return; … … 404 408 ipc_answer_0(callid, ENOENT); 405 409 } 406 } 407 } 408 409 static void 410 devman_forward(ipc_callid_t iid, ipc_call_t *icall,bool drv_to_parent)410 } 411 } 412 413 static void devman_forward(ipc_callid_t iid, ipc_call_t *icall, 414 bool drv_to_parent) 411 415 { 412 416 device_handle_t handle = IPC_GET_ARG2(*icall); 413 417 414 418 node_t *dev = find_dev_node(&device_tree, handle); 415 if ( NULL == dev) {419 if (dev == NULL) { 416 420 printf(NAME ": devman_forward error - no device with handle %x " 417 421 "was found.\n", handle); … … 423 427 424 428 if (drv_to_parent) { 425 if ( NULL != dev->parent)429 if (dev->parent != NULL) 426 430 driver = dev->parent->drv; 427 } else if ( DEVICE_USABLE == dev->state) {431 } else if (dev->state == DEVICE_USABLE) { 428 432 driver = dev->drv; 429 assert( NULL != driver);430 } 431 432 if ( NULL == driver) {433 assert(driver != NULL); 434 } 435 436 if (driver == NULL) { 433 437 printf(NAME ": devman_forward error - the device is not in " 434 438 "usable state.\n", handle); … … 450 454 return; 451 455 } 456 452 457 printf(NAME ": devman_forward: forward connection to device %s to " 453 458 "driver %s.\n", dev->pathname, driver->name); … … 460 465 { 461 466 dev_handle_t devmap_handle = IPC_GET_METHOD(*icall); 462 463 node_t *dev = find_devmap_tree_device(&device_tree, devmap_handle); 464 if (NULL == dev) 467 node_t *dev; 468 469 dev = find_devmap_tree_device(&device_tree, devmap_handle); 470 if (dev == NULL) 465 471 dev = find_devmap_class_device(&class_list, devmap_handle); 466 472 467 if ( NULL == dev || NULL == dev->drv) {473 if (dev == NULL || dev->drv == NULL) { 468 474 ipc_answer_0(iid, ENOENT); 469 475 return; 470 476 } 471 477 472 if ( DEVICE_USABLE != dev->state|| dev->drv->phone <= 0) {478 if (dev->state != DEVICE_USABLE || dev->drv->phone <= 0) { 473 479 ipc_answer_0(iid, EINVAL); 474 480 return; … … 493 499 * passes device handle to the driver as an ipc method.) 494 500 */ 495 if (IPC_ M_CONNECT_ME_TO != IPC_GET_METHOD(*icall))501 if (IPC_GET_METHOD(*icall) != IPC_M_CONNECT_ME_TO) 496 502 devman_connection_devmapper(iid, icall); 497 503 … … 531 537 /* Initialize list of available drivers. */ 532 538 init_driver_list(&drivers_list); 533 if ( 0 ==lookup_available_drivers(&drivers_list,534 DRIVER_DEFAULT_STORE) ) {539 if (lookup_available_drivers(&drivers_list, 540 DRIVER_DEFAULT_STORE) == 0) { 535 541 printf(NAME " no drivers found."); 536 542 return false; 537 543 } 544 538 545 printf(NAME ": devman_init - list of drivers has been initialized.\n"); 539 546
Note:
See TracChangeset
for help on using the changeset viewer.