On Thu, 8 Nov 2012, Pratyush Anand wrote:

> USB specs says that if an over-current is detected then a hub must switch off
> all affected port, wait to cool down and then switch on.
> 
> There are few controllers, which does not follow it, and expects software
> to switch off the port power.

Can you give any examples?

> This patch will add workaround for such controllers.
> 
> I think it will not affect others, even if HW switch off the port power.
> 
> Signed-off-by: Pratyush Anand <pratyush.an...@st.com>
> ---
>  drivers/usb/core/hub.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> index 1af04bd..6674344 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -4531,6 +4531,9 @@ static void hub_events(void)
>  
>                               dev_dbg(hub_dev, "over-current change on port "
>                                       "%d\n", i);
> +                             if (hdev == hdev->bus->root_hub)

Normally we test for root hubs by doing:

                                if (!hdev->parent)

You also might want to avoid turning off the power feature if it is 
already off:

                                if (!hdev->parent && (portstatus &
                                                USB_PORT_STAT_POWER))

> +                                     clear_port_feature(hdev, i,
> +                                             USB_PORT_FEAT_POWER);
>                               clear_port_feature(hdev, i,
>                                       USB_PORT_FEAT_C_OVER_CURRENT);
>                               msleep(100);    /* Cool down */

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to