Changeset 643b983 in mainline for uspace/drv/uhci/uhci.c


Ignore:
Timestamp:
2011-01-21T18:14:01Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bae9e76
Parents:
9600516
Message:

Init callback structure and TD for usb in transfers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci/uhci.c

    r9600516 r643b983  
    6868}
    6969/*----------------------------------------------------------------------------*/
    70 int init_tranfer_lists(transfer_list_t transfers[])
    71 {
    72         //TODO:refactor
    73         int ret;
    74         ret = transfer_list_init(&transfers[USB_TRANSFER_BULK], NULL);
    75         if (ret != EOK) {
    76                 uhci_print_error("Failed to inititalize bulk queue.\n");
    77                 return ret;
    78         }
    79 
    80         ret = transfer_list_init(
    81           &transfers[USB_TRANSFER_CONTROL], &transfers[USB_TRANSFER_BULK]);
    82         if (ret != EOK) {
    83                 uhci_print_error("Failed to inititalize control queue.\n");
    84                 transfer_list_fini(&transfers[USB_TRANSFER_BULK]);
    85                 return ret;
    86         }
    87 
    88         ret = transfer_list_init(
    89           &transfers[USB_TRANSFER_INTERRUPT], &transfers[USB_TRANSFER_CONTROL]);
    90         if (ret != EOK) {
    91                 uhci_print_error("Failed to interrupt control queue.\n");
    92                 transfer_list_fini(&transfers[USB_TRANSFER_CONTROL]);
    93                 transfer_list_fini(&transfers[USB_TRANSFER_BULK]);
    94                 return ret;
    95         }
    96 
    97         return EOK;
    98 }
    99 /*----------------------------------------------------------------------------*/
    10070int uhci_in(
    10171  device_t *dev,
     
    11080            usb_str_transfer_type(transfer_type),
    11181            size);
     82        if (size >= 1024)
     83                return ENOTSUP;
    11284
    113         callback( dev, USB_OUTCOME_OK, size, arg );
     85        callback_t *job = malloc(sizeof(callback_t));
     86        if (job == NULL) {
     87                uhci_print_error("Failed to allocate callback structure.\n");
     88                return ENOMEM;
     89        }
     90
     91#define CHECK_RET_FREE_JOB(r, message) \
     92        if (r != EOK) { \
     93                uhci_print_error(message); \
     94                callback_fini(job); \
     95                trans_free(job); \
     96                return r; \
     97        } else (void) 0
     98
     99        int ret = callback_in_init(job, dev, buffer, size, callback, arg);
     100        CHECK_RET_FREE_JOB(ret, "Failed to initialize callback structure.\n");
     101
     102        transfer_descriptor_t *td = trans_malloc(sizeof(transfer_descriptor_t));
     103        ret = (td == NULL) ? ENOMEM : EOK;
     104        CHECK_RET_FREE_JOB(ret, "Failed to allocate tranfer descriptor.\n");
     105
     106        transfer_descriptor_init(td, 3, size, false, target, USB_PID_IN);
     107
     108
     109        // TODO: add to list
     110//      callback(dev, USB_OUTCOME_OK, size, arg);
    114111
    115112        return EOK;
     
    152149}
    153150/*----------------------------------------------------------------------------*/
     151int init_tranfer_lists(transfer_list_t transfers[])
     152{
     153        //TODO:refactor
     154        transfers[USB_TRANSFER_ISOCHRONOUS].first = NULL;
     155        transfers[USB_TRANSFER_ISOCHRONOUS].last = NULL;
     156        int ret;
     157        ret = transfer_list_init(&transfers[USB_TRANSFER_BULK], NULL);
     158        if (ret != EOK) {
     159                uhci_print_error("Failed to inititalize bulk queue.\n");
     160                return ret;
     161        }
     162
     163        ret = transfer_list_init(
     164          &transfers[USB_TRANSFER_CONTROL], &transfers[USB_TRANSFER_BULK]);
     165        if (ret != EOK) {
     166                uhci_print_error("Failed to inititalize control queue.\n");
     167                transfer_list_fini(&transfers[USB_TRANSFER_BULK]);
     168                return ret;
     169        }
     170
     171        ret = transfer_list_init(
     172          &transfers[USB_TRANSFER_INTERRUPT], &transfers[USB_TRANSFER_CONTROL]);
     173        if (ret != EOK) {
     174                uhci_print_error("Failed to interrupt control queue.\n");
     175                transfer_list_fini(&transfers[USB_TRANSFER_CONTROL]);
     176                transfer_list_fini(&transfers[USB_TRANSFER_BULK]);
     177                return ret;
     178        }
     179
     180        return EOK;
     181}
Note: See TracChangeset for help on using the changeset viewer.