Changeset e247d83 in mainline


Ignore:
Timestamp:
2011-05-23T14:04:51Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
563ead9
Parents:
8953514
Message:

Const, type-casting and other minor fixes

Location:
uspace/drv
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/hc.c

    r8953514 re247d83  
    8585        /* allow access to hc control registers */
    8686        regs_t *io;
    87         ret = pio_enable(regs, reg_size, (void**)&io);
     87        ret = pio_enable(regs, reg_size, (void **)&io);
    8888        CHECK_RET_RETURN(ret,
    8989            "Failed(%d) to gain access to registers at %p: %s.\n",
     
    143143        }
    144144
    145         uint16_t status = pio_read_16(&registers->usbcmd);
     145        const uint16_t status = pio_read_16(&registers->usbcmd);
    146146        if (status != 0)
    147147                usb_log_warning("Previous command value: %x.\n", status);
     
    212212        /* Init USB frame list page*/
    213213        instance->frame_list = get_page();
    214         ret = instance ? EOK : ENOMEM;
     214        ret = instance->frame_list ? EOK : ENOMEM;
    215215        CHECK_RET_RETURN(ret, "Failed to get frame list page.\n");
    216216        usb_log_debug("Initialized frame list at %p.\n", instance->frame_list);
     
    277277                &instance->transfers_control_slow);
    278278
    279         /*FSBR*/
     279        /*FSBR, This feature is not needed (adds no benefit) and is supposedly
     280         * buggy on certain hw, enable at your own risk. */
    280281#ifdef FSBR
    281282        transfer_list_set_next(&instance->transfers_bulk_full,
     
    428429                }
    429430
    430                 uintptr_t frame_list =
     431                const uintptr_t frame_list =
    431432                    pio_read_32(&instance->registers->flbaseadd) & ~0xfff;
    432433                if (frame_list != addr_to_phys(instance->frame_list)) {
  • uspace/drv/uhci-hcd/hc.h

    r8953514 re247d83  
    154154 */
    155155static inline hc_t * fun_to_hc(ddf_fun_t *fun)
    156         { return (hc_t*)fun->driver_data; }
     156{
     157        assert(fun);
     158        return fun->driver_data;
     159}
    157160#endif
    158161/**
  • uspace/drv/uhci-hcd/pci.c

    r8953514 re247d83  
    5252 * @return Error code.
    5353 */
    54 int pci_get_my_registers(ddf_dev_t *dev,
     54int pci_get_my_registers(const ddf_dev_t *dev,
    5555    uintptr_t *io_reg_address, size_t *io_reg_size, int *irq_no)
    5656{
    57         assert(dev != NULL);
     57        assert(dev);
     58        assert(io_reg_address);
     59        assert(io_reg_size);
     60        assert(irq_no);
    5861
    5962        int parent_phone =
     
    6669        int rc = hw_res_get_resource_list(parent_phone, &hw_resources);
    6770        if (rc != EOK) {
    68                 goto leave;
     71                async_hangup(parent_phone);
     72                return rc;
    6973        }
    7074
     
    7882        size_t i;
    7983        for (i = 0; i < hw_resources.count; i++) {
    80                 hw_resource_t *res = &hw_resources.resources[i];
     84                const hw_resource_t *res = &hw_resources.resources[i];
    8185                switch (res->type)
    8286                {
     
    99103                }
    100104        }
     105        async_hangup(parent_phone);
    101106
    102         if (!io_found || !irq_found) {
    103                 rc = ENOENT;
    104                 goto leave;
    105         }
     107        if (!io_found || !irq_found)
     108                return ENOENT;
    106109
    107110        *io_reg_address = io_address;
     
    109112        *irq_no = irq;
    110113
    111         rc = EOK;
    112 leave:
    113         async_hangup(parent_phone);
    114         return rc;
     114        return EOK;
    115115}
    116116/*----------------------------------------------------------------------------*/
     
    120120 * @return Error code.
    121121 */
    122 int pci_enable_interrupts(ddf_dev_t *device)
     122int pci_enable_interrupts(const ddf_dev_t *device)
    123123{
    124         int parent_phone = devman_parent_device_connect(device->handle,
    125             IPC_FLAG_BLOCKING);
    126         bool enabled = hw_res_enable_interrupt(parent_phone);
     124        const int parent_phone =
     125            devman_parent_device_connect(device->handle, IPC_FLAG_BLOCKING);
     126        if (parent_phone < 0) {
     127                return parent_phone;
     128        }
     129        const bool enabled = hw_res_enable_interrupt(parent_phone);
    127130        async_hangup(parent_phone);
    128131        return enabled ? EOK : EIO;
     
    134137 * @return Error code.
    135138 */
    136 int pci_disable_legacy(ddf_dev_t *device)
     139int pci_disable_legacy(const ddf_dev_t *device)
    137140{
    138141        assert(device);
    139         int parent_phone =
     142        const int parent_phone =
    140143            devman_parent_device_connect(device->handle, IPC_FLAG_BLOCKING);
    141144        if (parent_phone < 0) {
     
    145148        /* See UHCI design guide for these values p.45,
    146149         * write all WC bits in USB legacy register */
    147         sysarg_t address = 0xc0;
    148         sysarg_t value = 0xaf00;
     150        const sysarg_t address = 0xc0;
     151        const sysarg_t value = 0xaf00;
    149152
    150         int rc = async_req_3_0(parent_phone, DEV_IFACE_ID(PCI_DEV_IFACE),
     153        const int rc = async_req_3_0(parent_phone, DEV_IFACE_ID(PCI_DEV_IFACE),
    151154            IPC_M_CONFIG_SPACE_WRITE_16, address, value);
    152155        async_hangup(parent_phone);
  • uspace/drv/uhci-hcd/pci.h

    r8953514 re247d83  
    3838#include <ddf/driver.h>
    3939
    40 int pci_get_my_registers(ddf_dev_t *, uintptr_t *, size_t *, int *);
    41 int pci_enable_interrupts(ddf_dev_t *);
    42 int pci_disable_legacy(ddf_dev_t *);
     40int pci_get_my_registers(const ddf_dev_t *, uintptr_t *, size_t *, int *);
     41int pci_enable_interrupts(const ddf_dev_t *);
     42int pci_disable_legacy(const ddf_dev_t *);
    4343
    4444#endif
  • uspace/drv/uhci-hcd/root_hub.c

    r8953514 re247d83  
    6060                return ret;
    6161        }
     62        assert(match_str);
    6263
    6364        ret = ddf_fun_add_match_id(fun, match_str, 100);
  • uspace/drv/uhci-hcd/transfer_list.c

    r8953514 re247d83  
    5858                return ENOMEM;
    5959        }
    60         uint32_t queue_head_pa = addr_to_phys(instance->queue_head);
     60        const uint32_t queue_head_pa = addr_to_phys(instance->queue_head);
    6161        usb_log_debug2("Transfer list %s setup with QH: %p (%#" PRIx32" ).\n",
    6262            name, instance->queue_head, queue_head_pa);
     
    9090{
    9191        assert(instance);
     92        assert(instance->queue_head);
    9293        assert(next);
    93         if (!instance->queue_head)
    94                 return;
    9594        /* Set queue_head.next to point to the follower */
    9695        qh_set_next_qh(instance->queue_head, next->queue_head);
     
    137136        write_barrier();
    138137
    139         /* Add to the driver list */
     138        /* Add to the driver's list */
    140139        list_append(&batch->link, &instance->batch_list);
    141140
     
    160159        link_t *current = instance->batch_list.next;
    161160        while (current != &instance->batch_list) {
    162                 link_t *next = current->next;
     161                link_t * const next = current->next;
    163162                usb_transfer_batch_t *batch =
    164163                    usb_transfer_batch_from_link(current);
     
    182181        fibril_mutex_lock(&instance->guard);
    183182        while (!list_empty(&instance->batch_list)) {
    184                 link_t *current = instance->batch_list.next;
     183                link_t * const current = instance->batch_list.next;
    185184                usb_transfer_batch_t *batch =
    186185                    usb_transfer_batch_from_link(current);
  • uspace/drv/uhci-hcd/uhci.c

    r8953514 re247d83  
    7777{
    7878        assert(dev);
    79         hc_t *hc = &((uhci_t*)dev->driver_data)->hc;
     79        uhci_t *uhci = dev->driver_data;
     80        assert(uhci);
     81        hc_t *hc = &uhci->hc;
    8082        uint16_t status = IPC_GET_ARG1(*call);
    8183        assert(hc);
     
    144146{
    145147        assert(fun);
    146         return &((rh_t*)fun->driver_data)->resource_list;
     148        rh_t *rh = fun->driver_data;
     149        assert(rh);
     150        return &rh->resource_list;
    147151}
    148152/*----------------------------------------------------------------------------*/
  • uspace/drv/uhci-hcd/uhci.h

    r8953514 re247d83  
    3535#ifndef DRV_UHCI_UHCI_H
    3636#define DRV_UHCI_UHCI_H
    37 #include <ddi.h>
    3837#include <ddf/driver.h>
    3938
  • uspace/drv/uhci-rhd/port.c

    r8953514 re247d83  
    209209int uhci_port_reset_enable(int portno, void *arg)
    210210{
    211         uhci_port_t *port = (uhci_port_t *) arg;
     211        uhci_port_t *port = arg;
    212212
    213213        usb_log_debug2("%s: new_device_enable_port.\n", port->id_string);
Note: See TracChangeset for help on using the changeset viewer.