Changeset 5d915b7 in mainline


Ignore:
Timestamp:
2011-09-14T14:25:07Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8e3d17f
Parents:
1e647c7d
Message:

uhci: Minor tweaks and comment fixes

Location:
uspace/drv/bus/usb/uhci
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/uhci/hw_struct/link_pointer.h

    r1e647c7d r5d915b7  
    3535#define DRV_UHCI_HW_STRUCT_LINK_POINTER_H
    3636
    37 /* UHCI link pointer, used by many data structures */
     37/** UHCI link pointer, used by many data structures */
    3838typedef uint32_t link_pointer_t;
    3939
  • uspace/drv/bus/usb/uhci/hw_struct/queue_head.h

    r1e647c7d r5d915b7  
    5858        assert(instance);
    5959
    60         instance->element = 0 | LINK_POINTER_TERMINATE_FLAG;
    61         instance->next = 0 | LINK_POINTER_TERMINATE_FLAG;
     60        instance->element = LINK_POINTER_TERM;
     61        instance->next = LINK_POINTER_TERM;
    6262}
    6363/*----------------------------------------------------------------------------*/
     
    7171static inline void qh_set_next_qh(qh_t *instance, qh_t *next)
    7272{
    73         uint32_t pa = addr_to_phys(next);
     73        /* Physical address has to be below 4GB,
     74         * it is an UHCI limitation and malloc32
     75         * should guarantee this */
     76        const uint32_t pa = addr_to_phys(next);
    7477        if (pa) {
    7578                instance->next = LINK_POINTER_QH(pa);
     
    8891static inline void qh_set_element_td(qh_t *instance, td_t *td)
    8992{
    90         uint32_t pa = addr_to_phys(td);
     93        /* Physical address has to be below 4GB,
     94         * it is an UHCI limitation and malloc32
     95         * should guarantee this */
     96        const uint32_t pa = addr_to_phys(td);
    9197        if (pa) {
    9298                instance->element = LINK_POINTER_TD(pa);
  • uspace/drv/bus/usb/uhci/hw_struct/transfer_descriptor.c

    r1e647c7d r5d915b7  
    113113 * @return Error code.
    114114 */
    115 int td_status(td_t *instance)
     115int td_status(const td_t *instance)
    116116{
    117117        assert(instance);
     
    119119        /* This is hc internal error it should never be reported. */
    120120        if ((instance->status & TD_STATUS_ERROR_BIT_STUFF) != 0)
    121                 return EAGAIN;
     121                return EIO;
    122122
    123123        /* CRC or timeout error, like device not present or bad data,
     
    150150 * @param[in] instance TD structure to use.
    151151 */
    152 void td_print_status(td_t *instance)
     152void td_print_status(const td_t *instance)
    153153{
    154154        assert(instance);
  • uspace/drv/bus/usb/uhci/hw_struct/transfer_descriptor.h

    r1e647c7d r5d915b7  
    6969#define TD_STATUS_ACTLEN_MASK 0x7ff
    7070
    71         /* double word with USB device specific info */
     71        /** Double word with USB device specific info */
    7272        volatile uint32_t device;
    7373#define TD_DEVICE_MAXLEN_POS 21
     
    8787        /* According to UHCI design guide, there is 16 bytes of
    8888         * data available here.
    89          * According to linux kernel the hardware does not care,
    90          * it just needs to be aligned. We don't use it anyway.
     89         * According to Linux kernel the hardware does not care,
     90         * memory just needs to be aligned. We don't use it anyway.
    9191         */
    9292} __attribute__((packed)) td_t;
     
    9797    const void *buffer, const td_t *next);
    9898
    99 int td_status(td_t *instance);
     99int td_status(const td_t *instance);
    100100
    101 void td_print_status(td_t *instance);
     101void td_print_status(const td_t *instance);
    102102/*----------------------------------------------------------------------------*/
    103103/** Helper function for parsing actual size out of TD.
     
    106106 * @return Parsed actual size.
    107107 */
    108 static inline size_t td_act_size(td_t *instance)
     108static inline size_t td_act_size(const td_t *instance)
    109109{
    110110        assert(instance);
    111111        const uint32_t s = instance->status;
     112        /* Actual size is encoded as n-1 (UHCI design guide p. 23) */
    112113        return ((s >> TD_STATUS_ACTLEN_POS) + 1) & TD_STATUS_ACTLEN_MASK;
    113114}
     
    119120 * false otherwise.
    120121 */
    121 static inline bool td_is_short(td_t *instance)
     122static inline bool td_is_short(const td_t *instance)
    122123{
    123124        const size_t act_size = td_act_size(instance);
     
    134135 * @return Toggle bit value.
    135136 */
    136 static inline int td_toggle(td_t *instance)
     137static inline int td_toggle(const td_t *instance)
    137138{
    138139        assert(instance);
     
    145146 * @return Active bit value.
    146147 */
    147 static inline bool td_is_active(td_t *instance)
     148static inline bool td_is_active(const td_t *instance)
    148149{
    149150        assert(instance);
  • uspace/drv/bus/usb/uhci/main.c

    r1e647c7d r5d915b7  
    6464        assert(device);
    6565
    66         int ret = device_setup_uhci(device);
     66        const int ret = device_setup_uhci(device);
    6767        if (ret != EOK) {
    6868                usb_log_error("Failed to initialize UHCI driver: %s.\n",
    6969                    str_error(ret));
    70                 return ret;
     70        } else {
     71                usb_log_info("Controlling new UHCI device '%s'.\n",
     72                    device->name);
    7173        }
    72         usb_log_info("Controlling new UHCI device '%s'.\n", device->name);
    7374
    74         return EOK;
     75        return ret;
    7576}
    7677/*----------------------------------------------------------------------------*/
  • uspace/drv/bus/usb/uhci/pci.c

    r1e647c7d r5d915b7  
    6161        assert(io_reg_size);
    6262        assert(irq_no);
    63        
     63
    6464        async_sess_t *parent_sess =
    6565            devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle,
     
    6767        if (!parent_sess)
    6868                return ENOMEM;
    69        
     69
    7070        hw_resource_list_t hw_resources;
    7171        int rc = hw_res_get_resource_list(parent_sess, &hw_resources);
     
    7474                return rc;
    7575        }
    76        
     76
    7777        uintptr_t io_address = 0;
    7878        size_t io_size = 0;
     
    102102                }
    103103        }
    104        
     104
    105105        async_hangup(parent_sess);
    106        
     106
    107107        if (!io_found || !irq_found)
    108108                return ENOENT;
    109        
     109
    110110        *io_reg_address = io_address;
    111111        *io_reg_size = io_size;
    112112        *irq_no = irq;
    113        
     113
    114114        return EOK;
    115115}
    116 
     116/*----------------------------------------------------------------------------*/
    117117/** Call the PCI driver with a request to enable interrupts
    118118 *
     
    127127        if (!parent_sess)
    128128                return ENOMEM;
    129        
     129
    130130        const bool enabled = hw_res_enable_interrupt(parent_sess);
    131131        async_hangup(parent_sess);
    132        
     132
    133133        return enabled ? EOK : EIO;
    134134}
    135 
     135/*----------------------------------------------------------------------------*/
    136136/** Call the PCI driver with a request to clear legacy support register
    137137 *
  • uspace/drv/bus/usb/uhci/root_hub.c

    r1e647c7d r5d915b7  
    5050int rh_init(rh_t *instance, ddf_fun_t *fun, uintptr_t reg_addr, size_t reg_size)
    5151{
    52         int ret;
    53 
     52        assert(instance);
    5453        assert(fun);
    55 
    56         ret = ddf_fun_add_match_id(fun, "usb&uhci&root-hub", 100);
    57         if (ret != EOK) {
    58                 usb_log_error("Failed to add root hub match id: %s\n",
    59                     str_error(ret));
    60                 return ret;
    61         }
    6254
    6355        /* Initialize resource structure */
     
    7062        instance->io_regs.res.io_range.endianness = LITTLE_ENDIAN;
    7163
    72         return EOK;
     64        const int ret = ddf_fun_add_match_id(fun, "usb&uhci&root-hub", 100);
     65        if (ret != EOK) {
     66                usb_log_error("Failed to add root hub match id: %s\n",
     67                    str_error(ret));
     68        }
     69        return ret;
    7370}
    7471/**
  • uspace/drv/bus/usb/uhci/uhci_batch.c

    r1e647c7d r5d915b7  
    134134        memcpy(dest, usb_batch->setup_buffer, usb_batch->setup_size);
    135135        dest += usb_batch->setup_size;
    136         /* Copy generic data if unless they are provided by the device */
     136        /* Copy generic data unless they are provided by the device */
    137137        if (usb_batch->ep->direction != USB_DIRECTION_IN) {
    138138                memcpy(dest, usb_batch->buffer, usb_batch->buffer_size);
     
    142142            " memory structures ready.\n", usb_batch,
    143143            USB_TRANSFER_BATCH_ARGS(*usb_batch));
     144
    144145        assert(
    145146            batch_setup[usb_batch->ep->transfer_type][usb_batch->ep->direction]);
     
    215216        assert(uhci_batch);
    216217        assert(uhci_batch->usb_batch);
     218        assert(uhci_batch->usb_batch->ep);
     219        assert(uhci_batch->usb_batch->ep->direction == USB_DIRECTION_OUT ||
     220            uhci_batch->usb_batch->ep->direction == USB_DIRECTION_IN);
     221
    217222        static const usb_packet_id pids[] = {
    218223                [USB_DIRECTION_IN] = USB_PID_IN,
    219224                [USB_DIRECTION_OUT] = USB_PID_OUT,
    220225        };
    221         assert(uhci_batch->usb_batch->ep->direction == USB_DIRECTION_OUT ||
    222             uhci_batch->usb_batch->ep->direction == USB_DIRECTION_IN);
    223226
    224227        const usb_packet_id pid = pids[uhci_batch->usb_batch->ep->direction];
  • uspace/drv/bus/usb/uhci/uhci_batch.h

    r1e647c7d r5d915b7  
    6464bool uhci_transfer_batch_is_complete(uhci_transfer_batch_t *uhci_batch);
    6565
     66static inline void * uhci_transfer_batch_setup_buffer(
     67    const uhci_transfer_batch_t *uhci_batch)
     68{
     69        assert(uhci_batch);
     70        assert(uhci_batch->device_buffer);
     71        return uhci_batch->device_buffer + sizeof(qh_t) +
     72            uhci_batch->td_count * sizeof(td_t);
     73}
     74/*----------------------------------------------------------------------------*/
    6675static inline void * uhci_transfer_batch_data_buffer(
    67     uhci_transfer_batch_t *uhci_batch)
     76    const uhci_transfer_batch_t *uhci_batch)
    6877{
    6978        assert(uhci_batch);
    7079        assert(uhci_batch->usb_batch);
    71         assert(uhci_batch->device_buffer);
    72         return uhci_batch->device_buffer + sizeof(qh_t) +
    73             uhci_batch->td_count * sizeof(td_t) +
     80        return uhci_transfer_batch_setup_buffer(uhci_batch) +
    7481            uhci_batch->usb_batch->setup_size;
    75 }
    76 /*----------------------------------------------------------------------------*/
    77 static inline void * uhci_transfer_batch_setup_buffer(
    78     uhci_transfer_batch_t *uhci_batch)
    79 {
    80         assert(uhci_batch);
    81         assert(uhci_batch->usb_batch);
    82         assert(uhci_batch->device_buffer);
    83         return uhci_batch->device_buffer + sizeof(qh_t) +
    84             uhci_batch->td_count * sizeof(td_t);
    8582}
    8683/*----------------------------------------------------------------------------*/
Note: See TracChangeset for help on using the changeset viewer.