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