Changeset ae3a941 in mainline for uspace/drv


Ignore:
Timestamp:
2018-02-26T16:51:40Z (8 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/drv
Files:
43 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;
Note: See TracChangeset for help on using the changeset viewer.