Re: [U-Boot] [PATCH v2 3/4] dm: usb: Use device_unbind_children to clean up usb devs on stop
On 3 July 2015 at 17:06, Simon Glass s...@chromium.org wrote: On 1 July 2015 at 12:53, Hans de Goede hdego...@redhat.com wrote: On an usb stop instead of leaving orphan usb devices behind simply remove them. The result of this commit is best seen in the output of dm tree after plugging out an usb hub with 2 devices plugges in and plugging in a keyb. instead, before this commit the output would be: usb [ + ]`-- sunxi-musb usb_hub [ ]|-- usb_hub usb_mass_st [ ]| |-- usb_mass_storage usb_dev_gen [ ]| `-- generic_bus_0_dev_3 usb_dev_gen [ + ]`-- generic_bus_0_dev_1 Notice the non active usb_hub child and its 2 non active children. The first child being non-active as in this example also causes usb_get_dev_index to return NULL when probing the first child, which results in the usb kbd code not binding to the keyboard. With this commit in place the output after swapping and usb reset is: usb [ + ]`-- sunxi-musb usb_dev_gen [ + ]`-- generic_bus_0_dev_1 As expected, and usb_get_dev_index works properly and the keyboard works. Signed-off-by: Hans de Goede hdego...@redhat.com --- Changes in v2: -We only need to call device_unbind_children, the children are removed already by the device_remove call on the host -Do not add #ifdef-s around usb_stop() --- drivers/usb/host/usb-uclass.c | 3 +++ 1 file changed, 3 insertions(+) Acked-by: Simon Glass s...@chromium.org Applied to u-boot-dm/next, thanks! ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2 3/4] dm: usb: Use device_unbind_children to clean up usb devs on stop
On 1 July 2015 at 12:53, Hans de Goede hdego...@redhat.com wrote: On an usb stop instead of leaving orphan usb devices behind simply remove them. The result of this commit is best seen in the output of dm tree after plugging out an usb hub with 2 devices plugges in and plugging in a keyb. instead, before this commit the output would be: usb [ + ]`-- sunxi-musb usb_hub [ ]|-- usb_hub usb_mass_st [ ]| |-- usb_mass_storage usb_dev_gen [ ]| `-- generic_bus_0_dev_3 usb_dev_gen [ + ]`-- generic_bus_0_dev_1 Notice the non active usb_hub child and its 2 non active children. The first child being non-active as in this example also causes usb_get_dev_index to return NULL when probing the first child, which results in the usb kbd code not binding to the keyboard. With this commit in place the output after swapping and usb reset is: usb [ + ]`-- sunxi-musb usb_dev_gen [ + ]`-- generic_bus_0_dev_1 As expected, and usb_get_dev_index works properly and the keyboard works. Signed-off-by: Hans de Goede hdego...@redhat.com --- Changes in v2: -We only need to call device_unbind_children, the children are removed already by the device_remove call on the host -Do not add #ifdef-s around usb_stop() --- drivers/usb/host/usb-uclass.c | 3 +++ 1 file changed, 3 insertions(+) Acked-by: Simon Glass s...@chromium.org ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 3/4] dm: usb: Use device_unbind_children to clean up usb devs on stop
On an usb stop instead of leaving orphan usb devices behind simply remove them. The result of this commit is best seen in the output of dm tree after plugging out an usb hub with 2 devices plugges in and plugging in a keyb. instead, before this commit the output would be: usb [ + ]`-- sunxi-musb usb_hub [ ]|-- usb_hub usb_mass_st [ ]| |-- usb_mass_storage usb_dev_gen [ ]| `-- generic_bus_0_dev_3 usb_dev_gen [ + ]`-- generic_bus_0_dev_1 Notice the non active usb_hub child and its 2 non active children. The first child being non-active as in this example also causes usb_get_dev_index to return NULL when probing the first child, which results in the usb kbd code not binding to the keyboard. With this commit in place the output after swapping and usb reset is: usb [ + ]`-- sunxi-musb usb_dev_gen [ + ]`-- generic_bus_0_dev_1 As expected, and usb_get_dev_index works properly and the keyboard works. Signed-off-by: Hans de Goede hdego...@redhat.com --- Changes in v2: -We only need to call device_unbind_children, the children are removed already by the device_remove call on the host -Do not add #ifdef-s around usb_stop() --- drivers/usb/host/usb-uclass.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c index bce6cec..2df6740 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -146,6 +146,9 @@ int usb_stop(void) ret = device_remove(bus); if (ret !err) err = ret; + ret = device_unbind_children(bus); + if (ret !err) + err = ret; } #ifdef CONFIG_SANDBOX -- 2.4.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot