Changeset 816f5f4 in mainline


Ignore:
Timestamp:
2017-10-15T16:55:48Z (7 years ago)
Author:
Michal Staruch <salmelu@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9b2f69e
Parents:
2770b66
Message:

Remote USB (async) sending structures

remote_usb_register_endpoint is now sending a whole new structure, instead of 5 numeric arguments pulled out of structure.
This allows future extensibility for the structure as well as a working code to be used for other remote async calls.

Location:
uspace
Files:
12 edited

Legend:

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

    r2770b66 r816f5f4  
    9595           usb_hid_polling_callback,
    9696           /* How much data to request. */
    97            hid_dev->poll_pipe_mapping->pipe.max_packet_size,
     97           hid_dev->poll_pipe_mapping->pipe.desc.max_packet_size,
    9898           /* Delay */
    9999           -1,
  • uspace/drv/bus/usb/usbmast/main.c

    r2770b66 r816f5f4  
    172172            usb_device_get_name(dev));
    173173        usb_log_debug("Bulk in endpoint: %d [%zuB].\n",
    174             epm_in->pipe.endpoint_no, epm_in->pipe.max_packet_size);
     174            epm_in->pipe.desc.endpoint_no, epm_in->pipe.desc.max_packet_size);
    175175        usb_log_debug("Bulk out endpoint: %d [%zuB].\n",
    176             epm_out->pipe.endpoint_no, epm_out->pipe.max_packet_size);
     176            epm_out->pipe.desc.endpoint_no, epm_out->pipe.desc.max_packet_size);
    177177
    178178        usb_log_debug("Get LUN count...\n");
  • uspace/lib/drv/generic/remote_usb.c

    r2770b66 r816f5f4  
    175175} pack8_t;
    176176
    177 int usb_register_endpoint(async_exch_t *exch, usb_endpoint_t endpoint,
    178     usb_transfer_type_t type, usb_direction_t direction,
    179     size_t mps, unsigned packets, unsigned interval)
    180 {
    181         if (!exch)
    182                 return EBADMEM;
    183         pack8_t pack;
    184         pack.arr[0] = type;
    185         pack.arr[1] = direction;
    186         pack.arr[2] = interval;
    187         pack.arr[3] = packets;
    188 
    189         return async_req_4_0(exch, DEV_IFACE_ID(USB_DEV_IFACE),
    190             IPC_M_USB_REGISTER_ENDPOINT, endpoint, pack.arg, mps);
    191 
    192 }
    193 
    194 int usb_unregister_endpoint(async_exch_t *exch, usb_endpoint_t endpoint,
    195     usb_direction_t direction)
    196 {
    197         if (!exch)
    198                 return EBADMEM;
    199         return async_req_3_0(exch, DEV_IFACE_ID(USB_DEV_IFACE),
    200             IPC_M_USB_UNREGISTER_ENDPOINT, endpoint, direction);
     177int usb_register_endpoint(async_exch_t *exch,
     178        usb_endpoint_desc_t *endpoint_desc)
     179{
     180        if (!exch)
     181                return EBADMEM;
     182
     183        aid_t opening_request = async_send_1(exch,
     184            DEV_IFACE_ID(USB_DEV_IFACE), IPC_M_USB_REGISTER_ENDPOINT, NULL);
     185
     186        if (opening_request == 0) {
     187                return ENOMEM;
     188        }
     189
     190        const int ret = async_data_write_start(exch, (void *) endpoint_desc,
     191                sizeof(usb_endpoint_desc_t));
     192
     193        if (ret != EOK) {
     194                async_forget(opening_request);
     195                return ret;
     196        }
     197
     198        /* Wait for the answer. */
     199        sysarg_t opening_request_rc;
     200        async_wait_for(opening_request, &opening_request_rc);
     201
     202        return (int) opening_request_rc;
     203}
     204
     205int usb_unregister_endpoint(async_exch_t *exch,
     206        usb_endpoint_desc_t *endpoint_desc)
     207{
     208        if (!exch)
     209                return EBADMEM;
     210
     211        aid_t opening_request = async_send_1(exch,
     212                DEV_IFACE_ID(USB_DEV_IFACE), IPC_M_USB_UNREGISTER_ENDPOINT, NULL);
     213
     214        if (opening_request == 0) {
     215                return ENOMEM;
     216        }
     217
     218        const int ret = async_data_write_start(exch, endpoint_desc,
     219                sizeof(usb_endpoint_desc_t));
     220        if (ret != EOK) {
     221                async_forget(opening_request);
     222                return ret;
     223        }
     224
     225        /* Wait for the answer. */
     226        sysarg_t opening_request_rc;
     227        async_wait_for(opening_request, &opening_request_rc);
     228
     229        return (int) opening_request_rc;
    201230}
    202231
     
    317346};
    318347
     348typedef struct {
     349        ipc_callid_t caller;
     350        ipc_callid_t data_caller;
     351        void *buffer;
     352} async_transaction_t;
     353
    319354void remote_usb_get_my_interface(ddf_fun_t *fun, void *iface,
    320355    ipc_callid_t callid, ipc_call_t *call)
     
    417452    ipc_callid_t callid, ipc_call_t *call)
    418453{
    419         usb_iface_t *usb_iface = (usb_iface_t *) iface;
     454        assert(fun);
     455        assert(iface);
     456        assert(call);
     457
     458        const usb_iface_t *usb_iface = iface;
    420459
    421460        if (!usb_iface->register_endpoint) {
     
    424463        }
    425464
    426         const usb_endpoint_t endpoint = DEV_IPC_GET_ARG1(*call);
    427         const pack8_t pack = { .arg = DEV_IPC_GET_ARG2(*call)};
    428         const size_t max_packet_size = DEV_IPC_GET_ARG3(*call);
    429 
    430         const usb_transfer_type_t transfer_type = pack.arr[0];
    431         const usb_direction_t direction = pack.arr[1];
    432         unsigned packets = pack.arr[2];
    433         unsigned interval = pack.arr[3];
    434 
    435         const int ret = usb_iface->register_endpoint(fun, endpoint,
    436             transfer_type, direction, max_packet_size, packets, interval);
    437 
    438         async_answer_0(callid, ret);
     465        void *buffer = malloc(sizeof(usb_endpoint_desc_t));
     466        if (!buffer) {
     467                async_answer_0(callid, ENOMEM);
     468                return;
     469        }
     470
     471        size_t size = 0;
     472        int rc = async_data_write_accept(&buffer, false,
     473                1, sizeof(usb_endpoint_desc_t), 0, &size);
     474
     475        if (rc != EOK) {
     476                free(buffer);
     477                async_answer_0(callid, rc);
     478                return;
     479        }
     480
     481        usb_endpoint_desc_t *endpoint_desc = (usb_endpoint_desc_t *) buffer;
     482        rc = usb_iface->register_endpoint(fun, endpoint_desc);
     483
     484        free(buffer);
     485        async_answer_0(callid, rc);
    439486}
    440487
     
    442489    ipc_callid_t callid, ipc_call_t *call)
    443490{
    444         usb_iface_t *usb_iface = (usb_iface_t *) iface;
     491        assert(fun);
     492        assert(iface);
     493        assert(call);
     494
     495        const usb_iface_t *usb_iface = iface;
    445496
    446497        if (!usb_iface->unregister_endpoint) {
     
    449500        }
    450501
    451         usb_endpoint_t endpoint = (usb_endpoint_t) DEV_IPC_GET_ARG1(*call);
    452         usb_direction_t direction = (usb_direction_t) DEV_IPC_GET_ARG2(*call);
    453 
    454         int rc = usb_iface->unregister_endpoint(fun, endpoint, direction);
    455 
    456         async_answer_0(callid, rc);
    457 }
    458 
    459 typedef struct {
    460         ipc_callid_t caller;
    461         ipc_callid_t data_caller;
    462         void *buffer;
    463 } async_transaction_t;
     502        void *buffer = malloc(sizeof(usb_endpoint_desc_t));
     503        if (!buffer) {
     504                async_answer_0(callid, ENOMEM);
     505                return;
     506        }
     507
     508        size_t size = 0;
     509        int rc = async_data_write_accept(&buffer, false,
     510                1, sizeof(usb_endpoint_desc_t), 0, &size);
     511
     512        if (rc != EOK) {
     513                free(buffer);
     514                async_answer_0(callid, rc);
     515                return;
     516        }
     517
     518        usb_endpoint_desc_t *endpoint_desc = (usb_endpoint_desc_t *) buffer;
     519        usb_iface->unregister_endpoint(fun, endpoint_desc);
     520
     521        free(buffer);
     522        if (rc != EOK) {
     523                async_answer_0(callid, rc);
     524        }
     525}
    464526
    465527static void async_transaction_destroy(async_transaction_t *trans)
  • uspace/lib/drv/include/usb_iface.h

    r2770b66 r816f5f4  
    5757extern int usb_device_remove(async_exch_t *, unsigned port);
    5858
    59 extern int usb_register_endpoint(async_exch_t *, usb_endpoint_t,
    60     usb_transfer_type_t, usb_direction_t, size_t, unsigned, unsigned);
    61 extern int usb_unregister_endpoint(async_exch_t *, usb_endpoint_t,
    62     usb_direction_t);
     59extern int usb_register_endpoint(async_exch_t *, usb_endpoint_desc_t *);
     60extern int usb_unregister_endpoint(async_exch_t *, usb_endpoint_desc_t *);
    6361extern int usb_read(async_exch_t *, usb_endpoint_t, uint64_t, void *, size_t,
    6462    size_t *);
     
    8381        int (*device_remove)(ddf_fun_t *, unsigned);
    8482
    85         int (*register_endpoint)(ddf_fun_t *, usb_endpoint_t,
    86             usb_transfer_type_t, usb_direction_t, size_t, unsigned, unsigned);
    87         int (*unregister_endpoint)(ddf_fun_t *, usb_endpoint_t,
    88             usb_direction_t);
     83        int (*register_endpoint)(ddf_fun_t *, usb_endpoint_desc_t *);
     84        int (*unregister_endpoint)(ddf_fun_t *, usb_endpoint_desc_t *);
    8985
    9086        int (*read)(ddf_fun_t *, usb_endpoint_t, uint64_t, uint8_t *, size_t,
  • uspace/lib/usb/include/usb/usb.h

    r2770b66 r816f5f4  
    163163
    164164
    165 /** USB complete address type. 
     165/** USB complete address type.
    166166 * Pair address + endpoint is identification of transaction recipient.
    167167 */
     
    173173        uint32_t packed;
    174174} usb_target_t;
     175
     176/** Description of usb endpoint.
     177 */
     178typedef struct {
     179        /** Endpoint number. */
     180        usb_endpoint_t endpoint_no;
     181
     182        /** Endpoint transfer type. */
     183        usb_transfer_type_t transfer_type;
     184
     185        /** Endpoint direction. */
     186        usb_direction_t direction;
     187
     188        /** Maximum packet size for the endpoint. */
     189        size_t max_packet_size;
     190
     191        /** Number of packets per frame/uframe.
     192         * Only valid for HS INT and ISO transfers. All others should set to 1*/
     193        unsigned packets;
     194
     195        struct {
     196                unsigned polling_interval;
     197        } usb2;
     198} usb_endpoint_desc_t;
    175199
    176200/** Check USB target for allowed values (address and endpoint).
  • uspace/lib/usbdev/include/usb/dev/pipes.h

    r2770b66 r816f5f4  
    5050 */
    5151typedef struct {
    52         /** Endpoint number. */
    53         usb_endpoint_t endpoint_no;
    54 
    55         /** Endpoint transfer type. */
    56         usb_transfer_type_t transfer_type;
    57 
    58         /** Endpoint direction. */
    59         usb_direction_t direction;
    60 
    61         /** Maximum packet size for the endpoint. */
    62         size_t max_packet_size;
    63 
    64         /** Number of packets per frame/uframe.
    65          * Only valid for HS INT and ISO transfers. All others should set to 1*/
    66         unsigned packets;
    67 
     52        /** Endpoint description */
     53        usb_endpoint_desc_t desc;
    6854        /** Whether to automatically reset halt on the endpoint.
    6955         * Valid only for control endpoint zero.
    7056         */
    7157        bool auto_reset_halt;
    72 
    7358        /** The connection used for sending the data. */
    7459        usb_dev_session_t *bus_session;
  • uspace/lib/usbdev/src/devdrv.c

    r2770b66 r816f5f4  
    5656        /** Connection to device on USB bus */
    5757        usb_dev_session_t *bus_session;
    58        
     58
    5959        /** devman handle */
    6060        devman_handle_t handle;
    61        
     61
    6262        /** The default control pipe. */
    6363        usb_pipe_t ctrl_pipe;
    64        
     64
    6565        /** Other endpoint pipes.
    6666         *
     
    6969         */
    7070        usb_endpoint_mapping_t *pipes;
    71        
     71
    7272        /** Number of other endpoint pipes. */
    7373        size_t pipes_count;
    74        
     74
    7575        /** Current interface.
    7676         *
     
    7979         */
    8080        int interface_no;
    81        
     81
    8282        /** Alternative interfaces. */
    8383        usb_alternate_interfaces_t alternate_interfaces;
    84        
     84
    8585        /** Some useful descriptors for USB device. */
    8686        usb_device_descriptors_t descriptors;
    87        
     87
    8888        /** Generic DDF device backing this one. DO NOT TOUCH! */
    8989        ddf_dev_t *ddf_dev;
    90        
     90
    9191        /** Custom driver data.
    9292         *
     
    146146                return rc;
    147147        }
    148        
     148
    149149        /* Change current alternative */
    150150        usb_dev->alternate_interfaces.current = alternate_setting;
     
    296296        assert(usb_dev);
    297297        assert(usb_dev->pipes || usb_dev->pipes_count == 0);
    298        
     298
    299299        /* Destroy the pipes. */
    300300        for (size_t i = 0; i < usb_dev->pipes_count; ++i) {
     
    304304                        usb_pipe_unregister(&usb_dev->pipes[i].pipe);
    305305        }
    306        
     306
    307307        free(usb_dev->pipes);
    308308        usb_dev->pipes = NULL;
     
    332332        assert(usb_dev);
    333333        for (unsigned i = 0; i < usb_dev->pipes_count; ++i) {
    334                 if (usb_dev->pipes[i].pipe.endpoint_no == ep)
     334                if (usb_dev->pipes[i].pipe.desc.endpoint_no == ep)
    335335                        return &usb_dev->pipes[i];
    336336        }
     
    462462        assert(handle);
    463463        assert(iface_no);
    464        
     464
    465465        async_exch_t *exch = async_exchange_begin(sess);
    466466        if (!exch)
    467467                return EPARTY;
    468        
     468
    469469        int ret = usb_get_my_device_handle(exch, handle);
    470470        if (ret == EOK) {
     
    475475                }
    476476        }
    477        
     477
    478478        async_exchange_end(exch);
    479479        return ret;
     
    504504                return ENOMEM;
    505505        }
    506        
     506
    507507        return usb_device_init(usb_dev, ddf_dev, desc, err, h, iface_no);
    508508}
  • uspace/lib/usbdev/src/devpoll.c

    r2770b66 r816f5f4  
    9696                    (int) mapping->interface->interface_subclass,
    9797                    (int) mapping->interface->interface_protocol,
    98                     data->request_size, pipe->max_packet_size);
     98                    data->request_size, pipe->desc.max_packet_size);
    9999        }
    100100
     
    128128                        usb_request_clear_endpoint_halt(
    129129                            usb_device_get_default_pipe(data->dev),
    130                             pipe->endpoint_no);
     130                            pipe->desc.endpoint_no);
    131131                }
    132132
     
    156156
    157157                /* Take a rest before next request. */
    158                
     158
    159159                // FIXME TODO: This is broken, the time is in ms not us.
    160160                // but first we need to fix drivers to actually stop using this,
     
    216216        if (request_size == 0)
    217217                return EINVAL;
    218        
    219         if (!epm || (epm->pipe.transfer_type != USB_TRANSFER_INTERRUPT) ||
    220             (epm->pipe.direction != USB_DIRECTION_IN))
     218
     219        if (!epm || (epm->pipe.desc.transfer_type != USB_TRANSFER_INTERRUPT) ||
     220            (epm->pipe.desc.direction != USB_DIRECTION_IN))
    221221                return EINVAL;
    222        
     222
    223223
    224224        polling_data_t *polling_data = malloc(sizeof(polling_data_t));
  • uspace/lib/usbdev/src/pipes.c

    r2770b66 r816f5f4  
    5151        assert(pipe != NULL);
    5252
    53         if (!pipe->auto_reset_halt || (pipe->endpoint_no != 0)) {
     53        if (!pipe->auto_reset_halt || (pipe->desc.endpoint_no != 0)) {
    5454                return;
    5555        }
     
    8888        }
    8989
    90         if ((pipe->direction != USB_DIRECTION_BOTH)
    91             || (pipe->transfer_type != USB_TRANSFER_CONTROL)) {
     90        if ((pipe->desc.direction != USB_DIRECTION_BOTH)
     91            || (pipe->desc.transfer_type != USB_TRANSFER_CONTROL)) {
    9292                return EBADF;
    9393        }
     
    9898        async_exch_t *exch = async_exchange_begin(pipe->bus_session);
    9999        size_t act_size = 0;
    100         const int rc = usb_read(exch, pipe->endpoint_no, setup_packet, buffer,
     100        const int rc = usb_read(exch, pipe->desc.endpoint_no, setup_packet, buffer,
    101101            buffer_size, &act_size);
    102102        async_exchange_end(exch);
     
    142142        }
    143143
    144         if ((pipe->direction != USB_DIRECTION_BOTH)
    145             || (pipe->transfer_type != USB_TRANSFER_CONTROL)) {
     144        if ((pipe->desc.direction != USB_DIRECTION_BOTH)
     145            || (pipe->desc.transfer_type != USB_TRANSFER_CONTROL)) {
    146146                return EBADF;
    147147        }
     
    152152        async_exch_t *exch = async_exchange_begin(pipe->bus_session);
    153153        const int rc = usb_write(exch,
    154             pipe->endpoint_no, setup_packet, buffer, buffer_size);
     154            pipe->desc.endpoint_no, setup_packet, buffer, buffer_size);
    155155        async_exchange_end(exch);
    156156
     
    183183        }
    184184
    185         if (pipe->direction != USB_DIRECTION_IN) {
    186                 return EBADF;
    187         }
    188 
    189         if (pipe->transfer_type == USB_TRANSFER_CONTROL) {
     185        if (pipe->desc.direction != USB_DIRECTION_IN) {
     186                return EBADF;
     187        }
     188
     189        if (pipe->desc.transfer_type == USB_TRANSFER_CONTROL) {
    190190                return EBADF;
    191191        }
    192192
    193193        /* Isochronous transfer are not supported (yet) */
    194         if (pipe->transfer_type != USB_TRANSFER_INTERRUPT &&
    195             pipe->transfer_type != USB_TRANSFER_BULK)
     194        if (pipe->desc.transfer_type != USB_TRANSFER_INTERRUPT &&
     195            pipe->desc.transfer_type != USB_TRANSFER_BULK)
    196196            return ENOTSUP;
    197197
     
    199199        size_t act_size = 0;
    200200        const int rc =
    201             usb_read(exch, pipe->endpoint_no, 0, buffer, size, &act_size);
     201            usb_read(exch, pipe->desc.endpoint_no, 0, buffer, size, &act_size);
    202202        async_exchange_end(exch);
    203203
     
    224224        }
    225225
    226         if (pipe->direction != USB_DIRECTION_OUT) {
    227                 return EBADF;
    228         }
    229 
    230         if (pipe->transfer_type == USB_TRANSFER_CONTROL) {
     226        if (pipe->desc.direction != USB_DIRECTION_OUT) {
     227                return EBADF;
     228        }
     229
     230        if (pipe->desc.transfer_type == USB_TRANSFER_CONTROL) {
    231231                return EBADF;
    232232        }
    233233
    234234        /* Isochronous transfer are not supported (yet) */
    235         if (pipe->transfer_type != USB_TRANSFER_INTERRUPT &&
    236             pipe->transfer_type != USB_TRANSFER_BULK)
     235        if (pipe->desc.transfer_type != USB_TRANSFER_INTERRUPT &&
     236            pipe->desc.transfer_type != USB_TRANSFER_BULK)
    237237            return ENOTSUP;
    238238
    239239        async_exch_t *exch = async_exchange_begin(pipe->bus_session);
    240         const int rc = usb_write(exch, pipe->endpoint_no, 0, buffer, size);
     240        const int rc = usb_write(exch, pipe->desc.endpoint_no, 0, buffer, size);
    241241        async_exchange_end(exch);
    242242        return rc;
     
    258258        assert(pipe);
    259259
    260         pipe->endpoint_no = endpoint_no;
    261         pipe->transfer_type = transfer_type;
    262         pipe->packets = packets;
    263         pipe->max_packet_size = max_packet_size;
    264         pipe->direction = direction;
     260        pipe->desc.endpoint_no = endpoint_no;
     261        pipe->desc.transfer_type = transfer_type;
     262        pipe->desc.packets = packets;
     263        pipe->desc.max_packet_size = max_packet_size;
     264        pipe->desc.direction = direction;
    265265        pipe->auto_reset_halt = false;
    266266        pipe->bus_session = bus_session;
     
    297297        assert(pipe);
    298298        assert(pipe->bus_session);
     299
     300        pipe->desc.usb2.polling_interval = interval;
    299301        async_exch_t *exch = async_exchange_begin(pipe->bus_session);
    300302        if (!exch)
    301303                return ENOMEM;
    302         const int ret = usb_register_endpoint(exch, pipe->endpoint_no,
    303             pipe->transfer_type, pipe->direction, pipe->max_packet_size,
    304             pipe->packets, interval);
     304
     305        const int ret = usb_register_endpoint(exch, &pipe->desc);
     306
    305307        async_exchange_end(exch);
    306308        return ret;
     
    319321        if (!exch)
    320322                return ENOMEM;
    321         const int ret = usb_unregister_endpoint(exch, pipe->endpoint_no,
    322             pipe->direction);
     323
     324        const int ret = usb_unregister_endpoint(exch, &pipe->desc);
     325
    323326        async_exchange_end(exch);
    324327        return ret;
  • uspace/lib/usbdev/src/pipesinit.c

    r2770b66 r816f5f4  
    288288        if (config_descriptor == NULL)
    289289                return EBADMEM;
    290        
     290
    291291        if (config_descriptor_size <
    292292            sizeof(usb_standard_configuration_descriptor_t)) {
     
    343343        static_assert(DEV_DESCR_MAX_PACKET_SIZE_OFFSET < CTRL_PIPE_MIN_PACKET_SIZE);
    344344
    345         if ((pipe->direction != USB_DIRECTION_BOTH) ||
    346             (pipe->transfer_type != USB_TRANSFER_CONTROL) ||
    347             (pipe->endpoint_no != 0)) {
     345        if ((pipe->desc.direction != USB_DIRECTION_BOTH) ||
     346            (pipe->desc.transfer_type != USB_TRANSFER_CONTROL) ||
     347            (pipe->desc.endpoint_no != 0)) {
    348348                return EINVAL;
    349349        }
     
    369369        }
    370370
    371         pipe->max_packet_size
     371        pipe->desc.max_packet_size
    372372            = dev_descr_start[DEV_DESCR_MAX_PACKET_SIZE_OFFSET];
    373373
  • uspace/lib/usbdev/src/request.c

    r2770b66 r816f5f4  
    844844        }
    845845        return usb_request_clear_endpoint_halt(ctrl_pipe,
    846             target_pipe->endpoint_no);
     846            target_pipe->desc.endpoint_no);
    847847}
    848848
     
    858858{
    859859        uint16_t status_tmp;
    860         uint16_t pipe_index = (uint16_t) pipe->endpoint_no;
     860        uint16_t pipe_index = (uint16_t) pipe->desc.endpoint_no;
    861861        int rc = usb_request_get_status(ctrl_pipe,
    862862            USB_REQUEST_RECIPIENT_ENDPOINT, uint16_host2usb(pipe_index),
  • uspace/lib/usbhost/src/ddf_helpers.c

    r2770b66 r816f5f4  
    8686/** Register endpoint interface function.
    8787 * @param fun DDF function.
    88  * @param address USB address of the device.
    89  * @param endpoint USB endpoint number to be registered.
    90  * @param transfer_type Endpoint's transfer type.
    91  * @param direction USB communication direction the endpoint is capable of.
    92  * @param max_packet_size Maximu size of packets the endpoint accepts.
    93  * @param interval Preferred timeout between communication.
     88 * @param endpoint_desc Endpoint description.
    9489 * @return Error code.
    9590 */
    9691static int register_endpoint(
    97     ddf_fun_t *fun, usb_endpoint_t endpoint,
    98     usb_transfer_type_t transfer_type, usb_direction_t direction,
    99     size_t max_packet_size, unsigned packets, unsigned interval)
     92        ddf_fun_t *fun, usb_endpoint_desc_t *endpoint_desc)
    10093{
    10194        assert(fun);
     
    10598        assert(hcd->bus);
    10699        assert(dev);
    107         const size_t size = max_packet_size;
     100
     101        const size_t size = endpoint_desc->max_packet_size;
    108102
    109103        usb_log_debug("Register endpoint %d:%d %s-%s %zuB %ums.\n",
    110             dev->address, endpoint, usb_str_transfer_type(transfer_type),
    111             usb_str_direction(direction), max_packet_size, interval);
    112 
    113         return bus_add_ep(hcd->bus, dev, endpoint, direction, transfer_type,
    114             max_packet_size, packets, size);
    115 }
    116 
    117 /** Unregister endpoint interface function.
    118  * @param fun DDF function.
    119  * @param address USB address of the endpoint.
    120  * @param endpoint USB endpoint number.
    121  * @param direction Communication direction of the enpdoint to unregister.
    122  * @return Error code.
    123  */
     104                dev->address, endpoint_desc->endpoint_no,
     105                usb_str_transfer_type(endpoint_desc->transfer_type),
     106                usb_str_direction(endpoint_desc->direction),
     107                endpoint_desc->max_packet_size, endpoint_desc->usb2.polling_interval);
     108
     109        return bus_add_ep(hcd->bus, dev, endpoint_desc->endpoint_no,
     110                endpoint_desc->direction, endpoint_desc->transfer_type,
     111                endpoint_desc->max_packet_size, endpoint_desc->packets,
     112                size);
     113}
     114
     115 /** Unregister endpoint interface function.
     116  * @param fun DDF function.
     117  * @param endpoint_desc Endpoint description.
     118  * @return Error code.
     119  */
    124120static int unregister_endpoint(
    125     ddf_fun_t *fun, usb_endpoint_t endpoint, usb_direction_t direction)
     121        ddf_fun_t *fun, usb_endpoint_desc_t *endpoint_desc)
    126122{
    127123        assert(fun);
     
    131127        assert(hcd->bus);
    132128        assert(dev);
     129
    133130        const usb_target_t target = {{
    134131                .address = dev->address,
    135                 .endpoint = endpoint
     132                .endpoint = endpoint_desc->endpoint_no
    136133        }};
     134
    137135        usb_log_debug("Unregister endpoint %d:%d %s.\n",
    138             dev->address, endpoint, usb_str_direction(direction));
    139         return bus_remove_ep(hcd->bus, target, direction);
     136                dev->address, endpoint_desc->endpoint_no,
     137                usb_str_direction(endpoint_desc->direction));
     138        return bus_remove_ep(hcd->bus, target, endpoint_desc->direction);
    140139}
    141140
Note: See TracChangeset for help on using the changeset viewer.