Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/devman/main.c

    rc6c389ed r38b3baf  
    6666static driver_t *devman_driver_register(void)
    6767{
     68        printf(NAME ": devman_driver_register \n");
     69       
    6870        ipc_call_t icall;
    69         ipc_callid_t iid;
     71        ipc_callid_t iid = async_get_call(&icall);
    7072        driver_t *driver = NULL;
    71 
    72         printf(NAME ": devman_driver_register \n");
    73        
    74         iid = async_get_call(&icall);
     73       
    7574        if (IPC_GET_METHOD(icall) != DEVMAN_DRIVER_REGISTER) {
    7675                ipc_answer_0(iid, EREFUSED);
     
    8685                return NULL;
    8786        }
    88 
    8987        printf(NAME ": the %s driver is trying to register by the service.\n",
    9088            drv_name);
     
    9391        driver = find_driver(&drivers_list, drv_name);
    9492       
    95         if (driver == NULL) {
     93        if (NULL == driver) {
    9694                printf(NAME ": no driver named %s was found.\n", drv_name);
    9795                free(drv_name);
     
    148146        }
    149147       
    150         if (match_id == NULL) {
     148        if (NULL == match_id) {
    151149                printf(NAME ": ERROR: devman_receive_match_id - failed to "
    152150                    "allocate match id.\n");
     
    162160        rc = async_data_write_accept((void **) &match_id_str, true, 0, 0, 0, 0);
    163161        match_id->id = match_id_str;
    164         if (rc != EOK) {
     162        if (EOK != rc) {
    165163                delete_match_id(match_id);
    166164                printf(NAME ": devman_receive_match_id - failed to receive "
     
    183181 * @return              Zero on success, negative error code otherwise.
    184182 */
    185 static int devman_receive_match_ids(ipcarg_t match_count,
    186     match_id_list_t *match_ids)
     183static int
     184devman_receive_match_ids(ipcarg_t match_count, match_id_list_t *match_ids)
    187185{
    188186        int ret = EOK;
     
    207205       
    208206        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) {
    212210                fibril_rwlock_write_unlock(&tree->rwlock);
    213211                ipc_answer_0(callid, ENOENT);
    214212                return;
    215         }
     213        }       
    216214       
    217215        char *dev_name = NULL;
    218216        int rc = async_data_write_accept((void **)&dev_name, true, 0, 0, 0, 0);
    219         if (rc != EOK) {
     217        if (EOK != rc) {
    220218                fibril_rwlock_write_unlock(&tree->rwlock);
    221219                ipc_answer_0(callid, rc);
     
    229227                ipc_answer_0(callid, ENOMEM);
    230228                return;
    231         }
    232 
     229        }       
    233230        fibril_rwlock_write_unlock(&tree->rwlock);
    234231       
     
    248245        /* Create devmap path and name for the device. */
    249246        char *devmap_pathname = NULL;
    250 
    251247        asprintf(&devmap_pathname, "%s/%s%c%s", DEVMAP_CLASS_NAMESPACE,
    252248            cli->dev_class->name, DEVMAP_SEPARATOR, cli->dev_name);
    253         if (devmap_pathname == NULL)
     249        if (NULL == devmap_pathname)
    254250                return;
    255251       
     
    283279       
    284280        node_t *dev = find_dev_node(&device_tree, handle);
    285         if (dev == NULL) {
     281        if (NULL == dev) {
    286282                ipc_answer_0(callid, ENOENT);
    287283                return;
     
    322318       
    323319        driver_t *driver = devman_driver_register();
    324         if (driver == NULL)
     320        if (NULL == driver)
    325321                return;
    326322       
     
    377373        free(pathname);
    378374
    379         if (dev == NULL) {
     375        if (NULL == dev) {
    380376                ipc_answer_0(iid, ENOENT);
    381377                return;
     
    408404                                ipc_answer_0(callid, ENOENT);
    409405                }
    410         }
    411 }
    412 
    413 static void devman_forward(ipc_callid_t iid, ipc_call_t *icall,
    414     bool drv_to_parent)
     406        }       
     407}
     408
     409static void
     410devman_forward(ipc_callid_t iid, ipc_call_t *icall, bool drv_to_parent)
    415411{
    416412        device_handle_t handle = IPC_GET_ARG2(*icall);
    417413       
    418414        node_t *dev = find_dev_node(&device_tree, handle);
    419         if (dev == NULL) {
     415        if (NULL == dev) {
    420416                printf(NAME ": devman_forward error - no device with handle %x "
    421417                    "was found.\n", handle);
     
    427423       
    428424        if (drv_to_parent) {
    429                 if (dev->parent != NULL)
     425                if (NULL != dev->parent)
    430426                        driver = dev->parent->drv;
    431         } else if (dev->state == DEVICE_USABLE) {
     427        } else if (DEVICE_USABLE == dev->state) {
    432428                driver = dev->drv;
    433                 assert(driver != NULL);
    434         }
    435        
    436         if (driver == NULL) {
     429                assert(NULL != driver);
     430        }
     431       
     432        if (NULL == driver) {
    437433                printf(NAME ": devman_forward error - the device is not in "
    438434                    "usable state.\n", handle);
     
    454450                return;
    455451        }
    456 
    457452        printf(NAME ": devman_forward: forward connection to device %s to "
    458453            "driver %s.\n", dev->pathname, driver->name);
     
    465460{
    466461        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)
    471465                dev = find_devmap_class_device(&class_list, devmap_handle);
    472466       
    473         if (dev == NULL || dev->drv == NULL) {
     467        if (NULL == dev || NULL == dev->drv) {
    474468                ipc_answer_0(iid, ENOENT);
    475469                return;
    476470        }
    477471       
    478         if (dev->state != DEVICE_USABLE || dev->drv->phone <= 0) {
     472        if (DEVICE_USABLE != dev->state || dev->drv->phone <= 0) {
    479473                ipc_answer_0(iid, EINVAL);
    480474                return;
     
    499493         * passes device handle to the driver as an ipc method.)
    500494         */
    501         if (IPC_GET_METHOD(*icall) != IPC_M_CONNECT_ME_TO)
     495        if (IPC_M_CONNECT_ME_TO != IPC_GET_METHOD(*icall))
    502496                devman_connection_devmapper(iid, icall);
    503497
     
    537531        /* Initialize list of available drivers. */
    538532        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)) {
    541535                printf(NAME " no drivers found.");
    542536                return false;
    543537        }
    544 
    545538        printf(NAME ": devman_init  - list of drivers has been initialized.\n");
    546539
Note: See TracChangeset for help on using the changeset viewer.