Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/uhcirh/port.c

    rffa96c2 r56fd7cf  
    3232 * @brief UHCI root hub port routines
    3333 */
    34 #include <ddi.h>
     34#include <libarch/ddi.h>  /* pio_read and pio_write */
    3535#include <fibril_synch.h> /* async_usleep */
    3636#include <errno.h>
     
    150150{
    151151        uhci_port_t *instance = port;
    152         int rc;
    153152        assert(instance);
    154153
    155154        unsigned allowed_failures = MAX_ERROR_COUNT;
     155#define CHECK_RET_FAIL(ret, msg...) \
     156        if (ret != EOK) { \
     157                usb_log_error(msg); \
     158                if (!(allowed_failures-- > 0)) { \
     159                        usb_log_fatal( \
     160                           "Maximum number of failures reached, " \
     161                           "bailing out.\n"); \
     162                        return ret; \
     163                } \
     164                continue; \
     165        } else (void)0
    156166
    157167        while (1) {
     
    172182                    instance->id_string, port_status);
    173183
    174                 rc = usb_hc_connection_open(&instance->hc_connection);
    175                 if (rc != EOK) {
    176                         usb_log_error("%s: Failed to connect to HC %s.\n",
    177                             instance->id_string, str_error(rc));
    178                         if (!(allowed_failures-- > 0))
    179                                 goto fatal_error;
    180                         continue;
    181                 }
     184                int ret = usb_hc_connection_open(&instance->hc_connection);
     185                CHECK_RET_FAIL(ret, "%s: Failed to connect to HC %s.\n",
     186                    instance->id_string, str_error(ret));
    182187
    183188                /* Remove any old device */
     
    199204                }
    200205
    201                 rc = usb_hc_connection_close(&instance->hc_connection);
    202                 if (rc != EOK) {
    203                         usb_log_error("%s: Failed to disconnect from HC %s.\n",
    204                             instance->id_string, str_error(rc));
    205                         if (!(allowed_failures-- > 0))
    206                                 goto fatal_error;
    207                         continue;
    208                 }
    209         }
    210 
    211         return EOK;
    212 
    213 fatal_error:
    214         usb_log_fatal("Maximum number of failures reached, bailing out.\n");
    215         return rc;
     206                ret = usb_hc_connection_close(&instance->hc_connection);
     207                CHECK_RET_FAIL(ret, "%s: Failed to disconnect from hc: %s.\n",
     208                    instance->id_string, str_error(ret));
     209        }
     210        return EOK;
    216211}
    217212
     
    269264        int ret, count = MAX_ERROR_COUNT;
    270265        do {
    271                 port->attached_device.fun = ddf_fun_create(port->rh, fun_inner,
    272                     NULL);
    273                 if (port->attached_device.fun == NULL) {
    274                         ret = ENOMEM;
    275                         continue;
    276                 }
    277 
    278                 ret = usb_hc_new_device_wrapper(port->rh,
    279                     port->attached_device.fun,
    280                     &port->hc_connection,
     266                ret = usb_hc_new_device_wrapper(port->rh, &port->hc_connection,
    281267                    speed, uhci_port_reset_enable, port,
    282                     &port->attached_device.address, NULL);
    283 
    284                 if (ret != EOK) {
    285                         ddf_fun_destroy(port->attached_device.fun);
    286                         port->attached_device.fun = NULL;
    287                 }
    288 
     268                    &port->attached_device.address, NULL, NULL,
     269                    &port->attached_device.fun);
    289270        } while (ret != EOK && count-- > 0);
    290271
Note: See TracChangeset for help on using the changeset viewer.