Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/devman.c

    r4c9b28a rd87561c  
    11/*
    22 * Copyright (c) 2007 Josef Cejka
    3  * Copyright (c) 2013 Jiri Svoboda
     3 * Copyright (c) 2011 Jiri Svoboda
    44 * Copyright (c) 2010 Lenka Trochtova
    55 * All rights reserved.
     
    230230        }
    231231       
    232         list_foreach(match_ids->ids, link, match_id_t, match_id) {
     232        match_id_t *match_id = NULL;
     233       
     234        list_foreach(match_ids->ids, link) {
     235                match_id = list_get_instance(link, match_id_t, link);
     236               
    233237                ipc_call_t answer2;
    234238                aid_t req2 = async_send_1(exch, DEVMAN_ADD_MATCH_ID,
     
    401405}
    402406
    403 static int devman_get_str_internal(sysarg_t method, sysarg_t arg1,
    404     sysarg_t arg2, sysarg_t *r1, char *buf, size_t buf_size)
     407static int devman_get_str_internal(sysarg_t method, sysarg_t arg1, char *buf,
     408    size_t buf_size)
    405409{
    406410        async_exch_t *exch;
     
    412416       
    413417        ipc_call_t answer;
    414         aid_t req = async_send_2(exch, method, arg1, arg2, &answer);
     418        aid_t req = async_send_1(exch, method, arg1, &answer);
    415419        aid_t dreq = async_data_read(exch, buf, buf_size - 1, &dreply);
    416420        async_wait_for(dreq, &dretval);
     
    430434        }
    431435       
    432         if (r1 != NULL)
    433                 *r1 = IPC_GET_ARG1(answer);
    434436        act_size = IPC_GET_ARG2(dreply);
    435437        assert(act_size <= buf_size - 1);
     
    441443int devman_fun_get_path(devman_handle_t handle, char *buf, size_t buf_size)
    442444{
    443         return devman_get_str_internal(DEVMAN_FUN_GET_PATH, handle, 0, NULL,
    444             buf, buf_size);
    445 }
    446 
    447 int devman_fun_get_match_id(devman_handle_t handle, size_t index, char *buf,
    448     size_t buf_size, unsigned int *rscore)
    449 {
    450         int rc;
    451         sysarg_t score = 0;
    452 
    453         rc = devman_get_str_internal(DEVMAN_FUN_GET_MATCH_ID, handle, index,
    454             &score, buf, buf_size);
    455         if (rc != EOK)
    456                 return rc;
    457 
    458         *rscore = score;
    459         return rc;
     445        return devman_get_str_internal(DEVMAN_FUN_GET_PATH, handle, buf,
     446            buf_size);
    460447}
    461448
    462449int devman_fun_get_name(devman_handle_t handle, char *buf, size_t buf_size)
    463450{
    464         return devman_get_str_internal(DEVMAN_FUN_GET_NAME, handle, 0, NULL,
    465             buf, buf_size);
     451        return devman_get_str_internal(DEVMAN_FUN_GET_NAME, handle, buf,
     452            buf_size);
    466453}
    467454
    468455int devman_fun_get_driver_name(devman_handle_t handle, char *buf, size_t buf_size)
    469456{
    470         return devman_get_str_internal(DEVMAN_FUN_GET_DRIVER_NAME, handle, 0,
    471             NULL, buf, buf_size);
     457        return devman_get_str_internal(DEVMAN_FUN_GET_DRIVER_NAME, handle, buf,
     458            buf_size);
    472459}
    473460
     
    596583}
    597584
    598 int devman_dev_get_parent(devman_handle_t devh, devman_handle_t *funh)
     585int devman_fun_sid_to_handle(service_id_t sid, devman_handle_t *handle)
    599586{
    600587        async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT);
     
    602589                return ENOMEM;
    603590       
    604         sysarg_t retval = async_req_1_1(exch, DEVMAN_DEV_GET_PARENT,
    605             devh, funh);
    606        
    607         devman_exchange_end(exch);
    608         return (int) retval;
    609 }
    610 
    611 int devman_fun_sid_to_handle(service_id_t sid, devman_handle_t *handle)
    612 {
    613         async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT);
    614         if (exch == NULL)
    615                 return ENOMEM;
    616        
    617591        sysarg_t retval = async_req_1_1(exch, DEVMAN_FUN_SID_TO_HANDLE,
    618592            sid, handle);
     
    622596}
    623597
    624 int devman_get_drivers(devman_handle_t **drvs,
    625     size_t *count)
    626 {
    627         return devman_get_handles_internal(DEVMAN_GET_DRIVERS, 0, drvs, count);
    628 }
    629 
    630 int devman_driver_get_devices(devman_handle_t drvh, devman_handle_t **devs,
    631     size_t *count)
    632 {
    633         return devman_get_handles_internal(DEVMAN_DRIVER_GET_DEVICES,
    634             drvh, devs, count);
    635 }
    636 
    637 int devman_driver_get_handle(const char *drvname, devman_handle_t *handle)
    638 {
    639         async_exch_t *exch;
    640 
    641         exch = devman_exchange_begin(DEVMAN_CLIENT);
    642         if (exch == NULL)
    643                 return ENOMEM;
    644        
    645         ipc_call_t answer;
    646         aid_t req = async_send_0(exch, DEVMAN_DRIVER_GET_HANDLE, &answer);
    647         sysarg_t retval = async_data_write_start(exch, drvname,
    648             str_size(drvname));
    649        
    650         devman_exchange_end(exch);
    651        
    652         if (retval != EOK) {
    653                 async_forget(req);
    654                 return retval;
    655         }
    656        
    657         async_wait_for(req, &retval);
    658        
    659         if (retval != EOK) {
    660                 if (handle != NULL)
    661                         *handle = (devman_handle_t) -1;
    662                
    663                 return retval;
    664         }
    665        
    666         if (handle != NULL)
    667                 *handle = (devman_handle_t) IPC_GET_ARG1(answer);
    668        
    669         return retval;
    670 }
    671 
    672 int devman_driver_get_match_id(devman_handle_t handle, size_t index, char *buf,
    673     size_t buf_size, unsigned int *rscore)
    674 {
    675         int rc;
    676         sysarg_t score = 0;
    677 
    678         rc = devman_get_str_internal(DEVMAN_DRIVER_GET_MATCH_ID, handle, index,
    679             &score, buf, buf_size);
    680         if (rc != EOK)
    681                 return rc;
    682 
    683         *rscore = score;
    684         return rc;
    685 }
    686 
    687 int devman_driver_get_name(devman_handle_t handle, char *buf, size_t buf_size)
    688 {
    689         return devman_get_str_internal(DEVMAN_DRIVER_GET_NAME, handle, 0, NULL,
    690             buf, buf_size);
    691 }
    692 
    693 int devman_driver_get_state(devman_handle_t drvh, driver_state_t *rstate)
    694 {
    695         sysarg_t state;
    696         async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT);
    697         if (exch == NULL)
    698                 return ENOMEM;
    699        
    700         int rc = async_req_1_1(exch, DEVMAN_DRIVER_GET_STATE, drvh,
    701             &state);
    702        
    703         devman_exchange_end(exch);
    704         if (rc != EOK)
    705                 return rc;
    706 
    707         *rstate = state;
    708         return rc;
    709 }
    710 
    711 int devman_driver_load(devman_handle_t drvh)
    712 {
    713         async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT);
    714         if (exch == NULL)
    715                 return ENOMEM;
    716        
    717         int rc = async_req_1_0(exch, DEVMAN_DRIVER_LOAD, drvh);
    718        
    719         devman_exchange_end(exch);
    720         return rc;
    721 }
    722 
    723598/** @}
    724599 */
Note: See TracChangeset for help on using the changeset viewer.