Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 2489353 in mainline


Ignore:
Timestamp:
2018-01-13T20:47:58Z (4 years ago)
Author:
Petr Manek <petr.manek@…>
Branches:
lfn, master
Children:
7dddd7b
Parents:
1ed3eb4
git-author:
Petr Manek <petr.manek@…> (2018-01-13 18:38:22)
git-committer:
Petr Manek <petr.manek@…> (2018-01-13 20:47:58)
Message:

usbdev: driver can destroy endpoint mappings

Location:
uspace/lib/usbdev
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/include/usb/dev/device.h

    r1ed3eb4 r2489353  
    8888usb_endpoint_mapping_t * usb_device_get_mapped_ep(usb_device_t *,
    8989    usb_endpoint_t);
     90int usb_device_unmap_ep(usb_endpoint_mapping_t *);
    9091
    9192int usb_device_get_iface_number(usb_device_t *);
  • uspace/lib/usbdev/src/devdrv.c

    r1ed3eb4 r2489353  
    4848#include <devman.h>
    4949#include <errno.h>
     50#include <str_error.h>
    5051#include <stdlib.h>
    5152
     
    299300
    300301        /* Destroy the pipes. */
     302        int rc;
    301303        for (size_t i = 0; i < usb_dev->pipes_count; ++i) {
    302304                usb_log_debug2("Unregistering pipe %zu: %spresent.\n",
    303305                    i, usb_dev->pipes[i].present ? "" : "not ");
    304                 if (usb_dev->pipes[i].present)
    305                         usb_pipe_unregister(&usb_dev->pipes[i].pipe);
     306
     307                rc = usb_device_unmap_ep(usb_dev->pipes + i);
     308                if (rc != EOK && rc != ENOENT)
     309                        usb_log_warning("Unregistering pipe %zu failed: %s", i, str_error(rc));
    306310        }
    307311
     
    337341        }
    338342        return NULL;
     343}
     344
     345int usb_device_unmap_ep(usb_endpoint_mapping_t *epm)
     346{
     347        assert(epm);
     348
     349        if (!epm->present)
     350                return ENOENT;
     351
     352        const int rc = usb_pipe_unregister(&epm->pipe);
     353        if (rc != EOK)
     354                return rc;
     355
     356        epm->present = false;
     357        return EOK;
    339358}
    340359
Note: See TracChangeset for help on using the changeset viewer.