Changeset 17aca1c in mainline for uspace/srv/devmap/devmap.c


Ignore:
Timestamp:
2011-02-04T20:56:52Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0397e5a4, e29e09cf
Parents:
e778543 (diff), 0b37882 (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.
Message:

Merge mainline changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/devmap/devmap.c

    re778543 r17aca1c  
    374374       
    375375        if (IPC_GET_IMETHOD(icall) != DEVMAP_DRIVER_REGISTER) {
    376                 ipc_answer_0(iid, EREFUSED);
     376                async_answer_0(iid, EREFUSED);
    377377                return NULL;
    378378        }
     
    381381            (devmap_driver_t *) malloc(sizeof(devmap_driver_t));
    382382        if (driver == NULL) {
    383                 ipc_answer_0(iid, ENOMEM);
     383                async_answer_0(iid, ENOMEM);
    384384                return NULL;
    385385        }
     
    392392        if (rc != EOK) {
    393393                free(driver);
    394                 ipc_answer_0(iid, rc);
     394                async_answer_0(iid, rc);
    395395                return NULL;
    396396        }
     
    405405                free(driver->name);
    406406                free(driver);
    407                 ipc_answer_0(callid, ENOTSUP);
    408                 ipc_answer_0(iid, ENOTSUP);
     407                async_answer_0(callid, ENOTSUP);
     408                async_answer_0(iid, ENOTSUP);
    409409                return NULL;
    410410        }
    411411       
    412412        driver->phone = IPC_GET_ARG5(call);
    413         ipc_answer_0(callid, EOK);
     413        async_answer_0(callid, EOK);
    414414       
    415415        /*
     
    423423         */
    424424        list_initialize(&driver->devices);
    425         list_initialize(&(driver->drivers));
     425
     426        link_initialize(&driver->drivers);
    426427       
    427428        fibril_mutex_lock(&drivers_list_mutex);
     
    438439        fibril_mutex_unlock(&drivers_list_mutex);
    439440       
    440         ipc_answer_0(iid, EOK);
     441        async_answer_0(iid, EOK);
    441442       
    442443        return driver;
     
    456457       
    457458        if (driver->phone != 0)
    458                 ipc_hangup(driver->phone);
     459                async_hangup(driver->phone);
    459460       
    460461        /* Remove it from list of drivers */
     
    491492{
    492493        if (driver == NULL) {
    493                 ipc_answer_0(iid, EREFUSED);
     494                async_answer_0(iid, EREFUSED);
    494495                return;
    495496        }
     
    499500            (devmap_device_t *) malloc(sizeof(devmap_device_t));
    500501        if (device == NULL) {
    501                 ipc_answer_0(iid, ENOMEM);
     502                async_answer_0(iid, ENOMEM);
    502503                return;
    503504        }
     
    512513        if (rc != EOK) {
    513514                free(device);
    514                 ipc_answer_0(iid, rc);
     515                async_answer_0(iid, rc);
    515516                return;
    516517        }
     
    520521                free(fqdn);
    521522                free(device);
    522                 ipc_answer_0(iid, EINVAL);
     523                async_answer_0(iid, EINVAL);
    523524                return;
    524525        }
     
    534535                free(device->name);
    535536                free(device);
    536                 ipc_answer_0(iid, ENOMEM);
    537                 return;
    538         }
    539        
    540         list_initialize(&(device->devices));
    541         list_initialize(&(device->driver_devices));
     537                async_answer_0(iid, ENOMEM);
     538                return;
     539        }
     540       
     541        link_initialize(&device->devices);
     542        link_initialize(&device->driver_devices);
    542543       
    543544        /* Check that device is not already registered */
     
    549550                free(device->name);
    550551                free(device);
    551                 ipc_answer_0(iid, EEXISTS);
     552                async_answer_0(iid, EEXISTS);
    552553                return;
    553554        }
     
    571572        fibril_mutex_unlock(&devices_list_mutex);
    572573       
    573         ipc_answer_1(iid, EOK, device->handle);
     574        async_answer_1(iid, EOK, device->handle);
    574575}
    575576
     
    602603        if ((dev == NULL) || (dev->driver == NULL) || (dev->driver->phone == 0)) {
    603604                fibril_mutex_unlock(&devices_list_mutex);
    604                 ipc_answer_0(callid, ENOENT);
     605                async_answer_0(callid, ENOENT);
    605606                return;
    606607        }
    607608       
    608609        if (dev->forward_interface == 0) {
    609                 ipc_forward_fast(callid, dev->driver->phone,
     610                async_forward_fast(callid, dev->driver->phone,
    610611                    dev->handle, 0, 0,
    611612                    IPC_FF_NONE);
    612613        } else {
    613                 ipc_forward_fast(callid, dev->driver->phone,
     614                async_forward_fast(callid, dev->driver->phone,
    614615                    dev->forward_interface, dev->handle, 0,
    615616                    IPC_FF_NONE);
     
    633634            DEVMAP_NAME_MAXLEN, 0, NULL);
    634635        if (rc != EOK) {
    635                 ipc_answer_0(iid, rc);
     636                async_answer_0(iid, rc);
    636637                return;
    637638        }
     
    641642        if (!devmap_fqdn_split(fqdn, &ns_name, &name)) {
    642643                free(fqdn);
    643                 ipc_answer_0(iid, EINVAL);
     644                async_answer_0(iid, EINVAL);
    644645                return;
    645646        }
     
    668669                }
    669670               
    670                 ipc_answer_0(iid, ENOENT);
     671                async_answer_0(iid, ENOENT);
    671672                free(ns_name);
    672673                free(name);
     
    675676        }
    676677       
    677         ipc_answer_1(iid, EOK, dev->handle);
     678        async_answer_1(iid, EOK, dev->handle);
    678679       
    679680        fibril_mutex_unlock(&devices_list_mutex);
     
    696697            DEVMAP_NAME_MAXLEN, 0, NULL);
    697698        if (rc != EOK) {
    698                 ipc_answer_0(iid, rc);
     699                async_answer_0(iid, rc);
    699700                return;
    700701        }
     
    721722                }
    722723               
    723                 ipc_answer_0(iid, ENOENT);
     724                async_answer_0(iid, ENOENT);
    724725                free(name);
    725726                fibril_mutex_unlock(&devices_list_mutex);
     
    727728        }
    728729       
    729         ipc_answer_1(iid, EOK, namespace->handle);
     730        async_answer_1(iid, EOK, namespace->handle);
    730731       
    731732        fibril_mutex_unlock(&devices_list_mutex);
     
    743744                    devmap_device_find_handle(IPC_GET_ARG1(*icall));
    744745                if (dev == NULL)
    745                         ipc_answer_1(iid, EOK, DEV_HANDLE_NONE);
     746                        async_answer_1(iid, EOK, DEV_HANDLE_NONE);
    746747                else
    747                         ipc_answer_1(iid, EOK, DEV_HANDLE_DEVICE);
     748                        async_answer_1(iid, EOK, DEV_HANDLE_DEVICE);
    748749        } else
    749                 ipc_answer_1(iid, EOK, DEV_HANDLE_NAMESPACE);
     750                async_answer_1(iid, EOK, DEV_HANDLE_NAMESPACE);
    750751       
    751752        fibril_mutex_unlock(&devices_list_mutex);
     
    755756{
    756757        fibril_mutex_lock(&devices_list_mutex);
    757         ipc_answer_1(iid, EOK, list_count(&namespaces_list));
     758        async_answer_1(iid, EOK, list_count(&namespaces_list));
    758759        fibril_mutex_unlock(&devices_list_mutex);
    759760}
     
    766767            devmap_namespace_find_handle(IPC_GET_ARG1(*icall));
    767768        if (namespace == NULL)
    768                 ipc_answer_0(iid, EEXISTS);
     769                async_answer_0(iid, EEXISTS);
    769770        else
    770                 ipc_answer_1(iid, EOK, namespace->refcnt);
     771                async_answer_1(iid, EOK, namespace->refcnt);
    771772       
    772773        fibril_mutex_unlock(&devices_list_mutex);
     
    778779        size_t size;
    779780        if (!async_data_read_receive(&callid, &size)) {
    780                 ipc_answer_0(callid, EREFUSED);
    781                 ipc_answer_0(iid, EREFUSED);
     781                async_answer_0(callid, EREFUSED);
     782                async_answer_0(iid, EREFUSED);
    782783                return;
    783784        }
    784785       
    785786        if ((size % sizeof(dev_desc_t)) != 0) {
    786                 ipc_answer_0(callid, EINVAL);
    787                 ipc_answer_0(iid, EINVAL);
     787                async_answer_0(callid, EINVAL);
     788                async_answer_0(iid, EINVAL);
    788789                return;
    789790        }
     
    794795        if (count != list_count(&namespaces_list)) {
    795796                fibril_mutex_unlock(&devices_list_mutex);
    796                 ipc_answer_0(callid, EOVERFLOW);
    797                 ipc_answer_0(iid, EOVERFLOW);
     797                async_answer_0(callid, EOVERFLOW);
     798                async_answer_0(iid, EOVERFLOW);
    798799                return;
    799800        }
     
    802803        if (desc == NULL) {
    803804                fibril_mutex_unlock(&devices_list_mutex);
    804                 ipc_answer_0(callid, ENOMEM);
    805                 ipc_answer_0(iid, ENOMEM);
     805                async_answer_0(callid, ENOMEM);
     806                async_answer_0(iid, ENOMEM);
    806807                return;
    807808        }
     
    824825        fibril_mutex_unlock(&devices_list_mutex);
    825826       
    826         ipc_answer_0(iid, retval);
     827        async_answer_0(iid, retval);
    827828}
    828829
     
    835836        size_t size;
    836837        if (!async_data_read_receive(&callid, &size)) {
    837                 ipc_answer_0(callid, EREFUSED);
    838                 ipc_answer_0(iid, EREFUSED);
     838                async_answer_0(callid, EREFUSED);
     839                async_answer_0(iid, EREFUSED);
    839840                return;
    840841        }
    841842       
    842843        if ((size % sizeof(dev_desc_t)) != 0) {
    843                 ipc_answer_0(callid, EINVAL);
    844                 ipc_answer_0(iid, EINVAL);
     844                async_answer_0(callid, EINVAL);
     845                async_answer_0(iid, EINVAL);
    845846                return;
    846847        }
     
    852853        if (namespace == NULL) {
    853854                fibril_mutex_unlock(&devices_list_mutex);
    854                 ipc_answer_0(callid, ENOENT);
    855                 ipc_answer_0(iid, ENOENT);
     855                async_answer_0(callid, ENOENT);
     856                async_answer_0(iid, ENOENT);
    856857                return;
    857858        }
     
    860861        if (count != namespace->refcnt) {
    861862                fibril_mutex_unlock(&devices_list_mutex);
    862                 ipc_answer_0(callid, EOVERFLOW);
    863                 ipc_answer_0(iid, EOVERFLOW);
     863                async_answer_0(callid, EOVERFLOW);
     864                async_answer_0(iid, EOVERFLOW);
    864865                return;
    865866        }
     
    868869        if (desc == NULL) {
    869870                fibril_mutex_unlock(&devices_list_mutex);
    870                 ipc_answer_0(callid, ENOMEM);
    871                 ipc_answer_0(iid, EREFUSED);
     871                async_answer_0(callid, ENOMEM);
     872                async_answer_0(iid, EREFUSED);
    872873                return;
    873874        }
     
    891892        fibril_mutex_unlock(&devices_list_mutex);
    892893       
    893         ipc_answer_0(iid, retval);
     894        async_answer_0(iid, retval);
    894895}
    895896
     
    910911        if (!fnd) {
    911912                fibril_mutex_unlock(&null_devices_mutex);
    912                 ipc_answer_0(iid, ENOMEM);
     913                async_answer_0(iid, ENOMEM);
    913914                return;
    914915        }
     
    920921        if (dev_name == NULL) {
    921922                fibril_mutex_unlock(&null_devices_mutex);
    922                 ipc_answer_0(iid, ENOMEM);
     923                async_answer_0(iid, ENOMEM);
    923924                return;
    924925        }
     
    928929        if (device == NULL) {
    929930                fibril_mutex_unlock(&null_devices_mutex);
    930                 ipc_answer_0(iid, ENOMEM);
     931                async_answer_0(iid, ENOMEM);
    931932                return;
    932933        }
     
    938939                fibril_mutex_lock(&devices_list_mutex);
    939940                fibril_mutex_unlock(&null_devices_mutex);
    940                 ipc_answer_0(iid, ENOMEM);
    941                 return;
    942         }
    943        
    944         list_initialize(&(device->devices));
    945         list_initialize(&(device->driver_devices));
     941                async_answer_0(iid, ENOMEM);
     942                return;
     943        }
     944       
     945        link_initialize(&device->devices);
     946        link_initialize(&device->driver_devices);
    946947       
    947948        /* Get unique device handle */
     
    960961        fibril_mutex_unlock(&null_devices_mutex);
    961962       
    962         ipc_answer_1(iid, EOK, (sysarg_t) i);
     963        async_answer_1(iid, EOK, (sysarg_t) i);
    963964}
    964965
     
    967968        sysarg_t i = IPC_GET_ARG1(*icall);
    968969        if (i >= NULL_DEVICES) {
    969                 ipc_answer_0(iid, ELIMIT);
     970                async_answer_0(iid, ELIMIT);
    970971                return;
    971972        }
     
    975976        if (null_devices[i] == NULL) {
    976977                fibril_mutex_unlock(&null_devices_mutex);
    977                 ipc_answer_0(iid, ENOENT);
     978                async_answer_0(iid, ENOENT);
    978979                return;
    979980        }
     
    986987       
    987988        fibril_mutex_unlock(&null_devices_mutex);
    988         ipc_answer_0(iid, EOK);
     989        async_answer_0(iid, EOK);
    989990}
    990991
     
    10121013{
    10131014        /* Accept connection */
    1014         ipc_answer_0(iid, EOK);
     1015        async_answer_0(iid, EOK);
    10151016       
    10161017        devmap_driver_t *driver = devmap_driver_register();
     
    10291030                case DEVMAP_DRIVER_UNREGISTER:
    10301031                        if (NULL == driver)
    1031                                 ipc_answer_0(callid, ENOENT);
     1032                                async_answer_0(callid, ENOENT);
    10321033                        else
    1033                                 ipc_answer_0(callid, EOK);
     1034                                async_answer_0(callid, EOK);
    10341035                        break;
    10351036                case DEVMAP_DEVICE_REGISTER:
     
    10481049                        break;
    10491050                default:
    1050                         ipc_answer_0(callid, ENOENT);
     1051                        async_answer_0(callid, ENOENT);
    10511052                }
    10521053        }
     
    10671068{
    10681069        /* Accept connection */
    1069         ipc_answer_0(iid, EOK);
     1070        async_answer_0(iid, EOK);
    10701071       
    10711072        bool cont = true;
     
    11061107                        break;
    11071108                default:
    1108                         ipc_answer_0(callid, ENOENT);
     1109                        async_answer_0(callid, ENOENT);
    11091110                }
    11101111        }
     
    11301131        default:
    11311132                /* No such interface */
    1132                 ipc_answer_0(iid, ENOENT);
     1133                async_answer_0(iid, ENOENT);
    11331134        }
    11341135}
     
    11501151       
    11511152        /* Register device mapper at naming service */
    1152         if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAP, 0, 0, NULL, NULL) != 0)
     1153        if (service_register(SERVICE_DEVMAP) != EOK)
    11531154                return -1;
    11541155       
Note: See TracChangeset for help on using the changeset viewer.