/**
 * This function will be invoked when usb device plug out is detected and it would clean
 * and release all hub class related resources.
 *
 * @param arg the argument.
 *
 * @return the error code, RT_EOK on successfully.
 */
static rt_err_t rt_usb_adk_stop(void* arg)
{
    uadkinst_t adkinst;
    uifinst_t ifinst = (uifinst_t)arg;

    RT_ASSERT(ifinst != RT_NULL);

    RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usb_adk_stop\n"));

    adkinst = (uadkinst_t)ifinst->user_data;
    if(adkinst == RT_NULL)
    {
        rt_free(ifinst);
        return RT_EOK;
    }

    if(adkinst->pipe_in != RT_NULL)
        rt_usb_hcd_free_pipe(ifinst->uinst->hcd, adkinst->pipe_in);

    if(adkinst->pipe_out != RT_NULL)
        rt_usb_hcd_free_pipe(ifinst->uinst->hcd, adkinst->pipe_out);

    /* unregister adk device */
    rt_device_unregister(&adkinst->device);

    /* free adk instance */
    if(adkinst != RT_NULL) rt_free(adkinst);

    /* free interface instance */
    rt_free(ifinst);

    return RT_EOK;
}
Пример #2
0
/**
 * This function will be invoked when usb hub plug out is detected and it would clean 
 * and release all hub class related resources.
 *
 * @param arg the argument.
 * 
 * @return the error code, RT_EOK on successfully.
 */
static rt_err_t rt_usbh_hub_disable(void* arg)
{
    int i;
    uhub_t hub;
    struct uinstance* device;
    struct uintf* intf = (struct uintf*)arg;

    /* paremeter check */
    RT_ASSERT(intf != RT_NULL);

    RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_hub_stop\n"));

    device = intf->device;
    hub = (uhub_t)intf->user_data;

    if(hub->pipe_in != RT_NULL)
        rt_usb_hcd_free_pipe(device->hcd, hub->pipe_in);

    for(i=0; i<hub->num_ports; i++)
    {
        if(hub->child[i] != RT_NULL)
            rt_usbh_detach_instance(hub->child[i]);
    }
    
    if(hub != RT_NULL) rt_free(hub);
    if(intf != RT_NULL) rt_free(intf);

    return RT_EOK;
}
Пример #3
0
/**
 * This function will be invoked when usb hub plug out is detected and it would clean 
 * and release all hub class related resources.
 *
 * @param arg the argument.
 * 
 * @return the error code, RT_EOK on successfully.
 */
static rt_err_t rt_usb_hub_stop(void* arg)
{
    int i;
    uhubinst_t uhub;
    uinst_t uinst;
    uifinst_t ifinst = (uifinst_t)arg;

    /* paremeter check */
    RT_ASSERT(ifinst != RT_NULL);

    RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usb_hub_stop\n"));

    uinst = ifinst->uinst;
    uhub = (uhubinst_t)ifinst->user_data;

    if(uhub->pipe_in != RT_NULL)
        rt_usb_hcd_free_pipe(uinst->hcd, uhub->pipe_in);

    for(i=0; i<uhub->num_ports; i++)
    {
        if(uhub->child[i] != RT_NULL)
            rt_usb_detach_instance(uhub->child[i]);
    }
    
    if(uhub != RT_NULL) rt_free(uhub);
    if(ifinst != RT_NULL) rt_free(ifinst);

    return RT_EOK;
}
Пример #4
0
/**
 * This function will be invoked when usb device plug out is detected and it would clean 
 * and release all hub class related resources.
 *
 * @param arg the argument.
 * 
 * @return the error code, RT_EOK on successfully.
 */
static rt_err_t rt_usbh_adk_disable(void* arg)
{
    uadk_t adk;
    struct uintf* intf = (struct uintf*)arg;

    RT_ASSERT(intf != RT_NULL);

    RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_adk_stop\n"));

    adk = (uadk_t)intf->user_data;
    if(adk == RT_NULL) 
    {
        rt_free(intf);    
        return RT_EOK;
    }
    
    if(adk->pipe_in != RT_NULL)
        rt_usb_hcd_free_pipe(intf->device->hcd, adk->pipe_in);

    if(adk->pipe_out != RT_NULL)
        rt_usb_hcd_free_pipe(intf->device->hcd, adk->pipe_out);

    /* unregister adk device */
    rt_device_unregister(&adk->device);

    /* free adk instance */
    if(adk != RT_NULL) 
    {
        rt_free(adk);
    }
    
    /* free interface instance */
    rt_free(intf);

    return RT_EOK;
}