Changeset b3c39690 in mainline for uspace/drv/bus/usb/usbdiag


Ignore:
Timestamp:
2018-01-21T23:19:20Z (8 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
db51a6a6
Parents:
09187c6e
git-author:
Ondřej Hlavatý <aearsis@…> (2018-01-21 23:19:14)
git-committer:
Ondřej Hlavatý <aearsis@…> (2018-01-21 23:19:20)
Message:

usb: remove misleading usb_device_get_mapped_ep

Even though this method may seem very convenient to use, it's actually
wrong. The devices are usually not required to have strict endpoint
numbers. That's why the mapping mechanism exists. Therefore, it's just
not possible to rely on fixed endpoint mapping.

There could be similar method, that would take the transfer type and
direction, but it's much better to ask for the complete mapping then.

Location:
uspace/drv/bus/usb/usbdiag
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbdiag/device.c

    r09187c6e rb3c39690  
    6464};
    6565
    66 static int device_init(usbdiag_dev_t *dev)
     66static int device_init(usbdiag_dev_t *dev, const usb_endpoint_description_t **endpoints)
    6767{
    6868        int rc;
     
    7777
    7878#define _MAP_EP(target, ep_no) do {\
    79         usb_endpoint_mapping_t *epm = usb_device_get_mapped_ep(dev->usb_dev, USBDIAG_EP_##ep_no);\
     79        usb_endpoint_mapping_t *epm = usb_device_get_mapped_ep_desc(dev->usb_dev, endpoints[USBDIAG_EP_##ep_no]);\
    8080        if (!epm || !epm->present) {\
    8181                usb_log_error("Failed to map endpoint: " #ep_no ".");\
     
    108108}
    109109
    110 int usbdiag_dev_create(usb_device_t *dev, usbdiag_dev_t **out_diag_dev)
     110int usbdiag_dev_create(usb_device_t *dev, usbdiag_dev_t **out_diag_dev, const usb_endpoint_description_t **endpoints)
    111111{
    112112        assert(dev);
     
    120120
    121121        int err;
    122         if ((err = device_init(diag_dev)))
     122        if ((err = device_init(diag_dev, endpoints)))
    123123                goto err_init;
    124124
  • uspace/drv/bus/usb/usbdiag/device.h

    r09187c6e rb3c39690  
    3838
    3939#include <usb/dev/device.h>
     40#include <usb/dev/driver.h>
    4041
    4142#define USBDIAG_EP_INTR_IN    1
     
    6061} usbdiag_dev_t;
    6162
    62 int usbdiag_dev_create(usb_device_t *, usbdiag_dev_t **);
     63int usbdiag_dev_create(usb_device_t *, usbdiag_dev_t **, const usb_endpoint_description_t **);
    6364void usbdiag_dev_destroy(usbdiag_dev_t *);
    6465
  • uspace/drv/bus/usb/usbdiag/main.c

    r09187c6e rb3c39690  
    4545#define NAME "usbdiag"
    4646
     47static const usb_endpoint_description_t *diag_endpoints[];
     48
    4749static int device_add(usb_device_t *dev)
    4850{
     
    5153
    5254        usbdiag_dev_t *diag_dev;
    53         if ((rc = usbdiag_dev_create(dev, &diag_dev))) {
     55        if ((rc = usbdiag_dev_create(dev, &diag_dev, diag_endpoints))) {
    5456                usb_log_error("Failed create device: %s.", str_error(rc));
    5557                goto err;
Note: See TracChangeset for help on using the changeset viewer.