[linux-usb] Is UAC1 (USB Audio Class 1.0) broken?
Hi Community, Felipe, I am trying to get UAC1 working on Freescale i.MX6SL EVK board (as USB peripheral device), which is based on kernel 3.10.17. In order to get UAC1 working with my Ubuntu 12.04 LTS host, I have to make a few changes to driver/usb/gadget/f_uac1.c I check Mr. Torvald's master branch, some kernel stable branches, something similar to my change to f_uac1.c is not there. Then, I did some more basic testing, and found: 1) Windows 7 can not detect. Still need more work to get Windows 7 detected. 2) MacOS (forgot exact version) complains 'The selected device has no output controls', which results in that I can not adjust volume. Music playback via UAC1 on MacOS is no problem. Anybody tried UAC1 (or UAC2) recently? Is UAC1 broken? Thanks. Xuebing Wang -- 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
[PATCH] usb: phy: return -ENODEV on failure of try_module_get
When __usb_find_phy_dev() does not return error and try_module_get() fails, return -ENODEV Signed-off-by: Arjun Sreedharan --- drivers/usb/phy/phy.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c index 36b6bce..8ad3638 100644 --- a/drivers/usb/phy/phy.c +++ b/drivers/usb/phy/phy.c @@ -232,6 +232,7 @@ struct usb_phy *usb_get_phy_dev(struct device *dev, u8 index) phy = __usb_find_phy_dev(dev, &phy_bind_list, index); if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) { dev_dbg(dev, "unable to find transceiver\n"); + phy = IS_ERR(phy) ? phy : ERR_PTR(-ENODEV); goto err0; } -- 1.7.11.7 -- 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
[PATCH] usb: gadget: remove $(PWD) in ccflags-y
The variable $(PWD) is useless, and it may break the compilation. For example, it breaks the kernel compilation when it's done with buildroot : /home/trem/Codes/armadeus/armadeus/buildroot/output/host/usr/bin/ccache /home/trem/Codes/armadeus/armadeus/buildroot/output/host/usr/bin/arm-buildroot-linux-uclibcgnueabi-gcc -Wp,-MD,drivers/usb/gadget/legacy/.hid.o.d -nostdinc -isystem /home/trem/Codes/armadeus/armadeus/buildroot/output/host/usr/lib/gcc/arm-buildroot-linux-uclibcgnueabi/4.7.3/include -I./arch/arm/include -Iarch/arm/include/generated -Iinclude -I./arch/arm/include/uapi -Iarch/arm/include/generated/uapi -I./include/uapi -Iinclude/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -mlittle-endian -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-dwarf2-cfi-asm -mabi=aapcs-linux -mno-thumb-interwork -mfpu=vfp -funwind-tables -marm -D__LINUX_ARM_ARCH__=5 -march=armv5te -mtune=arm9tdmi -msoft-float -Uarm -fno-delete-null-pointer-checks -O2 --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fno-stack-protector -Wno-unused-but-set-variable -fomit-frame-pointer -fno-var-tracking-assignments -g -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -DCC_HAVE_ASM_GOTO -I/home/trem/Codes/armadeus/armadeus/buildroot/drivers/usb/gadget/ -I/home/trem/Codes/armadeus/armadeus/buildroot/drivers/usb/gadget/udc/ -I/home/trem/Codes/armadeus/armadeus/buildroot/drivers/usb/gadget/function/ -DMODULE -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(hid)" -D"KBUILD_MODNAME=KBUILD_STR(g_hid)" -c -o drivers/usb/gadget/legacy/hid.o drivers/usb/gadget/legacy/hid.c drivers/usb/gadget/epautoconf.c:23:26: erreur fatale: gadget_chips.h : Aucun fichier ou dossier de ce type This compilation line include : /buildroot/driver/usb/gadget but the real path is : /buildroot/output/build/linux-3.17-rc1/driver/usb/gadget Signed-off-by: Philippe Reynes --- drivers/usb/gadget/Makefile |2 +- drivers/usb/gadget/function/Makefile |4 ++-- drivers/usb/gadget/legacy/Makefile |6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile index a186afe..9add915 100644 --- a/drivers/usb/gadget/Makefile +++ b/drivers/usb/gadget/Makefile @@ -3,7 +3,7 @@ # subdir-ccflags-$(CONFIG_USB_GADGET_DEBUG) := -DDEBUG subdir-ccflags-$(CONFIG_USB_GADGET_VERBOSE)+= -DVERBOSE_DEBUG -ccflags-y += -I$(PWD)/drivers/usb/gadget/udc +ccflags-y += -Idrivers/usb/gadget/udc obj-$(CONFIG_USB_LIBCOMPOSITE) += libcomposite.o libcomposite-y := usbstring.o config.o epautoconf.o diff --git a/drivers/usb/gadget/function/Makefile b/drivers/usb/gadget/function/Makefile index 6d91f21..83ae106 100644 --- a/drivers/usb/gadget/function/Makefile +++ b/drivers/usb/gadget/function/Makefile @@ -2,8 +2,8 @@ # USB peripheral controller drivers # -ccflags-y := -I$(PWD)/drivers/usb/gadget/ -ccflags-y += -I$(PWD)/drivers/usb/gadget/udc/ +ccflags-y := -Idrivers/usb/gadget/ +ccflags-y += -Idrivers/usb/gadget/udc/ # USB Functions usb_f_acm-y:= f_acm.o diff --git a/drivers/usb/gadget/legacy/Makefile b/drivers/usb/gadget/legacy/Makefile index a11aad5..edba2d1 100644 --- a/drivers/usb/gadget/legacy/Makefile +++ b/drivers/usb/gadget/legacy/Makefile @@ -2,9 +2,9 @@ # USB gadget drivers # -ccflags-y := -I$(PWD)/drivers/usb/gadget/ -ccflags-y += -I$(PWD)/drivers/usb/gadget/udc/ -ccflags-y += -I$(PWD)/drivers/usb/gadget/function/ +ccflags-y := -Idrivers/usb/gadget/ +ccflags-y += -Idrivers/usb/gadget/udc/ +ccflags-y += -Idrivers/usb/gadget/function/ g_zero-y := zero.o g_audio-y := audio.o -- 1.7.4.4 -- 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
Re: [PATCH 1/7] usb-phy: samsung-usb3: Remove older phy-samsung-usb3 driver
On Thursday, August 14, 2014 11:24 PM, Vivek Gautam wrote: > > Removing this older USB 3.0 DRD controller PHY driver, since > a new driver based on generic phy framework is now available. > > Signed-off-by: Vivek Gautam Reviewed-by: Jingoo Han Best regards, Jingoo Han > --- > drivers/usb/phy/Kconfig|8 - > drivers/usb/phy/Makefile |1 - > drivers/usb/phy/phy-samsung-usb.h | 80 - > drivers/usb/phy/phy-samsung-usb3.c | 350 > > 4 files changed, 439 deletions(-) > delete mode 100644 drivers/usb/phy/phy-samsung-usb3.c -- 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
Re: [PATCH RFC 6/7] usb: host: ehci-exynos: Remove unnecessary usb-phy support
On Thursday, August 14, 2014 11:24 PM, Vivek Gautam wrote: > > Now that we have completely moved from older USB-PHY drivers > to newer GENERIC-PHY drivers for PHYs available with USB controllers > on Exynos series of SoCs, we can remove the support for the same > in our host drivers too. > This should fix the issue on ehci-exynos, wherein in the absence of > SAMSUNG_USB2PHY config symbol, we ended up getting the NOP_USB_XCEIV phy > when the same is enabled. And thus the PHYs are not configured properly. > > Reported-by: Sachin Kamat > Signed-off-by: Vivek Gautam Reviewed-by: Jingoo Han Best regards, Jingoo Han > --- > drivers/usb/host/ehci-exynos.c | 53 > ++-- > 1 file changed, 8 insertions(+), 45 deletions(-) > > diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c > index cda0a2f..54944cc 100644 > --- a/drivers/usb/host/ehci-exynos.c > +++ b/drivers/usb/host/ehci-exynos.c > @@ -21,11 +21,8 @@ > #include > #include > #include > -#include > -#include > #include > #include > -#include > > #include "ehci.h" > > @@ -47,9 +44,7 @@ static struct hc_driver __read_mostly exynos_ehci_hc_driver; > > struct exynos_ehci_hcd { > struct clk *clk; > - struct usb_phy *phy; > - struct usb_otg *otg; > - struct phy *phy_g[PHY_NUMBER]; > + struct phy *phy[PHY_NUMBER]; > }; > > #define to_exynos_ehci(hcd) (struct exynos_ehci_hcd > *)(hcd_to_ehci(hcd)->priv) > @@ -62,18 +57,6 @@ static int exynos_ehci_get_phy(struct device *dev, > int phy_number; > int ret = 0; > > - exynos_ehci->phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); > - if (IS_ERR(exynos_ehci->phy)) { > - ret = PTR_ERR(exynos_ehci->phy); > - if (ret != -ENXIO && ret != -ENODEV) { > - dev_err(dev, "no usb2 phy configured\n"); > - return ret; > - } > - dev_dbg(dev, "Failed to get usb2 phy\n"); > - } else { > - exynos_ehci->otg = exynos_ehci->phy->otg; > - } > - > for_each_available_child_of_node(dev->of_node, child) { > ret = of_property_read_u32(child, "reg", &phy_number); > if (ret) { > @@ -98,7 +81,7 @@ static int exynos_ehci_get_phy(struct device *dev, > } > dev_dbg(dev, "Failed to get usb2 phy\n"); > } > - exynos_ehci->phy_g[phy_number] = phy; > + exynos_ehci->phy[phy_number] = phy; > } > > return ret; > @@ -111,16 +94,13 @@ static int exynos_ehci_phy_enable(struct device *dev) > int i; > int ret = 0; > > - if (!IS_ERR(exynos_ehci->phy)) > - return usb_phy_init(exynos_ehci->phy); > - > for (i = 0; ret == 0 && i < PHY_NUMBER; i++) > - if (!IS_ERR(exynos_ehci->phy_g[i])) > - ret = phy_power_on(exynos_ehci->phy_g[i]); > + if (!IS_ERR(exynos_ehci->phy[i])) > + ret = phy_power_on(exynos_ehci->phy[i]); > if (ret) > for (i--; i >= 0; i--) > - if (!IS_ERR(exynos_ehci->phy_g[i])) > - phy_power_off(exynos_ehci->phy_g[i]); > + if (!IS_ERR(exynos_ehci->phy[i])) > + phy_power_off(exynos_ehci->phy[i]); > > return ret; > } > @@ -131,14 +111,9 @@ static void exynos_ehci_phy_disable(struct device *dev) > struct exynos_ehci_hcd *exynos_ehci = to_exynos_ehci(hcd); > int i; > > - if (!IS_ERR(exynos_ehci->phy)) { > - usb_phy_shutdown(exynos_ehci->phy); > - return; > - } > - > for (i = 0; i < PHY_NUMBER; i++) > - if (!IS_ERR(exynos_ehci->phy_g[i])) > - phy_power_off(exynos_ehci->phy_g[i]); > + if (!IS_ERR(exynos_ehci->phy[i])) > + phy_power_off(exynos_ehci->phy[i]); > } > > static void exynos_setup_vbus_gpio(struct device *dev) > @@ -231,9 +206,6 @@ skip_phy: > goto fail_io; > } > > - if (exynos_ehci->otg) > - exynos_ehci->otg->set_host(exynos_ehci->otg, &hcd->self); > - > err = exynos_ehci_phy_enable(&pdev->dev); > if (err) { > dev_err(&pdev->dev, "Failed to enable USB phy\n"); > @@ -273,9 +245,6 @@ static int exynos_ehci_remove(struct platform_device > *pdev) > > usb_remove_hcd(hcd); > > - if (exynos_ehci->otg) > - exynos_ehci->otg->set_host(exynos_ehci->otg, &hcd->self); > - > exynos_ehci_phy_disable(&pdev->dev); > > clk_disable_unprepare(exynos_ehci->clk); > @@ -298,9 +267,6 @@ static int exynos_ehci_suspend(struct device *dev) > if (rc) > return rc; > > - if (exynos_ehci->otg) > - exynos_ehci->otg->set_host(exynos_ehci->otg, &hcd->self); > - > exynos_ehci_phy_disable(dev); > > clk_disable_unprepare(exynos_ehci->clk); > @@ -316,9
Re: [PATCH RFC 7/7] usb: host: ohci-exynos: Remove unnecessary usb-phy support
On Thursday, August 14, 2014 11:24 PM, Vivek Gautam wrote: > > Now that we have completely moved from older USB-PHY drivers > to newer GENERIC-PHY drivers for PHYs available with USB controllers > on Exynos series of SoCs, we can remove the support for the same > in our host drivers too. > This should fix the issue on ohci-exynos, wherein in the absence of > SAMSUNG_USB2PHY config symbol, we ended up getting the NOP_USB_XCEIV phy > when the same is enabled. And thus the PHYs are not configured properly. > > Reported-by: Sachin Kamat > Signed-off-by: Vivek Gautam Reviewed-by: Jingoo Han Best regards, Jingoo Han > --- > drivers/usb/host/ohci-exynos.c | 64 > ++-- > 1 file changed, 9 insertions(+), 55 deletions(-) > > diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c > index a72ab8f..0199a8b 100644 > --- a/drivers/usb/host/ohci-exynos.c > +++ b/drivers/usb/host/ohci-exynos.c > @@ -19,11 +19,8 @@ > #include > #include > #include > -#include > -#include > #include > #include > -#include > > #include "ohci.h" > > @@ -38,9 +35,7 @@ static struct hc_driver __read_mostly exynos_ohci_hc_driver; > > struct exynos_ohci_hcd { > struct clk *clk; > - struct usb_phy *phy; > - struct usb_otg *otg; > - struct phy *phy_g[PHY_NUMBER]; > + struct phy *phy[PHY_NUMBER]; > }; > > static int exynos_ohci_get_phy(struct device *dev, > @@ -51,28 +46,7 @@ static int exynos_ohci_get_phy(struct device *dev, > int phy_number; > int ret = 0; > > - exynos_ohci->phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2); > - if (IS_ERR(exynos_ohci->phy)) { > - ret = PTR_ERR(exynos_ohci->phy); > - if (ret != -ENXIO && ret != -ENODEV) { > - dev_err(dev, "no usb2 phy configured\n"); > - return ret; > - } > - dev_dbg(dev, "Failed to get usb2 phy\n"); > - } else { > - exynos_ohci->otg = exynos_ohci->phy->otg; > - } > - > - /* > - * Getting generic phy: > - * We are keeping both types of phys as a part of transiting OHCI > - * to generic phy framework, so as to maintain backward compatibilty > - * with old DTB. > - * If there are existing devices using DTB files built from them, > - * to remove the support for old bindings in this driver, > - * we need to make sure that such devices have their DTBs > - * updated to ones built from new DTS. > - */ > + /* Get the generic phys */ > for_each_available_child_of_node(dev->of_node, child) { > ret = of_property_read_u32(child, "reg", &phy_number); > if (ret) { > @@ -97,7 +71,7 @@ static int exynos_ohci_get_phy(struct device *dev, > } > dev_dbg(dev, "Failed to get usb2 phy\n"); > } > - exynos_ohci->phy_g[phy_number] = phy; > + exynos_ohci->phy[phy_number] = phy; > } > > return ret; > @@ -110,16 +84,13 @@ static int exynos_ohci_phy_enable(struct device *dev) > int i; > int ret = 0; > > - if (!IS_ERR(exynos_ohci->phy)) > - return usb_phy_init(exynos_ohci->phy); > - > for (i = 0; ret == 0 && i < PHY_NUMBER; i++) > - if (!IS_ERR(exynos_ohci->phy_g[i])) > - ret = phy_power_on(exynos_ohci->phy_g[i]); > + if (!IS_ERR(exynos_ohci->phy[i])) > + ret = phy_power_on(exynos_ohci->phy[i]); > if (ret) > for (i--; i >= 0; i--) > - if (!IS_ERR(exynos_ohci->phy_g[i])) > - phy_power_off(exynos_ohci->phy_g[i]); > + if (!IS_ERR(exynos_ohci->phy[i])) > + phy_power_off(exynos_ohci->phy[i]); > > return ret; > } > @@ -130,14 +101,9 @@ static void exynos_ohci_phy_disable(struct device *dev) > struct exynos_ohci_hcd *exynos_ohci = to_exynos_ohci(hcd); > int i; > > - if (!IS_ERR(exynos_ohci->phy)) { > - usb_phy_shutdown(exynos_ohci->phy); > - return; > - } > - > for (i = 0; i < PHY_NUMBER; i++) > - if (!IS_ERR(exynos_ohci->phy_g[i])) > - phy_power_off(exynos_ohci->phy_g[i]); > + if (!IS_ERR(exynos_ohci->phy[i])) > + phy_power_off(exynos_ohci->phy[i]); > } > > static int exynos_ohci_probe(struct platform_device *pdev) > @@ -209,9 +175,6 @@ skip_phy: > goto fail_io; > } > > - if (exynos_ohci->otg) > - exynos_ohci->otg->set_host(exynos_ohci->otg, &hcd->self); > - > platform_set_drvdata(pdev, hcd); > > err = exynos_ohci_phy_enable(&pdev->dev); > @@ -244,9 +207,6 @@ static int exynos_ohci_remove(struct platform_device > *pdev) > > usb_remove_hcd(hcd); > > - if (exynos_ohci->otg) > - exynos_ohci->otg->set_host(exynos_ohc
Re: [PATCH] usb: gadget: remove $(PWD) in ccflags-y
On Mon, Aug 18, 2014 at 12:08:07AM +0200, Philippe Reynes wrote: > The variable $(PWD) is useless, and it may break the compilation. > For example, it breaks the kernel compilation when it's done with > buildroot : > > /home/trem/Codes/armadeus/armadeus/buildroot/output/host/usr/bin/ccache > /home/trem/Codes/armadeus/armadeus/buildroot/output/host/usr/bin/arm-buildroot-linux-uclibcgnueabi-gcc > -Wp,-MD,drivers/usb/gadget/legacy/.hid.o.d -nostdinc -isystem > /home/trem/Codes/armadeus/armadeus/buildroot/output/host/usr/lib/gcc/arm-buildroot-linux-uclibcgnueabi/4.7.3/include > -I./arch/arm/include -Iarch/arm/include/generated -Iinclude > -I./arch/arm/include/uapi -Iarch/arm/include/generated/uapi > -I./include/uapi -Iinclude/generated/uapi -include > ./include/linux/kconfig.h -D__KERNEL__ -mlittle-endian -Wall -Wundef > -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common > -Werror-implicit-function-declaration -Wno-format-security > -fno-dwarf2-cfi-asm -mabi=aapcs-linux -mno-thumb-interwork -mfpu=vfp > -funwind-tables -marm -D__LINUX_ARM_ARCH__=5 -march=armv5te > -mtune=arm9tdmi -msoft-float -Uarm -fno-delete-null-pointer-checks -O2 > --param=allow-store-data-races=0 -Wframe-larger-than=1024 > -fno-stack-protector -Wno-unused-but-set-variable -fomit-frame-pointer > -fno-var-tracking-assignments -g -Wdeclaration-after-statement > -Wno-pointer-sign -fno-strict-overflow -fconserve-stack > -Werror=implicit-int -Werror=strict-prototypes -DCC_HAVE_ASM_GOTO > -I/home/trem/Codes/armadeus/armadeus/buildroot/drivers/usb/gadget/ > -I/home/trem/Codes/armadeus/armadeus/buildroot/drivers/usb/gadget/udc/ > -I/home/trem/Codes/armadeus/armadeus/buildroot/drivers/usb/gadget/function/ > -DMODULE -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(hid)" > -D"KBUILD_MODNAME=KBUILD_STR(g_hid)" -c -o > drivers/usb/gadget/legacy/hid.o drivers/usb/gadget/legacy/hid.c > drivers/usb/gadget/epautoconf.c:23:26: erreur fatale: gadget_chips.h : > Aucun fichier ou dossier de ce type > > This compilation line include : > /buildroot/driver/usb/gadget > but the real path is : > /buildroot/output/build/linux-3.17-rc1/driver/usb/gadget > > Signed-off-by: Philippe Reynes > --- > drivers/usb/gadget/Makefile |2 +- > drivers/usb/gadget/function/Makefile |4 ++-- > drivers/usb/gadget/legacy/Makefile |6 +++--- > 3 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile > index a186afe..9add915 100644 > --- a/drivers/usb/gadget/Makefile > +++ b/drivers/usb/gadget/Makefile > @@ -3,7 +3,7 @@ > # > subdir-ccflags-$(CONFIG_USB_GADGET_DEBUG):= -DDEBUG > subdir-ccflags-$(CONFIG_USB_GADGET_VERBOSE) += -DVERBOSE_DEBUG > -ccflags-y+= -I$(PWD)/drivers/usb/gadget/udc > +ccflags-y+= -Idrivers/usb/gadget/udc Ick, why are these here at all, shouldn't you just use the proper relative paths in the .c files for the include files? That way just building a .o file individually will work properly, otherwise, it will not. And getting rid of those other ccflags would be good to do as well, no need for them to be in a Makefile. thanks, greg k-h -- 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
Re: [PATCH] usb: phy: return -ENODEV on failure of try_module_get
On Mon, Aug 18, 2014 at 12:04:42AM +0530, Arjun Sreedharan wrote: > When __usb_find_phy_dev() does not return error and > try_module_get() fails, return -ENODEV > > Signed-off-by: Arjun Sreedharan > --- > drivers/usb/phy/phy.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c > index 36b6bce..8ad3638 100644 > --- a/drivers/usb/phy/phy.c > +++ b/drivers/usb/phy/phy.c > @@ -232,6 +232,7 @@ struct usb_phy *usb_get_phy_dev(struct device *dev, u8 > index) > phy = __usb_find_phy_dev(dev, &phy_bind_list, index); > if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) { > dev_dbg(dev, "unable to find transceiver\n"); > + phy = IS_ERR(phy) ? phy : ERR_PTR(-ENODEV); Please just spell out the if () statement, don't use ? : unless necessary. thanks, greg k-h -- 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
[PATCH 2/2v v2] USB: ftdi_sio: fix some coding style issues
Changes two simple if statements to switch statements. Fixes some issues reported by checkpatch.pl like whitespace. Bracing changes so all arms of a statement have consistent bracing. Signed-off-by: Jaša Bartelj --- drivers/usb/serial/ftdi_sio.c | 48 +-- drivers/usb/serial/ftdi_sio_ids.h | 4 ++-- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 19cf267..3340dea 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -58,7 +58,7 @@ struct ftdi_private { int custom_divisor; /* custom_divisor kludge, this is for baud_base (different from what goes to the chip!) */ - __u16 last_set_data_urb_value ; + __u16 last_set_data_urb_value; /* the last data state set - needed for doing * a break */ @@ -1038,6 +1038,7 @@ static unsigned short int ftdi_232am_baud_base_to_divisor(int baud, int base) unsigned short int divisor; /* divisor shifted 3 bits to the left */ int divisor3 = base / 2 / baud; + if ((divisor3 & 0x7) == 7) divisor3++; /* round x.7/8 up to x+1 */ divisor = divisor3 >> 3; @@ -1064,6 +1065,7 @@ static __u32 ftdi_232bm_baud_base_to_divisor(int baud, int base) __u32 divisor; /* divisor shifted 3 bits to the left */ int divisor3 = base / 2 / baud; + divisor = divisor3 >> 3; divisor |= (__u32)divfrac[divisor3 & 0x7] << 14; /* Deal with special cases for highest baud rates. */ @@ -1433,16 +1435,23 @@ static int set_serial_info(struct tty_struct *tty, check_and_exit: if ((old_priv.flags & ASYNC_SPD_MASK) != (priv->flags & ASYNC_SPD_MASK)) { - if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) + switch (priv->flags & ASYNC_SPD_MASK) { + case ASYNC_SPD_HI: tty->alt_speed = 57600; - else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) + break; + case ASYNC_SPD_VHI: tty->alt_speed = 115200; - else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) + break; + case ASYNC_SPD_SHI: tty->alt_speed = 230400; - else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) + break; + case ASYNC_SPD_WARP: tty->alt_speed = 460800; - else + break; + default: tty->alt_speed = 0; + break; + } } if (((old_priv.flags & ASYNC_SPD_MASK) != (priv->flags & ASYNC_SPD_MASK)) || @@ -1450,9 +1459,9 @@ check_and_exit: (old_priv.custom_divisor != priv->custom_divisor))) { change_speed(tty, port); mutex_unlock(&priv->cfg_lock); - } - else + } else { mutex_unlock(&priv->cfg_lock); + } return 0; } @@ -1491,8 +1500,6 @@ static void ftdi_determine_type(struct usb_serial_port *port) dev_dbg(&port->dev, "%s: bcdDevice = 0x%x, bNumInterfaces = %u\n", __func__, version, interfaces); if (interfaces > 1) { - int inter; - /* Multiple interfaces.*/ if (version == 0x0800) { priv->chip_type = FT4232H; @@ -1502,20 +1509,26 @@ static void ftdi_determine_type(struct usb_serial_port *port) priv->chip_type = FT2232H; /* Hi-speed - baud clock runs at 120MHz */ priv->baud_base = 12000 / 2; - } else + } else { priv->chip_type = FT2232C; + } /* Determine interface code. */ - inter = serial->interface->altsetting->desc.bInterfaceNumber; - if (inter == 0) { + switch (serial->interface->altsetting->desc.bInterfaceNumber) { + case 0: priv->interface = INTERFACE_A; - } else if (inter == 1) { + break; + case 1: priv->interface = INTERFACE_B; - } else if (inter == 2) { + break; + case 2: priv->interface = INTERFACE_C; - } else if (inter == 3) { + break; + case 3: priv->interface = INTERFACE_D; + break; } + /* BM-type devices have a bug where bcdDevice gets set
[PATCH 01/13] usb: gadget: introduce .connect gadget driver API
We introduce the connect API at usb_gadget_driver, the udc driver uses it to tell gadget driver that it is ready to CONNECT, and the dp can be pulled up from now on. Meanwhile, we introduce an API usb_udc_ready_to_connect to encapsulate above operation. Signed-off-by: Peter Chen --- include/linux/usb/gadget.h | 29 - 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index c3a6185..385af59 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -873,12 +873,39 @@ struct usb_gadget_driver { void(*disconnect)(struct usb_gadget *); void(*suspend)(struct usb_gadget *); void(*resume)(struct usb_gadget *); + int (*connect)(struct usb_gadget *, bool connect); /* FIXME support safe rmmod */ struct device_driverdriver; }; - +/** + * usb_udc_ready_to_connect - The udc is ready to connect (physical pullup dp) + * @driver: the gadget driver for this gadget + * @gadget: the udc device + * @connect: whether the udc is ready to connect or not + * + * The USB 2.0 spec 7.2.1 and 7.1.5 requires the dp should not be pulled up if + * the vbus is not there, else it will fail Back-voltage Testing at below + * USB-IF certification test. + * www.usb.org/developers/docs/USB-IFTestProc1_3.pdf + * + * Some udcs have hardware logic that even the pullup bit is set by software, + * it can still meet above Back-voltage Testing requirement, these kinds of + * udcs only need to set connect as true at its .udc_start. But other udcs + * may have no this capability, so they need the software pullup bit is not + * set when the vbus is not there, otherwise it will break the spec, and can't + * pass Back-voltage Testing. So they need to set connect as false when the + * vbus is not there, and set connect as true when the vbus is there. + */ +static inline int usb_udc_ready_to_connect(struct usb_gadget_driver *driver, + struct usb_gadget *gadget, bool connect) +{ + if (driver->connect) + return driver->connect(gadget, connect); + else + return -EOPNOTSUPP; +} /*-*/ -- 1.7.9.5 -- 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
[PATCH 02/13] usb: udc: set the udc is ready to pullup dp when it needs
Except for chipidea driver, all other udc drivers will tell the gadget driver that they are ready to pullup dp at udc_start, it is the default behaviour. The chipidea driver is ready to pullup dp when the vbus is there, and isn't ready to pullup dp when the vbus is not there. Other udc drivers which should not pull up when vbus is not there should change like chipidea does to pass the Back-Voltage Testing at www.usb.org/developers/docs/USB-IFTestProc1_3.pdf. Signed-off-by: Peter Chen --- drivers/usb/chipidea/udc.c |9 - drivers/usb/dwc2/gadget.c |2 ++ drivers/usb/dwc3/gadget.c |2 ++ drivers/usb/gadget/udc/amd5536udc.c |1 + drivers/usb/gadget/udc/atmel_usba_udc.c |2 ++ drivers/usb/gadget/udc/bcm63xx_udc.c|2 ++ drivers/usb/gadget/udc/dummy_hcd.c |1 + drivers/usb/gadget/udc/fotg210-udc.c|1 + drivers/usb/gadget/udc/fsl_qe_udc.c |1 + drivers/usb/gadget/udc/fsl_udc_core.c |2 ++ drivers/usb/gadget/udc/fusb300_udc.c|1 + drivers/usb/gadget/udc/gr_udc.c |2 ++ drivers/usb/gadget/udc/lpc32xx_udc.c|2 ++ drivers/usb/gadget/udc/m66592-udc.c |2 ++ drivers/usb/gadget/udc/mv_u3d_core.c|1 + drivers/usb/gadget/udc/mv_udc_core.c|2 ++ drivers/usb/gadget/udc/net2272.c|1 + drivers/usb/gadget/udc/net2280.c|1 + drivers/usb/gadget/udc/omap_udc.c |1 + drivers/usb/gadget/udc/pch_udc.c|1 + drivers/usb/gadget/udc/pxa25x_udc.c |1 + drivers/usb/gadget/udc/pxa27x_udc.c |1 + drivers/usb/gadget/udc/r8a66597-udc.c |1 + drivers/usb/gadget/udc/s3c-hsudc.c |1 + drivers/usb/gadget/udc/s3c2410_udc.c|1 + drivers/usb/musb/musb_gadget.c |2 ++ drivers/usb/renesas_usbhs/mod_gadget.c |7 ++- 27 files changed, 45 insertions(+), 6 deletions(-) diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index b8125aa..2830066 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -86,10 +86,8 @@ static int hw_device_state(struct ci_hdrc *ci, u32 dma) /* interrupt, error, port change, reset, sleep/suspend */ hw_write(ci, OP_USBINTR, ~0, USBi_UI|USBi_UEI|USBi_PCI|USBi_URI|USBi_SLI); - hw_write(ci, OP_USBCMD, USBCMD_RS, USBCMD_RS); } else { hw_write(ci, OP_USBINTR, ~0, 0); - hw_write(ci, OP_USBCMD, USBCMD_RS, 0); } return 0; } @@ -1477,8 +1475,10 @@ static int ci_udc_vbus_session(struct usb_gadget *_gadget, int is_active) pm_runtime_get_sync(&_gadget->dev); hw_device_reset(ci, USBMODE_CM_DC); hw_device_state(ci, ci->ep0out->qh.dma); + usb_udc_ready_to_connect(ci->driver, _gadget, true); usb_gadget_set_state(_gadget, USB_STATE_POWERED); } else { + usb_udc_ready_to_connect(ci->driver, _gadget, false); if (ci->driver) ci->driver->disconnect(&ci->gadget); hw_device_state(ci, 0); @@ -1531,9 +1531,6 @@ static int ci_udc_pullup(struct usb_gadget *_gadget, int is_on) { struct ci_hdrc *ci = container_of(_gadget, struct ci_hdrc, gadget); - if (!ci->vbus_active) - return -EOPNOTSUPP; - if (is_on) hw_write(ci, OP_USBCMD, USBCMD_RS, USBCMD_RS); else @@ -1676,6 +1673,8 @@ static int ci_udc_start(struct usb_gadget *gadget, if (retval) pm_runtime_put_sync(&ci->gadget.dev); + usb_udc_ready_to_connect(driver, gadget, true); + return retval; } diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 0ba9c33..2421eaa 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -2865,6 +2865,8 @@ static int s3c_hsotg_udc_start(struct usb_gadget *gadget, goto err; } + usb_udc_ready_to_connect(driver, gadget, true); + hsotg->last_rst = jiffies; dev_info(hsotg->dev, "bound driver %s\n", driver->driver.name); return 0; diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 349cacc..d952eaa 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1680,6 +1680,8 @@ static int dwc3_gadget_start(struct usb_gadget *g, dwc3_gadget_enable_irq(dwc); + usb_udc_ready_to_connect(driver, g, true); + spin_unlock_irqrestore(&dwc->lock, flags); return 0; diff --git a/drivers/usb/gadget/udc/amd5536udc.c b/drivers/usb/gadget/udc/amd5536udc.c index 41b062e..f8af622 100644 --- a/drivers/usb/gadget/udc/amd5536udc.c +++ b/drivers/usb/gadget/udc/amd5536udc.c @@ -1940,6 +1940,7 @@ static int amd5536_udc_start(struct usb_gadget *g, writel(tmp, &dev->regs-
[PATCH 00/13] usb: gadget: change pullup dp stratery
We have a discussion at http://www.spinics.net/lists/linux-usb/msg111860.html about current pullup dp limitations, this patchset is intended to fix two problems in discussion, they are: - Some function drivers (uvc, obex) can't pullup on demand, they needs to pullup dp after app loads. - Some udc drivers (chipidea) don't want to pullup dp when the vbus is not there, they have no hardware logic to avoid violating usb 2.0 spec 7.2.1 and 7.1.5. So, we can't pullup dp unconditionally at udc-core, the strateries for pullup dp at this patchset: - If the udc is ready to pullup dp and all functions at gadget driver want to pullup dp, it will pullup dp. This patchset defines one .connect API at usb_gadget_driver, and the udc driver can call it on demand, besides, we disable function default when adding it, the function driver can enable itself on demand. Tested at below gadget driver at chipidea platforms g_zero g_mass_storage g_serial configfs (mass storage/acm) Pass allmodconfig compile for this change. Tests and comments are welcome, thanks. Peter Chen (13): usb: gadget: introduce .connect gadget driver API usb: udc: set the udc is ready to pullup dp when it needs usb: gadget: composite: add .connect API for its usb_gadget_driver usb: gadget: configfs: add .connect API for its usb_gadget_driver usb: gadget: gadgetfs: add .connect API for its usb_gadget_driver usb: gadget: dbgp: add .connect API for its usb_gadget_driver usb: gadget: composite: change pullup/pulldown dp strategy usb: gadget: composite: deactivate function default usb: gadget: function: activate function at bind usb: gagdet: f_obex: delete the deactivate function operation at bind usb: gagdet: f_uvc: delete the deactivate function operation at bind usb: gadget: udc-core: change dp pullup/pulldown strategy usb: gadget: udc-core: change dp pullup/pulldown strategy for soft_connect drivers/usb/chipidea/udc.c |9 drivers/usb/dwc2/gadget.c|2 ++ drivers/usb/dwc3/gadget.c|2 ++ drivers/usb/gadget/composite.c | 27 +++- drivers/usb/gadget/configfs.c|1 + drivers/usb/gadget/function/f_acm.c |2 ++ drivers/usb/gadget/function/f_ecm.c |1 + drivers/usb/gadget/function/f_eem.c |1 + drivers/usb/gadget/function/f_fs.c |1 + drivers/usb/gadget/function/f_hid.c |1 + drivers/usb/gadget/function/f_loopback.c |1 + drivers/usb/gadget/function/f_mass_storage.c |1 + drivers/usb/gadget/function/f_midi.c |1 + drivers/usb/gadget/function/f_ncm.c |1 + drivers/usb/gadget/function/f_obex.c | 10 + drivers/usb/gadget/function/f_phonet.c |1 + drivers/usb/gadget/function/f_rndis.c|1 + drivers/usb/gadget/function/f_serial.c |1 + drivers/usb/gadget/function/f_sourcesink.c |1 + drivers/usb/gadget/function/f_subset.c |1 + drivers/usb/gadget/function/f_uac1.c |1 + drivers/usb/gadget/function/f_uac2.c |1 + drivers/usb/gadget/function/f_uvc.c |6 -- drivers/usb/gadget/legacy/dbgp.c | 12 +++ drivers/usb/gadget/legacy/inode.c| 12 +++ drivers/usb/gadget/legacy/printer.c |1 + drivers/usb/gadget/legacy/tcm_usb_gadget.c |1 + drivers/usb/gadget/udc/amd5536udc.c |1 + drivers/usb/gadget/udc/atmel_usba_udc.c |2 ++ drivers/usb/gadget/udc/bcm63xx_udc.c |2 ++ drivers/usb/gadget/udc/dummy_hcd.c |1 + drivers/usb/gadget/udc/fotg210-udc.c |1 + drivers/usb/gadget/udc/fsl_qe_udc.c |1 + drivers/usb/gadget/udc/fsl_udc_core.c|2 ++ drivers/usb/gadget/udc/fusb300_udc.c |1 + drivers/usb/gadget/udc/gr_udc.c |2 ++ drivers/usb/gadget/udc/lpc32xx_udc.c |2 ++ drivers/usb/gadget/udc/m66592-udc.c |2 ++ drivers/usb/gadget/udc/mv_u3d_core.c |1 + drivers/usb/gadget/udc/mv_udc_core.c |2 ++ drivers/usb/gadget/udc/net2272.c |1 + drivers/usb/gadget/udc/net2280.c |1 + drivers/usb/gadget/udc/omap_udc.c|1 + drivers/usb/gadget/udc/pch_udc.c |1 + drivers/usb/gadget/udc/pxa25x_udc.c |1 + drivers/usb/gadget/udc/pxa27x_udc.c |1 + drivers/usb/gadget/udc/r8a66597-udc.c|1 + drivers/usb/gadget/udc/s3c-hsudc.c |1 + drivers/usb/gadget/udc/s3c2410_udc.c |1 + drivers/usb/gadget/udc/udc-core.c|6 ++ drivers/usb/musb/musb_gadget.c |2 ++ drivers/usb/renesas_usbhs/mod_gadget.c |7 ++- include/linux/usb/composite.h|4 include/linux/usb/gadget.h | 29 +- 54 files
[PATCH 05/13] usb: gadget: gadgetfs: add .connect API for its usb_gadget_driver
It is used for udc to pullup dp when necessary Signed-off-by: Peter Chen --- drivers/usb/gadget/legacy/inode.c | 12 1 file changed, 12 insertions(+) diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c index 2e4ce77..1166e77 100644 --- a/drivers/usb/gadget/legacy/inode.c +++ b/drivers/usb/gadget/legacy/inode.c @@ -1770,6 +1770,17 @@ gadgetfs_suspend (struct usb_gadget *gadget) spin_unlock (&dev->lock); } +/* + * UDC driver calls this when it wants to pull up dp. + */ +static int gadgetfs_connect(struct usb_gadget *gadget, bool connect) +{ + if (connect) + return usb_gadget_connect(gadget); + else + return usb_gadget_disconnect(gadget); +} + static struct usb_gadget_driver gadgetfs_driver = { .function = (char *) driver_desc, .bind = gadgetfs_bind, @@ -1777,6 +1788,7 @@ static struct usb_gadget_driver gadgetfs_driver = { .setup = gadgetfs_setup, .disconnect = gadgetfs_disconnect, .suspend= gadgetfs_suspend, + .connect= gadgetfs_connect, .driver = { .name = (char *) shortname, -- 1.7.9.5 -- 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
[PATCH 06/13] usb: gadget: dbgp: add .connect API for its usb_gadget_driver
It is used for udc to pullup dp when necessary Signed-off-by: Peter Chen --- drivers/usb/gadget/legacy/dbgp.c | 12 1 file changed, 12 insertions(+) diff --git a/drivers/usb/gadget/legacy/dbgp.c b/drivers/usb/gadget/legacy/dbgp.c index 986fc51..bcc780b 100644 --- a/drivers/usb/gadget/legacy/dbgp.c +++ b/drivers/usb/gadget/legacy/dbgp.c @@ -402,6 +402,17 @@ fail: return err; } +/* + * UDC driver calls this when it wants to pull up dp. + */ +static int dbgp_connect(struct usb_gadget *gadget, bool connect) +{ + if (connect) + return usb_gadget_connect(gadget); + else + return usb_gadget_disconnect(gadget); +} + static __refdata struct usb_gadget_driver dbgp_driver = { .function = "dbgp", .max_speed = USB_SPEED_HIGH, @@ -409,6 +420,7 @@ static __refdata struct usb_gadget_driver dbgp_driver = { .unbind = dbgp_unbind, .setup = dbgp_setup, .disconnect = dbgp_disconnect, + .connect = dbgp_connect, .driver = { .owner = THIS_MODULE, .name = "dbgp" -- 1.7.9.5 -- 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
[PATCH 04/13] usb: gadget: configfs: add .connect API for its usb_gadget_driver
Define .connect for configfs_driver_template, and export composite_connect for configfs. Signed-off-by: Peter Chen --- drivers/usb/gadget/composite.c |2 +- drivers/usb/gadget/configfs.c |1 + include/linux/usb/composite.h |1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index c4ce977..ada0905 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -2069,7 +2069,7 @@ composite_resume(struct usb_gadget *gadget) /* * UDC driver calls this when it wants to pull up dp. */ -static int composite_connect(struct usb_gadget *gadget, bool connect) +int composite_connect(struct usb_gadget *gadget, bool connect) { if (connect) return usb_gadget_connect(gadget); diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index 811c2c7..63badc9 100644 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -1451,6 +1451,7 @@ static const struct usb_gadget_driver configfs_driver_template = { .setup = composite_setup, .disconnect = composite_disconnect, + .connect= composite_connect, .max_speed = USB_SPEED_SUPER, .driver = { diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index c330f5e..820ca85 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h @@ -501,6 +501,7 @@ extern int usb_string_ids_n(struct usb_composite_dev *c, unsigned n); extern void composite_disconnect(struct usb_gadget *gadget); extern int composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl); +extern int composite_connect(struct usb_gadget *gadget, bool connect); /* * Some systems will need runtime overrides for the product identifiers -- 1.7.9.5 -- 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
[PATCH 03/13] usb: gadget: composite: add .connect API for its usb_gadget_driver
It is used for udc to pullup dp when necessary Signed-off-by: Peter Chen --- drivers/usb/gadget/composite.c | 13 + 1 file changed, 13 insertions(+) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 6935a82..c4ce977 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -2066,6 +2066,17 @@ composite_resume(struct usb_gadget *gadget) cdev->suspended = 0; } +/* + * UDC driver calls this when it wants to pull up dp. + */ +static int composite_connect(struct usb_gadget *gadget, bool connect) +{ + if (connect) + return usb_gadget_connect(gadget); + else + return usb_gadget_disconnect(gadget); +} + /*-*/ static const struct usb_gadget_driver composite_driver_template = { @@ -2078,6 +2089,8 @@ static const struct usb_gadget_driver composite_driver_template = { .suspend= composite_suspend, .resume = composite_resume, + .connect= composite_connect, + .driver = { .owner = THIS_MODULE, }, -- 1.7.9.5 -- 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
[PATCH 10/13] usb: gagdet: f_obex: delete the deactivate function operation at bind
The deactivate function has already done by composite.c for every function. Signed-off-by: Peter Chen --- drivers/usb/gadget/function/f_obex.c | 10 +- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/usb/gadget/function/f_obex.c b/drivers/usb/gadget/function/f_obex.c index aebae18..59d173c 100644 --- a/drivers/usb/gadget/function/f_obex.c +++ b/drivers/usb/gadget/function/f_obex.c @@ -372,15 +372,7 @@ static int obex_bind(struct usb_configuration *c, struct usb_function *f) if (status) goto fail; - /* Avoid letting this gadget enumerate until the userspace -* OBEX server is active. -*/ - status = usb_function_deactivate(f); - if (status < 0) - WARNING(cdev, "obex ttyGS%d: can't prevent enumeration, %d\n", - obex->port_num, status); - else - obex->can_activate = true; + obex->can_activate = true; DBG(cdev, "obex ttyGS%d: %s speed IN/%s OUT/%s\n", -- 1.7.9.5 -- 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
[PATCH 11/13] usb: gagdet: f_uvc: delete the deactivate function operation at bind
The deactivate function has already done by composite.c for every function. Signed-off-by: Peter Chen --- drivers/usb/gadget/function/f_uvc.c |6 -- 1 file changed, 6 deletions(-) diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c index e2a1f50..716cee4 100644 --- a/drivers/usb/gadget/function/f_uvc.c +++ b/drivers/usb/gadget/function/f_uvc.c @@ -685,12 +685,6 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) uvc->control_req->complete = uvc_function_ep0_complete; uvc->control_req->context = uvc; - /* Avoid letting this gadget enumerate until the userspace server is -* active. -*/ - if ((ret = usb_function_deactivate(f)) < 0) - goto error; - if (v4l2_device_register(&cdev->gadget->dev, &uvc->v4l2_dev)) { printk(KERN_INFO "v4l2_device_register failed\n"); goto error; -- 1.7.9.5 -- 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
[PATCH 12/13] usb: gadget: udc-core: change dp pullup/pulldown strategy
Currently, the dp pullup will according to whether udc is available to pullup up and the function driver's requirement, so, delete the unconditional dp pullup operation at udc-core. But we still need to pulldown up unconditionally when the gadget driver is unloaded no matter the connection is there or not, so tell the gadget driver do it. Signed-off-by: Peter Chen --- drivers/usb/gadget/udc/udc-core.c |3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c index b0d9817..fcb4686 100644 --- a/drivers/usb/gadget/udc/udc-core.c +++ b/drivers/usb/gadget/udc/udc-core.c @@ -283,7 +283,7 @@ static void usb_gadget_remove_driver(struct usb_udc *udc) kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE); - usb_gadget_disconnect(udc->gadget); + usb_udc_ready_to_connect(udc->driver, udc->gadget, false); udc->driver->disconnect(udc->gadget); udc->driver->unbind(udc->gadget); usb_gadget_udc_stop(udc->gadget, NULL); @@ -351,7 +351,6 @@ static int udc_bind_to_driver(struct usb_udc *udc, struct usb_gadget_driver *dri driver->unbind(udc->gadget); goto err1; } - usb_gadget_connect(udc->gadget); kobject_uevent(&udc->dev.kobj, KOBJ_CHANGE); return 0; -- 1.7.9.5 -- 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
[PATCH 13/13] usb: gadget: udc-core: change dp pullup/pulldown strategy for soft_connect
Currently, the dp pullup will according to whether udc is available to pullup up and the function driver's requirement, so, delete the unconditional dp pullup operation at udc-core. But we still need to pulldown up unconditionally when the gadget driver is unloaded no matter the connection is there or not, so tell the gadget driver do it. Signed-off-by: Peter Chen --- drivers/usb/gadget/udc/udc-core.c |3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c index fcb4686..2c0c55e1 100644 --- a/drivers/usb/gadget/udc/udc-core.c +++ b/drivers/usb/gadget/udc/udc-core.c @@ -459,9 +459,8 @@ static ssize_t usb_udc_softconn_store(struct device *dev, if (sysfs_streq(buf, "connect")) { usb_gadget_udc_start(udc->gadget, udc->driver); - usb_gadget_connect(udc->gadget); } else if (sysfs_streq(buf, "disconnect")) { - usb_gadget_disconnect(udc->gadget); + usb_udc_ready_to_connect(udc->driver, udc->gadget, false); usb_gadget_udc_stop(udc->gadget, udc->driver); } else { dev_err(dev, "unsupported command '%s'\n", buf); -- 1.7.9.5 -- 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
[PATCH 08/13] usb: gadget: composite: deactivate function default
Each function driver should activate itself at its function driver when necessary. Most of functions would like to activate them just after binding, but some may have special requirements for when to activate themselves, eg, uvc, it needs the app to open video device first. We do not need to consider deactivations count when the bind has failed, since the usb_composite_dev will be reinitialized at calling composite_bind next time. Signed-off-by: Peter Chen --- drivers/usb/gadget/composite.c |5 + 1 file changed, 5 insertions(+) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 770aa5e..64932ab 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -208,6 +208,11 @@ int usb_add_function(struct usb_configuration *config, function->config = config; list_add_tail(&function->list, &config->functions); + /* +* Deactive default, activates itself at each function driver +* according to requirement. +*/ + usb_function_deactivate(function); /* REVISIT *require* function->bind? */ if (function->bind) { -- 1.7.9.5 -- 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
[PATCH 09/13] usb: gadget: function: activate function at bind
For these functions, it has no special requirement when to activate them, so activate their function at function.bind. Signed-off-by: Peter Chen --- drivers/usb/gadget/function/f_acm.c |2 ++ drivers/usb/gadget/function/f_ecm.c |1 + drivers/usb/gadget/function/f_eem.c |1 + drivers/usb/gadget/function/f_fs.c |1 + drivers/usb/gadget/function/f_hid.c |1 + drivers/usb/gadget/function/f_loopback.c |1 + drivers/usb/gadget/function/f_mass_storage.c |1 + drivers/usb/gadget/function/f_midi.c |1 + drivers/usb/gadget/function/f_ncm.c |1 + drivers/usb/gadget/function/f_phonet.c |1 + drivers/usb/gadget/function/f_rndis.c|1 + drivers/usb/gadget/function/f_serial.c |1 + drivers/usb/gadget/function/f_sourcesink.c |1 + drivers/usb/gadget/function/f_subset.c |1 + drivers/usb/gadget/function/f_uac1.c |1 + drivers/usb/gadget/function/f_uac2.c |1 + drivers/usb/gadget/legacy/printer.c |1 + drivers/usb/gadget/legacy/tcm_usb_gadget.c |1 + 18 files changed, 19 insertions(+) diff --git a/drivers/usb/gadget/function/f_acm.c b/drivers/usb/gadget/function/f_acm.c index ab1065a..b0d635b 100644 --- a/drivers/usb/gadget/function/f_acm.c +++ b/drivers/usb/gadget/function/f_acm.c @@ -691,6 +691,8 @@ acm_bind(struct usb_configuration *c, struct usb_function *f) if (status) goto fail; + usb_function_activate(f); + DBG(cdev, "acm ttyGS%d: %s speed IN/%s OUT/%s NOTIFY/%s\n", acm->port_num, gadget_is_superspeed(c->cdev->gadget) ? "super" : diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/function/f_ecm.c index 798760f..ac3b03e 100644 --- a/drivers/usb/gadget/function/f_ecm.c +++ b/drivers/usb/gadget/function/f_ecm.c @@ -807,6 +807,7 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f) ecm->port.open = ecm_open; ecm->port.close = ecm_close; + usb_function_activate(f); DBG(cdev, "CDC Ethernet: %s speed IN/%s OUT/%s NOTIFY/%s\n", gadget_is_superspeed(c->cdev->gadget) ? "super" : gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full", diff --git a/drivers/usb/gadget/function/f_eem.c b/drivers/usb/gadget/function/f_eem.c index 4d8b236..b68aa12 100644 --- a/drivers/usb/gadget/function/f_eem.c +++ b/drivers/usb/gadget/function/f_eem.c @@ -318,6 +318,7 @@ static int eem_bind(struct usb_configuration *c, struct usb_function *f) if (status) goto fail; + usb_function_activate(f); DBG(cdev, "CDC Ethernet (EEM): %s speed IN/%s OUT/%s\n", gadget_is_superspeed(c->cdev->gadget) ? "super" : gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full", diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index dc30adf..6346476 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -2759,6 +2759,7 @@ static int _ffs_func_bind(struct usb_configuration *c, /* And we're done */ ffs_event_add(ffs, FUNCTIONFS_BIND); + usb_function_activate(f); return 0; error: diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c index a95290a..3c240f3 100644 --- a/drivers/usb/gadget/function/f_hid.c +++ b/drivers/usb/gadget/function/f_hid.c @@ -624,6 +624,7 @@ static int __init hidg_bind(struct usb_configuration *c, struct usb_function *f) goto fail; device_create(hidg_class, NULL, dev, NULL, "%s%d", "hidg", hidg->minor); + usb_function_activate(f); return 0; diff --git a/drivers/usb/gadget/function/f_loopback.c b/drivers/usb/gadget/function/f_loopback.c index 4557cd0..e359eb4 100644 --- a/drivers/usb/gadget/function/f_loopback.c +++ b/drivers/usb/gadget/function/f_loopback.c @@ -222,6 +222,7 @@ autoconf_fail: if (ret) return ret; + usb_function_activate(f); DBG(cdev, "%s speed %s: IN/%s, OUT/%s\n", (gadget_is_superspeed(c->cdev->gadget) ? "super" : (gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full")), diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c index b963939..26a64a0 100644 --- a/drivers/usb/gadget/function/f_mass_storage.c +++ b/drivers/usb/gadget/function/f_mass_storage.c @@ -3162,6 +3162,7 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f) if (ret) goto autoconf_fail; + usb_function_activate(f); return 0; autoconf_fail: diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/function/f_midi.c index 807b31c..59e46be 100644 --- a/drivers/usb/gadget/function/f_midi.c +++ b/drivers/usb/gadget/fu
[PATCH 07/13] usb: gadget: composite: change pullup/pulldown dp strategy
- If the udc is ready to pullup dp and all functions at gadget driver want to pullup dp, it will pullup dp. - If the udc doesn't want to pullup dp or one of functions at gadget driver doesn't want to pullup up. it will pull down dp. Signed-off-by: Peter Chen --- drivers/usb/gadget/composite.c | 17 - include/linux/usb/composite.h |3 +++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index ada0905..770aa5e 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -310,7 +310,7 @@ int usb_function_activate(struct usb_function *function) status = -EINVAL; else { cdev->deactivations--; - if (cdev->deactivations == 0) + if (cdev->deactivations == 0 && cdev->connect) status = usb_gadget_connect(cdev->gadget); } @@ -2071,10 +2071,17 @@ composite_resume(struct usb_gadget *gadget) */ int composite_connect(struct usb_gadget *gadget, bool connect) { - if (connect) - return usb_gadget_connect(gadget); - else - return usb_gadget_disconnect(gadget); + struct usb_composite_dev*cdev = get_gadget_data(gadget); + int status = 0; + + if (cdev->deactivations == 0 && connect) + status = usb_gadget_connect(gadget); + else if (!connect) + status = usb_gadget_disconnect(gadget); + + cdev->connect = connect; + + return status; } /*-*/ diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index 820ca85..a9c7322 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h @@ -488,6 +488,9 @@ struct usb_composite_dev { /* protects deactivations and delayed_status counts*/ spinlock_t lock; + + /* udc can accept pull dp or not */ + boolconnect; }; extern int usb_string_id(struct usb_composite_dev *c); -- 1.7.9.5 -- 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
[PATCH] usb: phy: return -ENODEV on failure of try_module_get
When __usb_find_phy_dev() does not return error and try_module_get() fails, return -ENODEV. Signed-off-by: Arjun Sreedharan --- drivers/usb/phy/phy.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/phy/phy.c b/drivers/usb/phy/phy.c index 36b6bce..fd0d7f1 100644 --- a/drivers/usb/phy/phy.c +++ b/drivers/usb/phy/phy.c @@ -232,6 +232,9 @@ struct usb_phy *usb_get_phy_dev(struct device *dev, u8 index) phy = __usb_find_phy_dev(dev, &phy_bind_list, index); if (IS_ERR(phy) || !try_module_get(phy->dev->driver->owner)) { dev_dbg(dev, "unable to find transceiver\n"); + if (!IS_ERR(phy)) + phy = ERR_PTR(-ENODEV); + goto err0; } -- 1.7.11.7 -- 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