Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset c9f3b45c in mainline


Ignore:
Timestamp:
2010-05-27T15:16:49Z (11 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master
Children:
692c40cb
Parents:
957cfa58
Message:

devman, libdrv: replace async_string_receive by async_data_write_accept

Location:
uspace
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/driver.c

    r957cfa58 rc9f3b45c  
    8989}
    9090
    91 /** Wrapper for receiving strings
    92  *
    93  * This wrapper only makes it more comfortable to use async_data_write_*
    94  * functions to receive strings.
    95  *
    96  * @param str      Pointer to string pointer (which should be later disposed
    97  *                 by free()). If the operation fails, the pointer is not
    98  *                 touched.
    99  * @param max_size Maximum size (in bytes) of the string to receive. 0 means
    100  *                 no limit.
    101  * @param received If not NULL, the size of the received data is stored here.
    102  *
    103  * @return Zero on success or a value from @ref errno.h on failure.
    104  *
    105  */
    106 static int async_string_receive(char **str, const size_t max_size, size_t *received)
    107 {
    108         ipc_callid_t callid;
    109         size_t size;
    110         if (!async_data_write_receive(&callid, &size)) {
    111                 ipc_answer_0(callid, EINVAL);
    112                 return EINVAL;
    113         }
    114        
    115         if ((max_size > 0) && (size > max_size)) {
    116                 ipc_answer_0(callid, EINVAL);
    117                 return EINVAL;
    118         }
    119        
    120         char *data = (char *) malloc(size + 1);
    121         if (data == NULL) {
    122                 ipc_answer_0(callid, ENOMEM);
    123                 return ENOMEM;
    124         }
    125        
    126         int rc = async_data_write_finalize(callid, data, size);
    127         if (rc != EOK) {
    128                 free(data);
    129                 return rc;
    130         }
    131        
    132         data[size] = 0;
    133         *str = data;
    134         if (received != NULL)
    135                 *received = size;
    136        
    137         return EOK;
    138 }
    139 
    14091int register_interrupt_handler(device_t *dev, int irq, interrupt_handler_t *handler, irq_code_t *pseudocode)
    14192{
     
    213164        dev->handle = dev_handle;
    214165       
    215         async_string_receive(&dev_name, 0, NULL);
     166        async_data_write_accept((void **)&dev_name, true, 0, 0, 0, 0);
    216167        dev->name = dev_name;
    217168       
  • uspace/srv/devman/main.c

    r957cfa58 rc9f3b45c  
    6161static dev_tree_t device_tree;
    6262
    63 /** Wrapper for receiving strings
    64  *
    65  * This wrapper only makes it more comfortable to use async_data_write_*
    66  * functions to receive strings.
    67  *
    68  * @param str      Pointer to string pointer (which should be later disposed
    69  *                 by free()). If the operation fails, the pointer is not
    70  *                 touched.
    71  * @param max_size Maximum size (in bytes) of the string to receive. 0 means
    72  *                 no limit.
    73  * @param received If not NULL, the size of the received data is stored here.
    74  *
    75  * @return Zero on success or a value from @ref errno.h on failure.
    76  *
    77  */
    78 static int async_string_receive(char **str, const size_t max_size, size_t *received)
    79 {
    80         ipc_callid_t callid;
    81         size_t size;
    82         if (!async_data_write_receive(&callid, &size)) {
    83                 ipc_answer_0(callid, EINVAL);
    84                 return EINVAL;
    85         }
    86        
    87         if ((max_size > 0) && (size > max_size)) {
    88                 ipc_answer_0(callid, EINVAL);
    89                 return EINVAL;
    90         }
    91        
    92         char *data = (char *) malloc(size + 1);
    93         if (data == NULL) {
    94                 ipc_answer_0(callid, ENOMEM);
    95                 return ENOMEM;
    96         }
    97        
    98         int rc = async_data_write_finalize(callid, data, size);
    99         if (rc != EOK) {
    100                 free(data);
    101                 return rc;
    102         }
    103        
    104         data[size] = 0;
    105         *str = data;
    106         if (received != NULL)
    107                 *received = size;
    108        
    109         return EOK;
    110 }
    11163
    11264/**
     
    12981       
    13082        // Get driver name
    131         int rc = async_string_receive(&drv_name, DEVMAN_NAME_MAXLEN, NULL);     
     83        int rc = async_data_write_accept((void **)&drv_name, true, 0, 0, 0, 0);
    13284        if (rc != EOK) {
    13385                ipc_answer_0(iid, rc);
     
    205157       
    206158        char *match_id_str;
    207         rc = async_string_receive(&match_id_str, DEVMAN_NAME_MAXLEN, NULL);     
     159        rc = async_data_write_accept((void **)&match_id_str, true, 0, 0, 0, 0);
    208160        match_id->id = match_id_str;
    209161        if (EOK != rc) {
     
    262214       
    263215        char *dev_name = NULL;
    264         int rc = async_string_receive(&dev_name, DEVMAN_NAME_MAXLEN, NULL);     
     216        int rc = async_data_write_accept((void **)&dev_name, true, 0, 0, 0, 0);
    265217        if (EOK != rc) {
    266218                fibril_rwlock_write_unlock(&tree->rwlock);
     
    354306static void devman_device_get_handle(ipc_callid_t iid, ipc_call_t *icall)
    355307{
    356         char *pathname;
    357        
    358         /* Get fqdn */
    359         int rc = async_string_receive(&pathname, 0, NULL);
     308        char *pathname;
     309        int rc = async_data_write_accept((void **)&pathname, true, 0, 0, 0, 0);
    360310        if (rc != EOK) {
    361311                ipc_answer_0(iid, rc);
Note: See TracChangeset for help on using the changeset viewer.