Ignore:
File:
1 edited

Legend:

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

    re882e3a rc53007f  
    3232 * @brief UHCI root hub port routines
    3333 */
    34 #include <libarch/ddi.h>  /* pio_read and pio_write */
     34#include <ddi.h>
    3535#include <fibril_synch.h> /* async_usleep */
    3636#include <errno.h>
     
    6363        return pio_read_16(port->address);
    6464}
    65 /*----------------------------------------------------------------------------*/
     65
    6666/** Register writing helper function.
    6767 *
     
    7575        pio_write_16(port->address, val);
    7676}
    77 /*----------------------------------------------------------------------------*/
     77
    7878/** Initialize UHCI root hub port instance.
    7979 *
     
    127127        return EOK;
    128128}
    129 /*----------------------------------------------------------------------------*/
     129
    130130/** Cleanup UHCI root hub port instance.
    131131 *
     
    141141        return;
    142142}
    143 /*----------------------------------------------------------------------------*/
     143
    144144/** Periodically checks port status and reports new devices.
    145145 *
     
    150150{
    151151        uhci_port_t *instance = port;
     152        int rc;
    152153        assert(instance);
    153154
    154155        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
    166156
    167157        while (1) {
     
    182172                    instance->id_string, port_status);
    183173
    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));
     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                }
    187182
    188183                /* Remove any old device */
     
    204199                }
    205200
    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;
    211 }
    212 /*----------------------------------------------------------------------------*/
     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
     213fatal_error:
     214        usb_log_fatal("Maximum number of failures reached, bailing out.\n");
     215        return rc;
     216}
     217
    213218/** Callback for enabling port during adding a new device.
    214219 *
     
    247252        return EOK;
    248253}
    249 /*----------------------------------------------------------------------------*/
     254
    250255/** Initialize and report connected device.
    251256 *
     
    279284        usb_log_info("%s: New device, address %d (handle %" PRIun ").\n",
    280285            port->id_string, port->attached_device.address,
    281             port->attached_device.fun->handle);
    282         return EOK;
    283 }
    284 /*----------------------------------------------------------------------------*/
     286            ddf_fun_get_handle(port->attached_device.fun));
     287        return EOK;
     288}
     289
    285290/** Remove device.
    286291 *
     
    324329        return EOK;
    325330}
    326 /*----------------------------------------------------------------------------*/
     331
    327332/** Enable or disable root hub port.
    328333 *
     
    358363        return EOK;
    359364}
    360 /*----------------------------------------------------------------------------*/
     365
    361366/** Print the port status value in a human friendly way
    362367 *
Note: See TracChangeset for help on using the changeset viewer.