Changeset e6edc8d1 in mainline for uspace/drv/bus/usb/ehci/res.c


Ignore:
Timestamp:
2013-07-11T19:13:37Z (11 years ago)
Author:
Manuele Conti <conti.ma@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
67632f7
Parents:
52ff62d3 (diff), 2b3e8840 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge with mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ehci/res.c

    r52ff62d3 re6edc8d1  
    145145                return ENOMEM;
    146146
    147 #define CHECK_RET_HANGUP_RETURN(ret, message...) \
    148         if (ret != EOK) { \
    149                 usb_log_error(message); \
    150                 async_hangup(parent_sess); \
    151                 return ret; \
    152         } else (void)0
    153 
    154147        /* Read the first EEC. i.e. Legacy Support register */
    155148        uint32_t usblegsup;
    156         int ret = pci_config_space_read_32(parent_sess,
     149        int rc = pci_config_space_read_32(parent_sess,
    157150            eecp + USBLEGSUP_OFFSET, &usblegsup);
    158         CHECK_RET_HANGUP_RETURN(ret,
    159             "Failed to read USBLEGSUP: %s.\n", str_error(ret));
     151        if (rc != EOK) {
     152                usb_log_error("Failed to read USBLEGSUP: %s.\n",
     153                    str_error(rc));
     154                goto error;
     155        }
     156
    160157        usb_log_debug("USBLEGSUP: %" PRIx32 ".\n", usblegsup);
    161158
     
    163160         * byte. (OS Control semaphore)*/
    164161        usb_log_debug("Requesting OS control.\n");
    165         ret = pci_config_space_write_8(parent_sess,
     162        rc = pci_config_space_write_8(parent_sess,
    166163            eecp + USBLEGSUP_OFFSET + 3, 1);
    167         CHECK_RET_HANGUP_RETURN(ret, "Failed to request OS EHCI control: %s.\n",
    168             str_error(ret));
     164        if (rc != EOK) {
     165                usb_log_error("Failed to request OS EHCI control: %s.\n",
     166                    str_error(rc));
     167                goto error;
     168        }
    169169
    170170        size_t wait = 0;
    171171        /* Wait for BIOS to release control. */
    172         ret = pci_config_space_read_32(
     172        rc = pci_config_space_read_32(
    173173            parent_sess, eecp + USBLEGSUP_OFFSET, &usblegsup);
     174        if (rc != EOK) {
     175                usb_log_error("Failed reading PCI config space: %s.\n",
     176                    str_error(rc));
     177                goto error;
     178        }
     179
    174180        while ((wait < DEFAULT_WAIT) && (usblegsup & USBLEGSUP_BIOS_CONTROL)) {
    175181                async_usleep(WAIT_STEP);
    176                 ret = pci_config_space_read_32(parent_sess,
     182                rc = pci_config_space_read_32(parent_sess,
    177183                    eecp + USBLEGSUP_OFFSET, &usblegsup);
     184                if (rc != EOK) {
     185                        usb_log_error("Failed reading PCI config space: %s.\n",
     186                            str_error(rc));
     187                        goto error;
     188                }
    178189                wait += WAIT_STEP;
    179190        }
     
    188199        usb_log_warning( "BIOS failed to release control after "
    189200            "%zu usecs, force it.\n", wait);
    190         ret = pci_config_space_write_32(parent_sess,
     201        rc = pci_config_space_write_32(parent_sess,
    191202            eecp + USBLEGSUP_OFFSET, USBLEGSUP_OS_CONTROL);
    192         CHECK_RET_HANGUP_RETURN(ret, "Failed to force OS control: "
    193             "%s.\n", str_error(ret));
     203        if (rc != EOK) {
     204                usb_log_error("Failed to force OS control: "
     205                    "%s.\n", str_error(rc));
     206                goto error;
     207        }
     208
    194209        /*
    195210         * Check capability type here, value of 01h identifies the capability
     
    201216                /* Read the second EEC Legacy Support and Control register */
    202217                uint32_t usblegctlsts;
    203                 ret = pci_config_space_read_32(parent_sess,
     218                rc = pci_config_space_read_32(parent_sess,
    204219                    eecp + USBLEGCTLSTS_OFFSET, &usblegctlsts);
    205                 CHECK_RET_HANGUP_RETURN(ret, "Failed to get USBLEGCTLSTS: %s.\n",
    206                     str_error(ret));
     220                if (rc != EOK) {
     221                        usb_log_error("Failed to get USBLEGCTLSTS: %s.\n",
     222                            str_error(rc));
     223                        goto error;
     224                }
     225
    207226                usb_log_debug("USBLEGCTLSTS: %" PRIx32 ".\n", usblegctlsts);
    208227                /*
     
    211230                 * interfering. NOTE: Three upper bits are WC
    212231                 */
    213                 ret = pci_config_space_write_32(parent_sess,
     232                rc = pci_config_space_write_32(parent_sess,
    214233                    eecp + USBLEGCTLSTS_OFFSET, 0xe0000000);
    215                 CHECK_RET_HANGUP_RETURN(ret, "Failed(%d) zero USBLEGCTLSTS.\n", ret);
     234                if (rc != EOK) {
     235                        usb_log_error("Failed(%d) zero USBLEGCTLSTS.\n", rc);
     236                        goto error;
     237                }
     238
    216239                udelay(10);
    217                 ret = pci_config_space_read_32(parent_sess,
     240                rc = pci_config_space_read_32(parent_sess,
    218241                    eecp + USBLEGCTLSTS_OFFSET, &usblegctlsts);
    219                 CHECK_RET_HANGUP_RETURN(ret, "Failed to get USBLEGCTLSTS 2: %s.\n",
    220                     str_error(ret));
     242                if (rc != EOK) {
     243                        usb_log_error("Failed to get USBLEGCTLSTS 2: %s.\n",
     244                            str_error(rc));
     245                        goto error;
     246                }
     247
    221248                usb_log_debug("Zeroed USBLEGCTLSTS: %" PRIx32 ".\n",
    222249                    usblegctlsts);
     
    224251
    225252        /* Read again Legacy Support register */
    226         ret = pci_config_space_read_32(parent_sess,
     253        rc = pci_config_space_read_32(parent_sess,
    227254            eecp + USBLEGSUP_OFFSET, &usblegsup);
    228         CHECK_RET_HANGUP_RETURN(ret, "Failed to read USBLEGSUP: %s.\n",
    229             str_error(ret));
     255        if (rc != EOK) {
     256                usb_log_error("Failed to read USBLEGSUP: %s.\n",
     257                    str_error(rc));
     258                goto error;
     259        }
     260
    230261        usb_log_debug("USBLEGSUP: %" PRIx32 ".\n", usblegsup);
    231262        async_hangup(parent_sess);
    232263        return EOK;
    233 #undef CHECK_RET_HANGUP_RETURN
     264error:
     265        async_hangup(parent_sess);
     266        return rc;
    234267}
    235268
     
    239272        usb_log_debug("Disabling EHCI legacy support.\n");
    240273
    241 #define CHECK_RET_RETURN(ret, message...) \
    242         if (ret != EOK) { \
    243                 usb_log_error(message); \
    244                 return ret; \
    245         } else (void)0
    246 
    247274        /* Map EHCI registers */
    248275        void *regs = NULL;
    249         int ret = pio_enable((void*)reg_base, reg_size, &regs);
    250         CHECK_RET_RETURN(ret, "Failed to map registers %p: %s.\n",
    251             (void *) reg_base, str_error(ret));
     276        int rc = pio_enable((void*)reg_base, reg_size, &regs);
     277        if (rc != EOK) {
     278                usb_log_error("Failed to map registers %p: %s.\n",
     279                    (void *) reg_base, str_error(rc));
     280                return rc;
     281        }
    252282
    253283        usb_log_debug2("Registers mapped at: %p.\n", regs);
     
    263293        usb_log_debug("Value of EECP: %x.\n", eecp);
    264294
    265         ret = disable_extended_caps(device, eecp);
    266         CHECK_RET_RETURN(ret, "Failed to disable extended capabilities: %s.\n",
    267             str_error(ret));
    268 
    269 #undef CHECK_RET_RETURN
     295        rc = disable_extended_caps(device, eecp);
     296        if (rc != EOK) {
     297                usb_log_error("Failed to disable extended capabilities: %s.\n",
     298                    str_error(rc));
     299                return rc;
     300        }
    270301
    271302        /*
     
    306337            usbcmd, *usbcmd, usbsts, *usbsts, usbint, *usbint, usbconf,*usbconf);
    307338
    308         return ret;
     339        return rc;
    309340}
    310341
Note: See TracChangeset for help on using the changeset viewer.