Changeset b77931d in mainline


Ignore:
Timestamp:
2011-11-05T16:08: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:
d176b1d
Parents:
ab27e01
Message:

usb: usb_pipe_t was always allocated in usb_endpoint_mapping_t, embed it.

Location:
uspace
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbhid/main.c

    rab27e01 rb77931d  
    113113           usb_hid_polling_callback,
    114114           /* How much data to request. */
    115            dev->pipes[hid_dev->poll_pipe_index].pipe->max_packet_size,
     115           dev->pipes[hid_dev->poll_pipe_index].pipe.max_packet_size,
    116116           /* Callback when the polling ends. */
    117117           usb_hid_polling_ended_callback,
  • uspace/drv/bus/usb/usbmast/bo_trans.c

    rab27e01 rb77931d  
    6767        int retval = EOK;
    6868        size_t act_size;
    69         usb_pipe_t *bulk_in_pipe = mfun->mdev->usb_dev->pipes[BULK_IN_EP].pipe;
    70         usb_pipe_t *bulk_out_pipe = mfun->mdev->usb_dev->pipes[BULK_OUT_EP].pipe;
     69        usb_pipe_t *bulk_in_pipe = &mfun->mdev->usb_dev->pipes[BULK_IN_EP].pipe;
     70        usb_pipe_t *bulk_out_pipe = &mfun->mdev->usb_dev->pipes[BULK_OUT_EP].pipe;
    7171        usb_direction_t ddir;
    7272        void *dbuf;
     
    118118                if (ddir == USB_DIRECTION_IN) {
    119119                        usb_pipe_clear_halt(&mfun->mdev->usb_dev->ctrl_pipe,
    120                             mfun->mdev->usb_dev->pipes[BULK_IN_EP].pipe);
     120                            &mfun->mdev->usb_dev->pipes[BULK_IN_EP].pipe);
    121121                } else {
    122122                        usb_pipe_clear_halt(&mfun->mdev->usb_dev->ctrl_pipe,
    123                             mfun->mdev->usb_dev->pipes[BULK_OUT_EP].pipe);
     123                            &mfun->mdev->usb_dev->pipes[BULK_OUT_EP].pipe);
    124124                }
    125125        } else if (rc != EOK) {
     
    216216        usb_massstor_reset(mdev);
    217217        usb_pipe_clear_halt(&mdev->usb_dev->ctrl_pipe,
    218             mdev->usb_dev->pipes[BULK_IN_EP].pipe);
     218            &mdev->usb_dev->pipes[BULK_IN_EP].pipe);
    219219        usb_pipe_clear_halt(&mdev->usb_dev->ctrl_pipe,
    220             mdev->usb_dev->pipes[BULK_OUT_EP].pipe);
     220            &mdev->usb_dev->pipes[BULK_OUT_EP].pipe);
    221221}
    222222
  • uspace/drv/bus/usb/usbmast/main.c

    rab27e01 rb77931d  
    140140
    141141        usb_log_info("Initializing mass storage `%s'.\n", dev->ddf_dev->name);
    142         usb_log_debug(" Bulk in endpoint: %d [%zuB].\n",
    143             dev->pipes[BULK_IN_EP].pipe->endpoint_no,
     142        usb_log_debug("Bulk in endpoint: %d [%zuB].\n",
     143            dev->pipes[BULK_IN_EP].pipe.endpoint_no,
    144144            (size_t) dev->pipes[BULK_IN_EP].descriptor->max_packet_size);
    145145        usb_log_debug("Bulk out endpoint: %d [%zuB].\n",
    146             dev->pipes[BULK_OUT_EP].pipe->endpoint_no,
     146            dev->pipes[BULK_OUT_EP].pipe.endpoint_no,
    147147            (size_t) dev->pipes[BULK_OUT_EP].descriptor->max_packet_size);
    148148
  • uspace/lib/usbdev/include/usb/dev/pipes.h

    rab27e01 rb77931d  
    141141typedef struct {
    142142        /** Endpoint pipe. */
    143         usb_pipe_t *pipe;
     143        usb_pipe_t pipe;
    144144        /** Endpoint description. */
    145145        const usb_endpoint_description_t *description;
     
    149149        int interface_setting;
    150150        /** Found descriptor fitting the description. */
    151         usb_standard_endpoint_descriptor_t *descriptor;
     151        const usb_standard_endpoint_descriptor_t *descriptor;
    152152        /** Interface descriptor the endpoint belongs to. */
    153         usb_standard_interface_descriptor_t *interface;
     153        const usb_standard_interface_descriptor_t *interface;
    154154        /** Whether the endpoint was actually found. */
    155155        bool present;
  • uspace/lib/usbdev/src/devdrv.c

    rab27e01 rb77931d  
    361361        /* Now allocate and fully initialize. */
    362362        for (i = 0; i < pipe_count; i++) {
    363                 pipes[i].pipe = malloc(sizeof(usb_pipe_t));
    364                 if (pipes[i].pipe == NULL) {
    365                         rc = ENOMEM;
    366                         goto rollback_free_only;
    367                 }
    368363                pipes[i].description = endpoints[i];
    369364                pipes[i].interface_no = interface_no;
     
    392387        for (i = 0; i < pipe_count; i++) {
    393388                if (pipes[i].present) {
    394                         rc = usb_pipe_register(pipes[i].pipe,
     389                        rc = usb_pipe_register(&pipes[i].pipe,
    395390                            pipes[i].descriptor->poll_interval, &hc_conn);
    396391                        if (rc != EOK) {
     
    420415        for (i = 0; i < pipe_count; i++) {
    421416                if (pipes[i].present) {
    422                         usb_pipe_unregister(pipes[i].pipe, &hc_conn);
     417                        usb_pipe_unregister(&pipes[i].pipe, &hc_conn);
    423418                }
    424419        }
     
    434429         */
    435430rollback_free_only:
    436         for (i = 0; i < pipe_count; i++) {
    437                 if (pipes[i].pipe != NULL) {
    438                         free(pipes[i].pipe);
    439                 }
    440         }
    441431        free(pipes);
    442432
     
    480470                    i, pipes[i].present ? "" : "not ");
    481471                if (pipes[i].present)
    482                         usb_pipe_unregister(pipes[i].pipe, &hc_conn);
    483                 free(pipes[i].pipe);
     472                        usb_pipe_unregister(&pipes[i].pipe, &hc_conn);
    484473        }
    485474
  • uspace/lib/usbdev/src/devpoll.c

    rab27e01 rb77931d  
    7373
    7474        usb_pipe_t *pipe
    75             = polling_data->dev->pipes[polling_data->pipe_index].pipe;
     75            = &polling_data->dev->pipes[polling_data->pipe_index].pipe;
    7676       
    7777        if (polling_data->debug > 0) {
     
    208208                return EINVAL;
    209209        }
    210         if ((dev->pipes[pipe_index].pipe->transfer_type != USB_TRANSFER_INTERRUPT)
    211             || (dev->pipes[pipe_index].pipe->direction != USB_DIRECTION_IN)) {
     210        if ((dev->pipes[pipe_index].pipe.transfer_type != USB_TRANSFER_INTERRUPT)
     211            || (dev->pipes[pipe_index].pipe.direction != USB_DIRECTION_IN)) {
    212212                return EINVAL;
    213213        }
     
    254254                return EINVAL;
    255255        }
    256         if ((dev->pipes[pipe_index].pipe->transfer_type != USB_TRANSFER_INTERRUPT)
    257             || (dev->pipes[pipe_index].pipe->direction != USB_DIRECTION_IN)) {
     256        if ((dev->pipes[pipe_index].pipe.transfer_type != USB_TRANSFER_INTERRUPT)
     257            || (dev->pipes[pipe_index].pipe.direction != USB_DIRECTION_IN)) {
    258258                return EINVAL;
    259259        }
  • uspace/lib/usbdev/src/pipesinit.c

    rab27e01 rb77931d  
    192192        }
    193193
    194         if (ep_mapping->pipe == NULL) {
    195                 return EBADMEM;
    196         }
    197194        if (ep_mapping->present) {
    198195                return EEXISTS;
    199196        }
    200197
    201         int rc = usb_pipe_initialize(ep_mapping->pipe, wire,
     198        int rc = usb_pipe_initialize(&ep_mapping->pipe, wire,
    202199            ep_no, description.transfer_type, endpoint->max_packet_size,
    203200            description.direction);
     
    254251 *
    255252 * The mapping array is expected to conform to following rules:
    256  * - @c pipe must point to already allocated structure with uninitialized pipe
     253 * - @c pipe must be uninitialized pipe
    257254 * - @c description must point to prepared endpoint description
    258255 * - @c descriptor does not need to be initialized (will be overwritten)
     
    297294        }
    298295
    299         /*
    300          * Go through the mapping and set all endpoints to not present.
    301          */
    302         size_t i;
    303         for (i = 0; i < mapping_count; i++) {
     296        /* Go through the mapping and set all endpoints to not present. */
     297        for (size_t i = 0; i < mapping_count; i++) {
    304298                mapping[i].present = false;
    305299                mapping[i].descriptor = NULL;
     
    307301        }
    308302
    309         /*
    310          * Prepare the descriptor parser.
    311          */
     303        /* Prepare the descriptor parser. */
    312304        const usb_dp_parser_t dp_parser = {
    313305                .nesting = descriptor_nesting
Note: See TracChangeset for help on using the changeset viewer.