Changeset d93f5afb in mainline


Ignore:
Timestamp:
2013-08-02T15:59:51Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
dcbda00
Parents:
3969a42
Message:

libusbdev: Cleanup unused code.

Location:
uspace
Files:
1 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbhub/usbhub.c

    r3969a42 rd93f5afb  
    111111        fibril_condvar_initialize(&hub_dev->pending_ops_cv);
    112112
    113         usb_pipe_t *control_pipe = usb_device_get_default_pipe(usb_dev);
    114 
    115         int opResult = usb_pipe_start_long_transfer(control_pipe);
    116         if (opResult != EOK) {
    117                 usb_log_error("Failed to start long ctrl pipe transfer: %s\n",
    118                     str_error(opResult));
    119                 return opResult;
    120         }
    121 
    122113        /* Set hub's first configuration. (There should be only one) */
    123         opResult = usb_set_first_configuration(usb_dev);
    124         if (opResult != EOK) {
    125                 usb_pipe_end_long_transfer(control_pipe);
     114        int opResult = usb_set_first_configuration(usb_dev);
     115        if (opResult != EOK) {
    126116                usb_log_error("Could not set hub configuration: %s\n",
    127117                    str_error(opResult));
     
    132122        opResult = usb_hub_process_hub_specific_info(hub_dev);
    133123        if (opResult != EOK) {
    134                 usb_pipe_end_long_transfer(control_pipe);
    135124                usb_log_error("Could process hub specific info, %s\n",
    136125                    str_error(opResult));
     
    143132            fun_exposed, HUB_FNC_NAME);
    144133        if (hub_dev->hub_fun == NULL) {
    145                 usb_pipe_end_long_transfer(control_pipe);
    146134                usb_log_error("Failed to create hub function.\n");
    147135                return ENOMEM;
     
    151139        opResult = ddf_fun_bind(hub_dev->hub_fun);
    152140        if (opResult != EOK) {
    153                 usb_pipe_end_long_transfer(control_pipe);
    154141                usb_log_error("Failed to bind hub function: %s.\n",
    155142                   str_error(opResult));
     
    164151            -1, usb_hub_polling_terminated_callback, hub_dev);
    165152        if (opResult != EOK) {
    166                 usb_pipe_end_long_transfer(control_pipe);
    167153                /* Function is already bound */
    168154                ddf_fun_unbind(hub_dev->hub_fun);
     
    176162            usb_device_get_name(hub_dev->usb_device), hub_dev->port_count);
    177163
    178         usb_pipe_end_long_transfer(control_pipe);
    179164        return EOK;
    180165}
  • uspace/lib/usbdev/include/usb/dev/device.h

    r3969a42 rd93f5afb  
    9595void * usb_device_data_get(usb_device_t *);
    9696
    97 /* Legacy support */
    98 usb_address_t usb_device_address(usb_device_t *);
    99 devman_handle_t usb_device_hc_handle(usb_device_t*);
    100 
    10197#endif
    10298/**
  • uspace/lib/usbdev/include/usb/dev/pipes.h

    r3969a42 rd93f5afb  
    4141#include <usb/usb.h>
    4242#include <usb/descriptor.h>
    43 #include <usb/dev/usb_device_connection.h>
    4443#include <usb_iface.h>
    4544
     
    5150 */
    5251typedef struct {
    53         /** The connection used for sending the data. */
    54         usb_device_connection_t *wire;
    55 
    5652        /** Endpoint number. */
    5753        usb_endpoint_t endpoint_no;
     
    7167        bool auto_reset_halt;
    7268
     69        /** The connection used for sending the data. */
    7370        usb_dev_session_t *bus_session;
    7471} usb_pipe_t;
     
    108105} usb_endpoint_mapping_t;
    109106
    110 int usb_pipe_initialize(usb_pipe_t *, usb_device_connection_t *,
    111     usb_endpoint_t, usb_transfer_type_t, size_t, usb_direction_t,
    112     usb_dev_session_t *);
    113 int usb_pipe_initialize_default_control(usb_pipe_t *,
    114     usb_device_connection_t *, usb_dev_session_t *);
     107int usb_pipe_initialize(usb_pipe_t *, usb_endpoint_t, usb_transfer_type_t,
     108    size_t, usb_direction_t, usb_dev_session_t *);
     109int usb_pipe_initialize_default_control(usb_pipe_t *, usb_dev_session_t *);
    115110
    116111int usb_pipe_probe_default_control(usb_pipe_t *);
    117112int usb_pipe_initialize_from_configuration(usb_endpoint_mapping_t *,
    118     size_t, const uint8_t *, size_t, usb_device_connection_t *,
    119     usb_dev_session_t *);
     113    size_t, const uint8_t *, size_t, usb_dev_session_t *);
    120114
    121115int usb_pipe_register(usb_pipe_t *, unsigned);
    122116int usb_pipe_unregister(usb_pipe_t *);
    123 
    124 int usb_pipe_start_long_transfer(usb_pipe_t *);
    125 int usb_pipe_end_long_transfer(usb_pipe_t *);
    126117
    127118int usb_pipe_read(usb_pipe_t *, void *, size_t, size_t *);
  • uspace/lib/usbdev/src/devdrv.c

    r3969a42 rd93f5afb  
    4545/** USB device structure. */
    4646typedef struct usb_device {
    47         /** Connection to USB hc, used by wire and arbitrary requests. */
    48         usb_hc_connection_t hc_conn;
    49         /** Connection backing the pipes.
    50          * Typically, you will not need to use this attribute at all.
    51          */
    52         usb_device_connection_t wire;
     47        /** Connection to device on USB bus */
     48        usb_dev_session_t *bus_session;
     49        /** devman handle */
     50        devman_handle_t handle;
    5351        /** The default control pipe. */
    5452        usb_pipe_t ctrl_pipe;
     
    7876        void *driver_data;
    7977
    80         /** Connection to device on USB bus */
    81         usb_dev_session_t *bus_session;
    82         /** devman handle */
    83         devman_handle_t handle;
    8478} usb_device_t;
    8579
     
    157151        assert(usb_dev->descriptors.full_config == NULL);
    158152
    159         /* It is worth to start a long transfer. */
    160         usb_pipe_start_long_transfer(&usb_dev->ctrl_pipe);
    161 
    162153        /* Get the device descriptor. */
    163154        int rc = usb_request_get_device_descriptor(&usb_dev->ctrl_pipe,
    164155            &usb_dev->descriptors.device);
    165156        if (rc != EOK) {
    166                 goto leave;
     157                return rc;
    167158        }
    168159
     
    173164            &usb_dev->descriptors.full_config_size);
    174165
    175 leave:
    176         usb_pipe_end_long_transfer(&usb_dev->ctrl_pipe);
    177166
    178167        return rc;
     
    198187 * - registers endpoints with the host controller
    199188 *
    200  * @param[in] wire Initialized backing connection to the host controller.
    201189 * @param[in] endpoints Endpoints description, NULL terminated.
    202190 * @param[in] config_descr Configuration descriptor of active configuration.
     
    240228        int rc = usb_pipe_initialize_from_configuration(pipes, pipe_count,
    241229            usb_dev->descriptors.full_config,
    242             usb_dev->descriptors.full_config_size, &usb_dev->wire,
     230            usb_dev->descriptors.full_config_size,
    243231            usb_dev->bus_session);
    244232        if (rc != EOK) {
     
    353341}
    354342
    355 static int usb_dev_get_info(usb_device_t *usb_dev, devman_handle_t *handle,
    356     usb_address_t *address, int *iface_no)
    357 {
    358         assert(usb_dev);
    359 
    360         int ret = EOK;
    361         async_exch_t *exch = async_exchange_begin(usb_dev->bus_session);
    362         if (!exch)
    363                 ret = ENOMEM;
    364 
    365         if (ret == EOK && address)
    366                 ret = usb_get_my_address(exch, address);
    367 
    368         if (ret == EOK && handle)
    369                 ret = usb_get_hc_handle(exch, handle);
    370 
    371         if (ret == EOK && iface_no) {
    372                 ret = usb_get_my_interface(exch, iface_no);
    373                 if (ret == ENOTSUP) {
    374                         ret = EOK;
    375                         *iface_no = -1;
    376                 }
    377         }
    378 
    379         async_exchange_end(exch);
    380         return ret;
    381 }
    382 
    383343/** Clean instance of a USB device.
    384344 *
     
    393353                usb_device_destroy_pipes(usb_dev);
    394354                /* Ignore errors and hope for the best. */
    395                 usb_hc_connection_deinitialize(&usb_dev->hc_conn);
    396355                usb_alternate_interfaces_deinit(&usb_dev->alternate_interfaces);
    397356                usb_device_release_descriptors(usb_dev);
     
    437396        }
    438397
    439         /* Get assigned params */
    440         devman_handle_t hc_handle;
    441         usb_address_t address;
    442 
    443         int rc = usb_dev_get_info(usb_dev, &hc_handle, &address, NULL);
    444         if (rc != EOK) {
    445                 usb_dev_disconnect(usb_dev->bus_session);
    446                 *errstr_ptr = "device parameters retrieval";
    447                 return rc;
    448         }
    449 
    450         /* Initialize hc connection. */
    451         usb_hc_connection_initialize(&usb_dev->hc_conn, hc_handle);
    452 
    453         /* Initialize backing wire and control pipe. */
    454         rc = usb_device_connection_initialize(
    455             &usb_dev->wire, &usb_dev->hc_conn, address);
    456         if (rc != EOK) {
    457                 usb_dev_disconnect(usb_dev->bus_session);
    458                 *errstr_ptr = "device connection initialization";
    459                 return rc;
    460         }
    461 
    462398        /* This pipe was registered by the hub driver,
    463399         * during device initialization. */
    464         rc = usb_pipe_initialize_default_control(
    465             &usb_dev->ctrl_pipe, &usb_dev->wire, usb_dev->bus_session);
     400        int rc = usb_pipe_initialize_default_control(
     401            &usb_dev->ctrl_pipe, usb_dev->bus_session);
    466402        if (rc != EOK) {
    467403                usb_dev_disconnect(usb_dev->bus_session);
     
    470406        }
    471407
    472         /* Open hc connection for pipe registration. */
    473         rc = usb_hc_connection_open(&usb_dev->hc_conn);
    474         if (rc != EOK) {
    475                 usb_dev_disconnect(usb_dev->bus_session);
    476                 *errstr_ptr = "hc connection open";
    477                 return rc;
    478         }
    479 
    480408        /* Retrieve standard descriptors. */
    481409        rc = usb_device_retrieve_descriptors(usb_dev);
    482410        if (rc != EOK) {
    483411                *errstr_ptr = "descriptor retrieval";
    484                 usb_hc_connection_close(&usb_dev->hc_conn);
    485412                usb_dev_disconnect(usb_dev->bus_session);
    486413                return rc;
     
    499426                rc = usb_device_create_pipes(usb_dev, endpoints);
    500427                if (rc != EOK) {
    501                         usb_hc_connection_close(&usb_dev->hc_conn);
    502428                        usb_device_fini(usb_dev);
    503429                        *errstr_ptr = "pipes initialization";
     
    506432        }
    507433
    508         usb_hc_connection_close(&usb_dev->hc_conn);
    509434        return EOK;
    510435}
     
    645570}
    646571
    647 usb_address_t usb_device_address(usb_device_t *usb_dev)
    648 {
    649         assert(usb_dev);
    650         return usb_dev->wire.address;
    651 }
    652 
    653 devman_handle_t usb_device_hc_handle(usb_device_t *usb_dev)
    654 {
    655         assert(usb_dev);
    656         return usb_dev->hc_conn.hc_handle;
    657 }
    658572/**
    659573 * @}
  • uspace/lib/usbdev/src/devpoll.c

    r3969a42 rd93f5afb  
    8787        }
    8888
    89         usb_pipe_start_long_transfer(pipe);
    9089        size_t failed_attempts = 0;
    9190        while (failed_attempts <= params->max_failures) {
     
    148147        }
    149148
    150         usb_pipe_end_long_transfer(pipe);
    151 
    152149        const bool failed = failed_attempts > 0;
    153150
  • uspace/lib/usbdev/src/pipes.c

    r3969a42 rd93f5afb  
    3838#include <assert.h>
    3939
    40 /** Prepare pipe for a long transfer.
    41  *
    42  * Long transfer is transfer consisting of several requests to the HC.
    43  * Calling this function is optional and it has positive effect of
    44  * improved performance because IPC session is initiated only once.
    45  *
    46  * @param pipe Pipe over which the transfer will happen.
    47  * @return Error code.
    48  */
    49 int usb_pipe_start_long_transfer(usb_pipe_t *pipe)
    50 {
    51         assert(pipe);
    52         assert(pipe->wire);
    53         assert(pipe->wire->hc_connection);
    54         return usb_hc_connection_open(pipe->wire->hc_connection);
    55 }
    56 
    57 /** Terminate a long transfer on a pipe.
    58  * @param pipe Pipe where to end the long transfer.
    59  * @return Error code.
    60  * @see usb_pipe_start_long_transfer
    61  */
    62 int usb_pipe_end_long_transfer(usb_pipe_t *pipe)
    63 {
    64         assert(pipe);
    65         assert(pipe->wire);
    66         assert(pipe->wire->hc_connection);
    67         return usb_hc_connection_close(pipe->wire->hc_connection);
    68 }
    69 
    7040/** Try to clear endpoint halt of default control pipe.
    7141 *
     
    271241 *
    272242 * @param pipe Endpoint pipe to be initialized.
    273  * @param connection Connection to the USB device backing this pipe (the wire).
    274243 * @param endpoint_no Endpoint number (in USB 1.1 in range 0 to 15).
    275244 * @param transfer_type Transfer type (e.g. interrupt or bulk).
     
    278247 * @return Error code.
    279248 */
    280 int usb_pipe_initialize(usb_pipe_t *pipe,
    281     usb_device_connection_t *connection, usb_endpoint_t endpoint_no,
     249int usb_pipe_initialize(usb_pipe_t *pipe, usb_endpoint_t endpoint_no,
    282250    usb_transfer_type_t transfer_type, size_t max_packet_size,
    283251    usb_direction_t direction, usb_dev_session_t *bus_session)
    284252{
    285253        assert(pipe);
    286         assert(connection);
    287 
    288         pipe->wire = connection;
     254
    289255        pipe->endpoint_no = endpoint_no;
    290256        pipe->transfer_type = transfer_type;
     
    300266 *
    301267 * @param pipe Endpoint pipe to be initialized.
    302  * @param connection Connection to the USB device backing this pipe (the wire).
    303268 * @return Error code.
    304269 */
    305270int usb_pipe_initialize_default_control(usb_pipe_t *pipe,
    306     usb_device_connection_t *connection, usb_dev_session_t *bus_session)
    307 {
    308         assert(pipe);
    309         assert(connection);
    310 
    311         int rc = usb_pipe_initialize(pipe, connection, 0, USB_TRANSFER_CONTROL,
     271    usb_dev_session_t *bus_session)
     272{
     273        assert(pipe);
     274
     275        const int rc = usb_pipe_initialize(pipe, 0, USB_TRANSFER_CONTROL,
    312276            CTRL_PIPE_MIN_PACKET_SIZE, USB_DIRECTION_BOTH, bus_session);
    313277
  • uspace/lib/usbdev/src/pipesinit.c

    r3969a42 rd93f5afb  
    148148 * @param interface Interface descriptor under which belongs the @p endpoint.
    149149 * @param endpoint Endpoint descriptor.
    150  * @param wire Connection backing the endpoint pipes.
    151150 * @return Error code.
    152151 */
     
    155154    usb_standard_interface_descriptor_t *interface,
    156155    usb_standard_endpoint_descriptor_t *endpoint_desc,
    157     usb_device_connection_t *wire, usb_dev_session_t *bus_session)
     156    usb_dev_session_t *bus_session)
    158157{
    159158
     
    193192        }
    194193
    195         int rc = usb_pipe_initialize(&ep_mapping->pipe, wire,
     194        int rc = usb_pipe_initialize(&ep_mapping->pipe,
    196195            ep_no, description.transfer_type,
    197196            uint16_usb2host(endpoint_desc->max_packet_size),
     
    236235                            (usb_standard_endpoint_descriptor_t *)
    237236                                descriptor,
    238                             (usb_device_connection_t *) parser_data->arg,
    239237                            bus_session);
    240238                }
     
    281279    usb_endpoint_mapping_t *mapping, size_t mapping_count,
    282280    const uint8_t *config_descriptor, size_t config_descriptor_size,
    283     usb_device_connection_t *connection, usb_dev_session_t *bus_session)
    284 {
    285         assert(connection);
     281    usb_dev_session_t *bus_session)
     282{
    286283
    287284        if (config_descriptor == NULL) {
     
    307304                .data = config_descriptor,
    308305                .size = config_descriptor_size,
    309                 .arg = connection
    310306        };
    311307
     
    348344                return EINVAL;
    349345        }
    350 
    351 
    352         usb_pipe_start_long_transfer(pipe);
    353346
    354347        uint8_t dev_descr_start[CTRL_PIPE_MIN_PACKET_SIZE];
     
    368361                }
    369362        }
    370         usb_pipe_end_long_transfer(pipe);
    371363        if (rc != EOK) {
    372364                return rc;
  • uspace/lib/usbvirt/include/usbvirt/device.h

    r3969a42 rd93f5afb  
    4040#include <usb/dev/request.h>
    4141#include <async.h>
     42#include <errno.h>
    4243
    4344
Note: See TracChangeset for help on using the changeset viewer.