Changeset b7b7898 in mainline for uspace/drv/bus/usb/usbdiag/main.c


Ignore:
Timestamp:
2017-12-22T12:03:16Z (8 years ago)
Author:
Petr Mánek <petr.manek@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
96c416a
Parents:
2986763
git-author:
Petr Mánek <petr.manek@…> (2017-12-22 12:02:50)
git-committer:
Petr Mánek <petr.manek@…> (2017-12-22 12:03:16)
Message:

usbdiag: refactoring

Reconciliated the usb_diag and usbdiag prefix in favor of the latter. Removed a ton of copy-pasta code for the burst tests in favor of single generic static burst test for every direction, which is then called by individual functions for different endpoint type. This also allowed to get rid of the ugly translation macros in device.c. Deleted unused usbdiag.h header file. Refactored the remote interface to comply with all aforementioned modifications.

File:
1 edited

Legend:

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

    r2986763 rb7b7898  
    4141#include <str_error.h>
    4242
    43 #include "usbdiag.h"
    4443#include "device.h"
    4544
     
    5150        usb_log_info("Adding device '%s'", usb_device_get_name(dev));
    5251
    53         usb_diag_dev_t *diag_dev;
    54         if ((rc = usb_diag_dev_create(dev, &diag_dev))) {
     52        usbdiag_dev_t *diag_dev;
     53        if ((rc = usbdiag_dev_create(dev, &diag_dev))) {
    5554                usb_log_error("Failed create device: %s.\n", str_error(rc));
    5655                goto err;
     
    7372        ddf_fun_unbind(diag_dev->fun);
    7473err_create:
    75         usb_diag_dev_destroy(diag_dev);
     74        usbdiag_dev_destroy(diag_dev);
    7675err:
    7776        return rc;
     
    8382        usb_log_info("Removing device '%s'", usb_device_get_name(dev));
    8483
    85         usb_diag_dev_t *diag_dev = usb_device_to_usb_diag_dev(dev);
     84        usbdiag_dev_t *diag_dev = usb_device_to_usbdiag_dev(dev);
    8685
    8786        /* TODO: Make sure nothing is going on with the device. */
     
    9291        }
    9392
    94         usb_diag_dev_destroy(diag_dev);
     93        usbdiag_dev_destroy(diag_dev);
    9594
    9695        return EOK;
     
    104103        usb_log_info("Device '%s' gone.", usb_device_get_name(dev));
    105104
    106         usb_diag_dev_t *diag_dev = usb_device_to_usb_diag_dev(dev);
     105        usbdiag_dev_t *diag_dev = usb_device_to_usbdiag_dev(dev);
    107106
    108107        /* TODO: Make sure nothing is going on with the device. */
     
    110109        /* TODO: Remove device from list */
    111110
    112         usb_diag_dev_destroy(diag_dev);
     111        usbdiag_dev_destroy(diag_dev);
    113112
    114113        return EOK;
     
    175174
    176175static const usb_endpoint_description_t *diag_endpoints[] = {
    177         [USB_DIAG_EP_INTR_IN] = &intr_in_ep,
    178         [USB_DIAG_EP_INTR_OUT] = &intr_out_ep,
    179         [USB_DIAG_EP_BULK_IN] = &bulk_in_ep,
    180         [USB_DIAG_EP_BULK_OUT] = &bulk_out_ep,
    181         [USB_DIAG_EP_ISOCH_IN] = &isoch_in_ep,
    182         [USB_DIAG_EP_ISOCH_OUT] = &isoch_out_ep,
     176        [USBDIAG_EP_INTR_IN] = &intr_in_ep,
     177        [USBDIAG_EP_INTR_OUT] = &intr_out_ep,
     178        [USBDIAG_EP_BULK_IN] = &bulk_in_ep,
     179        [USBDIAG_EP_BULK_OUT] = &bulk_out_ep,
     180        [USBDIAG_EP_ISOCH_IN] = &isoch_in_ep,
     181        [USBDIAG_EP_ISOCH_OUT] = &isoch_out_ep,
    183182        NULL
    184183};
Note: See TracChangeset for help on using the changeset viewer.