Ignore:
File:
1 edited

Legend:

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

    r8b1e15ac r64d2b10  
    123123}
    124124
    125 static int devman_send_match_id(int phone, match_id_t *match_id)
    126 {
    127         ipc_call_t answer;
    128 
    129         aid_t req = async_send_1(phone, DEVMAN_ADD_MATCH_ID, match_id->score,
    130             &answer);
    131         int retval = async_data_write_start(phone, match_id->id,
    132             str_size(match_id->id));
    133 
     125static int devman_send_match_id(int phone, match_id_t *match_id) \
     126{
     127        ipc_call_t answer;
     128        aid_t req = async_send_1(phone, DEVMAN_ADD_MATCH_ID, match_id->score, &answer);
     129        int retval = async_data_write_start(phone, match_id->id, str_size(match_id->id));
    134130        async_wait_for(req, NULL);
    135131        return retval;
     
    137133
    138134
    139 static int devman_send_match_ids(int phone, match_id_list_t *match_ids)
     135static int devman_send_match_ids(int phone, match_id_list_t *match_ids) 
    140136{
    141137        link_t *link = match_ids->ids.next;
    142138        match_id_t *match_id = NULL;
    143139        int ret = EOK;
    144 
     140       
    145141        while (link != &match_ids->ids) {
    146142                match_id = list_get_instance(link, match_id_t, link);
    147                 ret = devman_send_match_id(phone, match_id);
    148                 if (ret != EOK) {
    149                         printf("Driver failed to send match id, error %d\n",
    150                             ret);
    151                         return ret;
    152                 }
    153 
     143                if (EOK != (ret = devman_send_match_id(phone, match_id)))
     144                {
     145                        printf("Driver failed to send match id, error number = %d\n", ret);
     146                        return ret;                     
     147                }
    154148                link = link->next;
    155149        }
    156 
    157         return ret;
    158 }
    159 
    160 /** Add function to a device.
    161  *
    162  * Request devman to add a new function to the specified device owned by
    163  * this driver task.
    164  *
    165  * @param name          Name of the new function
    166  * @param ftype         Function type, fun_inner or fun_exposed
    167  * @param match_ids     Match IDs (should be empty for fun_exposed)
    168  * @param devh          Devman handle of the device
    169  * @param funh          Place to store handle of the new function
    170  *
    171  * @return              EOK on success or negative error code.
    172  */
    173 int devman_add_function(const char *name, fun_type_t ftype,
    174     match_id_list_t *match_ids, devman_handle_t devh, devman_handle_t *funh)
    175 {
     150        return ret;     
     151}
     152
     153int devman_child_device_register(
     154        const char *name, match_id_list_t *match_ids, devman_handle_t parent_handle, devman_handle_t *handle)
     155{               
    176156        int phone = devman_get_phone(DEVMAN_DRIVER, IPC_FLAG_BLOCKING);
    177         int fun_handle;
    178157       
    179158        if (phone < 0)
     
    182161        async_serialize_start();
    183162       
    184         int match_count = list_count(&match_ids->ids);
    185         ipc_call_t answer;
    186 
    187         aid_t req = async_send_3(phone, DEVMAN_ADD_FUNCTION, (sysarg_t) ftype,
    188             devh, match_count, &answer);
     163        int match_count = list_count(&match_ids->ids); 
     164        ipc_call_t answer;
     165        aid_t req = async_send_2(phone, DEVMAN_ADD_CHILD_DEVICE, parent_handle, match_count, &answer);
    189166
    190167        sysarg_t retval = async_data_write_start(phone, name, str_size(name));
     
    201178        async_serialize_end();
    202179       
    203         if (retval == EOK)
    204                 fun_handle = (int) IPC_GET_ARG1(answer);
    205         else
    206                 fun_handle = -1;
    207        
    208         *funh = fun_handle;
    209 
     180        if (retval != EOK) {
     181                if (handle != NULL) {
     182                        *handle = -1;
     183                }
     184                return retval;
     185        }       
     186       
     187        if (handle != NULL)
     188                *handle = (int) IPC_GET_ARG1(answer);   
     189               
    210190        return retval;
    211191}
    212192
    213 int devman_add_device_to_class(devman_handle_t devman_handle,
    214     const char *class_name)
     193int devman_add_device_to_class(devman_handle_t devman_handle, const char *class_name)
    215194{
    216195        int phone = devman_get_phone(DEVMAN_DRIVER, IPC_FLAG_BLOCKING);
     
    221200        async_serialize_start();
    222201        ipc_call_t answer;
    223         aid_t req = async_send_1(phone, DEVMAN_ADD_DEVICE_TO_CLASS,
    224             devman_handle, &answer);
    225        
    226         sysarg_t retval = async_data_write_start(phone, class_name,
    227             str_size(class_name));
     202        aid_t req = async_send_1(phone, DEVMAN_ADD_DEVICE_TO_CLASS, devman_handle, &answer);
     203       
     204        sysarg_t retval = async_data_write_start(phone, class_name, str_size(class_name));
    228205        if (retval != EOK) {
    229206                async_wait_for(req, NULL);
     
    235212        async_serialize_end();
    236213       
    237         return retval;
     214        return retval; 
    238215}
    239216
     
    288265}
    289266
    290 int devman_device_get_handle(const char *pathname, devman_handle_t *handle,
    291     unsigned int flags)
     267int devman_device_get_handle(const char *pathname, devman_handle_t *handle, unsigned int flags)
    292268{
    293269        int phone = devman_get_phone(DEVMAN_CLIENT, flags);
     
    302278            &answer);
    303279       
    304         sysarg_t retval = async_data_write_start(phone, pathname,
    305             str_size(pathname));
     280        sysarg_t retval = async_data_write_start(phone, pathname, str_size(pathname));
    306281        if (retval != EOK) {
    307282                async_wait_for(req, NULL);
Note: See TracChangeset for help on using the changeset viewer.