Changeset ae3a941 in mainline


Ignore:
Timestamp:
2018-02-26T16:51:40Z (6 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e773f58
Parents:
3692678
Message:

usb: cstyle

Location:
uspace
Files:
68 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/block/usbmast/scsi_ms.c

    r3692678 rae3a941  
    8888        rc = usb_massstor_cmd(mfun, 0xDEADBEEF, &cmd);
    8989
    90         if (rc != EOK) {
     90        if (rc != EOK) {
    9191                usb_log_error("Test Unit Ready failed on device %s: %s.",
    92                    usb_device_get_name(mfun->mdev->usb_dev), str_error(rc));
     92                    usb_device_get_name(mfun->mdev->usb_dev), str_error(rc));
    9393                return rc;
    9494        }
     
    9898        if (cmd.status != CMDS_GOOD)
    9999                usb_log_warning("Test Unit Ready command failed on device %s.",
    100                    usb_device_get_name(mfun->mdev->usb_dev));
     100                    usb_device_get_name(mfun->mdev->usb_dev));
    101101
    102102        return EOK;
     
    118118                if (rc != EOK) {
    119119                        usb_log_error("Inquiry transport failed, device %s: %s.",
    120                            usb_device_get_name(mfun->mdev->usb_dev), str_error(rc));
     120                            usb_device_get_name(mfun->mdev->usb_dev), str_error(rc));
    121121                        return rc;
    122122                }
     
    125125                if (rc != EOK) {
    126126                        usb_log_error("Inquiry transport failed, device %s: %s.",
    127                            usb_device_get_name(mfun->mdev->usb_dev), str_error(rc));
     127                            usb_device_get_name(mfun->mdev->usb_dev), str_error(rc));
    128128                        return rc;
    129129                }
     
    184184        if (rc != EOK) {
    185185                usb_log_error("Inquiry transport failed, device %s: %s.",
    186                    usb_device_get_name(mfun->mdev->usb_dev), str_error(rc));
     186                    usb_device_get_name(mfun->mdev->usb_dev), str_error(rc));
    187187                return rc;
    188188        }
     
    190190        if (cmd.status != CMDS_GOOD) {
    191191                usb_log_error("Inquiry command failed, device %s.",
    192                    usb_device_get_name(mfun->mdev->usb_dev));
     192                    usb_device_get_name(mfun->mdev->usb_dev));
    193193                return EIO;
    194194        }
     
    196196        if (cmd.rcvd_size < SCSI_STD_INQUIRY_DATA_MIN_SIZE) {
    197197                usb_log_error("SCSI Inquiry response too short (%zu).",
    198                     cmd.rcvd_size);
     198                     cmd.rcvd_size);
    199199                return EIO;
    200200        }
     
    250250        rc = usb_massstor_cmd(mfun, 0xDEADBEEF, &cmd);
    251251
    252         if (rc != EOK || cmd.status != CMDS_GOOD) {
     252        if (rc != EOK || cmd.status != CMDS_GOOD) {
    253253                usb_log_error("Request Sense failed, device %s: %s.",
    254                    usb_device_get_name(mfun->mdev->usb_dev), str_error(rc));
     254                    usb_device_get_name(mfun->mdev->usb_dev), str_error(rc));
    255255                return rc;
    256256        }
     
    294294        if (rc != EOK) {
    295295                usb_log_error("Read Capacity (10) transport failed, device %s: %s.",
    296                    usb_device_get_name(mfun->mdev->usb_dev), str_error(rc));
     296                    usb_device_get_name(mfun->mdev->usb_dev), str_error(rc));
    297297                return rc;
    298298        }
     
    300300        if (cmd.status != CMDS_GOOD) {
    301301                usb_log_error("Read Capacity (10) command failed, device %s.",
    302                    usb_device_get_name(mfun->mdev->usb_dev));
     302                    usb_device_get_name(mfun->mdev->usb_dev));
    303303                return EIO;
    304304        }
     
    306306        if (cmd.rcvd_size < sizeof(data)) {
    307307                usb_log_error("SCSI Read Capacity response too short (%zu).",
    308                     cmd.rcvd_size);
     308                     cmd.rcvd_size);
    309309                return EIO;
    310310        }
     
    351351        if (rc != EOK) {
    352352                usb_log_error("Read (10) transport failed, device %s: %s.",
    353                    usb_device_get_name(mfun->mdev->usb_dev), str_error(rc));
     353                    usb_device_get_name(mfun->mdev->usb_dev), str_error(rc));
    354354                return rc;
    355355        }
     
    357357        if (cmd.status != CMDS_GOOD) {
    358358                usb_log_error("Read (10) command failed, device %s.",
    359                    usb_device_get_name(mfun->mdev->usb_dev));
     359                    usb_device_get_name(mfun->mdev->usb_dev));
    360360                return EIO;
    361361        }
     
    405405        rc = usbmast_run_cmd(mfun, &cmd);
    406406
    407         if (rc != EOK) {
     407        if (rc != EOK) {
    408408                usb_log_error("Write (10) transport failed, device %s: %s.",
    409                    usb_device_get_name(mfun->mdev->usb_dev), str_error(rc));
     409                    usb_device_get_name(mfun->mdev->usb_dev), str_error(rc));
    410410                return rc;
    411411        }
     
    413413        if (cmd.status != CMDS_GOOD) {
    414414                usb_log_error("Write (10) command failed, device %s.",
    415                    usb_device_get_name(mfun->mdev->usb_dev));
     415                    usb_device_get_name(mfun->mdev->usb_dev));
    416416                return EIO;
    417417        }
     
    452452        if (rc != EOK) {
    453453                usb_log_error("Synchronize Cache (10) transport failed, device %s: %s.",
    454                    usb_device_get_name(mfun->mdev->usb_dev), str_error(rc));
     454                    usb_device_get_name(mfun->mdev->usb_dev), str_error(rc));
    455455                return rc;
    456456        }
     
    458458        if (cmd.status != CMDS_GOOD) {
    459459                usb_log_error("Synchronize Cache (10) command failed, device %s.",
    460                    usb_device_get_name(mfun->mdev->usb_dev));
     460                    usb_device_get_name(mfun->mdev->usb_dev));
    461461                return EIO;
    462462        }
  • uspace/drv/bus/usb/ehci/ehci_batch.h

    r3692678 rae3a941  
    6363} ehci_transfer_batch_t;
    6464
    65 ehci_transfer_batch_t * ehci_transfer_batch_create(endpoint_t *ep);
     65ehci_transfer_batch_t *ehci_transfer_batch_create(endpoint_t *ep);
    6666int ehci_transfer_batch_prepare(ehci_transfer_batch_t *batch);
    6767void ehci_transfer_batch_commit(const ehci_transfer_batch_t *batch);
     
    6969void ehci_transfer_batch_destroy(ehci_transfer_batch_t *batch);
    7070
    71 static inline ehci_transfer_batch_t * ehci_transfer_batch_get(usb_transfer_batch_t *usb_batch)
     71static inline ehci_transfer_batch_t *ehci_transfer_batch_get(
     72    usb_transfer_batch_t *usb_batch)
    7273{
    7374        assert(usb_batch);
  • uspace/drv/bus/usb/ehci/ehci_bus.c

    r3692678 rae3a941  
    5454        ehci_endpoint_t *instance = ehci_endpoint_get(ep);
    5555        if (qh_toggle_from_td(instance->qh))
    56                 usb_log_warning("EP(%p): Resetting toggle bit for transfer directed EP", instance);
     56                usb_log_warning("EP(%p): Resetting toggle bit for transfer "
     57                    "directed EP", instance);
    5758        qh_toggle_set(instance->qh, 0);
    5859}
     
    7273/** Creates new hcd endpoint representation.
    7374 */
    74 static endpoint_t *ehci_endpoint_create(device_t *dev, const usb_endpoint_descriptors_t *desc)
     75static endpoint_t *ehci_endpoint_create(device_t *dev,
     76    const usb_endpoint_descriptors_t *desc)
    7577{
    7678        assert(dev);
  • uspace/drv/bus/usb/ehci/ehci_bus.h

    r3692678 rae3a941  
    7878 * @return Pointer to assigned ehci endpoint structure
    7979 */
    80 static inline ehci_endpoint_t * ehci_endpoint_get(const endpoint_t *ep)
     80static inline ehci_endpoint_t *ehci_endpoint_get(const endpoint_t *ep)
    8181{
    8282        assert(ep);
     
    8484}
    8585
    86 static inline ehci_endpoint_t * ehci_endpoint_list_instance(link_t *l)
     86static inline ehci_endpoint_t *ehci_endpoint_list_instance(link_t *l)
    8787{
    8888        return list_get_instance(l, ehci_endpoint_t, eplist_link);
  • uspace/drv/bus/usb/ehci/ehci_rh.h

    r3692678 rae3a941  
    8080} ehci_rh_t;
    8181
    82 errno_t ehci_rh_init(ehci_rh_t *instance, ehci_caps_regs_t *caps, ehci_regs_t *regs,
    83     fibril_mutex_t *guard, const char *name);
     82errno_t ehci_rh_init(ehci_rh_t *instance, ehci_caps_regs_t *caps,
     83    ehci_regs_t *regs, fibril_mutex_t *guard, const char *name);
    8484errno_t ehci_rh_schedule(ehci_rh_t *instance, usb_transfer_batch_t *batch);
    8585errno_t ehci_rh_interrupt(ehci_rh_t *instance);
  • uspace/drv/bus/usb/ehci/hc.h

    r3692678 rae3a941  
    104104extern errno_t hc_start(hc_device_t *);
    105105extern errno_t hc_setup_roothub(hc_device_t *);
    106 extern errno_t hc_gen_irq_code(irq_code_t *, hc_device_t *, const hw_res_list_parsed_t *, int *);
     106extern errno_t hc_gen_irq_code(irq_code_t *, hc_device_t *,
     107    const hw_res_list_parsed_t *, int *);
    107108extern errno_t hc_gone(hc_device_t *);
    108109
  • uspace/drv/bus/usb/ehci/hw_struct/iso_transfer_descriptor.h

    r3692678 rae3a941  
    7272        /* 64 bit struct only */
    7373        volatile uint32_t extended_bp[7];
    74 } __attribute__((packed,aligned(32))) itd_t;
     74} __attribute__((packed, aligned(32))) itd_t;
    7575#endif
    7676/**
  • uspace/drv/bus/usb/ehci/hw_struct/queue_head.c

    r3692678 rae3a941  
    7070            QH_EP_CHAR_EP_SET(ep->endpoint) |
    7171            speed[ep->device->speed] |
    72             QH_EP_CHAR_MAX_LENGTH_SET(ep->max_packet_size)
    73         );
     72            QH_EP_CHAR_MAX_LENGTH_SET(ep->max_packet_size));
    7473        if (ep->transfer_type == USB_TRANSFER_CONTROL) {
    7574                if (ep->device->speed != USB_SPEED_HIGH)
     
    8079        }
    8180        uint32_t ep_cap = QH_EP_CAP_C_MASK_SET(3 << 2) |
    82                     QH_EP_CAP_MULTI_SET(ep->packets_per_uframe);
     81            QH_EP_CAP_MULTI_SET(ep->packets_per_uframe);
    8382        if (usb_speed_is_11(ep->device->speed)) {
    8483                assert(ep->device->tt.dev != NULL);
  • uspace/drv/bus/usb/ehci/hw_struct/queue_head.h

    r3692678 rae3a941  
    143143        /* 64 bit struct only */
    144144        volatile uint32_t extended_bp[5];
    145 } __attribute__((packed,aligned(32))) qh_t;
     145} __attribute__((packed, aligned(32))) qh_t;
    146146
    147147static inline void qh_append_qh(qh_t *qh, const qh_t *next)
  • uspace/drv/bus/usb/ehci/hw_struct/split_iso_transfer_descriptor.h

    r3692678 rae3a941  
    8989        /* 64 bit struct only */
    9090        volatile uint32_t extended_bp[2];
    91 } __attribute__((packed,aligned(32))) sitd_t;
     91} __attribute__((packed, aligned(32))) sitd_t;
    9292#endif
    9393/**
  • uspace/drv/bus/usb/ohci/hc.h

    r3692678 rae3a941  
    8484} hc_t;
    8585
    86 static inline hc_t * hcd_to_hc(hc_device_t *hcd)
     86static inline hc_t *hcd_to_hc(hc_device_t *hcd)
    8787{
    8888        assert(hcd);
     
    9191
    9292extern errno_t hc_add(hc_device_t *, const hw_res_list_parsed_t *);
    93 extern errno_t hc_gen_irq_code(irq_code_t *, hc_device_t *, const hw_res_list_parsed_t *, int *);
     93extern errno_t hc_gen_irq_code(irq_code_t *, hc_device_t *,
     94    const hw_res_list_parsed_t *, int *);
    9495extern errno_t hc_gain_control(hc_device_t *);
    9596extern errno_t hc_start(hc_device_t *);
  • uspace/drv/bus/usb/ohci/hw_struct/endpoint_descriptor.c

    r3692678 rae3a941  
    8484            | ((ep->endpoint & ED_STATUS_EN_MASK) << ED_STATUS_EN_SHIFT)
    8585            | ((dir[ep->direction] & ED_STATUS_D_MASK) << ED_STATUS_D_SHIFT)
    86             | ((ep->max_packet_size & ED_STATUS_MPS_MASK)
    87                 << ED_STATUS_MPS_SHIFT));
     86            | ((ep->max_packet_size & ED_STATUS_MPS_MASK) << ED_STATUS_MPS_SHIFT));
    8887
    8988        /* Low speed flag */
  • uspace/drv/bus/usb/ohci/hw_struct/endpoint_descriptor.h

    r3692678 rae3a941  
    107107#define ED_NEXT_PTR_MASK (0xfffffff0)
    108108#define ED_NEXT_PTR_SHIFT (0)
    109 } __attribute__((packed,aligned(32))) ed_t;
     109} __attribute__((packed, aligned(32))) ed_t;
    110110
    111111void ed_init(ed_t *instance, const endpoint_t *ep, const td_t *td);
     
    204204{
    205205        assert(instance);
    206         return (OHCI_MEM32_RD(instance->td_head) & ED_TDHEAD_TOGGLE_CARRY) ? 1 : 0;
     206        return !!(OHCI_MEM32_RD(instance->td_head) & ED_TDHEAD_TOGGLE_CARRY);
    207207}
    208208
  • uspace/drv/bus/usb/ohci/hw_struct/iso_transfer_descriptor.h

    r3692678 rae3a941  
    6969#define ITD_OFFSET_CC_SHIFT (12)
    7070
    71 } __attribute__((packed,aligned(32))) itd_t;
     71} __attribute__((packed, aligned(32))) itd_t;
    7272
    7373#endif
  • uspace/drv/bus/usb/ohci/hw_struct/transfer_descriptor.h

    r3692678 rae3a941  
    9090         */
    9191        volatile uint32_t be;
    92 } __attribute__((packed,aligned(32))) td_t;
     92} __attribute__((packed, aligned(32))) td_t;
    9393
    9494void td_init(td_t *, const td_t *, usb_direction_t, const void *, size_t, int);
     
    103103{
    104104        assert(instance);
    105         const int cc =(OHCI_MEM32_RD(instance->status)
    106             >> TD_STATUS_CC_SHIFT) & TD_STATUS_CC_MASK;
     105        const int cc = (OHCI_MEM32_RD(instance->status) >> TD_STATUS_CC_SHIFT)
     106                & TD_STATUS_CC_MASK;
    107107        /* This value is changed on transfer completion,
    108108         * either to CC_NOERROR or and error code.
  • uspace/drv/bus/usb/ohci/ohci_batch.h

    r3692678 rae3a941  
    6565} ohci_transfer_batch_t;
    6666
    67 ohci_transfer_batch_t * ohci_transfer_batch_create(endpoint_t *batch);
     67ohci_transfer_batch_t *ohci_transfer_batch_create(endpoint_t *batch);
    6868int ohci_transfer_batch_prepare(ohci_transfer_batch_t *ohci_batch);
    6969void ohci_transfer_batch_commit(const ohci_transfer_batch_t *batch);
     
    7171void ohci_transfer_batch_destroy(ohci_transfer_batch_t *ohci_batch);
    7272
    73 static inline ohci_transfer_batch_t * ohci_transfer_batch_get(usb_transfer_batch_t *usb_batch)
     73static inline ohci_transfer_batch_t *ohci_transfer_batch_get(
     74    usb_transfer_batch_t *usb_batch)
    7475{
    7576        assert(usb_batch);
  • uspace/drv/bus/usb/ohci/ohci_bus.c

    r3692678 rae3a941  
    7272/** Creates new hcd endpoint representation.
    7373 */
    74 static endpoint_t *ohci_endpoint_create(device_t *dev, const usb_endpoint_descriptors_t *desc)
     74static endpoint_t *ohci_endpoint_create(device_t *dev,
     75    const usb_endpoint_descriptors_t *desc)
    7576{
    7677        assert(dev);
     
    8283        endpoint_init(&ohci_ep->base, dev, desc);
    8384
    84         const errno_t err = dma_buffer_alloc(&ohci_ep->dma_buffer, sizeof(ed_t) + 2 * sizeof(td_t));
     85        const errno_t err = dma_buffer_alloc(&ohci_ep->dma_buffer,
     86            sizeof(ed_t) + 2 * sizeof(td_t));
    8587        if (err) {
    8688                free(ohci_ep);
  • uspace/drv/bus/usb/uhci/hw_struct/queue_head.h

    r3692678 rae3a941  
    4848        /** Pointer to the next entity (another QH or TD */
    4949        volatile link_pointer_t next;
    50         /** Pointer to the contained entities (execution controlled by vertical flag*/
     50        /**
     51         * Pointer to the contained entities
     52         * (execution controlled by vertical flag)
     53         */
    5154        volatile link_pointer_t element;
    52 } __attribute__((packed,aligned(16))) qh_t;
     55} __attribute__((packed, aligned(16))) qh_t;
    5356
    5457/** Initialize queue head structure
  • uspace/drv/bus/usb/uhci/hw_struct/transfer_descriptor.h

    r3692678 rae3a941  
    9595         * memory just needs to be aligned. We don't use it anyway.
    9696         */
    97 } __attribute__((packed,aligned(16))) td_t;
     97} __attribute__((packed, aligned(16))) td_t;
    9898
    9999
  • uspace/drv/bus/usb/uhci/uhci_batch.h

    r3692678 rae3a941  
    7070} uhci_transfer_batch_t;
    7171
    72 uhci_transfer_batch_t * uhci_transfer_batch_create(endpoint_t *);
     72uhci_transfer_batch_t *uhci_transfer_batch_create(endpoint_t *);
    7373int uhci_transfer_batch_prepare(uhci_transfer_batch_t *);
    7474bool uhci_transfer_batch_check_completed(uhci_transfer_batch_t *);
     
    7979 * @return Pointer to the setup buffer.
    8080 */
    81 static inline void * uhci_transfer_batch_setup_buffer(
     81static inline void *uhci_transfer_batch_setup_buffer(
    8282    const uhci_transfer_batch_t *uhci_batch)
    8383{
     
    9191 * @return Pointer to the data buffer.
    9292 */
    93 static inline void * uhci_transfer_batch_data_buffer(
     93static inline void *uhci_transfer_batch_data_buffer(
    9494    const uhci_transfer_batch_t *uhci_batch)
    9595{
     
    108108}
    109109
    110 static inline uhci_transfer_batch_t *uhci_transfer_batch_get(usb_transfer_batch_t *b)
     110static inline uhci_transfer_batch_t *uhci_transfer_batch_get(
     111    usb_transfer_batch_t *b)
    111112{
    112113        assert(b);
  • uspace/drv/bus/usb/usbdiag/device.h

    r3692678 rae3a941  
    7777} usbdiag_dev_t;
    7878
    79 errno_t usbdiag_dev_create(usb_device_t *, usbdiag_dev_t **, const usb_endpoint_description_t **);
     79errno_t usbdiag_dev_create(usb_device_t *, usbdiag_dev_t **,
     80    const usb_endpoint_description_t **);
    8081void usbdiag_dev_destroy(usbdiag_dev_t *);
    8182
    82 static inline usbdiag_dev_t * usb_device_to_usbdiag_dev(usb_device_t *usb_dev)
     83static inline usbdiag_dev_t *usb_device_to_usbdiag_dev(usb_device_t *usb_dev)
    8384{
    8485        assert(usb_dev);
     
    8687}
    8788
    88 static inline usbdiag_dev_t * ddf_dev_to_usbdiag_dev(ddf_dev_t *ddf_dev)
     89static inline usbdiag_dev_t *ddf_dev_to_usbdiag_dev(ddf_dev_t *ddf_dev)
    8990{
    9091        assert(ddf_dev);
     
    9293}
    9394
    94 static inline usbdiag_dev_t * ddf_fun_to_usbdiag_dev(ddf_fun_t *ddf_fun)
     95static inline usbdiag_dev_t *ddf_fun_to_usbdiag_dev(ddf_fun_t *ddf_fun)
    9596{
    9697        assert(ddf_fun);
  • uspace/drv/bus/usb/usbdiag/tests.h

    r3692678 rae3a941  
    3939#include <ddf/driver.h>
    4040
    41 errno_t usbdiag_dev_test_in(ddf_fun_t *, const usbdiag_test_params_t *, usbdiag_test_results_t *);
    42 errno_t usbdiag_dev_test_out(ddf_fun_t *, const usbdiag_test_params_t *, usbdiag_test_results_t *);
     41errno_t usbdiag_dev_test_in(ddf_fun_t *, const usbdiag_test_params_t *,
     42    usbdiag_test_results_t *);
     43errno_t usbdiag_dev_test_out(ddf_fun_t *, const usbdiag_test_params_t *,
     44    usbdiag_test_results_t *);
    4345
    4446#endif /* USBDIAG_TESTS_H_ */
  • uspace/drv/bus/usb/usbhub/port.c

    r3692678 rae3a941  
    4949#include "status.h"
    5050
    51 #define port_log(lvl, port, fmt, ...) do { usb_log_##lvl("(%p-%u): " fmt, (port->hub), (port->port_number), ##__VA_ARGS__); } while (0)
     51#define port_log(lvl, port, fmt, ...) do { \
     52                usb_log_##lvl("(%p-%u): " fmt, \
     53                    (port->hub), (port->port_number), ##__VA_ARGS__); \
     54        } while (0)
    5255
    5356/** Initialize hub port information.
     
    5558 * @param port Port to be initialized.
    5659 */
    57 void usb_hub_port_init(usb_hub_port_t *port, usb_hub_dev_t *hub, unsigned int port_number)
     60void usb_hub_port_init(usb_hub_port_t *port, usb_hub_dev_t *hub,
     61    unsigned int port_number)
    5862{
    5963        assert(port);
     
    7983        async_exch_t *exch = usb_device_bus_exchange_begin(port->hub->usb_device);
    8084        if (!exch) {
    81                 port_log(error, port, "Cannot remove the device, failed creating exchange.");
     85                port_log(error, port, "Cannot remove the device, "
     86                    "failed creating exchange.");
    8287                return;
    8388        }
     
    8590        const errno_t err = usbhc_device_remove(exch, port->port_number);
    8691        if (err)
    87                 port_log(error, port, "Failed to remove device: %s", str_error(err));
     92                port_log(error, port, "Failed to remove device: %s",
     93                    str_error(err));
    8894
    8995        usb_device_bus_exchange_end(exch);
     
    109115        err = usb_hub_reserve_default_address(port->hub, exch, &port->base);
    110116        if (err != EOK) {
    111                 port_log(error, port, "Failed to reserve default address: %s", str_error(err));
     117                port_log(error, port, "Failed to reserve default address: %s",
     118                    str_error(err));
    112119                return err;
    113120        }
     
    118125
    119126        port_log(debug, port, "Resetting port.");
    120         if ((err = usb_hub_set_port_feature(port->hub, port->port_number, USB_HUB_FEATURE_PORT_RESET))) {
    121                 port_log(warning, port, "Port reset request failed: %s", str_error(err));
     127        if ((err = usb_hub_set_port_feature(port->hub, port->port_number,
     128                            USB_HUB_FEATURE_PORT_RESET))) {
     129                port_log(warning, port, "Port reset request failed: %s",
     130                    str_error(err));
    122131                goto out_address;
    123132        }
    124133
    125134        if ((err = usb_port_wait_for_enabled(&port->base))) {
    126                 port_log(error, port, "Failed to reset port: %s", str_error(err));
     135                port_log(error, port, "Failed to reset port: %s",
     136                    str_error(err));
    127137                goto out_address;
    128138        }
    129139
    130140        port_log(debug, port, "Enumerating device.");
    131         if ((err = usbhc_device_enumerate(exch, port->port_number, port->speed))) {
    132                 port_log(error, port, "Failed to enumerate device: %s", str_error(err));
     141        if ((err = usbhc_device_enumerate(exch, port->port_number,
     142                            port->speed))) {
     143                port_log(error, port, "Failed to enumerate device: %s",
     144                    str_error(err));
    133145                /* Disable the port */
    134                 usb_hub_clear_port_feature(port->hub, port->port_number, USB2_HUB_FEATURE_PORT_ENABLE);
     146                usb_hub_clear_port_feature(port->hub, port->port_number,
     147                    USB2_HUB_FEATURE_PORT_ENABLE);
    135148                goto out_address;
    136149        }
     
    151164
    152165        port_log(debug, port, "Issuing a warm reset.");
    153         if ((err = usb_hub_set_port_feature(port->hub, port->port_number, USB3_HUB_FEATURE_BH_PORT_RESET))) {
    154                 port_log(warning, port, "Port reset request failed: %s", str_error(err));
     166        if ((err = usb_hub_set_port_feature(port->hub, port->port_number,
     167                            USB3_HUB_FEATURE_BH_PORT_RESET))) {
     168                port_log(warning, port, "Port reset request failed: %s",
     169                    str_error(err));
    155170                return err;
    156171        }
    157172
    158173        if ((err = usb_port_wait_for_enabled(&port->base))) {
    159                 port_log(error, port, "Failed to reset port: %s", str_error(err));
     174                port_log(error, port, "Failed to reset port: %s",
     175                    str_error(err));
    160176                return err;
    161177        }
    162178
    163179        port_log(debug, port, "Enumerating device.");
    164         if ((err = usbhc_device_enumerate(exch, port->port_number, port->speed))) {
    165                 port_log(error, port, "Failed to enumerate device: %s", str_error(err));
     180        if ((err = usbhc_device_enumerate(exch, port->port_number,
     181                            port->speed))) {
     182                port_log(error, port, "Failed to enumerate device: %s",
     183                    str_error(err));
    166184                return err;
    167185        }
     
    193211{
    194212        const bool connected = !!(status & USB_HUB_PORT_STATUS_CONNECTION);
    195         port_log(debug, port, "Connection change: device %s.", connected ? "attached" : "removed");
     213        port_log(debug, port, "Connection change: device %s.", connected
     214            ? "attached" : "removed");
    196215
    197216        if (connected) {
     
    212231}
    213232
    214 static void port_changed_overcurrent(usb_hub_port_t *port, usb_port_status_t status)
     233static void port_changed_overcurrent(usb_hub_port_t *port,
     234    usb_port_status_t status)
    215235{
    216236        const bool overcurrent = !!(status & USB_HUB_PORT_STATUS_OC);
     
    225245
    226246        if (!overcurrent) {
    227                 const errno_t err = usb_hub_set_port_feature(port->hub, port->port_number, USB_HUB_FEATURE_PORT_POWER);
     247                const errno_t err = usb_hub_set_port_feature(port->hub,
     248                    port->port_number, USB_HUB_FEATURE_PORT_POWER);
    228249                if (err)
    229                         port_log(error, port, "Failed to set port power after OC: %s.", str_error(err));
     250                        port_log(error, port, "Failed to set port power "
     251                            "after OC: %s.", str_error(err));
    230252        }
    231253}
     
    245267
    246268static void check_port_change(usb_hub_port_t *port, usb_port_status_t *status,
    247     change_handler_t handler, usb_port_status_t mask, usb_hub_class_feature_t feature)
     269    change_handler_t handler, usb_port_status_t mask,
     270    usb_hub_class_feature_t feature)
    248271{
    249272        if ((*status & mask) == 0)
     
    273296
    274297        usb_port_status_t status = 0;
    275         const errno_t err = usb_hub_get_port_status(port->hub, port->port_number, &status);
     298        const errno_t err = usb_hub_get_port_status(port->hub,
     299            port->port_number, &status);
    276300        if (err != EOK) {
    277                 port_log(error, port, "Failed to get port status: %s.", str_error(err));
     301                port_log(error, port, "Failed to get port status: %s.",
     302                    str_error(err));
    278303                return;
    279304        }
    280305
    281306        check_port_change(port, &status, &port_changed_connection,
    282             USB_HUB_PORT_STATUS_C_CONNECTION, USB_HUB_FEATURE_C_PORT_CONNECTION);
     307            USB_HUB_PORT_STATUS_C_CONNECTION,
     308            USB_HUB_FEATURE_C_PORT_CONNECTION);
    283309
    284310        check_port_change(port, &status, &port_changed_overcurrent,
     
    290316        if (port->hub->speed <= USB_SPEED_HIGH) {
    291317                check_port_change(port, &status, &port_changed_enabled,
    292                     USB2_HUB_PORT_STATUS_C_ENABLE, USB2_HUB_FEATURE_C_PORT_ENABLE);
     318                    USB2_HUB_PORT_STATUS_C_ENABLE,
     319                    USB2_HUB_FEATURE_C_PORT_ENABLE);
    293320        } else {
    294321                check_port_change(port, &status, &port_changed_reset,
    295                     USB3_HUB_PORT_STATUS_C_BH_RESET, USB3_HUB_FEATURE_C_BH_PORT_RESET);
     322                    USB3_HUB_PORT_STATUS_C_BH_RESET,
     323                    USB3_HUB_FEATURE_C_BH_PORT_RESET);
    296324
    297325                check_port_change(port, &status, NULL,
    298                     USB3_HUB_PORT_STATUS_C_LINK_STATE, USB3_HUB_FEATURE_C_PORT_LINK_STATE);
     326                    USB3_HUB_PORT_STATUS_C_LINK_STATE,
     327                    USB3_HUB_FEATURE_C_PORT_LINK_STATE);
    299328        }
    300329
    301330        /* Check for changes we ignored */
    302331        if (status & 0xffff0000) {
    303                 port_log(debug, port, "Port status change igored. Status: %#08" PRIx32, status);
     332                port_log(debug, port, "Port status change igored. "
     333                    "Status: %#08" PRIx32, status);
    304334        }
    305335}
  • uspace/drv/bus/usb/usbhub/status.h

    r3692678 rae3a941  
    5959        if (hub_speed == USB_SPEED_SUPER)
    6060                return USB_SPEED_SUPER;
    61         if (hub_speed == USB_SPEED_HIGH && (status & USB2_HUB_PORT_STATUS_HIGH_SPEED))
     61        if (hub_speed == USB_SPEED_HIGH
     62            && (status & USB2_HUB_PORT_STATUS_HIGH_SPEED))
    6263                return USB_SPEED_HIGH;
    6364        if ((status & USB2_HUB_PORT_STATUS_LOW_SPEED) != 0)
  • uspace/drv/bus/usb/usbhub/usbhub.h

    r3692678 rae3a941  
    8484
    8585errno_t usb_hub_set_depth(const usb_hub_dev_t *);
    86 errno_t usb_hub_get_port_status(const usb_hub_dev_t *, size_t, usb_port_status_t *);
    87 errno_t usb_hub_set_port_feature(const usb_hub_dev_t *, size_t, usb_hub_class_feature_t);
    88 errno_t usb_hub_clear_port_feature(const usb_hub_dev_t *, size_t, usb_hub_class_feature_t);
     86errno_t usb_hub_get_port_status(const usb_hub_dev_t *, size_t,
     87    usb_port_status_t *);
     88errno_t usb_hub_set_port_feature(const usb_hub_dev_t *, size_t,
     89    usb_hub_class_feature_t);
     90errno_t usb_hub_clear_port_feature(const usb_hub_dev_t *, size_t,
     91    usb_hub_class_feature_t);
    8992
    9093bool hub_port_changes_callback(usb_device_t *, uint8_t *, size_t, void *);
    9194
    92 errno_t usb_hub_reserve_default_address(usb_hub_dev_t *, async_exch_t *, usb_port_t *);
     95errno_t usb_hub_reserve_default_address(usb_hub_dev_t *, async_exch_t *,
     96    usb_port_t *);
    9397errno_t usb_hub_release_default_address(usb_hub_dev_t *, async_exch_t *);
    9498
  • uspace/drv/bus/usb/usbmid/dump.c

    r3692678 rae3a941  
    5454        const int type = data[1];
    5555        if (type == USB_DESCTYPE_INTERFACE) {
    56                 usb_standard_interface_descriptor_t *descriptor
    57                     = (usb_standard_interface_descriptor_t *) data;
     56                usb_standard_interface_descriptor_t *descriptor =
     57                    (usb_standard_interface_descriptor_t *) data;
    5858                usb_log_info("Found interface: %s (0x%02x/0x%02x/0x%02x).",
    5959                    usb_str_class(descriptor->interface_class),
  • uspace/drv/bus/usb/vhc/hub/hub.c

    r3692678 rae3a941  
    6868
    6969/** Convert hub port state to a char. */
    70 char hub_port_state_to_char(hub_port_state_t state) {
     70char hub_port_state_to_char(hub_port_state_t state)
     71{
    7172        switch (state) {
    72                 case HUB_PORT_STATE_NOT_CONFIGURED:
    73                         return '-';
    74                 case HUB_PORT_STATE_POWERED_OFF:
    75                         return 'O';
    76                 case HUB_PORT_STATE_DISCONNECTED:
    77                         return 'X';
    78                 case HUB_PORT_STATE_DISABLED:
    79                         return 'D';
    80                 case HUB_PORT_STATE_RESETTING:
    81                         return 'R';
    82                 case HUB_PORT_STATE_ENABLED:
    83                         return 'E';
    84                 case HUB_PORT_STATE_SUSPENDED:
    85                         return 'S';
    86                 case HUB_PORT_STATE_RESUMING:
    87                         return 'F';
    88                 default:
    89                         return '?';
     73        case HUB_PORT_STATE_NOT_CONFIGURED:
     74                return '-';
     75        case HUB_PORT_STATE_POWERED_OFF:
     76                return 'O';
     77        case HUB_PORT_STATE_DISCONNECTED:
     78                return 'X';
     79        case HUB_PORT_STATE_DISABLED:
     80                return 'D';
     81        case HUB_PORT_STATE_RESETTING:
     82                return 'R';
     83        case HUB_PORT_STATE_ENABLED:
     84                return 'E';
     85        case HUB_PORT_STATE_SUSPENDED:
     86                return 'S';
     87        case HUB_PORT_STATE_RESUMING:
     88                return 'F';
     89        default:
     90                return '?';
    9091        }
    9192}
     
    234235
    235236        switch (state) {
    236                 case HUB_PORT_STATE_POWERED_OFF:
    237                         clear_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION);
    238                         clear_port_status_change(port, HUB_STATUS_C_PORT_ENABLE);
    239                         clear_port_status_change(port, HUB_STATUS_C_PORT_RESET);
    240                         break;
    241                 case HUB_PORT_STATE_RESUMING:
    242                         port->state = state;
    243                         set_port_state_delayed(hub, port_index,
    244                             10, state, HUB_PORT_STATE_ENABLED);
    245                         break;
    246                 case HUB_PORT_STATE_RESETTING:
    247                         port->state = state;
    248                         set_port_state_delayed(hub, port_index,
    249                             10, state, HUB_PORT_STATE_ENABLED);
    250                         break;
    251                 case HUB_PORT_STATE_ENABLED:
    252                         if (port->state == HUB_PORT_STATE_RESETTING) {
    253                                 set_port_status_change(port, HUB_STATUS_C_PORT_RESET);
    254                         }
    255                         break;
    256                 default:
    257                         break;
     237        case HUB_PORT_STATE_POWERED_OFF:
     238                clear_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION);
     239                clear_port_status_change(port, HUB_STATUS_C_PORT_ENABLE);
     240                clear_port_status_change(port, HUB_STATUS_C_PORT_RESET);
     241                break;
     242        case HUB_PORT_STATE_RESUMING:
     243                port->state = state;
     244                set_port_state_delayed(hub, port_index,
     245                    10, state, HUB_PORT_STATE_ENABLED);
     246                break;
     247        case HUB_PORT_STATE_RESETTING:
     248                port->state = state;
     249                set_port_state_delayed(hub, port_index,
     250                    10, state, HUB_PORT_STATE_ENABLED);
     251                break;
     252        case HUB_PORT_STATE_ENABLED:
     253                if (port->state == HUB_PORT_STATE_RESETTING) {
     254                        set_port_status_change(port, HUB_STATUS_C_PORT_RESET);
     255                }
     256                break;
     257        default:
     258                break;
    258259        }
    259260
     
    336337        }
    337338
    338         uint32_t status;
    339         status = MAKE_BYTE(
     339        uint32_t status = MAKE_BYTE(
    340340            /* Current connect status. */
    341341            port->connected_device == NULL ? 0 : 1,
     
    344344            /* Suspend. */
    345345            (port->state == HUB_PORT_STATE_SUSPENDED)
    346                 || (port->state == HUB_PORT_STATE_RESUMING) ? 1 : 0,
     346            || (port->state == HUB_PORT_STATE_RESUMING) ? 1 : 0,
    347347            /* Over-current. */
    348348            0,
     
    350350            port->state == HUB_PORT_STATE_RESETTING ? 1 : 0,
    351351            /* Reserved. */
    352             0, 0, 0)
    353 
    354             | (MAKE_BYTE(
     352            0, 0, 0);
     353
     354        status |= MAKE_BYTE(
    355355            /* Port power. */
    356356            port->state == HUB_PORT_STATE_POWERED_OFF ? 0 : 1,
     
    359359            /* Reserved. */
    360360            0, 0, 0, 0, 0, 0
    361             )) << 8;
     361            ) << 8;
    362362
    363363        status |= (port->status_change << 16);
     
    463463static errno_t set_port_state_delayed_fibril(void *arg)
    464464{
    465         struct delay_port_state_change *change
    466             = (struct delay_port_state_change *) arg;
     465        struct delay_port_state_change *change =
     466            (struct delay_port_state_change *) arg;
    467467
    468468        async_usleep(change->delay);
     
    500500    hub_port_state_t old_state, hub_port_state_t new_state)
    501501{
    502         struct delay_port_state_change *change
    503             = malloc(sizeof(struct delay_port_state_change));
     502        struct delay_port_state_change *change =
     503            malloc(sizeof(struct delay_port_state_change));
    504504
    505505        change->hub = hub;
  • uspace/drv/bus/usb/vhc/transfer.c

    r3692678 rae3a941  
    5050                return false;
    5151        }
    52         const usb_device_request_setup_packet_t *setup
    53                 = &transfer->batch.setup.packet;
     52        const usb_device_request_setup_packet_t *setup =
     53            &transfer->batch.setup.packet;
    5454        if (setup->request_type != 0) {
    5555                return false;
     
    139139        assert(!list_empty(&dev->transfer_queue));
    140140
    141         vhc_transfer_t *transfer = list_get_instance(
    142             list_first(&dev->transfer_queue), vhc_transfer_t, link);
     141        vhc_transfer_t *transfer =
     142            list_get_instance(list_first(&dev->transfer_queue),
     143            vhc_transfer_t, link);
    143144        list_remove(&transfer->link);
    144145
     
    258259                            dev->dev_local, &data_transfer_size);
    259260                } else {
    260                         usb_log_warning("Device has no remote phone nor local node.");
     261                        usb_log_warning("Device has no remote phone "
     262                            "nor local node.");
    261263                        rc = ESTALL;
    262264                }
     
    269271                        if (is_set_address_transfer(transfer)) {
    270272                                usb_device_request_setup_packet_t *setup =
    271                                     (void*) transfer->batch.setup.buffer;
     273                                    (void *) transfer->batch.setup.buffer;
    272274                                dev->address = setup->value;
    273275                                usb_log_debug2("Address changed to %d",
  • uspace/drv/bus/usb/vhc/vhcd.h

    r3692678 rae3a941  
    9393errno_t vhc_virtdev_plug(vhc_data_t *, async_sess_t *, uintptr_t *);
    9494errno_t vhc_virtdev_plug_local(vhc_data_t *, usbvirt_device_t *, uintptr_t *);
    95 errno_t vhc_virtdev_plug_hub(vhc_data_t *, usbvirt_device_t *, uintptr_t *, usb_address_t address);
     95errno_t vhc_virtdev_plug_hub(vhc_data_t *, usbvirt_device_t *, uintptr_t *,
     96    usb_address_t address);
    9697void vhc_virtdev_unplug(vhc_data_t *, uintptr_t);
    9798
  • uspace/drv/bus/usb/xhci/bus.h

    r3692678 rae3a941  
    4545/** Endpoint management structure */
    4646typedef struct xhci_bus {
    47         bus_t base;             /**< Inheritance. Keep this first. */
    48 
    49         xhci_hc_t *hc;                          /**< Pointer to managing HC (to issue commands) */
    50 
    51         xhci_device_t **devices_by_slot;        /**< Devices by Slot ID */
     47        bus_t base; /**< Inheritance. Keep this first. */
     48        xhci_hc_t *hc; /**< Pointer to managing HC (to issue commands) */
     49        xhci_device_t **devices_by_slot; /**< Devices by Slot ID */
    5250} xhci_bus_t;
    5351
  • uspace/drv/bus/usb/xhci/commands.c

    r3692678 rae3a941  
    150150
    151151        while (cmd_link != NULL) {
    152                 xhci_cmd_t *cmd = list_get_instance(cmd_link, xhci_cmd_t, _header.link);
     152                xhci_cmd_t *cmd = list_get_instance(cmd_link, xhci_cmd_t,
     153                    _header.link);
    153154
    154155                if (cmd->_header.trb_phys == phys)
     
    158159        }
    159160
    160         return cmd_link ? list_get_instance(cmd_link, xhci_cmd_t, _header.link)
    161                 : NULL;
     161        return cmd_link
     162            ? list_get_instance(cmd_link, xhci_cmd_t, _header.link)
     163            : NULL;
    162164}
    163165
     
    167169
    168170        cr->state = state;
    169         if (state == XHCI_CR_STATE_OPEN
    170             || state == XHCI_CR_STATE_CLOSED)
     171        if (state == XHCI_CR_STATE_OPEN || state == XHCI_CR_STATE_CLOSED)
    171172                fibril_condvar_broadcast(&cr->state_cv);
    172173}
     
    206207        }
    207208
    208         usb_log_debug("Sending command %s", xhci_trb_str_type(TRB_TYPE(cmd->_header.trb)));
     209        usb_log_debug("Sending command %s",
     210            xhci_trb_str_type(TRB_TYPE(cmd->_header.trb)));
    209211
    210212        list_append(&cmd->_header.link, &cr->cmd_list);
     
    337339                usb_log_error("Command resulted in error: %s.", trb_codes[code]);
    338340        else
    339                 usb_log_error("Command resulted in reserved or vendor specific error.");
     341                usb_log_error("Command resulted in reserved or "
     342                    "vendor specific error.");
    340343}
    341344
     
    657660        }
    658661
    659         usb_log_error("Timeout while waiting for command: aborting current command.");
     662        usb_log_error("Timeout while waiting for command: "
     663            "aborting current command.");
    660664
    661665        cr_set_state(cr, XHCI_CR_STATE_CHANGING);
     
    663667        abort_command_ring(hc);
    664668
    665         fibril_condvar_wait_timeout(&cr->stopped_cv, &cr->guard, XHCI_CR_ABORT_TIMEOUT);
     669        fibril_condvar_wait_timeout(&cr->stopped_cv, &cr->guard,
     670            XHCI_CR_ABORT_TIMEOUT);
    666671
    667672        if (XHCI_REG_RD(hc->op_regs, XHCI_OP_CRR)) {
  • uspace/drv/bus/usb/xhci/commands.h

    r3692678 rae3a941  
    7070
    7171typedef enum {
    72         XHCI_CR_STATE_CLOSED,           /**< Commands are rejected with ENAK. */
    73         XHCI_CR_STATE_OPEN,             /**< Commands are enqueued normally. */
    74         XHCI_CR_STATE_CHANGING,         /**< Commands wait until state changes. */
    75         XHCI_CR_STATE_FULL,             /**< Commands wait until something completes. */
     72        XHCI_CR_STATE_CLOSED,   /**< Commands are rejected with ENAK. */
     73        XHCI_CR_STATE_OPEN,     /**< Commands are enqueued normally. */
     74        XHCI_CR_STATE_CHANGING, /**< Commands wait until state changes. */
     75        XHCI_CR_STATE_FULL,     /**< Commands wait until something completes. */
    7676} xhci_cr_state_t;
    7777
  • uspace/drv/bus/usb/xhci/debug.h

    r3692678 rae3a941  
    6363extern void xhci_dump_slot_ctx(const struct xhci_slot_ctx *);
    6464extern void xhci_dump_endpoint_ctx(const struct xhci_endpoint_ctx *);
    65 extern void xhci_dump_input_ctx(const struct xhci_hc *, const struct xhci_input_ctx *);
     65extern void xhci_dump_input_ctx(const struct xhci_hc *,
     66    const struct xhci_input_ctx *);
    6667
    6768#endif
  • uspace/drv/bus/usb/xhci/device.h

    r3692678 rae3a941  
    6262
    6363#define XHCI_DEV_FMT  "(%s, slot %d)"
    64 #define XHCI_DEV_ARGS(dev)               ddf_fun_get_name((dev).base.fun), (dev).slot_id
     64#define XHCI_DEV_ARGS(dev)      ddf_fun_get_name((dev).base.fun), (dev).slot_id
    6565
    6666/* Bus callbacks */
     
    7272void xhci_setup_slot_context(xhci_device_t *, xhci_slot_ctx_t *);
    7373
    74 static inline xhci_device_t * xhci_device_get(device_t *dev)
     74static inline xhci_device_t *xhci_device_get(device_t *dev)
    7575{
    7676        assert(dev);
  • uspace/drv/bus/usb/xhci/endpoint.h

    r3692678 rae3a941  
    7676        xhci_trb_ring_t ring;
    7777
    78         /** Primary stream context data array (or NULL if endpoint doesn't use streams). */
     78        /**
     79         * Primary stream context data array
     80         * (or NULL if endpoint doesn't use streams).
     81         */
    7982        xhci_stream_data_t *primary_stream_data_array;
    8083
     
    8386        dma_buffer_t primary_stream_ctx_dma;
    8487
    85         /** Size of the allocated primary stream data array (and context array). */
     88        /** Size of the allocated primary stream data and context array. */
    8689        uint16_t primary_stream_data_size;
    8790
     
    8992        uint32_t max_streams;
    9093
    91         /** Maximum number of consecutive USB transactions (0-15) that should be executed per scheduling opportunity */
     94        /**
     95         * Maximum number of consecutive USB transactions (0-15) that
     96         * should be executed per scheduling opportunity
     97         */
    9298        uint8_t max_burst;
    9399
    94         /** Maximum number of bursts within an interval that this endpoint supports */
     100        /**
     101         * Maximum number of bursts within an interval that
     102         * this endpoint supports
     103         */
    95104        uint8_t mult;
    96105
    97         /** Scheduling interval for periodic endpoints, as a number of 125us units. (0 - 2^16) */
     106        /**
     107         * Scheduling interval for periodic endpoints,
     108         * as a number of 125us units. (0 - 2^16)
     109         */
    98110        uint32_t interval;
    99111
    100         /** This field is a valid pointer for (and only for) isochronous transfers. */
     112        /**
     113         * This field is a valid pointer for (and only for) isochronous
     114         * endpoints.
     115         */
    101116        xhci_isoch_t isoch [0];
    102117} xhci_endpoint_t;
     
    111126extern int xhci_endpoint_type(xhci_endpoint_t *ep);
    112127
    113 extern endpoint_t *xhci_endpoint_create(device_t *, const usb_endpoint_descriptors_t *);
     128extern endpoint_t *xhci_endpoint_create(device_t *,
     129    const usb_endpoint_descriptors_t *);
    114130extern errno_t xhci_endpoint_register(endpoint_t *);
    115131extern void xhci_endpoint_unregister(endpoint_t *);
     
    122138extern errno_t xhci_endpoint_clear_halt(xhci_endpoint_t *, unsigned);
    123139
    124 static inline xhci_endpoint_t * xhci_endpoint_get(endpoint_t *ep)
     140static inline xhci_endpoint_t *xhci_endpoint_get(endpoint_t *ep)
    125141{
    126142        assert(ep);
     
    128144}
    129145
    130 static inline xhci_device_t * xhci_ep_to_dev(xhci_endpoint_t *ep)
     146static inline xhci_device_t *xhci_ep_to_dev(xhci_endpoint_t *ep)
    131147{
    132148        assert(ep);
  • uspace/drv/bus/usb/xhci/hc.h

    r3692678 rae3a941  
    9595        bool ac64;
    9696        bool csz;
    97         uint64_t wrap_time;             /** The last time when mfindex wrap happened */
    98         uint64_t wrap_count;    /** Amount of mfindex wraps HC has done */
    99         unsigned ist;                   /**< IST in microframes */
     97        uint64_t wrap_time;     /**< The last time when mfindex wrap happened */
     98        uint64_t wrap_count;    /**< Amount of mfindex wraps HC has done */
     99        unsigned ist;           /**< IST in microframes */
    100100
    101101        /** Port speed mapping */
  • uspace/drv/bus/usb/xhci/hw_struct/context.h

    r3692678 rae3a941  
    179179#define XHCI_CTX_SIZE_SMALL 32
    180180#define XHCI_ONE_CTX_SIZE(hc) (XHCI_CTX_SIZE_SMALL << hc->csz)
    181 #define XHCI_GET_CTX_FIELD(type, ctx, hc, ci) (xhci_##type##_ctx_to_charptr(ctx) + (ci) * XHCI_ONE_CTX_SIZE(hc))
     181#define XHCI_GET_CTX_FIELD(type, ctx, hc, ci) \
     182    (xhci_##type##_ctx_to_charptr(ctx) + (ci) * XHCI_ONE_CTX_SIZE(hc))
    182183
    183184/**
     
    185186 */
    186187#define XHCI_DEVICE_CTX_SIZE(hc) ((1 + XHCI_EP_COUNT) * XHCI_ONE_CTX_SIZE(hc))
    187 #define XHCI_GET_EP_CTX(dev_ctx, hc, dci) ((xhci_ep_ctx_t *)   XHCI_GET_CTX_FIELD(device, (dev_ctx), (hc), (dci)))
    188 #define XHCI_GET_SLOT_CTX(dev_ctx, hc)    ((xhci_slot_ctx_t *) XHCI_GET_CTX_FIELD(device, (dev_ctx), (hc), 0))
     188#define XHCI_GET_EP_CTX(dev_ctx, hc, dci) \
     189    ((xhci_ep_ctx_t *)   XHCI_GET_CTX_FIELD(device, (dev_ctx), (hc), (dci)))
     190#define XHCI_GET_SLOT_CTX(dev_ctx, hc) \
     191    ((xhci_slot_ctx_t *) XHCI_GET_CTX_FIELD(device, (dev_ctx), (hc), 0))
    189192
    190193/**
     
    210213typedef struct xhci_stream_ctx {
    211214        uint64_t data [2];
    212 #define XHCI_STREAM_DCS(ctx)       XHCI_QWORD_EXTRACT((ctx).data[0],  0, 0)
    213 #define XHCI_STREAM_SCT(ctx)       XHCI_QWORD_EXTRACT((ctx).data[0],  3, 1)
    214 #define XHCI_STREAM_DEQ_PTR(ctx)   (XHCI_QWORD_EXTRACT((ctx).data[0], 63, 4) << 4)
    215 #define XHCI_STREAM_EDTLA(ctx)     XHCI_QWORD_EXTRACT((ctx).data[1], 24, 0)
     215#define XHCI_STREAM_DCS(ctx)     XHCI_QWORD_EXTRACT((ctx).data[0],  0, 0)
     216#define XHCI_STREAM_SCT(ctx)     XHCI_QWORD_EXTRACT((ctx).data[0],  3, 1)
     217#define XHCI_STREAM_DEQ_PTR(ctx) (XHCI_QWORD_EXTRACT((ctx).data[0], 63, 4) << 4)
     218#define XHCI_STREAM_EDTLA(ctx)   XHCI_QWORD_EXTRACT((ctx).data[1], 24, 0)
    216219
    217220#define XHCI_STREAM_SCT_SET(ctx, val) \
     
    232235        uint32_t data [8];
    233236#define XHCI_INPUT_CTRL_CTX_DROP(ctx, idx) \
    234         XHCI_DWORD_EXTRACT((ctx).data[0], (idx), (idx))
     237    XHCI_DWORD_EXTRACT((ctx).data[0], (idx), (idx))
    235238
    236239#define XHCI_INPUT_CTRL_CTX_DROP_SET(ctx, idx) (ctx).data[0] |= (1 << (idx))
     
    238241
    239242#define XHCI_INPUT_CTRL_CTX_ADD(ctx, idx) \
    240         XHCI_DWORD_EXTRACT((ctx).data[1], (idx), (idx))
     243    XHCI_DWORD_EXTRACT((ctx).data[1], (idx), (idx))
    241244
    242245#define XHCI_INPUT_CTRL_CTX_ADD_SET(ctx, idx) (ctx).data[1] |= (1 << (idx))
    243246#define XHCI_INPUT_CTRL_CTX_ADD_CLEAR(ctx, idx) (ctx).data[1] &= ~(1 << (idx))
    244247
    245 #define XHCI_INPUT_CTRL_CTX_CONFIG_VALUE(ctx)   XHCI_DWORD_EXTRACT((ctx).data[7],  7,  0)
    246 #define XHCI_INPUT_CTRL_CTX_IFACE_NUMBER(ctx)   XHCI_DWORD_EXTRACT((ctx).data[7], 15,  8)
    247 #define XHCI_INPUT_CTRL_CTX_ALTER_SETTING(ctx)  XHCI_DWORD_EXTRACT((ctx).data[7], 23, 16)
     248#define XHCI_INPUT_CTRL_CTX_CONFIG_VALUE(ctx) \
     249    XHCI_DWORD_EXTRACT((ctx).data[7],  7,  0)
     250#define XHCI_INPUT_CTRL_CTX_IFACE_NUMBER(ctx) \
     251    XHCI_DWORD_EXTRACT((ctx).data[7], 15,  8)
     252#define XHCI_INPUT_CTRL_CTX_ALTER_SETTING(ctx) \
     253    XHCI_DWORD_EXTRACT((ctx).data[7], 23, 16)
    248254} __attribute__((packed)) xhci_input_ctrl_ctx_t;
    249255
     
    252258 */
    253259#define XHCI_INPUT_CTX_SIZE(hc) (XHCI_ONE_CTX_SIZE(hc) + XHCI_DEVICE_CTX_SIZE(hc))
    254 #define XHCI_GET_CTRL_CTX(ictx, hc)  ((xhci_input_ctrl_ctx_t *) XHCI_GET_CTX_FIELD(input, (ictx), (hc), 0))
    255 #define XHCI_GET_DEVICE_CTX(dev_ctx, hc) ((xhci_device_ctx_t *) XHCI_GET_CTX_FIELD(input, (ictx), (hc), 1))
     260#define XHCI_GET_CTRL_CTX(ictx, hc) \
     261    ((xhci_input_ctrl_ctx_t *) XHCI_GET_CTX_FIELD(input, (ictx), (hc), 0))
     262#define XHCI_GET_DEVICE_CTX(dev_ctx, hc) \
     263    ((xhci_device_ctx_t *) XHCI_GET_CTX_FIELD(input, (ictx), (hc), 1))
    256264
    257265typedef struct xhci_input_ctx {
  • uspace/drv/bus/usb/xhci/hw_struct/trb.h

    r3692678 rae3a941  
    160160 * The Chain bit is valid only in specific TRB types.
    161161 */
    162 static inline bool xhci_trb_is_chained(xhci_trb_t *trb) {
     162static inline bool xhci_trb_is_chained(xhci_trb_t *trb)
     163{
    163164        const int type = TRB_TYPE(*trb);
    164165        const bool chain_bit = XHCI_DWORD_EXTRACT(trb->control, 4, 4);
  • uspace/drv/bus/usb/xhci/isoch.h

    r3692678 rae3a941  
    8484        fibril_timer_t *reset_timer;
    8585
    86         /** The maximum size of an isochronous transfer and therefore the size of buffers */
     86        /**
     87         * The maximum size of an isochronous transfer
     88         * and therefore the size of buffers
     89         */
    8790        size_t max_size;
    8891
     
    123126extern errno_t isoch_schedule_out(xhci_transfer_t *);
    124127extern errno_t isoch_schedule_in(xhci_transfer_t *);
    125 extern void isoch_handle_transfer_event(xhci_hc_t *, xhci_endpoint_t *, xhci_trb_t *);
     128extern void isoch_handle_transfer_event(xhci_hc_t *, xhci_endpoint_t *,
     129    xhci_trb_t *);
    126130
    127131#endif
  • uspace/drv/bus/usb/xhci/main.c

    r3692678 rae3a941  
    6868}
    6969
    70 static errno_t hcd_irq_code_gen(irq_code_t *code, hc_device_t *hcd, const hw_res_list_parsed_t *hw_res, int *irq)
     70static errno_t hcd_irq_code_gen(irq_code_t *code, hc_device_t *hcd,
     71    const hw_res_list_parsed_t *hw_res, int *irq)
    7172{
    7273        xhci_hc_t *hc = hcd_to_hc(hcd);
  • uspace/drv/bus/usb/xhci/streams.h

    r3692678 rae3a941  
    4848        xhci_trb_ring_t ring;
    4949
    50         /** Pointer to the array of secondary stream context data for primary data. */
     50        /**
     51         * Pointer to the array of secondary stream context data for primary
     52         * data.
     53         */
    5154        xhci_stream_data_t *secondary_data;
    5255
     
    6164} xhci_stream_data_t;
    6265
    63 extern xhci_stream_data_t *xhci_get_stream_ctx_data(xhci_endpoint_t *ep, uint32_t stream_id);
    64 extern void xhci_stream_free_ds(xhci_endpoint_t *xhci_ep);
     66extern xhci_stream_data_t *xhci_get_stream_ctx_data(xhci_endpoint_t *, uint32_t);
     67extern void xhci_stream_free_ds(xhci_endpoint_t *);
    6568
    66 extern errno_t xhci_endpoint_remove_streams(xhci_hc_t *hc, xhci_device_t *dev, xhci_endpoint_t *xhci_ep);
    67 extern errno_t xhci_endpoint_request_primary_streams(xhci_hc_t *hc, xhci_device_t *dev,
    68     xhci_endpoint_t *xhci_ep, unsigned count);
    69 extern errno_t xhci_endpoint_request_secondary_streams(xhci_hc_t *hc, xhci_device_t *dev,
    70     xhci_endpoint_t *xhci_ep, unsigned *sizes, unsigned count);
     69extern errno_t xhci_endpoint_remove_streams(xhci_hc_t *, xhci_device_t *,
     70    xhci_endpoint_t *);
     71extern errno_t xhci_endpoint_request_primary_streams(xhci_hc_t *,
     72    xhci_device_t *, xhci_endpoint_t *, unsigned);
     73extern errno_t xhci_endpoint_request_secondary_streams(xhci_hc_t *,
     74    xhci_device_t *, xhci_endpoint_t *, unsigned *, unsigned);
    7175
    7276#endif
  • uspace/drv/bus/usb/xhci/transfers.h

    r3692678 rae3a941  
    5959extern void xhci_transfer_destroy(usb_transfer_batch_t *);
    6060
    61 static inline xhci_transfer_t *xhci_transfer_from_batch(usb_transfer_batch_t *batch)
     61static inline xhci_transfer_t *xhci_transfer_from_batch(
     62    usb_transfer_batch_t *batch)
    6263{
    6364        assert(batch);
  • uspace/drv/bus/usb/xhci/trb_ring.h

    r3692678 rae3a941  
    5757 */
    5858typedef struct xhci_trb_ring {
    59         list_t segments;                /* List of assigned segments */
    60         int segment_count;              /* Number of segments assigned */
     59        list_t segments;                /**< List of assigned segments */
     60        int segment_count;              /**< Number of segments assigned */
    6161
    62         /*
    63          * As the link TRBs connect physical addresses, we need to keep track of
    64          * active segment in virtual memory. The enqueue ptr should always belong
    65          * to the enqueue segment.
     62        /**
     63         * As the link TRBs connect physical addresses, we need to keep track
     64         * of active segment in virtual memory. The enqueue ptr should always
     65         * belong to the enqueue segment.
    6666         */
    6767        trb_segment_t *enqueue_segment;
    6868        xhci_trb_t *enqueue_trb;
    6969
    70         uintptr_t dequeue;              /* Last reported position of the dequeue pointer */
    71         bool pcs;                       /* Producer Cycle State: section 4.9.2 */
     70        uintptr_t dequeue; /**< Last reported position of the dequeue pointer */
     71        bool pcs;          /**< Producer Cycle State: section 4.9.2 */
    7272
    7373        fibril_mutex_t guard;
     
    7676extern errno_t xhci_trb_ring_init(xhci_trb_ring_t *, size_t);
    7777extern void xhci_trb_ring_fini(xhci_trb_ring_t *);
    78 extern errno_t xhci_trb_ring_enqueue(xhci_trb_ring_t *, xhci_trb_t *, uintptr_t *);
    79 extern errno_t xhci_trb_ring_enqueue_multiple(xhci_trb_ring_t *, xhci_trb_t *, size_t, uintptr_t *);
     78extern errno_t xhci_trb_ring_enqueue(xhci_trb_ring_t *, xhci_trb_t *,
     79    uintptr_t *);
     80extern errno_t xhci_trb_ring_enqueue_multiple(xhci_trb_ring_t *, xhci_trb_t *,
     81    size_t, uintptr_t *);
    8082extern size_t xhci_trb_ring_size(xhci_trb_ring_t *);
    8183
    82 extern void xhci_trb_ring_reset_dequeue_state(xhci_trb_ring_t *ring, uintptr_t *addr);
     84extern void xhci_trb_ring_reset_dequeue_state(xhci_trb_ring_t *, uintptr_t *);
    8385
    8486/**
     
    8688 * pointer inside the ring. Otherwise, the ring will soon show up as full.
    8789 */
    88 static inline void xhci_trb_ring_update_dequeue(xhci_trb_ring_t *ring, uintptr_t phys)
     90static inline void xhci_trb_ring_update_dequeue(xhci_trb_ring_t *ring,
     91    uintptr_t phys)
    8992{
    9093        ring->dequeue = phys;
     
    9598 */
    9699typedef struct xhci_event_ring {
    97         list_t segments;                /* List of assigned segments */
    98         int segment_count;              /* Number of segments assigned */
     100        list_t segments;                /**< List of assigned segments */
     101        int segment_count;              /**< Number of segments assigned */
    99102
    100         trb_segment_t *dequeue_segment; /* Current segment of the dequeue ptr */
    101         xhci_trb_t *dequeue_trb;        /* Next TRB to be processed */
    102         uintptr_t dequeue_ptr;          /* Physical address of the ERDP to be reported to the HC */
     103        trb_segment_t *dequeue_segment; /**< Current segment */
     104        xhci_trb_t *dequeue_trb;        /**< Next TRB to be processed */
     105        uintptr_t dequeue_ptr;  /**< Physical ERDP to be reported to the HC */
    103106
    104         dma_buffer_t erst;              /* ERST given to the HC */
     107        dma_buffer_t erst;      /**< ERST given to the HC */
    105108
    106         bool ccs;                       /* Consumer Cycle State: section 4.9.2 */
     109        bool ccs;               /**< Consumer Cycle State: section 4.9.2 */
    107110
    108111        fibril_mutex_t guard;
  • uspace/lib/drv/generic/remote_usb.c

    r3692678 rae3a941  
    5252usb_dev_session_t *usb_dev_connect_to_self(ddf_dev_t *dev)
    5353{
    54         return devman_parent_device_connect(ddf_dev_get_handle(dev), IPC_FLAG_BLOCKING);
     54        return devman_parent_device_connect(ddf_dev_get_handle(dev),
     55            IPC_FLAG_BLOCKING);
    5556}
    5657
     
    9091}
    9192
    92 static void remote_usb_get_my_description(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     93static void remote_usb_get_my_description(ddf_fun_t *, void *,
     94    ipc_callid_t, ipc_call_t *);
    9395
    9496/** Remote USB interface operations. */
  • uspace/lib/drv/generic/remote_usbdiag.c

    r3692678 rae3a941  
    5858}
    5959
    60 errno_t usbdiag_test_in(async_exch_t *exch, const usbdiag_test_params_t *params, usbdiag_test_results_t *results)
     60errno_t usbdiag_test_in(async_exch_t *exch,
     61    const usbdiag_test_params_t *params, usbdiag_test_results_t *results)
    6162{
    6263        if (!exch)
     
    6465
    6566        ipc_call_t answer;
    66         aid_t req = async_send_1(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), IPC_M_USBDIAG_TEST_IN, &answer);
    67 
    68         errno_t rc = async_data_write_start(exch, params, sizeof(usbdiag_test_params_t));
    69         if (rc != EOK) {
    70                 async_exchange_end(exch);
    71                 async_forget(req);
    72                 return rc;
    73         }
    74 
    75         rc = async_data_read_start(exch, results, sizeof(usbdiag_test_results_t));
     67        aid_t req = async_send_1(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE),
     68            IPC_M_USBDIAG_TEST_IN, &answer);
     69
     70        errno_t rc = async_data_write_start(exch, params,
     71            sizeof(usbdiag_test_params_t));
     72        if (rc != EOK) {
     73                async_exchange_end(exch);
     74                async_forget(req);
     75                return rc;
     76        }
     77
     78        rc = async_data_read_start(exch, results,
     79            sizeof(usbdiag_test_results_t));
    7680        if (rc != EOK) {
    7781                async_exchange_end(exch);
     
    8892}
    8993
    90 errno_t usbdiag_test_out(async_exch_t *exch, const usbdiag_test_params_t *params, usbdiag_test_results_t *results)
     94errno_t usbdiag_test_out(async_exch_t *exch,
     95    const usbdiag_test_params_t *params, usbdiag_test_results_t *results)
    9196{
    9297        if (!exch)
     
    9499
    95100        ipc_call_t answer;
    96         aid_t req = async_send_1(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE), IPC_M_USBDIAG_TEST_OUT, &answer);
    97 
    98         errno_t rc = async_data_write_start(exch, params, sizeof(usbdiag_test_params_t));
    99         if (rc != EOK) {
    100                 async_exchange_end(exch);
    101                 async_forget(req);
    102                 return rc;
    103         }
    104 
    105         rc = async_data_read_start(exch, results, sizeof(usbdiag_test_results_t));
     101        aid_t req = async_send_1(exch, DEV_IFACE_ID(USBDIAG_DEV_IFACE),
     102            IPC_M_USBDIAG_TEST_OUT, &answer);
     103
     104        errno_t rc = async_data_write_start(exch, params,
     105            sizeof(usbdiag_test_params_t));
     106        if (rc != EOK) {
     107                async_exchange_end(exch);
     108                async_forget(req);
     109                return rc;
     110        }
     111
     112        rc = async_data_read_start(exch, results,
     113            sizeof(usbdiag_test_results_t));
    106114        if (rc != EOK) {
    107115                async_exchange_end(exch);
     
    118126}
    119127
    120 static void remote_usbdiag_test_in(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    121 static void remote_usbdiag_test_out(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     128static void remote_usbdiag_test_in(ddf_fun_t *, void *,
     129    ipc_callid_t, ipc_call_t *);
     130static void remote_usbdiag_test_out(ddf_fun_t *, void *,
     131    ipc_callid_t, ipc_call_t *);
    122132
    123133/** Remote USB diagnostic interface operations. */
     
    133143};
    134144
    135 void remote_usbdiag_test_in(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
     145void remote_usbdiag_test_in(ddf_fun_t *fun, void *iface,
     146    ipc_callid_t callid, ipc_call_t *call)
    136147{
    137148        const usbdiag_iface_t *diag_iface = (usbdiag_iface_t *) iface;
     
    158169
    159170        usbdiag_test_results_t results;
    160         const errno_t ret = !diag_iface->test_in ? ENOTSUP : diag_iface->test_in(fun, &params, &results);
     171        const errno_t ret = !diag_iface->test_in ? ENOTSUP
     172            : diag_iface->test_in(fun, &params, &results);
    161173
    162174        if (ret != EOK) {
     
    185197}
    186198
    187 void remote_usbdiag_test_out(ddf_fun_t *fun, void *iface, ipc_callid_t callid, ipc_call_t *call)
     199void remote_usbdiag_test_out(ddf_fun_t *fun, void *iface,
     200    ipc_callid_t callid, ipc_call_t *call)
    188201{
    189202        const usbdiag_iface_t *diag_iface = (usbdiag_iface_t *) iface;
     
    210223
    211224        usbdiag_test_results_t results;
    212         const errno_t ret = !diag_iface->test_out ? ENOTSUP : diag_iface->test_out(fun, &params, &results);
     225        const errno_t ret = !diag_iface->test_out ? ENOTSUP
     226            : diag_iface->test_out(fun, &params, &results);
    213227
    214228        if (ret != EOK) {
  • uspace/lib/drv/include/usb_iface.h

    r3692678 rae3a941  
    4646
    4747typedef struct {
    48         usb_address_t address;          /** Current USB address */
    49         uint8_t depth;                  /** Depth in the hub hiearchy */
    50         usb_speed_t speed;              /** Speed of the device */
    51         devman_handle_t handle;         /** Handle to DDF function of the HC driver */
    52         int iface;                      /** Interface set by multi interface driver, -1 if none */
     48        usb_address_t address;  /**< Current USB address */
     49        uint8_t depth;          /**< Depth in the hub hiearchy */
     50        usb_speed_t speed;      /**< Speed of the device */
     51        devman_handle_t handle; /**< Handle to DDF function of the HC driver */
     52        /** Interface set by multi interface driver,  -1 if none */
     53        int iface;
    5354} usb_device_desc_t;
    5455
  • uspace/lib/drv/include/usbdiag_iface.h

    r3692678 rae3a941  
    6363
    6464async_sess_t *usbdiag_connect(devman_handle_t);
    65 void usbdiag_disconnect(async_sess_t*);
     65void usbdiag_disconnect(async_sess_t *);
    6666
    67 errno_t usbdiag_test_in(async_exch_t*, const usbdiag_test_params_t *, usbdiag_test_results_t *);
    68 errno_t usbdiag_test_out(async_exch_t*, const usbdiag_test_params_t *, usbdiag_test_results_t *);
     67errno_t usbdiag_test_in(async_exch_t *,
     68    const usbdiag_test_params_t *, usbdiag_test_results_t *);
     69errno_t usbdiag_test_out(async_exch_t*,
     70    const usbdiag_test_params_t *, usbdiag_test_results_t *);
    6971
    7072/** USB diagnostic device communication interface. */
    7173typedef struct {
    72         errno_t (*test_in)(ddf_fun_t*, const usbdiag_test_params_t *, usbdiag_test_results_t *);
    73         errno_t (*test_out)(ddf_fun_t*, const usbdiag_test_params_t *, usbdiag_test_results_t *);
     74        errno_t (*test_in)(ddf_fun_t *,
     75            const usbdiag_test_params_t *, usbdiag_test_results_t *);
     76        errno_t (*test_out)(ddf_fun_t*,
     77            const usbdiag_test_params_t *, usbdiag_test_results_t *);
    7478} usbdiag_iface_t;
    7579
  • uspace/lib/usb/include/usb/classes/hub.h

    r3692678 rae3a941  
    178178         */
    179179        uint8_t max_current;
    180 } __attribute__ ((packed)) usb_hub_descriptor_header_t;
     180} __attribute__((packed)) usb_hub_descriptor_header_t;
    181181
    182182/** One bit for the device and one bit for every port */
     
    187187 */
    188188typedef enum {
    189     /** This request resets a value reported in the hub status. */
    190     USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE = 0x20,
    191     /** This request resets a value reported in the port status. */
    192     USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE = 0x23,
    193     /**
    194     * This is an optional per-port diagnostic request that returns the bus
    195     * state value, as sampled at the last EOF2 point.
    196     */
    197     USB_HUB_REQ_TYPE_GET_STATE = 0xA3,
    198     /** This request returns the hub descriptor. */
    199     USB_HUB_REQ_TYPE_GET_DESCRIPTOR = 0xA0,
    200     /**
    201     * This request returns the current hub status and the states that have
    202     * changed since the previous acknowledgment.
    203     */
    204     USB_HUB_REQ_TYPE_GET_HUB_STATUS = 0xA0,
    205     /**
    206     * This request returns the current port status and the current value of the
    207     * port status change bits.
    208     */
    209     USB_HUB_REQ_TYPE_GET_PORT_STATUS = 0xA3,
    210     /** This request overwrites the hub descriptor. */
    211     USB_HUB_REQ_TYPE_SET_DESCRIPTOR = 0x20,
    212     /** This request sets a value reported in the hub status. */
    213     USB_HUB_REQ_TYPE_SET_HUB_FEATURE = 0x20,
    214     /**
    215     * This request sets the value that the hub uses to determine the index
    216     * into the Route String Index for the hub.
    217     */
    218     USB_HUB_REQ_TYPE_SET_HUB_DEPTH = 0x20,
    219     /** This request sets a value reported in the port status. */
    220     USB_HUB_REQ_TYPE_SET_PORT_FEATURE = 0x23,
     189        /** This request resets a value reported in the hub status. */
     190        USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE = 0x20,
     191        /** This request resets a value reported in the port status. */
     192        USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE = 0x23,
     193        /**
     194        * This is an optional per-port diagnostic request that returns the bus
     195        * state value, as sampled at the last EOF2 point.
     196        */
     197        USB_HUB_REQ_TYPE_GET_STATE = 0xA3,
     198        /** This request returns the hub descriptor. */
     199        USB_HUB_REQ_TYPE_GET_DESCRIPTOR = 0xA0,
     200        /**
     201        * This request returns the current hub status and the states that have
     202        * changed since the previous acknowledgment.
     203        */
     204        USB_HUB_REQ_TYPE_GET_HUB_STATUS = 0xA0,
     205        /**
     206        * This request returns the current port status and the current value of the
     207        * port status change bits.
     208        */
     209        USB_HUB_REQ_TYPE_GET_PORT_STATUS = 0xA3,
     210        /** This request overwrites the hub descriptor. */
     211        USB_HUB_REQ_TYPE_SET_DESCRIPTOR = 0x20,
     212        /** This request sets a value reported in the hub status. */
     213        USB_HUB_REQ_TYPE_SET_HUB_FEATURE = 0x20,
     214        /**
     215        * This request sets the value that the hub uses to determine the index
     216        * into the Route String Index for the hub.
     217        */
     218        USB_HUB_REQ_TYPE_SET_HUB_DEPTH = 0x20,
     219        /** This request sets a value reported in the port status. */
     220        USB_HUB_REQ_TYPE_SET_PORT_FEATURE = 0x23,
    221221} usb_hub_bm_request_type_t;
    222222
    223 /** @brief hub class request codes*/
    224 /// \TODO these are duplicit to standart descriptors
     223/**
     224 * @brief hub class request codes
     225 */
    225226typedef enum {
    226     /**  */
    227     USB_HUB_REQUEST_GET_STATUS = 0,
    228     /** */
    229     USB_HUB_REQUEST_CLEAR_FEATURE = 1,
    230     /** USB 1.0 only */
    231     USB_HUB_REQUEST_GET_STATE = 2,
    232     /** */
    233     USB_HUB_REQUEST_SET_FEATURE = 3,
    234     /** */
    235     USB_HUB_REQUEST_GET_DESCRIPTOR = 6,
    236     /** */
    237     USB_HUB_REQUEST_SET_DESCRIPTOR = 7,
    238     /** */
    239     USB_HUB_REQUEST_CLEAR_TT_BUFFER = 8,
    240     /** */
    241     USB_HUB_REQUEST_RESET_TT = 9,
    242     /** */
    243     USB_HUB_GET_TT_STATE = 10,
    244     /** */
    245     USB_HUB_STOP_TT = 11,
    246     /** USB 3+ only */
    247     USB_HUB_REQUEST_SET_HUB_DEPTH = 12,
     227        USB_HUB_REQUEST_GET_STATUS = 0,
     228        USB_HUB_REQUEST_CLEAR_FEATURE = 1,
     229        /** USB 1.0 only */
     230        USB_HUB_REQUEST_GET_STATE = 2,
     231        USB_HUB_REQUEST_SET_FEATURE = 3,
     232        USB_HUB_REQUEST_GET_DESCRIPTOR = 6,
     233        USB_HUB_REQUEST_SET_DESCRIPTOR = 7,
     234        USB_HUB_REQUEST_CLEAR_TT_BUFFER = 8,
     235        USB_HUB_REQUEST_RESET_TT = 9,
     236        USB_HUB_GET_TT_STATE = 10,
     237        USB_HUB_STOP_TT = 11,
     238        /** USB 3+ only */
     239        USB_HUB_REQUEST_SET_HUB_DEPTH = 12,
    248240} usb_hub_request_t;
    249241
  • uspace/lib/usb/include/usb/descriptor.h

    r3692678 rae3a941  
    101101        /** Number of possible configurations. */
    102102        uint8_t configuration_count;
    103 } __attribute__ ((packed)) usb_standard_device_descriptor_t;
     103} __attribute__((packed)) usb_standard_device_descriptor_t;
    104104
    105105/** USB device qualifier decriptor is basically a cut down version of the device
     
    129129        uint8_t configuration_count;
    130130        uint8_t reserved;
    131 } __attribute__ ((packed)) usb_standard_device_qualifier_descriptor_t;
     131} __attribute__((packed)) usb_standard_device_qualifier_descriptor_t;
    132132
    133133/** Standard USB configuration descriptor.
     
    156156         */
    157157        uint8_t max_power;
    158 } __attribute__ ((packed)) usb_standard_configuration_descriptor_t;
     158} __attribute__((packed)) usb_standard_configuration_descriptor_t;
    159159
    160160/** USB Other Speed Configuration descriptor shows values that would change
     
    191191        /** String descriptor describing this interface. */
    192192        uint8_t str_interface;
    193 } __attribute__ ((packed)) usb_standard_interface_descriptor_t;
     193} __attribute__((packed)) usb_standard_interface_descriptor_t;
    194194
    195195/** Standard USB endpoint descriptor.
     
    223223         */
    224224        uint8_t poll_interval;
    225 } __attribute__ ((packed)) usb_standard_endpoint_descriptor_t;
     225} __attribute__((packed)) usb_standard_endpoint_descriptor_t;
    226226
    227227/** Superspeed USB endpoint companion descriptor.
     
    254254         */
    255255        uint16_t bytes_per_interval;
    256 } __attribute__ ((packed)) usb_superspeed_endpoint_companion_descriptor_t;
     256} __attribute__((packed)) usb_superspeed_endpoint_companion_descriptor_t;
    257257
    258258/** Part of standard USB HID descriptor specifying one class descriptor.
     
    265265        /** Length of class-specific descriptor in bytes. */
    266266        uint16_t length;
    267 } __attribute__ ((packed)) usb_standard_hid_class_descriptor_info_t;
     267} __attribute__((packed)) usb_standard_hid_class_descriptor_info_t;
    268268
    269269/** Standard USB HID descriptor.
     
    296296        /** First mandatory class descriptor (Report) info. */
    297297        usb_standard_hid_class_descriptor_info_t report_desc_info;
    298 } __attribute__ ((packed)) usb_standard_hid_descriptor_t;
     298} __attribute__((packed)) usb_standard_hid_descriptor_t;
    299299
    300300#endif
  • uspace/lib/usb/include/usb/port.h

    r3692678 rae3a941  
    9090
    9191/* And these are to be called from the connected handler. */
    92 int usb_port_condvar_wait_timeout(usb_port_t *port, fibril_condvar_t *, suseconds_t);
     92int usb_port_condvar_wait_timeout(usb_port_t *port,
     93    fibril_condvar_t *, suseconds_t);
    9394
    9495/**
  • uspace/lib/usb/include/usb/usb.h

    r3692678 rae3a941  
    5454#define uint32_usb2host(n) uint32_t_le2host((n))
    5555
    56 const char * usb_str_transfer_type(usb_transfer_type_t t);
    57 const char * usb_str_transfer_type_short(usb_transfer_type_t t);
     56const char *usb_str_transfer_type(usb_transfer_type_t);
     57const char *usb_str_transfer_type_short(usb_transfer_type_t);
    5858
    5959const char *usb_str_direction(usb_direction_t);
     
    149149static inline bool usb_target_same(usb_target_t a, usb_target_t b)
    150150{
    151         return (a.address == b.address)
    152             && (a.endpoint == b.endpoint);
     151        return (a.address == b.address) && (a.endpoint == b.endpoint);
    153152}
    154153
     
    167166        USB_PID_SETUP = _MAKE_PID(3, 1),
    168167
    169         USB_PID_DATA0 = _MAKE_PID(0 ,3),
    170         USB_PID_DATA1 = _MAKE_PID(2 ,3),
     168        USB_PID_DATA0 = _MAKE_PID(0, 3),
     169        USB_PID_DATA1 = _MAKE_PID(2, 3),
    171170
    172         USB_PID_ACK = _MAKE_PID(0 ,2),
    173         USB_PID_NAK = _MAKE_PID(2 ,2),
    174         USB_PID_STALL = _MAKE_PID(3 ,2),
     171        USB_PID_ACK = _MAKE_PID(0, 2),
     172        USB_PID_NAK = _MAKE_PID(2, 2),
     173        USB_PID_STALL = _MAKE_PID(3, 2),
    175174
    176         USB_PID_PRE = _MAKE_PID(3 ,0),
     175        USB_PID_PRE = _MAKE_PID(3, 0),
    177176        /* USB_PID_ = _MAKE_PID( ,), */
    178177#undef _MAKE_PID
  • uspace/lib/usbdev/include/usb/dev/device.h

    r3692678 rae3a941  
    5959
    6060/* DDF parts */
    61 errno_t usb_device_create_ddf(ddf_dev_t *, const usb_endpoint_description_t **, const char **);
     61errno_t usb_device_create_ddf(ddf_dev_t *,
     62    const usb_endpoint_description_t **, const char **);
    6263void usb_device_destroy_ddf(ddf_dev_t *);
    6364
     
    6869}
    6970
    70 usb_device_t * usb_device_create(devman_handle_t);
     71usb_device_t *usb_device_create(devman_handle_t);
    7172void usb_device_destroy(usb_device_t *);
    7273
    73 const char * usb_device_get_name(usb_device_t *);
     74const char *usb_device_get_name(usb_device_t *);
    7475ddf_fun_t *usb_device_ddf_fun_create(usb_device_t *, fun_type_t, const char *);
    7576
    76 async_exch_t * usb_device_bus_exchange_begin(usb_device_t *);
     77async_exch_t *usb_device_bus_exchange_begin(usb_device_t *);
    7778void usb_device_bus_exchange_end(async_exch_t *);
    7879
     
    9596devman_handle_t usb_device_get_devman_handle(const usb_device_t *);
    9697
    97 const usb_device_descriptors_t * usb_device_descriptors(usb_device_t *);
     98const usb_device_descriptors_t *usb_device_descriptors(usb_device_t *);
    9899
    99 const usb_alternate_interfaces_t * usb_device_get_alternative_ifaces(
     100const usb_alternate_interfaces_t *usb_device_get_alternative_ifaces(
    100101    usb_device_t *);
    101102
    102 void * usb_device_data_alloc(usb_device_t *, size_t);
    103 void * usb_device_data_get(usb_device_t *);
     103void *usb_device_data_alloc(usb_device_t *, size_t);
     104void *usb_device_data_get(usb_device_t *);
    104105
    105106#endif
  • uspace/lib/usbdev/include/usb/dev/pipes.h

    r3692678 rae3a941  
    9292        const usb_standard_endpoint_descriptor_t *descriptor;
    9393        /** Relevant superspeed companion descriptor. */
    94         const usb_superspeed_endpoint_companion_descriptor_t *companion_descriptor;
     94        const usb_superspeed_endpoint_companion_descriptor_t
     95            *companion_descriptor;
    9596        /** Interface descriptor the endpoint belongs to. */
    9697        const usb_standard_interface_descriptor_t *interface;
     
    105106    size_t, const uint8_t *, size_t, usb_dev_session_t *);
    106107
    107 errno_t usb_pipe_register(usb_pipe_t *, const usb_standard_endpoint_descriptor_t *, const usb_superspeed_endpoint_companion_descriptor_t *);
     108errno_t usb_pipe_register(usb_pipe_t *,
     109    const usb_standard_endpoint_descriptor_t *,
     110    const usb_superspeed_endpoint_companion_descriptor_t *);
    108111errno_t usb_pipe_unregister(usb_pipe_t *);
    109112
  • uspace/lib/usbdev/include/usb/dev/poll.h

    r3692678 rae3a941  
    6060        size_t request_size;
    6161
    62         /** Data buffer of at least `request_size`. User is responsible for its allocation. */
     62        /**
     63         * Data buffer of at least `request_size`. User is responsible for its
     64         * allocation.
     65         */
    6366        uint8_t *buffer;
    6467
     
    7578
    7679
    77         /** Optional parameters - user can customize them, but they are defaulted to
    78          *  some reasonable values.
     80        /**
     81         * Optional parameters - user can customize them, but they are
     82         * defaulted to  some reasonable values.
    7983         */
    8084
     
    8690        int debug;
    8791
    88         /** Maximum number of consecutive errors before polling termination (default 3). */
     92        /**
     93         * Maximum number of consecutive errors before polling termination
     94         * (default 3).
     95         */
    8996        size_t max_failures;
    9097
     
    121128
    122129
    123         /** Internal parameters - user is not expected to set them. Messing with them
    124          *  can result in unexpected behavior if you do not know what you are doing.
     130        /**
     131         * Internal parameters - user is not expected to set them. Messing with
     132         * them can result in unexpected behavior if you do not know what you
     133         * are doing.
    125134         */
    126135
  • uspace/lib/usbdev/src/dp.c

    r3692678 rae3a941  
    127127 * @retval -1 Invalid input.
    128128 */
    129 static int get_descriptor_type(const usb_dp_parser_data_t *data, const uint8_t *start)
     129static int get_descriptor_type(const usb_dp_parser_data_t *data,
     130    const uint8_t *start)
    130131{
    131132        if (start == NULL) {
     
    258259        int parent_type = get_descriptor_type(data, parent);
    259260        int possible_sibling_type = get_descriptor_type(data, possible_sibling);
    260         if (is_nested_descriptor_type(parser, possible_sibling_type, parent_type)) {
     261        if (is_nested_descriptor_type(parser,
     262                    possible_sibling_type, parent_type)) {
    261263                return possible_sibling;
    262264        } else {
  • uspace/lib/usbdev/src/pipes.c

    r3692678 rae3a941  
    338338 * @return Error code.
    339339 */
    340 errno_t usb_pipe_write_dma(usb_pipe_t *pipe, void *base, void* ptr, size_t size)
     340errno_t usb_pipe_write_dma(usb_pipe_t *pipe, void *base, void *ptr, size_t size)
    341341{
    342342        assert(pipe);
     
    377377/** Initialize USB default control pipe.
    378378 *
    379  * This one is special because it must not be registered, it is registered automatically.
     379 * This one is special because it must not be registered, it is registered
     380 * automatically.
    380381 *
    381382 * @param pipe Endpoint pipe to be initialized.
     
    383384 * @return Error code.
    384385 */
    385 errno_t usb_pipe_initialize_default_control(usb_pipe_t *pipe, usb_dev_session_t *bus_session)
     386errno_t usb_pipe_initialize_default_control(usb_pipe_t *pipe,
     387    usb_dev_session_t *bus_session)
    386388{
    387389        const errno_t ret = usb_pipe_initialize(pipe, bus_session);
     
    402404 * @return Error code.
    403405 */
    404 errno_t usb_pipe_register(usb_pipe_t *pipe, const usb_standard_endpoint_descriptor_t *ep_desc, const usb_superspeed_endpoint_companion_descriptor_t *comp_desc)
     406errno_t usb_pipe_register(usb_pipe_t *pipe,
     407    const usb_standard_endpoint_descriptor_t *ep_desc,
     408    const usb_superspeed_endpoint_companion_descriptor_t *comp_desc)
    405409{
    406410        assert(pipe);
     
    429433#undef COPY
    430434
    431         const errno_t ret = usbhc_register_endpoint(exch, &pipe->desc, &descriptors);
     435        const errno_t ret = usbhc_register_endpoint(exch,
     436            &pipe->desc, &descriptors);
    432437        async_exchange_end(exch);
    433438        return ret;
  • uspace/lib/usbhid/src/hidparser.c

    r3692678 rae3a941  
    5252int usb_hid_translate_data(usb_hid_report_field_t *item, const uint8_t *data);
    5353
    54 uint32_t usb_hid_translate_data_reverse(usb_hid_report_field_t *item, 
    55         int32_t value);
     54uint32_t usb_hid_translate_data_reverse(usb_hid_report_field_t *item,
     55    int32_t value);
    5656
    5757
     
    7676 *
    7777 * @param parser Opaque report parser structure
    78  * @param report_id 
     78 * @param report_id
    7979 * @param type
    8080 * @return Number of items in specified report
    8181 */
    82 size_t usb_hid_report_size(usb_hid_report_t *report, uint8_t report_id, 
     82size_t usb_hid_report_size(usb_hid_report_t *report, uint8_t report_id,
    8383    usb_hid_report_type_t type)
    8484{
     
    100100 *
    101101 * @param parser Opaque report parser structure
    102  * @param report_id 
     102 * @param report_id
    103103 * @param type
    104104 * @return Number of items in specified report
    105105 */
    106 size_t usb_hid_report_byte_size(usb_hid_report_t *report, uint8_t report_id, 
     106size_t usb_hid_report_byte_size(usb_hid_report_t *report, uint8_t report_id,
    107107    usb_hid_report_type_t type)
    108108{
     
    117117                return 0;
    118118        } else {
    119                 return ((report_des->bit_length + 7) / 8) ;
     119                return ((report_des->bit_length + 7) / 8);
    120120        }
    121121}
     
    129129 * @param data Data for the report.
    130130 * @return Error code.
    131  */ 
    132 errno_t usb_hid_parse_report(const usb_hid_report_t *report, const uint8_t *data, 
     131 */
     132errno_t usb_hid_parse_report(const usb_hid_report_t *report, const uint8_t *data,
    133133    size_t size, uint8_t *report_id)
    134134{
    135135        usb_hid_report_description_t *report_des;
    136136        usb_hid_report_type_t type = USB_HID_REPORT_TYPE_INPUT;
    137        
     137
    138138        if (report == NULL) {
    139139                return EINVAL;
     
    146146        }
    147147
    148         report_des = usb_hid_report_find_description(report, *report_id, 
     148        report_des = usb_hid_report_find_description(report, *report_id,
    149149            type);
    150150
     
    158158
    159159                if (USB_HID_ITEM_FLAG_CONSTANT(item->item_flags) == 0) {
    160                        
     160
    161161                        if (USB_HID_ITEM_FLAG_VARIABLE(item->item_flags) == 0) {
    162162                                /* array */
    163                                 item->value = 
    164                                         usb_hid_translate_data(item, data);
    165                                
     163                                item->value =
     164                                    usb_hid_translate_data(item, data);
     165
    166166                                item->usage = USB_HID_EXTENDED_USAGE(
    167167                                    item->usages[item->value -
    168168                                    item->physical_minimum]);
    169169
    170                                 item->usage_page = 
     170                                item->usage_page =
    171171                                    USB_HID_EXTENDED_USAGE_PAGE(
    172172                                    item->usages[item->value -
     
    174174
    175175                                usb_hid_report_set_last_item(
    176                                     item->collection_path, 
    177                                     USB_HID_TAG_CLASS_GLOBAL, 
     176                                    item->collection_path,
     177                                    USB_HID_TAG_CLASS_GLOBAL,
    178178                                    item->usage_page);
    179179
    180180                                usb_hid_report_set_last_item(
    181                                     item->collection_path, 
     181                                    item->collection_path,
    182182                                    USB_HID_TAG_CLASS_LOCAL, item->usage);
    183183                        } else {
    184184                                /* variable item */
    185                                 item->value = usb_hid_translate_data(item, 
     185                                item->value = usb_hid_translate_data(item,
    186186                                    data);
    187187                        }
    188188                }
    189189        }
    190        
     190
    191191        return EOK;
    192192}
     
    214214        int resolution;
    215215        if (item->physical_maximum == item->physical_minimum) {
    216             resolution = 1;
    217         } else {
    218             resolution = (item->logical_maximum - item->logical_minimum) /
    219                 ((item->physical_maximum - item->physical_minimum) *
    220                 (usb_pow(10, (item->unit_exponent))));
     216                resolution = 1;
     217        } else {
     218                resolution = (item->logical_maximum - item->logical_minimum) /
     219                    ((item->physical_maximum - item->physical_minimum) *
     220                    (usb_pow(10, (item->unit_exponent))));
    221221        }
    222222
     
    255255        }
    256256
    257         return (int) (((value - item->logical_minimum) / resolution) + 
     257        return (int) (((value - item->logical_minimum) / resolution) +
    258258            item->physical_minimum);
    259259}
     
    262262/* OUTPUT API */
    263263
    264 /** 
     264/**
    265265 * Allocates output report buffer for output report
    266266 *
     
    270270 * @return Returns allocated output buffer for specified output
    271271 */
    272 uint8_t *usb_hid_report_output(usb_hid_report_t *report, size_t *size, 
     272uint8_t *usb_hid_report_output(usb_hid_report_t *report, size_t *size,
    273273    uint8_t report_id)
    274274{
     
    322322 * @return Error code
    323323 */
    324 errno_t usb_hid_report_output_translate(usb_hid_report_t *report, 
     324errno_t usb_hid_report_output_translate(usb_hid_report_t *report,
    325325    uint8_t report_id, uint8_t *buffer, size_t size)
    326326{
     
    329329        int length;
    330330        int32_t tmp_value;
    331        
     331
    332332        if (report == NULL) {
    333333                return EINVAL;
     
    339339
    340340        usb_hid_report_description_t *report_des;
    341         report_des = usb_hid_report_find_description(report, report_id, 
     341        report_des = usb_hid_report_find_description(report, report_id,
    342342            USB_HID_REPORT_TYPE_OUTPUT);
    343        
     343
    344344        if (report_des == NULL) {
    345345                return EINVAL;
     
    348348        list_foreach(report_des->report_items, ritems_link,
    349349            usb_hid_report_field_t, report_item) {
    350                 value = usb_hid_translate_data_reverse(report_item, 
     350                value = usb_hid_translate_data_reverse(report_item,
    351351                    report_item->value);
    352352
    353353                offset = report_des->bit_length - report_item->offset - 1;
    354354                length = report_item->size;
    355                
     355
    356356                usb_log_debug("\ttranslated value: %x", value);
    357357
    358358                if ((offset / 8) == ((offset + length - 1) / 8)) {
    359                         if (((size_t) (offset / 8) >= size) || 
     359                        if (((size_t) (offset / 8) >= size) ||
    360360                            ((size_t) (offset + length - 1) / 8) >= size) {
    361361                                break; // TODO ErrorCode
     
    364364                        value = value << shift;
    365365                        value = value & (((1 << length) - 1) << shift);
    366                        
     366
    367367                        uint8_t mask = 0;
    368368                        mask = 0xff - (((1 << length) - 1) << shift);
     
    376376                                if (i == (offset / 8)) {
    377377                                        tmp_value = value;
    378                                         tmp_value = tmp_value & 
     378                                        tmp_value = tmp_value &
    379379                                            ((1 << (8 - (offset % 8))) - 1);
    380380
    381381                                        tmp_value = tmp_value << (offset % 8);
    382                                        
     382
    383383                                        mask = ~(((1 << (8 - (offset % 8))) - 1)
    384384                                            << (offset % 8));
    385385
    386                                         buffer[i] = (buffer[i] & mask) | 
     386                                        buffer[i] = (buffer[i] & mask) |
    387387                                            tmp_value;
    388388                                } else if (i == ((offset + length - 1) / 8)) {
    389                                        
    390                                         value = value >> (length - 
     389
     390                                        value = value >> (length -
    391391                                            ((offset + length) % 8));
    392392
    393                                         value = value & ((1 << (length - 
     393                                        value = value & ((1 << (length -
    394394                                            ((offset + length) % 8))) - 1);
    395                                        
    396                                         mask = (1 << (length - 
     395
     396                                        mask = (1 << (length -
    397397                                            ((offset + length) % 8))) - 1;
    398398
     
    407407                report_item->value = 0;
    408408        }
    409        
     409
    410410        return EOK;
    411411}
     
    418418 * @return ranslated value
    419419 */
    420 uint32_t usb_hid_translate_data_reverse(usb_hid_report_field_t *item, 
     420uint32_t usb_hid_translate_data_reverse(usb_hid_report_field_t *item,
    421421    int value)
    422422{
     
    430430        if ((item->physical_minimum == 0) && (item->physical_maximum == 0)) {
    431431                item->physical_minimum = item->logical_minimum;
    432                 item->physical_maximum = item->logical_maximum;                 
    433         }
    434        
     432                item->physical_maximum = item->logical_maximum;
     433        }
     434
    435435        /* variable item */
    436436        if (item->physical_maximum == item->physical_minimum) {
    437             resolution = 1;
    438         } else {
    439             resolution = (item->logical_maximum - item->logical_minimum) /
    440                 ((item->physical_maximum - item->physical_minimum) *
    441                 (usb_pow(10, (item->unit_exponent))));
    442         }
    443 
    444         ret = ((value - item->physical_minimum) * resolution) + 
     437                resolution = 1;
     438        } else {
     439                resolution = (item->logical_maximum - item->logical_minimum) /
     440                    ((item->physical_maximum - item->physical_minimum) *
     441                    (usb_pow(10, (item->unit_exponent))));
     442        }
     443
     444        ret = ((value - item->physical_minimum) * resolution) +
    445445            item->logical_minimum;
    446446
    447447        usb_log_debug("\tvalue(%x), resolution(%x), phymin(%x) logmin(%x), "
    448             "ret(%x)\n", value, resolution, item->physical_minimum, 
     448            "ret(%x)\n", value, resolution, item->physical_minimum,
    449449            item->logical_minimum, ret);
    450        
     450
    451451        if ((item->logical_minimum < 0) || (item->logical_maximum < 0)) {
    452452                return USB_HID_INT32_TO_UINT32(ret, item->size);
     
    467467{
    468468        usb_hid_report_item_t *new_report_item;
    469        
     469
    470470        if (!(new_report_item = malloc(sizeof(usb_hid_report_item_t)))) {
    471471                return NULL;
    472         }                                       
     472        }
    473473        memcpy(new_report_item,item, sizeof(usb_hid_report_item_t));
    474474        link_initialize(&(new_report_item->link));
     
    485485 * @param field Current field. If NULL is given, the first one in the report
    486486 * is returned. Otherwise the next one i nthe list is returned.
    487  * @param path Usage path specifying which fields wa are interested in. 
     487 * @param path Usage path specifying which fields wa are interested in.
    488488 * @param flags Flags defining mode of usage paths comparison
    489489 * @param type Type of report we search.
     
    491491 * @retval Pointer to the founded report structure when founded
    492492 */
    493 usb_hid_report_field_t *usb_hid_report_get_sibling(usb_hid_report_t *report, 
    494     usb_hid_report_field_t *field, usb_hid_report_path_t *path, int flags, 
     493usb_hid_report_field_t *usb_hid_report_get_sibling(usb_hid_report_t *report,
     494    usb_hid_report_field_t *field, usb_hid_report_path_t *path, int flags,
    495495    usb_hid_report_type_t type)
    496496{
    497         usb_hid_report_description_t *report_des = 
     497        usb_hid_report_description_t *report_des =
    498498            usb_hid_report_find_description(report, path->report_id, type);
    499499
    500500        link_t *field_it;
    501        
     501
    502502        if (report_des == NULL) {
    503503                return NULL;
     
    511511
    512512        while (field_it != &report_des->report_items.head) {
    513                 field = list_get_instance(field_it, usb_hid_report_field_t, 
     513                field = list_get_instance(field_it, usb_hid_report_field_t,
    514514                    ritems_link);
    515515
     
    553553        usb_hid_report_description_t *report_des;
    554554        link_t *report_it;
    555        
     555
    556556        if (report_id > 0) {
    557                 report_des = usb_hid_report_find_description(report, report_id, 
     557                report_des = usb_hid_report_find_description(report, report_id,
    558558                    type);
    559559                if (report_des == NULL) {
     
    561561                } else {
    562562                        report_it = report_des->reports_link.next;
    563                 }       
     563                }
    564564        } else {
    565565                report_it = report->reports.head.next;
     
    567567
    568568        while (report_it != &report->reports.head) {
    569                 report_des = list_get_instance(report_it, 
     569                report_des = list_get_instance(report_it,
    570570                    usb_hid_report_description_t, reports_link);
    571571
     
    594594                return;
    595595        }
    596        
     596
    597597        report_item->usages_count = 0;
    598598        memset(report_item->usages, 0, USB_HID_MAX_USAGES);
    599        
     599
    600600        report_item->extended_usage_page = 0;
    601601        report_item->usage_minimum = 0;
  • uspace/lib/usbhid/src/hidpath.c

    r3692678 rae3a941  
    7373 * @return Error code
    7474 */
    75 errno_t usb_hid_report_path_append_item(usb_hid_report_path_t *usage_path, 
    76                                     int32_t usage_page, int32_t usage)
    77 {       
    78         usb_hid_report_usage_path_t *item
    79                 = malloc(sizeof(usb_hid_report_usage_path_t));
     75errno_t usb_hid_report_path_append_item(usb_hid_report_path_t *usage_path,
     76    int32_t usage_page, int32_t usage)
     77{
     78        usb_hid_report_usage_path_t *item =
     79            malloc(sizeof(usb_hid_report_usage_path_t));
    8080
    8181        if (item == NULL) {
     
    8787        item->usage_page = usage_page;
    8888        item->flags = 0;
    89        
     89
    9090        list_append (&item->rpath_items_link, &usage_path->items);
    9191        usage_path->depth++;
     
    9696/**
    9797 * Removes last item from the usage path structure
    98  * @param usage_path 
     98 * @param usage_path
    9999 * @return void
    100100 */
     
    103103        link_t *item_link;
    104104        usb_hid_report_usage_path_t *item;
    105        
    106         if(!list_empty(&usage_path->items)){
     105
     106        if (!list_empty(&usage_path->items)) {
    107107                item_link = list_last(&usage_path->items);
    108108                item = list_get_instance(item_link,
     
    124124{
    125125        usb_hid_report_usage_path_t *item;
    126        
    127         if(!list_empty(&usage_path->items)){
     126
     127        if (!list_empty(&usage_path->items)) {
    128128                item = list_get_instance(list_last(&usage_path->items),
    129                         usb_hid_report_usage_path_t, rpath_items_link);
     129                    usb_hid_report_usage_path_t, rpath_items_link);
    130130
    131131                memset(item, 0, sizeof(usb_hid_report_usage_path_t));
     
    143143 * @return void
    144144 */
    145 void usb_hid_report_set_last_item(usb_hid_report_path_t *usage_path, 
    146                                   int32_t tag, int32_t data)
     145void usb_hid_report_set_last_item(usb_hid_report_path_t *usage_path,
     146    int32_t tag, int32_t data)
    147147{
    148148        usb_hid_report_usage_path_t *item;
    149        
    150         if(!list_empty(&usage_path->items)){
     149
     150        if (!list_empty(&usage_path->items)) {
    151151                item = list_get_instance(list_last(&usage_path->items),
    152152                     usb_hid_report_usage_path_t, rpath_items_link);
    153153
    154                 switch(tag) {
    155                         case USB_HID_TAG_CLASS_GLOBAL:
    156                                 item->usage_page = data;
    157                                 break;
    158                         case USB_HID_TAG_CLASS_LOCAL:
    159                                 item->usage = data;
    160                                 break;
    161                 }
    162         }
    163        
    164 }
    165 
    166 
    167 /**
    168  *
    169  *
    170  *
    171  *
    172  */
     154                switch (tag) {
     155                case USB_HID_TAG_CLASS_GLOBAL:
     156                        item->usage_page = data;
     157                        break;
     158                case USB_HID_TAG_CLASS_LOCAL:
     159                        item->usage = data;
     160                        break;
     161                }
     162        }
     163}
     164
    173165void usb_hid_print_usage_path(usb_hid_report_path_t *path)
    174166{
     
    199191        usb_hid_report_usage_path_t *report_item;
    200192        usb_hid_report_usage_path_t *path_item;
    201        
     193
    202194        link_t *report_link;
    203195        link_t *path_link;
    204        
     196
    205197        int only_page;
    206        
     198
    207199        if (report_path->report_id != path->report_id) {
    208200                if (path->report_id != 0) {
     
    210202                }
    211203        }
    212        
     204
    213205        // Empty path match all others
    214206        if (path->depth == 0) {
    215207                return 0;
    216208        }
    217        
     209
    218210        if ((only_page = flags & USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY) != 0) {
    219211                flags -= USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY;
    220212        }
    221        
     213
    222214        switch (flags) {
    223215        /* Path is somewhere in report_path */
     
    226218                        return 1;
    227219                }
    228                
     220
    229221                path_link = list_first(&path->items);
    230222                path_item = list_get_instance(path_link,
    231223                    usb_hid_report_usage_path_t, rpath_items_link);
    232                
     224
    233225                list_foreach(report_path->items, rpath_items_link,
    234226                    usb_hid_report_usage_path_t, report_item) {
    235227                        if (USB_HID_SAME_USAGE_PAGE(report_item->usage_page,
    236228                            path_item->usage_page)) {
    237                                
     229
    238230                                if (only_page == 0) {
    239231                                        if (USB_HID_SAME_USAGE(report_item->usage,
     
    245237                        }
    246238                }
    247                
     239
    248240                return 1;
    249241                break;
    250        
     242
    251243        /* The paths must be identical */
    252244        case USB_HID_PATH_COMPARE_STRICT:
     
    255247                }
    256248                /* Fallthrough */
    257        
     249
    258250        /* Path is prefix of the report_path */
    259251        case USB_HID_PATH_COMPARE_BEGIN:
    260252                report_link = report_path->items.head.next;
    261253                path_link = path->items.head.next;
    262                
     254
    263255                while ((report_link != &report_path->items.head) &&
    264256                    (path_link != &path->items.head)) {
    265                        
     257
    266258                        report_item = list_get_instance(report_link,
    267259                            usb_hid_report_usage_path_t, rpath_items_link);
    268                        
     260
    269261                        path_item = list_get_instance(path_link,
    270262                            usb_hid_report_usage_path_t, rpath_items_link);
    271                        
     263
    272264                        if (!USB_HID_SAME_USAGE_PAGE(report_item->usage_page,
    273265                            path_item->usage_page) || ((only_page == 0) &&
     
    280272                        }
    281273                }
    282                
     274
    283275                if ((((flags & USB_HID_PATH_COMPARE_BEGIN) != 0) &&
    284276                    (path_link == &path->items.head)) ||
     
    290282                }
    291283                break;
    292        
     284
    293285        /* Path is suffix of report_path */
    294286        case USB_HID_PATH_COMPARE_END:
    295287                report_link = report_path->items.head.prev;
    296288                path_link = path->items.head.prev;
    297                
     289
    298290                if (list_empty(&path->items)) {
    299291                        return 0;
    300292                }
    301                
     293
    302294                while ((report_link != &report_path->items.head) &&
    303295                      (path_link != &path->items.head)) {
    304296                        report_item = list_get_instance(report_link,
    305297                            usb_hid_report_usage_path_t, rpath_items_link);
    306                        
     298
    307299                        path_item = list_get_instance(path_link,
    308300                            usb_hid_report_usage_path_t, rpath_items_link);
    309                        
     301
    310302                        if (!USB_HID_SAME_USAGE_PAGE(report_item->usage_page,
    311303                            path_item->usage_page) || ((only_page == 0) &&
     
    318310                        }
    319311                }
    320                
     312
    321313                if (path_link == &path->items.head) {
    322314                        return 0;
     
    325317                }
    326318                break;
    327        
     319
    328320        default:
    329321                return -1;
     
    340332        usb_hid_report_path_t *path;
    341333        path = malloc(sizeof(usb_hid_report_path_t));
    342         if(path == NULL){
     334        if (path == NULL) {
    343335                return NULL;
    344336        }
     
    363355        if (path == NULL)
    364356                return;
    365         while(!list_empty(&path->items)){
     357        while (!list_empty(&path->items)) {
    366358                usb_hid_report_remove_last_item(path);
    367359        }
     
    379371 */
    380372usb_hid_report_path_t *usb_hid_report_path_clone(
    381         usb_hid_report_path_t *usage_path)
     373    usb_hid_report_path_t *usage_path)
    382374{
    383375        usb_hid_report_usage_path_t *new_path_item;
    384376        usb_hid_report_path_t *new_usage_path = usb_hid_report_path ();
    385377
    386         if(new_usage_path == NULL){
     378        if (new_usage_path == NULL) {
    387379                return NULL;
    388380        }
    389381
    390382        new_usage_path->report_id = usage_path->report_id;
    391        
    392         if(list_empty(&usage_path->items)){
     383
     384        if (list_empty(&usage_path->items)) {
    393385                return new_usage_path;
    394386        }
     
    398390
    399391                new_path_item = malloc(sizeof(usb_hid_report_usage_path_t));
    400                 if(new_path_item == NULL) {
     392                if (new_path_item == NULL) {
    401393                        return NULL;
    402394                }
    403                
     395
    404396                link_initialize(&new_path_item->rpath_items_link);
    405397                new_path_item->usage_page = path_item->usage_page;
    406                 new_path_item->usage = path_item->usage;               
    407                 new_path_item->flags = path_item->flags;               
    408                
     398                new_path_item->usage = path_item->usage;
     399                new_path_item->flags = path_item->flags;
     400
    409401                list_append(&new_path_item->rpath_items_link,
    410402                    &new_usage_path->items);
     
    423415 * @return Error code
    424416 */
    425 errno_t usb_hid_report_path_set_report_id(usb_hid_report_path_t *path, 
    426         uint8_t report_id)
    427 {
    428         if(path == NULL){
     417errno_t usb_hid_report_path_set_report_id(usb_hid_report_path_t *path,
     418    uint8_t report_id)
     419{
     420        if (path == NULL) {
    429421                return EINVAL;
    430422        }
  • uspace/lib/usbhid/src/hidreport.c

    r3692678 rae3a941  
    7171        const uint8_t *d =
    7272            usb_dp_get_nested_descriptor(&parser, &parser_data,
    73                 usb_device_descriptors(dev)->full_config);
     73            usb_device_descriptors(dev)->full_config);
    7474       
    7575        /*
     
    163163
    164164
    165 errno_t usb_hid_process_report_descriptor(usb_device_t *dev, 
     165errno_t usb_hid_process_report_descriptor(usb_device_t *dev,
    166166    usb_hid_report_t *report, uint8_t **report_desc, size_t *report_size)
    167167{
  • uspace/lib/usbhid/src/hidreq.c

    r3692678 rae3a941  
    6565                return EINVAL;
    6666        }
    67        
    68         if (iface_no < 0) {
    69                 usb_log_warning("usbhid_req_set_report(): no interface given."
    70                     "\n");
    71                 return EINVAL;
    72         }
    73        
    74         /*
    75          * No need for checking other parameters, as they are checked in
    76          * the called function (usb_control_request_set()).
    77          */
    78        
    79         errno_t rc;
    80        
     67
     68        if (iface_no < 0) {
     69                usb_log_warning("usbhid_req_set_report(): no interface given."
     70                    "\n");
     71                return EINVAL;
     72        }
     73
     74        /*
     75         * No need for checking other parameters, as they are checked in
     76         * the called function (usb_control_request_set()).
     77         */
     78
     79        errno_t rc;
     80
    8181        uint16_t value = 0;
    8282        value |= (type << 8);
    8383
    8484        usb_log_debug("Sending Set Report request to the device.");
    85        
     85
    8686        rc = usb_control_request_set(ctrl_pipe,
    8787            USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE,
     
    9393                return rc;
    9494        }
    95        
     95
    9696        return EOK;
    9797}
     
    115115                return EINVAL;
    116116        }
    117        
    118         if (iface_no < 0) {
    119                 usb_log_warning("usbhid_req_set_report(): no interface given."
    120                     "\n");
    121                 return EINVAL;
    122         }
    123        
    124         /*
    125          * No need for checking other parameters, as they are checked in
    126          * the called function (usb_control_request_set()).
    127          */
    128        
     117
     118        if (iface_no < 0) {
     119                usb_log_warning("usbhid_req_set_report(): no interface given."
     120                    "\n");
     121                return EINVAL;
     122        }
     123
     124        /*
     125         * No need for checking other parameters, as they are checked in
     126         * the called function (usb_control_request_set()).
     127         */
     128
    129129        errno_t rc;
    130130
    131131        usb_log_debug("Sending Set Protocol request to the device ("
    132132            "protocol: %d, iface: %d).\n", protocol, iface_no);
    133        
    134         rc = usb_control_request_set(ctrl_pipe, 
    135             USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE, 
     133
     134        rc = usb_control_request_set(ctrl_pipe,
     135            USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE,
    136136            USB_HIDREQ_SET_PROTOCOL, protocol, iface_no, NULL, 0);
    137137
     
    141141                return rc;
    142142        }
    143        
     143
    144144        return EOK;
    145145}
     
    163163                return EINVAL;
    164164        }
    165        
    166         if (iface_no < 0) {
    167                 usb_log_warning("usbhid_req_set_report(): no interface given."
    168                     "\n");
    169                 return EINVAL;
    170         }
    171        
    172         /*
    173          * No need for checking other parameters, as they are checked in
    174          * the called function (usb_control_request_set()).
    175          */
    176        
     165
     166        if (iface_no < 0) {
     167                usb_log_warning("usbhid_req_set_report(): no interface given."
     168                    "\n");
     169                return EINVAL;
     170        }
     171
     172        /*
     173         * No need for checking other parameters, as they are checked in
     174         * the called function (usb_control_request_set()).
     175         */
     176
    177177        errno_t rc;
    178178
    179179        usb_log_debug("Sending Set Idle request to the device ("
    180180            "duration: %u, iface: %d).\n", duration, iface_no);
    181        
     181
    182182        uint16_t value = duration << 8;
    183        
     183
    184184        rc = usb_control_request_set(ctrl_pipe,
    185185            USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE,
     
    191191                return rc;
    192192        }
    193        
     193
    194194        return EOK;
    195195}
     
    203203 * @param[in][out] buffer Buffer for the report data.
    204204 * @param[in] buf_size Size of the buffer (in bytes).
    205  * @param[out] actual_size Actual size of report received from the device 
     205 * @param[out] actual_size Actual size of report received from the device
    206206 *                         (in bytes).
    207207 *
     
    210210 * @return Other value inherited from function usb_control_request_set().
    211211 */
    212 errno_t usbhid_req_get_report(usb_pipe_t *ctrl_pipe, int iface_no, 
    213     usb_hid_report_type_t type, uint8_t *buffer, size_t buf_size, 
     212errno_t usbhid_req_get_report(usb_pipe_t *ctrl_pipe, int iface_no,
     213    usb_hid_report_type_t type, uint8_t *buffer, size_t buf_size,
    214214    size_t *actual_size)
    215215{
     
    218218                return EINVAL;
    219219        }
    220        
    221         if (iface_no < 0) {
    222                 usb_log_warning("usbhid_req_set_report(): no interface given."
    223                     "\n");
    224                 return EINVAL;
    225         }
    226        
    227         /*
    228          * No need for checking other parameters, as they are checked in
    229          * the called function (usb_control_request_set()).
    230          */
    231        
     220
     221        if (iface_no < 0) {
     222                usb_log_warning("usbhid_req_set_report(): no interface given."
     223                    "\n");
     224                return EINVAL;
     225        }
     226
     227        /*
     228         * No need for checking other parameters, as they are checked in
     229         * the called function (usb_control_request_set()).
     230         */
     231
    232232        errno_t rc;
    233233
    234234        uint16_t value = 0;
    235235        value |= (type << 8);
    236        
     236
    237237        usb_log_debug("Sending Get Report request to the device.");
    238        
    239         rc = usb_control_request_get(ctrl_pipe, 
    240             USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE, 
     238
     239        rc = usb_control_request_get(ctrl_pipe,
     240            USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE,
    241241            USB_HIDREQ_GET_REPORT, value, iface_no, buffer, buf_size,
    242242            actual_size);
     
    247247                return rc;
    248248        }
    249        
     249
    250250        return EOK;
    251251}
     
    262262 * @return Other value inherited from function usb_control_request_set().
    263263 */
    264 errno_t usbhid_req_get_protocol(usb_pipe_t *ctrl_pipe, int iface_no, 
     264errno_t usbhid_req_get_protocol(usb_pipe_t *ctrl_pipe, int iface_no,
    265265    usb_hid_protocol_t *protocol)
    266266{
     
    269269                return EINVAL;
    270270        }
    271        
    272         if (iface_no < 0) {
    273                 usb_log_warning("usbhid_req_set_report(): no interface given."
    274                     "\n");
    275                 return EINVAL;
    276         }
    277        
    278         /*
    279          * No need for checking other parameters, as they are checked in
    280          * the called function (usb_control_request_set()).
    281          */
    282        
    283         errno_t rc;     
     271
     272        if (iface_no < 0) {
     273                usb_log_warning("usbhid_req_set_report(): no interface given."
     274                    "\n");
     275                return EINVAL;
     276        }
     277
     278        /*
     279         * No need for checking other parameters, as they are checked in
     280         * the called function (usb_control_request_set()).
     281         */
     282
     283        errno_t rc;
    284284
    285285        usb_log_debug("Sending Get Protocol request to the device ("
    286286            "iface: %d).\n", iface_no);
    287        
     287
    288288        uint8_t buffer[1];
    289289        size_t actual_size = 0;
    290        
    291         rc = usb_control_request_get(ctrl_pipe, 
    292             USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE, 
     290
     291        rc = usb_control_request_get(ctrl_pipe,
     292            USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE,
    293293            USB_HIDREQ_GET_PROTOCOL, 0, iface_no, buffer, 1, &actual_size);
    294294
     
    298298                return rc;
    299299        }
    300        
     300
    301301        if (actual_size != 1) {
    302302                usb_log_warning("Wrong data size: %zu, expected: 1.",
    303                         actual_size);
     303                    actual_size);
    304304                return ELIMIT;
    305305        }
    306        
     306
    307307        *protocol = buffer[0];
    308        
     308
    309309        return EOK;
    310310}
     
    320320 * @retval EOK if successful.
    321321 * @retval EINVAL if no HID device is given.
    322  * @return Other value inherited from one of functions 
     322 * @return Other value inherited from one of functions
    323323 *         usb_pipe_start_session(), usb_pipe_end_session(),
    324324 *         usb_control_request_set().
    325325 */
    326 errno_t usbhid_req_get_idle(usb_pipe_t *ctrl_pipe, int iface_no, uint8_t *duration)
    327 {
    328         if (ctrl_pipe == NULL) {
    329                 usb_log_warning("usbhid_req_set_report(): no pipe given.");
    330                 return EINVAL;
    331         }
    332        
    333         if (iface_no < 0) {
    334                 usb_log_warning("usbhid_req_set_report(): no interface given."
    335                     "\n");
    336                 return EINVAL;
    337         }
    338        
    339         /*
    340          * No need for checking other parameters, as they are checked in
    341          * the called function (usb_control_request_set()).
    342          */
    343        
     326errno_t usbhid_req_get_idle(usb_pipe_t *ctrl_pipe, int iface_no,
     327    uint8_t *duration)
     328{
     329        if (ctrl_pipe == NULL) {
     330                usb_log_warning("usbhid_req_set_report(): no pipe given.");
     331                return EINVAL;
     332        }
     333
     334        if (iface_no < 0) {
     335                usb_log_warning("usbhid_req_set_report(): no interface given."
     336                    "\n");
     337                return EINVAL;
     338        }
     339
     340        /*
     341         * No need for checking other parameters, as they are checked in
     342         * the called function (usb_control_request_set()).
     343         */
     344
    344345        errno_t rc;
    345346
    346347        usb_log_debug("Sending Get Idle request to the device ("
    347348            "iface: %d).\n", iface_no);
    348        
     349
    349350        uint16_t value = 0;
    350351        uint8_t buffer[1];
    351352        size_t actual_size = 0;
    352        
    353         rc = usb_control_request_get(ctrl_pipe, 
    354             USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE, 
    355             USB_HIDREQ_GET_IDLE, value, iface_no, buffer, 1, 
     353
     354        rc = usb_control_request_get(ctrl_pipe,
     355            USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE,
     356            USB_HIDREQ_GET_IDLE, value, iface_no, buffer, 1,
    356357            &actual_size);
    357358
     
    361362                return rc;
    362363        }
    363        
     364
    364365        if (actual_size != 1) {
    365366                usb_log_warning("Wrong data size: %zu, expected: 1.",
    366                         actual_size);
     367                    actual_size);
    367368                return ELIMIT;
    368369        }
    369        
     370
    370371        *duration = buffer[0];
    371        
     372
    372373        return EOK;
    373374}
  • uspace/lib/usbhost/include/usb/host/bus.h

    r3692678 rae3a941  
    111111        int (*device_online)(device_t *);                       /**< Optional */
    112112        void (*device_offline)(device_t *);                     /**< Optional */
    113         endpoint_t *(*endpoint_create)(device_t *, const usb_endpoint_descriptors_t *);
     113        endpoint_t *(*endpoint_create)(device_t *,
     114            const usb_endpoint_descriptors_t *);
    114115
    115116        /* Operations on endpoint */
  • uspace/lib/usbhost/include/usb/host/endpoint.h

    r3692678 rae3a941  
    102102
    103103        /* Policies for transfer buffers */
    104         dma_policy_t transfer_buffer_policy;            /**< A hint for optimal performance. */
    105         dma_policy_t required_transfer_buffer_policy;   /**< Enforced by the library. */
     104        /** A hint for optimal performance. */
     105        dma_policy_t transfer_buffer_policy;
     106        /** Enforced by the library. */
     107        dma_policy_t required_transfer_buffer_policy;
    106108
    107109        /**
     
    114116} endpoint_t;
    115117
    116 extern void endpoint_init(endpoint_t *, device_t *, const usb_endpoint_descriptors_t *);
     118extern void endpoint_init(endpoint_t *, device_t *,
     119    const usb_endpoint_descriptors_t *);
    117120
    118121extern void endpoint_add_ref(endpoint_t *);
  • uspace/lib/usbhost/include/usb/host/hcd.h

    r3692678 rae3a941  
    7878
    7979        /** Generate IRQ code to handle interrupts. */
    80         int (*irq_code_gen)(irq_code_t *, hc_device_t *, const hw_res_list_parsed_t *, int *);
     80        int (*irq_code_gen)(irq_code_t *, hc_device_t *,
     81            const hw_res_list_parsed_t *, int *);
    8182
    8283        /** Claim device from BIOS. */
     
    100101
    101102/* Drivers should call this before leaving hc_add */
    102 static inline void hc_device_setup(hc_device_t *hcd, bus_t *bus) {
     103static inline void hc_device_setup(hc_device_t *hcd, bus_t *bus)
     104{
    103105        hcd->bus = bus;
    104106}
  • uspace/lib/usbhost/include/usb/host/usb2_bus.h

    r3692678 rae3a941  
    6161} usb2_bus_helper_t;
    6262
    63 extern void usb2_bus_helper_init(usb2_bus_helper_t *, const bandwidth_accounting_t *);
     63extern void usb2_bus_helper_init(usb2_bus_helper_t *,
     64    const bandwidth_accounting_t *);
    6465
    6566extern int usb2_bus_device_enumerate(usb2_bus_helper_t *, device_t *);
  • uspace/lib/usbhost/src/bandwidth.c

    r3692678 rae3a941  
    7373         * transaction, but I did not find text in USB spec to confirm this */
    7474        /* NOTE: All data packets will be considered to be max_packet_size */
    75         switch (ep->device->speed)
    76         {
     75        switch (ep->device->speed) {
    7776        case USB_SPEED_LOW:
    7877                assert(type == USB_TRANSFER_INTERRUPT);
     
    143142        case USB_SPEED_LOW:
    144143                if (ep->direction == USB_DIRECTION_IN)
    145                         return 64060 + (2 * hub_ls_setup) + (677 * base_time) + host_delay;
     144                        return 64060 + (2 * hub_ls_setup) +
     145                                (677 * base_time) + host_delay;
    146146                else
    147                         return 64107 + (2 * hub_ls_setup) + (667 * base_time) + host_delay;
     147                        return 64107 + (2 * hub_ls_setup) +
     148                                (667 * base_time) + host_delay;
    148149
    149150        case USB_SPEED_FULL:
  • uspace/lib/usbhost/src/hcd.c

    r3692678 rae3a941  
    155155 * @return Negative error code.
    156156 */
    157 static errno_t hcd_ddf_setup_interrupts(hc_device_t *hcd, const hw_res_list_parsed_t *hw_res)
     157static errno_t hcd_ddf_setup_interrupts(hc_device_t *hcd,
     158    const hw_res_list_parsed_t *hw_res)
    158159{
    159160        assert(hcd);
    160         irq_code_t irq_code = {0};
     161        irq_code_t irq_code = { 0 };
    161162
    162163        if (!hc_driver->irq_code_gen)
     
    174175        /* Register handler to avoid interrupt lockup */
    175176        int irq_cap;
    176         ret = register_interrupt_handler(hcd->ddf_dev, irq, irq_handler, &irq_code, &irq_cap);
     177        ret = register_interrupt_handler(hcd->ddf_dev, irq, irq_handler,
     178            &irq_code, &irq_cap);
    177179        irq_code_clean(&irq_code);
    178180        if (ret != EOK) {
     
    212214
    213215        if (!hc_driver->hc_add) {
    214                 usb_log_error("Driver '%s' does not support adding devices.", hc_driver->name);
     216                usb_log_error("Driver '%s' does not support adding devices.",
     217                    hc_driver->name);
    215218                return ENOTSUP;
    216219        }
     
    292295
    293296        usb_log_info("Controlling new `%s' device `%s'.",
    294            hc_driver->name, ddf_dev_get_name(device));
     297            hc_driver->name, ddf_dev_get_name(device));
    295298        return EOK;
    296299
  • uspace/lib/usbvirt/src/ipc_hc.c

    r3692678 rae3a941  
    7777        }
    7878       
    79         errno_t rc = async_data_write_start(exch, setup_buffer, setup_buffer_size);
     79        errno_t rc = async_data_write_start(exch, setup_buffer,
     80            setup_buffer_size);
    8081        if (rc != EOK) {
    8182                async_exchange_end(exch);
     
    8586       
    8687        ipc_call_t data_request_call;
    87         aid_t data_request = async_data_read(exch, data_buffer, data_buffer_size,
    88             &data_request_call);
     88        aid_t data_request = async_data_read(exch, data_buffer,
     89            data_buffer_size, &data_request_call);
    8990       
    9091        async_exchange_end(exch);
     
    150151        }
    151152       
    152         errno_t rc = async_data_write_start(exch, setup_buffer, setup_buffer_size);
     153        errno_t rc = async_data_write_start(exch, setup_buffer,
     154            setup_buffer_size);
    153155        if (rc != EOK) {
    154156                async_exchange_end(exch);
     
    158160       
    159161        if (data_buffer_size > 0) {
    160                 rc = async_data_write_start(exch, data_buffer, data_buffer_size);
     162                rc = async_data_write_start(exch, data_buffer,
     163                    data_buffer_size);
    161164                if (rc != EOK) {
    162165                        async_exchange_end(exch);
  • uspace/lib/usbvirt/src/transfer.c

    r3692678 rae3a941  
    119119 * @return Error code.
    120120 */
    121 errno_t usbvirt_control_read(usbvirt_device_t *dev, const void *setup, size_t setup_size,
     121errno_t usbvirt_control_read(usbvirt_device_t *dev,
     122    const void *setup, size_t setup_size,
    122123    void *data, size_t data_size, size_t *data_size_sent)
    123124{
Note: See TracChangeset for help on using the changeset viewer.