Changes in / [edc4c66:a19a2d7] in mainline


Ignore:
Location:
uspace
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhub/ports.c

    redc4c66 ra19a2d7  
    181181                 */
    182182        } else {
    183                 // TODO: is this really reason to print a warning?
    184                 usb_log_warning("Device removed before being registered.\n");
    185 
    186                 /*
    187                  * Device was removed before port reset completed.
    188                  * We will announce a failed port reset to unblock the
    189                  * port reset callback from new device wrapper.
    190                  */
    191                 usb_hub_port_t *the_port = hub->ports + port;
    192                 fibril_mutex_lock(&the_port->reset_mutex);
    193                 the_port->reset_completed = true;
    194                 the_port->reset_okay = false;
    195                 fibril_condvar_broadcast(&the_port->reset_cv);
    196                 fibril_mutex_unlock(&the_port->reset_mutex);
     183                usb_log_warning("this is strange, disconnected device had "
     184                        "no address\n");
     185                //device was disconnected before it`s port was reset -
     186                //return default address
     187                usb_hub_release_default_address(hub);
    197188        }
    198189}
     
    216207                fibril_mutex_lock(&the_port->reset_mutex);
    217208                the_port->reset_completed = true;
    218                 the_port->reset_okay = true;
    219209                fibril_condvar_broadcast(&the_port->reset_cv);
    220210                fibril_mutex_unlock(&the_port->reset_mutex);
     
    329319        }
    330320
    331         if (my_port->reset_okay) {
    332                 return EOK;
    333         } else {
    334                 return ESTALL;
    335         }
     321        return EOK;
    336322}
    337323
  • uspace/drv/usbhub/ports.h

    redc4c66 ra19a2d7  
    5151         */
    5252        bool reset_completed;
    53         /** Whether to announce the port reset as successful. */
    54         bool reset_okay;
    5553
    5654        /** Information about attached device. */
  • uspace/drv/usbhub/usbhub.c

    redc4c66 ra19a2d7  
    177177
    178178        return true;
     179}
     180
     181/**
     182 * release default address used by given hub
     183 *
     184 * Also unsets hub->is_default_address_used. Convenience wrapper function.
     185 * @note hub->connection MUST be open for communication
     186 * @param hub hub representation
     187 * @return error code
     188 */
     189int usb_hub_release_default_address(usb_hub_info_t * hub) {
     190        int opResult = usb_hc_release_default_address(&hub->connection);
     191        if (opResult != EOK) {
     192                usb_log_error("could not release default address, errno %d\n",
     193                    opResult);
     194                return opResult;
     195        }
     196        hub->is_default_address_used = false;
     197        return EOK;
    179198}
    180199
  • uspace/drv/usbhub/usbhub.h

    redc4c66 ra19a2d7  
    9898    uint8_t *change_bitmap, size_t change_bitmap_size, void *arg);
    9999
     100int usb_hub_release_default_address(usb_hub_info_t * hub);
     101
    100102#endif
    101103/**
  • uspace/drv/vhc/connhost.c

    redc4c66 ra19a2d7  
    324324}
    325325
     326static int reserve_default_address(ddf_fun_t *fun, usb_speed_t ignored)
     327{
     328        usb_address_keeping_reserve_default(&addresses);
     329        return EOK;
     330}
     331
     332static int release_default_address(ddf_fun_t *fun)
     333{
     334        usb_address_keeping_release_default(&addresses);
     335        return EOK;
     336}
     337
    326338static int request_address(ddf_fun_t *fun, usb_speed_t ignored,
    327339    usb_address_t *address)
     
    376388
    377389usbhc_iface_t vhc_iface = {
     390        .reserve_default_address = reserve_default_address,
     391        .release_default_address = release_default_address,
    378392        .request_address = request_address,
    379393        .bind_address = bind_address,
  • uspace/lib/drv/generic/remote_usbhc.c

    redc4c66 ra19a2d7  
    5050static void remote_usbhc_control_write(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    5151static void remote_usbhc_control_read(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     52static void remote_usbhc_reserve_default_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     53static void remote_usbhc_release_default_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    5254static void remote_usbhc_request_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
    5355static void remote_usbhc_bind_address(ddf_fun_t *, void *, ipc_callid_t, ipc_call_t *);
     
    5961/** Remote USB host controller interface operations. */
    6062static remote_iface_func_ptr_t remote_usbhc_iface_ops [] = {
     63        remote_usbhc_reserve_default_address,
     64        remote_usbhc_release_default_address,
     65
    6166        remote_usbhc_request_address,
    6267        remote_usbhc_bind_address,
     
    122127
    123128        return trans;
     129}
     130
     131void remote_usbhc_reserve_default_address(ddf_fun_t *fun, void *iface,
     132    ipc_callid_t callid, ipc_call_t *call)
     133{
     134        usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;
     135
     136        if (!usb_iface->reserve_default_address) {
     137                async_answer_0(callid, ENOTSUP);
     138                return;
     139        }
     140       
     141        usb_speed_t speed = DEV_IPC_GET_ARG1(*call);
     142       
     143        int rc = usb_iface->reserve_default_address(fun, speed);
     144
     145        async_answer_0(callid, rc);
     146}
     147
     148void remote_usbhc_release_default_address(ddf_fun_t *fun, void *iface,
     149    ipc_callid_t callid, ipc_call_t *call)
     150{
     151        usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;
     152
     153        if (!usb_iface->release_default_address) {
     154                async_answer_0(callid, ENOTSUP);
     155                return;
     156        }
     157
     158        int rc = usb_iface->release_default_address(fun);
     159
     160        async_answer_0(callid, rc);
    124161}
    125162
  • uspace/lib/drv/include/usbhc_iface.h

    redc4c66 ra19a2d7  
    8484 */
    8585typedef enum {
     86        /** Reserve usage of default address.
     87         * This call informs the host controller that the caller will be
     88         * using default USB address. It is duty of the HC driver to ensure
     89         * that only single entity will have it reserved.
     90         * The address is returned via IPC_M_USBHC_RELEASE_DEFAULT_ADDRESS.
     91         * The caller can start using the address after receiving EOK
     92         * answer.
     93         */
     94        IPC_M_USBHC_RESERVE_DEFAULT_ADDRESS,
     95
     96        /** Release usage of default address.
     97         * @see IPC_M_USBHC_RESERVE_DEFAULT_ADDRESS
     98         */
     99        IPC_M_USBHC_RELEASE_DEFAULT_ADDRESS,
     100
    86101        /** Asks for address assignment by host controller.
    87102         * Answer:
  • uspace/lib/usb/include/usb/hub.h

    redc4c66 ra19a2d7  
    5959} usb_hc_attached_device_t;
    6060
     61int usb_hc_reserve_default_address(usb_hc_connection_t *, usb_speed_t);
     62int usb_hc_release_default_address(usb_hc_connection_t *);
     63
    6164usb_address_t usb_hc_request_address(usb_hc_connection_t *, usb_speed_t);
    6265int usb_hc_register_device(usb_hc_connection_t *,
  • uspace/lib/usb/src/host/endpoint.c

    redc4c66 ra19a2d7  
    9999        assert(instance);
    100100        if (instance->address == target.address &&
    101             (instance->endpoint == target.endpoint || target.endpoint == 0))
     101            instance->endpoint == target.endpoint)
    102102                instance->toggle = 0;
    103103}
  • uspace/lib/usb/src/hub.c

    redc4c66 ra19a2d7  
    4242#include <usb/debug.h>
    4343
    44 /** How much time to wait between attempts to register endpoint 0:0.
    45  * The value is based on typical value for port reset + some overhead.
    46  */
    47 #define ENDPOINT_0_0_REGISTER_ATTEMPT_DELAY_USEC (1000 * (10 + 2))
    48 
    4944/** Check that HC connection is alright.
    5045 *
     
    5853                } \
    5954        } while (false)
     55
     56
     57/** Tell host controller to reserve default address.
     58 * @deprecated
     59 *
     60 * @param connection Opened connection to host controller.
     61 * @param speed Speed of the device that will respond on the default address.
     62 * @return Error code.
     63 */
     64int usb_hc_reserve_default_address(usb_hc_connection_t *connection,
     65    usb_speed_t speed)
     66{
     67        CHECK_CONNECTION(connection);
     68
     69        usb_log_warning("usb_hc_reserve_default_address() considered obsolete");
     70
     71        return async_req_2_0(connection->hc_phone,
     72            DEV_IFACE_ID(USBHC_DEV_IFACE),
     73            IPC_M_USBHC_RESERVE_DEFAULT_ADDRESS, speed);
     74}
     75
     76/** Tell host controller to release default address.
     77 * @deprecated
     78 *
     79 * @param connection Opened connection to host controller.
     80 * @return Error code.
     81 */
     82int usb_hc_release_default_address(usb_hc_connection_t *connection)
     83{
     84        CHECK_CONNECTION(connection);
     85
     86        usb_log_warning("usb_hc_release_default_address() considered obsolete");
     87
     88        return async_req_1_0(connection->hc_phone,
     89            DEV_IFACE_ID(USBHC_DEV_IFACE),
     90            IPC_M_USBHC_RELEASE_DEFAULT_ADDRESS);
     91}
    6092
    6193/** Ask host controller for free address assignment.
     
    237269                if (rc != EOK) {
    238270                        /* Do not overheat the CPU ;-). */
    239                         async_usleep(ENDPOINT_0_0_REGISTER_ATTEMPT_DELAY_USEC);
     271                        async_usleep(10);
    240272                }
    241273        } while (rc != EOK);
Note: See TracChangeset for help on using the changeset viewer.