Changeset c6c389ed in mainline for uspace/srv/devman/main.c


Ignore:
Timestamp:
2010-10-23T16:08:18Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
791f58c
Parents:
58b833c
Message:

Yet more cstyle in devman.

File:
1 edited

Legend:

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

    r58b833c rc6c389ed  
    6666static driver_t *devman_driver_register(void)
    6767{
     68        ipc_call_t icall;
     69        ipc_callid_t iid;
     70        driver_t *driver = NULL;
     71
    6872        printf(NAME ": devman_driver_register \n");
    6973       
    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);
    7475        if (IPC_GET_METHOD(icall) != DEVMAN_DRIVER_REGISTER) {
    7576                ipc_answer_0(iid, EREFUSED);
     
    8586                return NULL;
    8687        }
     88
    8789        printf(NAME ": the %s driver is trying to register by the service.\n",
    8890            drv_name);
     
    9193        driver = find_driver(&drivers_list, drv_name);
    9294       
    93         if (NULL == driver) {
     95        if (driver == NULL) {
    9496                printf(NAME ": no driver named %s was found.\n", drv_name);
    9597                free(drv_name);
     
    146148        }
    147149       
    148         if (NULL == match_id) {
     150        if (match_id == NULL) {
    149151                printf(NAME ": ERROR: devman_receive_match_id - failed to "
    150152                    "allocate match id.\n");
     
    160162        rc = async_data_write_accept((void **) &match_id_str, true, 0, 0, 0, 0);
    161163        match_id->id = match_id_str;
    162         if (EOK != rc) {
     164        if (rc != EOK) {
    163165                delete_match_id(match_id);
    164166                printf(NAME ": devman_receive_match_id - failed to receive "
     
    181183 * @return              Zero on success, negative error code otherwise.
    182184 */
    183 static int
    184 devman_receive_match_ids(ipcarg_t match_count, match_id_list_t *match_ids)
     185static int devman_receive_match_ids(ipcarg_t match_count,
     186    match_id_list_t *match_ids)
    185187{
    186188        int ret = EOK;
     
    205207       
    206208        fibril_rwlock_write_lock(&tree->rwlock);
    207         node_t *parent =  find_dev_node_no_lock(&device_tree, parent_handle);
    208        
    209         if (NULL == parent) {
     209        node_t *parent = find_dev_node_no_lock(&device_tree, parent_handle);
     210       
     211        if (parent == NULL) {
    210212                fibril_rwlock_write_unlock(&tree->rwlock);
    211213                ipc_answer_0(callid, ENOENT);
    212214                return;
    213         }       
     215        }
    214216       
    215217        char *dev_name = NULL;
    216218        int rc = async_data_write_accept((void **)&dev_name, true, 0, 0, 0, 0);
    217         if (EOK != rc) {
     219        if (rc != EOK) {
    218220                fibril_rwlock_write_unlock(&tree->rwlock);
    219221                ipc_answer_0(callid, rc);
     
    227229                ipc_answer_0(callid, ENOMEM);
    228230                return;
    229         }       
     231        }
     232
    230233        fibril_rwlock_write_unlock(&tree->rwlock);
    231234       
     
    245248        /* Create devmap path and name for the device. */
    246249        char *devmap_pathname = NULL;
     250
    247251        asprintf(&devmap_pathname, "%s/%s%c%s", DEVMAP_CLASS_NAMESPACE,
    248252            cli->dev_class->name, DEVMAP_SEPARATOR, cli->dev_name);
    249         if (NULL == devmap_pathname)
     253        if (devmap_pathname == NULL)
    250254                return;
    251255       
     
    279283       
    280284        node_t *dev = find_dev_node(&device_tree, handle);
    281         if (NULL == dev) {
     285        if (dev == NULL) {
    282286                ipc_answer_0(callid, ENOENT);
    283287                return;
     
    318322       
    319323        driver_t *driver = devman_driver_register();
    320         if (NULL == driver)
     324        if (driver == NULL)
    321325                return;
    322326       
     
    373377        free(pathname);
    374378
    375         if (NULL == dev) {
     379        if (dev == NULL) {
    376380                ipc_answer_0(iid, ENOENT);
    377381                return;
     
    404408                                ipc_answer_0(callid, ENOENT);
    405409                }
    406         }       
    407 }
    408 
    409 static void
    410 devman_forward(ipc_callid_t iid, ipc_call_t *icall, bool drv_to_parent)
     410        }
     411}
     412
     413static void devman_forward(ipc_callid_t iid, ipc_call_t *icall,
     414    bool drv_to_parent)
    411415{
    412416        device_handle_t handle = IPC_GET_ARG2(*icall);
    413417       
    414418        node_t *dev = find_dev_node(&device_tree, handle);
    415         if (NULL == dev) {
     419        if (dev == NULL) {
    416420                printf(NAME ": devman_forward error - no device with handle %x "
    417421                    "was found.\n", handle);
     
    423427       
    424428        if (drv_to_parent) {
    425                 if (NULL != dev->parent)
     429                if (dev->parent != NULL)
    426430                        driver = dev->parent->drv;
    427         } else if (DEVICE_USABLE == dev->state) {
     431        } else if (dev->state == DEVICE_USABLE) {
    428432                driver = dev->drv;
    429                 assert(NULL != driver);
    430         }
    431        
    432         if (NULL == driver) {
     433                assert(driver != NULL);
     434        }
     435       
     436        if (driver == NULL) {
    433437                printf(NAME ": devman_forward error - the device is not in "
    434438                    "usable state.\n", handle);
     
    450454                return;
    451455        }
     456
    452457        printf(NAME ": devman_forward: forward connection to device %s to "
    453458            "driver %s.\n", dev->pathname, driver->name);
     
    460465{
    461466        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)
    465471                dev = find_devmap_class_device(&class_list, devmap_handle);
    466472       
    467         if (NULL == dev || NULL == dev->drv) {
     473        if (dev == NULL || dev->drv == NULL) {
    468474                ipc_answer_0(iid, ENOENT);
    469475                return;
    470476        }
    471477       
    472         if (DEVICE_USABLE != dev->state || dev->drv->phone <= 0) {
     478        if (dev->state != DEVICE_USABLE || dev->drv->phone <= 0) {
    473479                ipc_answer_0(iid, EINVAL);
    474480                return;
     
    493499         * passes device handle to the driver as an ipc method.)
    494500         */
    495         if (IPC_M_CONNECT_ME_TO != IPC_GET_METHOD(*icall))
     501        if (IPC_GET_METHOD(*icall) != IPC_M_CONNECT_ME_TO)
    496502                devman_connection_devmapper(iid, icall);
    497503
     
    531537        /* Initialize list of available drivers. */
    532538        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) {
    535541                printf(NAME " no drivers found.");
    536542                return false;
    537543        }
     544
    538545        printf(NAME ": devman_init  - list of drivers has been initialized.\n");
    539546
Note: See TracChangeset for help on using the changeset viewer.