Re: [PATCH v3 07/22] usb: chipidea: set usb gadeget's otg config
On Tue, 16 Jun 2015 17:21:50 +0800 Li Jun wrote: > On Tue, Jun 16, 2015 at 11:44:52AM +0300, Roger Quadros wrote: > > > > On Tue, 16 Jun 2015 14:51:57 +0800 > > Li Jun wrote: > > > > > Set gadget's otg features according to controller's capability and usb > > > property in device tree. > > > > > > Signed-off-by: Li Jun > > > --- > > > drivers/usb/chipidea/core.c | 18 ++ > > > drivers/usb/chipidea/udc.c | 20 +++- > > > include/linux/usb/chipidea.h | 4 > > > 3 files changed, 41 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c > > > index 74fea4f..45bd44e 100644 > > > --- a/drivers/usb/chipidea/core.c > > > +++ b/drivers/usb/chipidea/core.c > > > @@ -588,6 +588,24 @@ static int ci_get_platdata(struct device *dev, > > > of_usb_host_tpl_support(dev->of_node); > > > } > > > > > > + if (platdata->dr_mode == USB_DR_MODE_OTG) { > > > + if (!platdata->otg_rev) { > > > + platdata->otg_rev = > > > + of_usb_get_otg_rev(dev->of_node); > > > + } > > > + if (platdata->otg_rev) { > > > + if (!platdata->srp_support) > > > + platdata->srp_support = > > > + !of_usb_otg_srp_disabled(dev->of_node); > > > + if (!platdata->hnp_support) > > > + platdata->hnp_support = > > > + !of_usb_otg_hnp_disabled(dev->of_node); > > > + if (!platdata->adp_support) > > > + platdata->adp_support = > > > + !of_usb_otg_adp_disabled(dev->of_node); > > > + } > > > + } > > > + > > > > Looks like there is some scope of sharing this code among controller drivers > > and also adding sanity check. > > > > How about adding > > > > struct usb_otg_caps { > > u16 otg_rev; > > bool srp_support; > > bool hnp_support; > > bool adp_support; > > }; > > > I agree there is some sharing code across all controller drivers, > thus usb_otg_caps maybe desirable. > > > And below API > > > > /* sets device otg capabilities based on controller capabilities and device > > tree flags */ > > void of_usb_otg_set_capabilities(sturct device_node *node, struct > > usb_otg_caps *cntrl_caps, struct usb_otg_caps *device_caps) > I think cntrl_caps is not needed, only device_caps of controller is okay; > If DT is used, then all capabilities are updated by DT, after that, > controller driver can override some of them if it wants to correct > some wrong property in DT(not disable some feature the controller > can not support). OK. > > { > > u16 otg_rev = of_usb_get_otg_rev(dev->of_node); > > > > *device_caps = *cntrl_caps; > > if (!otg_rev) { /* legacy platform */ > > device_caps->adp_support = false; > > /* For SRP/HNP respect what controller supports */ > > return; > > } > > > > if (otg_rev < cntrl_caps->otg_rev) > > device_caps->otg_rev = cntrl_caps->otg_rev; > Not catch your point, if controller can support a higher version > protocol, even passed a lower setting in DT, we still use higher > version? My mistake. Should have been if (otg_rev < cntrl_caps->otg_rev) device_caps->org_rev = otg_rev; > > if (of_usb_otg_srp_disabled(dev->of_node)) > > device_caps->srp_support = false; > > if (of_usb_otg_hnp_disabled(dev->of_node)) > > device_caps->hnp_support = false; > > if (of_usb_otg_adp_disabled(dev->of_node)) > > device_caps->adp_support = false; > > > > /* sanity check */ > > if ((otg_rev < 0x0200) && device_caps->adp_support) { > > /* pre otg 2.0 doesn't support ADP */ > > device_caps->adp_support = false; > > } > > > > return; > > } cheers, -roger -- 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 v4 03/23] usb: otg: add usb_otg_caps structure for otg capabilities
On Wed, 17 Jun 2015 13:43:35 +0800 Li Jun wrote: > This patch adds a structure usb_otg_caps to cover all otg related > capabilities of the device, including otg revision, and if hnp/srp/adp > is supported. > > Signed-off-by: Li Jun Reviewed-by: Roger Quadros cheers, -roger > --- > include/linux/usb/otg.h | 15 +++ > 1 file changed, 15 insertions(+) > > diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h > index 52661c5..bd1dcf8 100644 > --- a/include/linux/usb/otg.h > +++ b/include/linux/usb/otg.h > @@ -41,6 +41,21 @@ struct usb_otg { > > }; > > +/** > + * struct usb_otg_caps - describes the otg capabilities of the device > + * @otg_rev: The OTG revision number the device is compliant with, it's > + * in binary-coded decimal (i.e. 2.0 is 0200H). > + * @hnp_support: Indicates if the device supports HNP. > + * @srp_support: Indicates if the device supports SRP. > + * @adp_support: Indicates if the device supports ADP. > + */ > +struct usb_otg_caps { > + u16 otg_rev; > + bool hnp_support; > + bool srp_support; > + bool adp_support; > +}; > + > extern const char *usb_otg_state_string(enum usb_otg_state state); > > /* Context: can sleep */ -- 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 v4 04/23] usb: add usb_otg_caps to usb_gadget structure.
On Wed, 17 Jun 2015 13:43:36 +0800 Li Jun wrote: > From: Macpaul Lin > > Add usb_otg_caps pointer to usb_gadget structure to indicate its > otg capabilities. > > Signed-off-by: Macpaul Lin > Signed-off-by: Li Jun > --- > include/linux/usb/gadget.h | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h > index 4f3dfb7..6b39087 100644 > --- a/include/linux/usb/gadget.h > +++ b/include/linux/usb/gadget.h > @@ -511,6 +511,7 @@ struct usb_gadget_ops { > * @dev: Driver model state for this abstract device. > * @out_epnum: last used out ep number > * @in_epnum: last used in ep number > + * @otg_caps: OTG capabilities of this gadget. > * @sg_supported: true if we can handle scatter-gather > * @is_otg: True if the USB device port uses a Mini-AB jack, so that the > * gadget driver must provide a USB OTG descriptor. > @@ -559,6 +560,7 @@ struct usb_gadget { > struct device dev; > unsignedout_epnum; > unsignedin_epnum; > + struct usb_otg_caps *otg_caps; Why does this need to be a pointer? > > unsignedsg_supported:1; > unsignedis_otg:1; cheers, -roger -- 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 v4 06/23] doc: dt-binding: usb: add otg related properties
On Wed, 17 Jun 2015 13:43:38 +0800 Li Jun wrote: > Add otg version, srp, hnp and adp support for usb OTG port, then those OTG > features don't have to be decided by usb gadget drivers. > > Signed-off-by: Li Jun Reviewed-by: Roger Quadros cheers, -roger > --- > Documentation/devicetree/bindings/usb/generic.txt | 15 +++ > 1 file changed, 15 insertions(+) > > diff --git a/Documentation/devicetree/bindings/usb/generic.txt > b/Documentation/devicetree/bindings/usb/generic.txt > index 477d5bb..bba8257 100644 > --- a/Documentation/devicetree/bindings/usb/generic.txt > +++ b/Documentation/devicetree/bindings/usb/generic.txt > @@ -11,6 +11,19 @@ Optional properties: > "peripheral" and "otg". In case this attribute isn't > passed via DT, USB DRD controllers should default to > OTG. > + - otg-rev: tells usb driver the release number of the OTG and EH supplement > + with which the device and its descriptors are compliant, > + in binary-coded decimal (i.e. 2.0 is 0200H). This > + property is used if any real OTG features(HNP/SRP/ADP) > + is enabled, if ADP is required, otg-rev should be > + 0x0200 or above. > + - hnp-disable: tells OTG controllers we want to disable OTG HNP, normally > HNP > + is the basic function of real OTG except you want it > + to be a srp-capable only B device. > + - srp-disable: tells OTG controllers we want to disable OTG SRP, SRP is > + optional for OTG device. > + - adp-disable: tells OTG controllers we want to disable OTG ADP, ADP is > + optional for OTG device. > > This is an attribute to a USB controller such as: > > @@ -21,4 +34,6 @@ dwc3@4a03 { > usb-phy = <&usb2_phy>, <&usb3,phy>; > maximum-speed = "super-speed"; > dr_mode = "otg"; > + otg-rev = <0x0200>; > + adp-disable; > }; -- 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 v4 07/23] usb: common: add API to get usb otg features from device tree
On Wed, 17 Jun 2015 13:43:39 +0800 Li Jun wrote: > Check property of usb hardware to get otg version and if SRP, HNP and ADP > are supported. > > Signed-off-by: Li Jun > --- > drivers/usb/common/common.c | 29 + > include/linux/usb/of.h | 7 +++ > 2 files changed, 36 insertions(+) > > diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c > index b530fd4..b846172 100644 > --- a/drivers/usb/common/common.c > +++ b/drivers/usb/common/common.c > @@ -154,6 +154,35 @@ bool of_usb_host_tpl_support(struct device_node *np) > return false; > } > EXPORT_SYMBOL_GPL(of_usb_host_tpl_support); > + > +/** > + * of_usb_get_otg_caps - to get usb otg capabilities according to > + * the passed properties in DT. > + * @np: Pointer to the given device_node > + * @otg_caps: Pointer to the target usb_otg_caps to be set > + * > + * The function gets and sets the otg capabilities > + */ > +void of_usb_get_otg_caps(struct device_node *np, struct usb_otg_caps > *otg_caps) > +{ > + u32 otg_rev; > + > + if (!otg_caps) > + return; > + > + if (!of_property_read_u32(np, "otg-rev", &otg_rev)) { > + otg_caps->otg_rev = otg_rev; > + if (!of_find_property(np, "hnp-disable", NULL)) > + otg_caps->hnp_support = true; > + if (!of_find_property(np, "srp-disable", NULL)) > + otg_caps->hnp_support = true; srp_support = true; > + if (!of_find_property(np, "adp-disable", NULL) && > + (otg_caps->otg_rev >= 0x0200)) > + otg_caps->hnp_support = true; adp_support = true; > + } I think we are loosing information here. The DT disable flags get changed to enable flags (xyz_support) and after this we can't really tell if the device tree really wanted us to disable the feature or enable it based on otg_rev/controller capabilities. Why not pass controller caps in otg_caps and then disable the flags if requested from DT? if (of_find_property(np, "foo-disbale", NULL)) otg_caps->foo_support = false; The controller can still override anything afterwards if it things something is wrong. My guess is most controllers won't have to. > +} > +EXPORT_SYMBOL_GPL(of_usb_get_otg_caps); > + > #endif > > MODULE_LICENSE("GPL"); > diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h > index cfe0528..bbf302b9 100644 > --- a/include/linux/usb/of.h > +++ b/include/linux/usb/of.h > @@ -15,6 +15,8 @@ > enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np); > enum usb_device_speed of_usb_get_maximum_speed(struct device_node *np); > bool of_usb_host_tpl_support(struct device_node *np); > +void of_usb_get_otg_caps(struct device_node *np, > + struct usb_otg_caps *otg_caps); > #else > static inline enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np) > { > @@ -30,6 +32,11 @@ static inline bool of_usb_host_tpl_support(struct > device_node *np) > { > return false; > } > +static inline void of_usb_get_otg_caps(struct device_node *np, > + struct usb_otg_caps *otg_caps) > +{ > + > +} > #endif > > #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_USB_SUPPORT) cheers, -roger -- 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 v4 10/23] usb: gadget: add usb otg descriptor allocate and init interface
On Wed, 17 Jun 2015 13:43:42 +0800 Li Jun wrote: > Allocate usb otg descriptor and initialize it according to gadget's otg > capabilities, if usb_otg_caps is not set, keep settings as current gadget > drivers. With this 2 new interfaces, gadget can use usb_otg_descriptor > for OTG 1.x, and usb_otg20_descriptor for OTG 2.0 or above, and otg > features can be decided by the combination of usb hardware property > and driver config. > > Signed-off-by: Li Jun > --- > drivers/usb/gadget/config.c | 56 > + > include/linux/usb/gadget.h | 4 > 2 files changed, 60 insertions(+) > > diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c > index 34e12fc..0fafa7a 100644 > --- a/drivers/usb/gadget/config.c > +++ b/drivers/usb/gadget/config.c > @@ -20,6 +20,7 @@ > #include > #include > #include > +#include > > /** > * usb_descriptor_fillbuf - fill buffer with descriptors > @@ -195,3 +196,58 @@ void usb_free_all_descriptors(struct usb_function *f) > usb_free_descriptors(f->ss_descriptors); > } > EXPORT_SYMBOL_GPL(usb_free_all_descriptors); > + > +struct usb_descriptor_header *usb_otg_descriptor_alloc( > + struct usb_gadget *gadget) > +{ > + struct usb_descriptor_header *otg_desc; > + unsigned length = 0; > + > + if (gadget->otg_caps && (gadget->otg_caps->otg_rev >= 0x0200)) > + length = sizeof(struct usb_otg20_descriptor); > + else > + length = sizeof(struct usb_otg_descriptor); > + > + otg_desc = kzalloc(length, GFP_KERNEL); > + return otg_desc; > +} > +EXPORT_SYMBOL_GPL(usb_otg_descriptor_alloc); > + > +int usb_otg_descriptor_init(struct usb_gadget *gadget, > + struct usb_descriptor_header *otg_desc) > +{ > + struct usb_otg_descriptor *otg1x_desc; > + struct usb_otg20_descriptor *otg20_desc; > + struct usb_otg_caps *otg_caps = gadget->otg_caps; > + u8 otg_attributes = 0; > + > + if (!otg_desc) > + return -EINVAL; > + > + if (otg_caps && otg_caps->otg_rev) { OK now I see why usb_gadget->otg_caps needs to be a pointer. :) > + if (otg_caps->hnp_support) > + otg_attributes |= USB_OTG_HNP; > + if (otg_caps->srp_support) > + otg_attributes |= USB_OTG_SRP; > + if (otg_caps->adp_support && (otg_caps->otg_rev >= 0x0200)) > + otg_attributes |= USB_OTG_ADP; > + } else { > + otg_attributes = USB_OTG_SRP | USB_OTG_HNP; > + } > + > + if (otg_caps && (otg_caps->otg_rev >= 0x0200)) { > + otg20_desc = (struct usb_otg20_descriptor *)otg_desc; > + otg20_desc->bLength = sizeof(struct usb_otg20_descriptor); > + otg20_desc->bDescriptorType = USB_DT_OTG; > + otg20_desc->bmAttributes = otg_attributes; > + otg20_desc->bcdOTG = cpu_to_le16(otg_caps->otg_rev); > + } else { > + otg1x_desc = (struct usb_otg_descriptor *)otg_desc; > + otg1x_desc->bLength = sizeof(struct usb_otg_descriptor); > + otg1x_desc->bDescriptorType = USB_DT_OTG; > + otg1x_desc->bmAttributes = otg_attributes; > + } > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(usb_otg_descriptor_init); > diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h > index 6b39087..5f65bd2 100644 > --- a/include/linux/usb/gadget.h > +++ b/include/linux/usb/gadget.h > @@ -1004,6 +1004,10 @@ int usb_assign_descriptors(struct usb_function *f, > struct usb_descriptor_header **ss); > void usb_free_all_descriptors(struct usb_function *f); > > +struct usb_descriptor_header *usb_otg_descriptor_alloc( > + struct usb_gadget *gadget); > +int usb_otg_descriptor_init(struct usb_gadget *gadget, > + struct usb_descriptor_header *otg_desc); > /*-*/ > > /* utility to simplify map/unmap of usb_requests to/from DMA */ Reviewed-by: Roger Quadros cheers, -roger -- 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 v4 04/23] usb: add usb_otg_caps to usb_gadget structure.
On Wed, Jun 17, 2015 at 11:29:36AM +0300, Roger Quadros wrote: > > On Wed, 17 Jun 2015 13:43:36 +0800 > Li Jun wrote: > > > From: Macpaul Lin > > > > Add usb_otg_caps pointer to usb_gadget structure to indicate its > > otg capabilities. > > > > Signed-off-by: Macpaul Lin > > Signed-off-by: Li Jun > > --- > > include/linux/usb/gadget.h | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h > > index 4f3dfb7..6b39087 100644 > > --- a/include/linux/usb/gadget.h > > +++ b/include/linux/usb/gadget.h > > @@ -511,6 +511,7 @@ struct usb_gadget_ops { > > * @dev: Driver model state for this abstract device. > > * @out_epnum: last used out ep number > > * @in_epnum: last used in ep number > > + * @otg_caps: OTG capabilities of this gadget. > > * @sg_supported: true if we can handle scatter-gather > > * @is_otg: True if the USB device port uses a Mini-AB jack, so that the > > * gadget driver must provide a USB OTG descriptor. > > @@ -559,6 +560,7 @@ struct usb_gadget { > > struct device dev; > > unsignedout_epnum; > > unsignedin_epnum; > > + struct usb_otg_caps *otg_caps; > > Why does this need to be a pointer? > we need create the same struct in controller driver anyway; usb_otg_caps is not only used for gadget, can be used for whole OTG, it's not proper we judge host's otg capability by gadget's setting; with a pointer, we need not create another one and no need data copy, instead, we have only one this struct in whole OTG device. Li Jun > > > > unsignedsg_supported:1; > > unsignedis_otg:1; > > > cheers, > -roger -- 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 v4 04/23] usb: add usb_otg_caps to usb_gadget structure.
On Wed, 17 Jun 2015 11:29:36 +0300 Roger Quadros wrote: > > On Wed, 17 Jun 2015 13:43:36 +0800 > Li Jun wrote: > > > From: Macpaul Lin > > > > Add usb_otg_caps pointer to usb_gadget structure to indicate its > > otg capabilities. > > > > Signed-off-by: Macpaul Lin > > Signed-off-by: Li Jun > > --- > > include/linux/usb/gadget.h | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h > > index 4f3dfb7..6b39087 100644 > > --- a/include/linux/usb/gadget.h > > +++ b/include/linux/usb/gadget.h > > @@ -511,6 +511,7 @@ struct usb_gadget_ops { > > * @dev: Driver model state for this abstract device. > > * @out_epnum: last used out ep number > > * @in_epnum: last used in ep number > > + * @otg_caps: OTG capabilities of this gadget. > > * @sg_supported: true if we can handle scatter-gather > > * @is_otg: True if the USB device port uses a Mini-AB jack, so that the > > * gadget driver must provide a USB OTG descriptor. > > @@ -559,6 +560,7 @@ struct usb_gadget { > > struct device dev; > > unsignedout_epnum; > > unsignedin_epnum; > > + struct usb_otg_caps *otg_caps; > > Why does this need to be a pointer? I got it. So that we can check if it is a legacy controller driver. > > > > > unsignedsg_supported:1; > > unsignedis_otg:1; So, Reviewed-by: Roger Quadros cheers, -roger -- 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 v3 2/2] USB: io_ti: Fix Edgeport firmware download code
On Mon, Jun 15, 2015 at 09:56:06AM -0500, Peter Berger wrote: > On Thu, 2015-06-11 at 11:10 +0200, Johan Hovold wrote: > > On Mon, Jun 08, 2015 at 02:36:36PM -0500, Peter Berger wrote: > > > On Fri, 2015-05-22 at 18:22 +0200, Johan Hovold wrote: > > > > On Fri, May 15, 2015 at 12:09:54AM -0500, Peter E. Berger wrote: > > > > > From: "Peter E. Berger" > > > > > > > > > > The io_ti driver fails to download firmware to Edgeport devices such > > > > > as the EP/416, even when the on-disk firmware image > > > > > (/lib/firmware/edgeport/down3.bin) is more current than the version > > > > > on the EP/416. The current download code is broken in a few ways. > > > > > Notably it mis-uses global variables OperationalMajorVersion and > > > > > OperationalMinorVersion (reading their values before they've been > > > > > properly > > > > > initialized and subsequently initializing them multiple times without > > > > > synchronization) and using an insufficient timeout in ti_vsend_sync() > > > > > when doing UMPC_COPY_DNLD_TO_I2C operations. With this patch, > > > > > firmware > > > > > downloads work as expected: if the on disk firmware version is newer > > > > > than that on the device, it will be downloaded. > > > > > > > > Thanks for fixing this. > > > > > > > > We should probably consider backporting some of this to stable as well. > > > > > > I am willing to start this process. Shall I wait until the patches are > > > first accepted here, or start this right away? > > > > I think the individual fixes should apply to older kernels without much > > extra effort. So as long a you try to keep individual fixes minimal (and > > with one fix per patch) the stable maintainers will usually take care of > > the backporting. > > > > > > But if you're fixing several independent issues, these should go in > > > > separate patches if possible. > > > > > > I suggest that these two patches are closely enough related (especially > > > now that the heartbeat patch uses the firmware version number that is > > > decoded in the "firmware download" patch) that they should be considered > > > together in a patchset. Do you agree or should I separate them? > > > > That's not what I meant. My point was that you may want to break this > > patch up into several patches that can be reviewed and backported > > individually (they may still depend on earlier patches in the series if > > necessary). > > Ah! Good idea. I've reworked the 2 patches into 10 separate > incremental patches, which also include fixes to address your other > review comments (below and from your other separate messages). That's a bit excessive. In this case it seems that a series of three or four patches would be appropriate. No need to do incremental changes to your own changes (e.g. after patch review). The guideline is one logical change per patch (e.g. fix firmware download timeout, fix firmware revision handling, etc). Johan -- 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
[RESEND PATCH 1/2] ARM: at91/dt: trivial: fix USB udc compatible string
To please checkpatch and the tiresome reader, add the "atmel," prefix to the USB udc compatible string. Signed-off-by: Nicolas Ferre Cc: #4.0+ --- Documentation/devicetree/bindings/usb/atmel-usb.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/atmel-usb.txt b/Documentation/devicetree/bindings/usb/atmel-usb.txt index 1be8d7a26c15..5883b73ea1b5 100644 --- a/Documentation/devicetree/bindings/usb/atmel-usb.txt +++ b/Documentation/devicetree/bindings/usb/atmel-usb.txt @@ -79,9 +79,9 @@ Atmel High-Speed USB device controller Required properties: - compatible: Should be one of the following - "at91sam9rl-udc" - "at91sam9g45-udc" - "sama5d3-udc" + "atmel,at91sam9rl-udc" + "atmel,at91sam9g45-udc" + "atmel,sama5d3-udc" - reg: Address and length of the register set for the device - interrupts: Should contain usba interrupt - clocks: Should reference the peripheral and host clocks -- 2.1.3 -- 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
[RESEND PATCH 2/2] ARM: at91/dt: update udc compatible strings
From: Boris Brezillon at91sam9g45, at91sam9x5 and sama5 SoCs should not use "atmel,at91sam9rl-udc" for their USB device compatible property since this compatible is attached to a specific hardware bug fix. Signed-off-by: Boris Brezillon Acked-by: Alexandre Belloni Tested-by: Bo Shen Acked-by: Nicolas Ferre Cc: #4.0+ --- Hi, This patch was forgotten while dealing with the series "usb: atmel_usba_udc: Rework errata handling". This patch and the previous one should be added to mainline as fixes, the soonest. In fact, the errata handling is now broken because of this desynchronization. We'll try to queue it during 4.2-rc phase for inclusion in arm-soc tree. Bye, arch/arm/boot/dts/at91sam9g45.dtsi | 2 +- arch/arm/boot/dts/at91sam9x5.dtsi | 2 +- arch/arm/boot/dts/sama5d3.dtsi | 2 +- arch/arm/boot/dts/sama5d4.dtsi | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi index d260ba779ae5..18177f5a7464 100644 --- a/arch/arm/boot/dts/at91sam9g45.dtsi +++ b/arch/arm/boot/dts/at91sam9g45.dtsi @@ -1148,7 +1148,7 @@ usb2: gadget@fff78000 { #address-cells = <1>; #size-cells = <0>; - compatible = "atmel,at91sam9rl-udc"; + compatible = "atmel,at91sam9g45-udc"; reg = <0x0060 0x8 0xfff78000 0x400>; interrupts = <27 IRQ_TYPE_LEVEL_HIGH 0>; diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi index 7521bdf17ef2..b6c8df8d380e 100644 --- a/arch/arm/boot/dts/at91sam9x5.dtsi +++ b/arch/arm/boot/dts/at91sam9x5.dtsi @@ -1108,7 +1108,7 @@ usb2: gadget@f803c000 { #address-cells = <1>; #size-cells = <0>; - compatible = "atmel,at91sam9rl-udc"; + compatible = "atmel,at91sam9g45-udc"; reg = <0x0050 0x8 0xf803c000 0x400>; interrupts = <23 IRQ_TYPE_LEVEL_HIGH 0>; diff --git a/arch/arm/boot/dts/sama5d3.dtsi b/arch/arm/boot/dts/sama5d3.dtsi index 5ab7548e04e1..9e2444b07bce 100644 --- a/arch/arm/boot/dts/sama5d3.dtsi +++ b/arch/arm/boot/dts/sama5d3.dtsi @@ -1321,7 +1321,7 @@ usb0: gadget@0050 { #address-cells = <1>; #size-cells = <0>; - compatible = "atmel,at91sam9rl-udc"; + compatible = "atmel,sama5d3-udc"; reg = <0x0050 0x10 0xf803 0x4000>; interrupts = <33 IRQ_TYPE_LEVEL_HIGH 2>; diff --git a/arch/arm/boot/dts/sama5d4.dtsi b/arch/arm/boot/dts/sama5d4.dtsi index 653a1f851f2b..3ee22ee13c5a 100644 --- a/arch/arm/boot/dts/sama5d4.dtsi +++ b/arch/arm/boot/dts/sama5d4.dtsi @@ -127,7 +127,7 @@ usb0: gadget@0040 { #address-cells = <1>; #size-cells = <0>; - compatible = "atmel,at91sam9rl-udc"; + compatible = "atmel,sama5d3-udc"; reg = <0x0040 0x10 0xfc02c000 0x4000>; interrupts = <47 IRQ_TYPE_LEVEL_HIGH 2>; -- 2.1.3 -- 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 v4 12/23] usb: gadget: ether: allocate and init otg descriptor by otg capabilities
On Wed, 17 Jun 2015 13:43:44 +0800 Li Jun wrote: > Allocate and initialize usb otg descriptor according to gadget otg > capabilities, add it for each usb configurations, free it while > composite unbind. If otg capability is not defined, keep its otg > descriptor unchanged. > > Signed-off-by: Li Jun > --- > drivers/usb/gadget/legacy/ether.c | 38 -- > 1 file changed, 24 insertions(+), 14 deletions(-) > > diff --git a/drivers/usb/gadget/legacy/ether.c > b/drivers/usb/gadget/legacy/ether.c > index a3323dc..06f4a30 100644 > --- a/drivers/usb/gadget/legacy/ether.c > +++ b/drivers/usb/gadget/legacy/ether.c > @@ -171,20 +171,7 @@ static struct usb_device_descriptor device_desc = { > .bNumConfigurations = 1, > }; > > -static struct usb_otg_descriptor otg_descriptor = { > - .bLength = sizeof otg_descriptor, > - .bDescriptorType = USB_DT_OTG, > - > - /* REVISIT SRP-only hardware is possible, although > - * it would not be called "OTG" ... > - */ > - .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, > -}; > - > -static const struct usb_descriptor_header *otg_desc[] = { > - (struct usb_descriptor_header *) &otg_descriptor, > - NULL, > -}; > +static const struct usb_descriptor_header *otg_desc[2]; > > static struct usb_string strings_dev[] = { > [USB_GADGET_MANUFACTURER_IDX].s = "", > @@ -229,6 +216,16 @@ static int rndis_do_config(struct usb_configuration *c) > /* FIXME alloc iConfiguration string, set it in c->strings */ > > if (gadget_is_otg(c->cdev->gadget)) { > + if (!otg_desc[0]) { > + struct usb_descriptor_header *usb_desc; > + > + usb_desc = usb_otg_descriptor_alloc(c->cdev->gadget); > + if (!usb_desc) > + return -ENOMEM; > + usb_otg_descriptor_init(c->cdev->gadget, usb_desc); > + otg_desc[0] = usb_desc; > + otg_desc[1] = NULL; > + } Why can't you do the otg_desc alloc/init in eth_bind()? That way you don't have to have this code twice in rndis_do_config() and eth_do_config(). It also matches the free being done in eth_unbind(). > c->descriptors = otg_desc; > c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; > } > @@ -271,6 +268,16 @@ static int eth_do_config(struct usb_configuration *c) > /* FIXME alloc iConfiguration string, set it in c->strings */ > > if (gadget_is_otg(c->cdev->gadget)) { > + if (!otg_desc[0]) { > + struct usb_descriptor_header *usb_desc; > + > + usb_desc = usb_otg_descriptor_alloc(c->cdev->gadget); > + if (!usb_desc) > + return -ENOMEM; > + usb_otg_descriptor_init(c->cdev->gadget, usb_desc); > + otg_desc[0] = usb_desc; > + otg_desc[1] = NULL; > + } > c->descriptors = otg_desc; > c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; > } > @@ -463,6 +470,9 @@ static int eth_unbind(struct usb_composite_dev *cdev) > usb_put_function(f_geth); > usb_put_function_instance(fi_geth); > } > + kfree(otg_desc[0]); > + otg_desc[0] = NULL; > + > return 0; > } > cheers, -roger -- 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 v4 11/23] usb: gadget: configfs: allocate and init otg descriptor by otg capabilities
On Wed, 17 Jun 2015 13:43:43 +0800 Li Jun wrote: > Allocate and initialize usb otg descriptor according to gadget otg > capabilities, add it for each usb configurations, free it while > composite unbind. If otg capability is not defined, keep its otg > descriptor unchanged. > > Signed-off-by: Li Jun Reviewed-by: Roger Quadros cheers, -roger > --- > drivers/usb/gadget/configfs.c | 29 - > 1 file changed, 20 insertions(+), 9 deletions(-) > > diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c > index 0495c94..c7b62ef 100644 > --- a/drivers/usb/gadget/configfs.c > +++ b/drivers/usb/gadget/configfs.c > @@ -41,6 +41,8 @@ int check_user_usb_string(const char *name, > #define MAX_NAME_LEN 40 > #define MAX_USB_STRING_LANGS 2 > > +static const struct usb_descriptor_header *otg_desc[2]; > + > struct gadget_info { > struct config_group group; > struct config_group functions_group; > @@ -55,9 +57,6 @@ struct gadget_info { > struct list_head available_func; > > const char *udc_name; > -#ifdef CONFIG_USB_OTG > - struct usb_otg_descriptor otg; > -#endif > struct usb_composite_driver composite; > struct usb_composite_dev cdev; > bool use_os_desc; > @@ -1376,6 +1375,19 @@ static int configfs_composite_bind(struct usb_gadget > *gadget, > memcpy(cdev->qw_sign, gi->qw_sign, OS_STRING_QW_SIGN_LEN); > } > > + if (gadget_is_otg(gadget) && !otg_desc[0]) { > + struct usb_descriptor_header *usb_desc; > + > + usb_desc = usb_otg_descriptor_alloc(gadget); > + if (!usb_desc) { > + ret = -ENOMEM; > + goto err_comp_cleanup; > + } > + usb_otg_descriptor_init(gadget, usb_desc); > + otg_desc[0] = usb_desc; > + otg_desc[1] = NULL; > + } > + > /* Go through all configs, attach all functions */ > list_for_each_entry(c, &gi->cdev.configs, list) { > struct config_usb_cfg *cfg; > @@ -1383,6 +1395,9 @@ static int configfs_composite_bind(struct usb_gadget > *gadget, > struct usb_function *tmp; > struct gadget_config_name *cn; > > + if (gadget_is_otg(gadget)) > + c->descriptors = otg_desc; > + > cfg = container_of(c, struct config_usb_cfg, c); > if (!list_empty(&cfg->string_list)) { > i = 0; > @@ -1437,6 +1452,8 @@ static void configfs_composite_unbind(struct usb_gadget > *gadget) > cdev = get_gadget_data(gadget); > gi = container_of(cdev, struct gadget_info, cdev); > > + kfree(otg_desc[0]); > + otg_desc[0] = NULL; > purge_configs_funcs(gi); > composite_dev_cleanup(cdev); > usb_ep_autoconfig_reset(cdev->gadget); > @@ -1510,12 +1527,6 @@ static struct config_group *gadgets_make( > if (!gi->composite.gadget_driver.function) > goto err; > > -#ifdef CONFIG_USB_OTG > - gi->otg.bLength = sizeof(struct usb_otg_descriptor); > - gi->otg.bDescriptorType = USB_DT_OTG; > - gi->otg.bmAttributes = USB_OTG_SRP | USB_OTG_HNP; > -#endif > - > config_group_init_type_name(&gi->group, name, > &gadget_root_type); > return &gi->group; -- 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 v4 13/23] usb: gadget: acm_ms: allocate and init otg descriptor by otg capabilities
On Wed, 17 Jun 2015 13:43:45 +0800 Li Jun wrote: > Allocate and initialize usb otg descriptor according to gadget otg > capabilities, add it for each usb configurations, free it while > composite unbind. If otg capability is not defined, keep its otg there is no composite unbind in acm_ms.c. > descriptor unchanged. > > Signed-off-by: Li Jun > --- > drivers/usb/gadget/legacy/acm_ms.c | 29 ++--- > 1 file changed, 14 insertions(+), 15 deletions(-) > > diff --git a/drivers/usb/gadget/legacy/acm_ms.c > b/drivers/usb/gadget/legacy/acm_ms.c > index 1194b09..f9b7b31 100644 > --- a/drivers/usb/gadget/legacy/acm_ms.c > +++ b/drivers/usb/gadget/legacy/acm_ms.c > @@ -58,21 +58,7 @@ static struct usb_device_descriptor device_desc = { > /*.bNumConfigurations = DYNAMIC*/ > }; > > -static struct usb_otg_descriptor otg_descriptor = { > - .bLength = sizeof otg_descriptor, > - .bDescriptorType = USB_DT_OTG, > - > - /* > - * REVISIT SRP-only hardware is possible, although > - * it would not be called "OTG" ... > - */ > - .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, > -}; > - > -static const struct usb_descriptor_header *otg_desc[] = { > - (struct usb_descriptor_header *) &otg_descriptor, > - NULL, > -}; > +static const struct usb_descriptor_header *otg_desc[2]; > > /* string IDs are assigned dynamically */ > static struct usb_string strings_dev[] = { > @@ -127,6 +113,16 @@ static int acm_ms_do_config(struct usb_configuration *c) > int status; > > if (gadget_is_otg(c->cdev->gadget)) { > + if (!otg_desc[0]) { > + struct usb_descriptor_header *usb_desc; > + > + usb_desc = usb_otg_descriptor_alloc(c->cdev->gadget); > + if (!usb_desc) > + return -ENOMEM; > + usb_otg_descriptor_init(c->cdev->gadget, usb_desc); > + otg_desc[0] = usb_desc; > + otg_desc[1] = NULL; I think it is symmetric to put this code in acm_ms_bind() as you are freeing the descriptor in acm_ms_unbind(). Same applies for all other gadgets as well. > + } > c->descriptors = otg_desc; > c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; > } > @@ -255,6 +251,9 @@ static int acm_ms_unbind(struct usb_composite_dev *cdev) > usb_put_function_instance(fi_msg); > usb_put_function(f_acm); > usb_put_function_instance(f_acm_inst); > + kfree(otg_desc[0]); > + otg_desc[0] = NULL; > + > return 0; > } > cheers, -roger -- 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 v4 07/23] usb: common: add API to get usb otg features from device tree
On Wed, Jun 17, 2015 at 11:45:45AM +0300, Roger Quadros wrote: > > On Wed, 17 Jun 2015 13:43:39 +0800 > Li Jun wrote: > > > Check property of usb hardware to get otg version and if SRP, HNP and ADP > > are supported. > > > > Signed-off-by: Li Jun > > --- > > drivers/usb/common/common.c | 29 + > > include/linux/usb/of.h | 7 +++ > > 2 files changed, 36 insertions(+) > > > > diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c > > index b530fd4..b846172 100644 > > --- a/drivers/usb/common/common.c > > +++ b/drivers/usb/common/common.c > > @@ -154,6 +154,35 @@ bool of_usb_host_tpl_support(struct device_node *np) > > return false; > > } > > EXPORT_SYMBOL_GPL(of_usb_host_tpl_support); > > + > > +/** > > + * of_usb_get_otg_caps - to get usb otg capabilities according to > > + * the passed properties in DT. > > + * @np: Pointer to the given device_node > > + * @otg_caps: Pointer to the target usb_otg_caps to be set > > + * > > + * The function gets and sets the otg capabilities > > + */ > > +void of_usb_get_otg_caps(struct device_node *np, struct usb_otg_caps > > *otg_caps) > > +{ > > + u32 otg_rev; > > + > > + if (!otg_caps) > > + return; > > + > > + if (!of_property_read_u32(np, "otg-rev", &otg_rev)) { > > + otg_caps->otg_rev = otg_rev; > > + if (!of_find_property(np, "hnp-disable", NULL)) > > + otg_caps->hnp_support = true; > > + if (!of_find_property(np, "srp-disable", NULL)) > > + otg_caps->hnp_support = true; > > srp_support = true; > My fault. > > + if (!of_find_property(np, "adp-disable", NULL) && > > + (otg_caps->otg_rev >= 0x0200)) > > + otg_caps->hnp_support = true; > > adp_support = true; > My fault. > > + } > > I think we are loosing information here. > The DT disable flags get changed to enable flags (xyz_support) > and after this we can't really tell if the device tree really > wanted us to disable the feature or enable it based on > otg_rev/controller capabilities. > > Why not pass controller caps in otg_caps and then disable the > flags if requested from DT? > if (of_find_property(np, "foo-disbale", NULL)) > otg_caps->foo_support = false; > > The controller can still override anything afterwards > if it things something is wrong. > My guess is most controllers won't have to. > After more thinking, I think I can use the normal usage of disable flags to handle this, I will update, thanks. Li Jun > > +} > > +EXPORT_SYMBOL_GPL(of_usb_get_otg_caps); > > + > > #endif > > > > MODULE_LICENSE("GPL"); > > diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h > > index cfe0528..bbf302b9 100644 > > --- a/include/linux/usb/of.h > > +++ b/include/linux/usb/of.h > > @@ -15,6 +15,8 @@ > > enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np); > > enum usb_device_speed of_usb_get_maximum_speed(struct device_node *np); > > bool of_usb_host_tpl_support(struct device_node *np); > > +void of_usb_get_otg_caps(struct device_node *np, > > + struct usb_otg_caps *otg_caps); > > #else > > static inline enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np) > > { > > @@ -30,6 +32,11 @@ static inline bool of_usb_host_tpl_support(struct > > device_node *np) > > { > > return false; > > } > > +static inline void of_usb_get_otg_caps(struct device_node *np, > > + struct usb_otg_caps *otg_caps) > > +{ > > + > > +} > > #endif > > > > #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_USB_SUPPORT) > > cheers, > -roger -- 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 v5 02/10] USB: io_ti: Add timeout parameter to ti_vsend_sync()
On Mon, Jun 15, 2015 at 10:47:25AM -0500, Peter E. Berger wrote: > From: "Peter E. Berger" > > Instead of having ti_vsend_sync() decide when to use non-default timeouts, > make "timeout" a parameter and leave the decision to the caller. > > Signed-off-by: Peter E. Berger > --- > drivers/usb/serial/io_ti.c | 28 +--- > 1 file changed, 17 insertions(+), 11 deletions(-) > > diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c > index 3206a6f..75f08c3 100644 > --- a/drivers/usb/serial/io_ti.c > +++ b/drivers/usb/serial/io_ti.c > @@ -210,6 +210,10 @@ static int edge_create_sysfs_attrs(struct > usb_serial_port *port); > static int edge_remove_sysfs_attrs(struct usb_serial_port *port); > > > +/* Timeouts in msecs: firmware downloads take longer */ > +#define TI_VSEND_TIMEOUT_DEFAULT 1000 > +#define TI_VSEND_TIMEOUT_FW_DOWNLOAD 1 > + > static int ti_vread_sync(struct usb_device *dev, __u8 request, > __u16 value, __u16 index, u8 *data, int size) > { > @@ -228,14 +232,11 @@ static int ti_vread_sync(struct usb_device *dev, __u8 > request, > return 0; > } > > -static int ti_vsend_sync(struct usb_device *dev, __u8 request, > +static int ti_vsend_sync(struct usb_device *dev, __u8 request, int timeout, > __u16 value, __u16 index, u8 *data, int size) So merge this one with the first patch. Also add the timeout argument at the end of the argument list to match the USB API. Thanks, Johan -- 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 v5 03/10] USB: io_ti: Move request_firmware() calls out of download_fw()
On Mon, Jun 15, 2015 at 10:47:26AM -0500, Peter E. Berger wrote: > From: "Peter E. Berger" > > The io_ti driver fails to download firmware to Edgeport > devices such as the EP/416, even when the on-disk firmware image > (/lib/firmware/edgeport/down3.bin) is more current than the version > on the EP/416. The current download code is broken in a few ways. > Notably it mis-uses global variables OperationalMajorVersion and > OperationalMinorVersion (reading their values before they've been > properly initialized and subsequently initializing them multiple times > without synchronization). This patch drops the global variables and > replaces the redundant calls to request_firmware()/release_firmware() > in download_fw() with a single call pair in edge_startup(); the firmware > image pointer is then passed to download_fw() and build_i2c_fw_hdr(). > > Signed-off-by: Peter E. Berger You should only need this one and the heartbeat patch (on top of the timeout fix); simply merge the later incremental fixes to these patches as needed and I'll take a look at the resulting v6. Thanks, Johan -- 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: optimal io size / custom alignment
On 17 June 2015 at 05:28, Martin K. Petersen wrote: > There are plenty of SSDs that report 4K physical sectors, fwiw. Oh didn't know that. Wonder if it's yet another garbage info. Though 4k is often a nice value to make use of. > We gave up on USB-SATA bridges long ago. Their designers appear to have > a pretty comprehensive misunderstanding of both the ATA and SCSI > protocols. Aren't there tons of thumb drives make use of it anyway? > Tom> I just feel like the kernel shouldn't bind values from totally > Tom> different source (raid stripe vs vpd limit) to the same variable. > > RAID devices communicate the stripe width through the Block Limits VPD. No I put it in the wrong way. What I meant was "sd vs md". For example, couldn't the scsi disk driver bind the value it reads from the VPD to another variable instead of "optimal i/o size", so that this value would be exclusively for RAID (and other virtual devices)? Is it even necessary for it to report? Because it seems only to make this variable ambiguous. If it HAS TO BE ambiguous, I see no reason why fdisk should use it to derive the alignment. It should simply let the users do their judgement and provide a way for them to adjust manually. -- 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 v2] USB SERIAL: option.c: add 2020:4000 IDs
On Fri, Jun 12, 2015 at 09:32:31AM +0200, Claudio Cappelli wrote: > On Wednesday 10 June 2015 20:38:30 Claudio Cappelli wrote: > > From: Claudio Cappelli > > > > Add device Olivetti Olicard 300 (Network Connect: MT6225) - IDs 2020:4000. > > > > Signed-off-by: Claudio Cappelli > > Suggested-by: Lars Melin > > > > --- > > > > drivers/usb/serial/option.c |1 + > > 1 file changed, 1 insertion(+) > > > > > > > > --- linux/drivers/usb/serial/option.c.orig 2015-06-10 10:42:43.0 > > +0200 > > +++ linux/drivers/usb/serial/option.c 2015-06-10 10:53:06.825265579 > > +0200 > > @@ -1765,6 +1765,7 @@ static const struct usb_device_id option > > { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x00, 0x00) }, > > { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* > > D-Link DWM-152/C1 */ > > { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* > > D-Link DWM-156/C1 */ > > + { USB_DEVICE_INTERFACE_CLASS(0x2020, 0x4000, 0xff) },/* > > OLICARD300 - MT6225 */ > > { USB_DEVICE(INOVIA_VENDOR_ID, INOVIA_SEW858) }, > > { USB_DEVICE(VIATELECOM_VENDOR_ID, VIATELECOM_PRODUCT_CDS7) }, > > { } /* Terminating entry */ > > > > Was this second version in the right format? > Since it was my first patch submit, I'd be > grateful if you could confirm. Looks good. I've added the usb-devices output from your earlier mail to the commit message and queued it up for 4.2-rc2. Thanks, Johan -- 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 v4 12/23] usb: gadget: ether: allocate and init otg descriptor by otg capabilities
On Wed, Jun 17, 2015 at 12:03:04PM +0300, Roger Quadros wrote: > > > > > if (gadget_is_otg(c->cdev->gadget)) { > > + if (!otg_desc[0]) { > > + struct usb_descriptor_header *usb_desc; > > + > > + usb_desc = usb_otg_descriptor_alloc(c->cdev->gadget); > > + if (!usb_desc) > > + return -ENOMEM; > > + usb_otg_descriptor_init(c->cdev->gadget, usb_desc); > > + otg_desc[0] = usb_desc; > > + otg_desc[1] = NULL; > > + } > > Why can't you do the otg_desc alloc/init in eth_bind()? > That way you don't have to have this code twice > in rndis_do_config() and eth_do_config(). > > It also matches the free being done in eth_unbind(). > > Okay, I will update for all legacy gadget drivers. Li Jun > > cheers, > -roger -- 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 1/1] usb: Fix warning simple_strtoul is obsolete, use kstrtoul instead This patch fixes "simple_strtoul is obsolete, use kstrtoul instead" warning in usb.c.
Signed-off-by: Sunny Kumar --- drivers/usb/storage/usb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index 6c10c88..a0c0f66 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c @@ -485,9 +485,9 @@ void usb_stor_adjust_quirks(struct usb_device *udev, unsigned long *fflags) p = quirks; while (*p) { /* Each entry consists of VID:PID:flags */ - if (vid == simple_strtoul(p, &p, 16) && + if (vid == kstrtoul(p, &p, 16) && *p == ':' && - pid == simple_strtoul(p+1, &p, 16) && + pid == kstrtoul(p+1, &p, 16) && *p == ':') break; -- 2.1.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
[PATCH v5 02/23] usb: add USB_OTG_ADP definition
From: Macpaul Lin Add USB_OTG_ADP definition for usb_otg_descriptor.bmAttributes. Signed-off-by: Macpaul Lin Signed-off-by: Li Jun Acked-by: Peter Chen --- include/uapi/linux/usb/ch9.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h index aec6899..f7adc6e 100644 --- a/include/uapi/linux/usb/ch9.h +++ b/include/uapi/linux/usb/ch9.h @@ -688,6 +688,7 @@ struct usb_otg20_descriptor { /* from usb_otg_descriptor.bmAttributes */ #define USB_OTG_SRP(1 << 0) #define USB_OTG_HNP(1 << 1)/* swap host/device roles */ +#define USB_OTG_ADP(1 << 2)/* support ADP */ /*-*/ -- 1.9.1 -- 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 v5 01/23] usb: add usb_otg20_descriptor for OTG 2.0 and above
From: Macpaul Lin OTG 2.0 introduces bcdOTG in otg descriptor to identify the OTG and EH supplement release number with which the OTG device is compliant, this patch adds structure usb_otg20_descriptor for OTG 2.0 and above. Signed-off-by: Macpaul Lin Signed-off-by: Li Jun Reviewed-by: Roger Quadros --- include/uapi/linux/usb/ch9.h | 11 +++ 1 file changed, 11 insertions(+) diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h index aa33fd1..aec6899 100644 --- a/include/uapi/linux/usb/ch9.h +++ b/include/uapi/linux/usb/ch9.h @@ -674,6 +674,17 @@ struct usb_otg_descriptor { __u8 bmAttributes; /* support for HNP, SRP, etc */ } __attribute__ ((packed)); +/* USB_DT_OTG (from OTG 2.0 supplement) */ +struct usb_otg20_descriptor { + __u8 bLength; + __u8 bDescriptorType; + + __u8 bmAttributes; /* support for HNP, SRP and ADP, etc */ + __le16 bcdOTG; /* OTG and EH supplement release number +* in binary-coded decimal(i.e. 2.0 is 0200H) +*/ +} __attribute__ ((packed)); + /* from usb_otg_descriptor.bmAttributes */ #define USB_OTG_SRP(1 << 0) #define USB_OTG_HNP(1 << 1)/* swap host/device roles */ -- 1.9.1 -- 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 v5 05/23] usb: gadget: composite: add USB_DT_OTG request handling
From: Macpaul Lin Copy usb_otg_descriptor from config's descriptor if host requests USB_DT_OTG. Signed-off-by: Macpaul Lin Signed-off-by: Li Jun Reviewed-by: Roger Quadros --- drivers/usb/gadget/composite.c | 27 +++ 1 file changed, 27 insertions(+) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 4e3447b..2c1c6eb 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -19,6 +19,7 @@ #include #include +#include #include #include "u_os_desc.h" @@ -1534,6 +1535,32 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) value = min(w_length, (u16) value); } break; + case USB_DT_OTG: + if (gadget_is_otg(gadget)) { + struct usb_configuration *config; + int otg_desc_len = 0; + + if (cdev->config) + config = cdev->config; + else + config = list_first_entry( + &cdev->configs, + struct usb_configuration, list); + if (!config) + goto done; + + if (gadget->otg_caps && + (gadget->otg_caps->otg_rev >= 0x0200)) + otg_desc_len += sizeof( + struct usb_otg20_descriptor); + else + otg_desc_len += sizeof( + struct usb_otg_descriptor); + + value = min_t(int, w_length, otg_desc_len); + memcpy(req->buf, config->descriptors[0], value); + } + break; } break; -- 1.9.1 -- 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 v5 00/23] usb gadget update for OTG 2.0
Changes for v5: - By default otg feature are enabled if usb controller can support it. use of_usb_set_otg_caps to set otg_rev and disable features by DT. - Update legacy drivers, allocate and init otg descriptor in bind function, free it in unbind, to make alloation and free are symmetric. - Add Roger's reviewed-by. Changes for v4: - Add usb_otg_caps structure for all otg related capability attributes. - Use one interface: of_usb_get_otg_caps to get all otg capabilities from DT, including otg_rev, hnp/srp/adp support. - Add usb_otg_descriptor_alloc interface to allocate otg descriptor for better code sharing. - Improve description of dt-binding doc. This is a follow-up of Macpaul Lin's previous patchset to resolve usb gadget driver working with OTG 2.0, and set otg features by not only usb driver config but also usb hardware property in DT, main changes: 1. Add usb_otg20_descriptor definition for OTG 2.0 which introduces bcdOTG field for otg revision, bcdOTG can be passed via device tree. 2. OTG features(SRP/HNP/ADP) can be decided by combination of usb HW properties and usb driver config. 3. Change the chipidea usb driver to use the updated mechanism. 4. Remove static usb otg descriptor definition, but allocate and init it according to otg capabilities in each gadget driver, if otg capabilities is not defined for legacy platforms, the usb otg descriptor content is kept the same as current static definition. Li Jun (19): usb: otg: add usb_otg_caps structure for otg capabilities doc: dt-binding: usb: add otg related properties usb: common: add API to set usb otg capabilities by device tree usb: chipidea: set usb gadeget's otg capabilities usb: chipidea: update ci_otg_is_fsm_mode conditions usb: gadget: add usb otg descriptor allocate and init interface usb: gadget: configfs: allocate and init otg descriptor by otg capabilities usb: gadget: ether: allocate and init otg descriptor by otg capabilities usb: gadget: acm_ms: allocate and init otg descriptor by otg capabilities usb: gadget: audio: allocate and init otg descriptor by otg capabilities usb: gadget: cdc2: allocate and init otg descriptor by otg capabilities usb: gadget: g_ffs: allocate and init otg descriptor by otg capabilities usb: gadget: hid: allocate and init otg descriptor by otg capabilities usb: gadget: mass_storage: allocate and init otg descriptor by otg capabilities usb: gadget: multi: allocate and init otg descriptor by otg capabilities usb: gadget: ncm: allocate and init otg descriptor by otg capabilities usb: gadget: printer: allocate and init otg descriptor by otg capabilities usb: gadget: serial: allocate and init otg descriptor by otg capabilities usb: gadget: zero: allocate and init otg descriptor by otg capabilities Macpaul Lin (4): usb: add usb_otg20_descriptor for OTG 2.0 and above usb: add USB_OTG_ADP definition usb: add usb_otg_caps to usb_gadget structure. usb: gadget: composite: add USB_DT_OTG request handling Documentation/devicetree/bindings/usb/generic.txt | 15 ++ drivers/usb/chipidea/ci.h | 5 +- drivers/usb/chipidea/core.c | 8 drivers/usb/chipidea/debug.c | 1 + drivers/usb/chipidea/udc.c| 7 ++- drivers/usb/common/common.c | 28 drivers/usb/gadget/composite.c| 27 +++ drivers/usb/gadget/config.c | 56 +++ drivers/usb/gadget/configfs.c | 29 drivers/usb/gadget/legacy/acm_ms.c| 44 +- drivers/usb/gadget/legacy/audio.c | 43 + drivers/usb/gadget/legacy/cdc2.c | 44 +- drivers/usb/gadget/legacy/ether.c | 52 ++--- drivers/usb/gadget/legacy/g_ffs.c | 42 + drivers/usb/gadget/legacy/hid.c | 45 +- drivers/usb/gadget/legacy/mass_storage.c | 44 +- drivers/usb/gadget/legacy/multi.c | 39 ++-- drivers/usb/gadget/legacy/ncm.c | 43 + drivers/usb/gadget/legacy/printer.c | 35 +++--- drivers/usb/gadget/legacy/serial.c| 29 ++-- drivers/usb/gadget/legacy/zero.c | 32 ++--- include/linux/usb/chipidea.h | 1 + include/linux/usb/gadget.h| 6 +++ include/linux/usb/of.h| 7 +++ include/linux/usb/otg.h | 15 ++ include/uapi/linux/usb/ch9.h | 12 + 26 files changed, 465 insertions(+), 244 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message
[PATCH v5 06/23] doc: dt-binding: usb: add otg related properties
Add otg version, srp, hnp and adp support for usb OTG port, then those OTG features don't have to be decided by usb gadget drivers. Signed-off-by: Li Jun Reviewed-by: Roger Quadros --- Documentation/devicetree/bindings/usb/generic.txt | 15 +++ 1 file changed, 15 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/generic.txt b/Documentation/devicetree/bindings/usb/generic.txt index 477d5bb..bba8257 100644 --- a/Documentation/devicetree/bindings/usb/generic.txt +++ b/Documentation/devicetree/bindings/usb/generic.txt @@ -11,6 +11,19 @@ Optional properties: "peripheral" and "otg". In case this attribute isn't passed via DT, USB DRD controllers should default to OTG. + - otg-rev: tells usb driver the release number of the OTG and EH supplement + with which the device and its descriptors are compliant, + in binary-coded decimal (i.e. 2.0 is 0200H). This + property is used if any real OTG features(HNP/SRP/ADP) + is enabled, if ADP is required, otg-rev should be + 0x0200 or above. + - hnp-disable: tells OTG controllers we want to disable OTG HNP, normally HNP + is the basic function of real OTG except you want it + to be a srp-capable only B device. + - srp-disable: tells OTG controllers we want to disable OTG SRP, SRP is + optional for OTG device. + - adp-disable: tells OTG controllers we want to disable OTG ADP, ADP is + optional for OTG device. This is an attribute to a USB controller such as: @@ -21,4 +34,6 @@ dwc3@4a03 { usb-phy = <&usb2_phy>, <&usb3,phy>; maximum-speed = "super-speed"; dr_mode = "otg"; + otg-rev = <0x0200>; + adp-disable; }; -- 1.9.1 -- 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 v5 03/23] usb: otg: add usb_otg_caps structure for otg capabilities
This patch adds a structure usb_otg_caps to cover all otg related capabilities of the device, including otg revision, and if hnp/srp/adp is supported. Signed-off-by: Li Jun Reviewed-by: Roger Quadros --- include/linux/usb/otg.h | 15 +++ 1 file changed, 15 insertions(+) diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h index 52661c5..bd1dcf8 100644 --- a/include/linux/usb/otg.h +++ b/include/linux/usb/otg.h @@ -41,6 +41,21 @@ struct usb_otg { }; +/** + * struct usb_otg_caps - describes the otg capabilities of the device + * @otg_rev: The OTG revision number the device is compliant with, it's + * in binary-coded decimal (i.e. 2.0 is 0200H). + * @hnp_support: Indicates if the device supports HNP. + * @srp_support: Indicates if the device supports SRP. + * @adp_support: Indicates if the device supports ADP. + */ +struct usb_otg_caps { + u16 otg_rev; + bool hnp_support; + bool srp_support; + bool adp_support; +}; + extern const char *usb_otg_state_string(enum usb_otg_state state); /* Context: can sleep */ -- 1.9.1 -- 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 v5 07/23] usb: common: add API to set usb otg capabilities by device tree
Check property of usb hardware to get otg version and if SRP, HNP and ADP are disabled. Signed-off-by: Li Jun --- drivers/usb/common/common.c | 28 include/linux/usb/of.h | 7 +++ 2 files changed, 35 insertions(+) diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c index b530fd4..04f6925 100644 --- a/drivers/usb/common/common.c +++ b/drivers/usb/common/common.c @@ -154,6 +154,34 @@ bool of_usb_host_tpl_support(struct device_node *np) return false; } EXPORT_SYMBOL_GPL(of_usb_host_tpl_support); + +/** + * of_usb_get_set_caps - to set usb otg capabilities according to + * the passed properties in DT. + * @np: Pointer to the given device_node + * @otg_caps: Pointer to the target usb_otg_caps to be set + * + * The function gets and sets the otg capabilities + */ +void of_usb_set_otg_caps(struct device_node *np, struct usb_otg_caps *otg_caps) +{ + u32 otg_rev; + + if (!otg_caps) + return; + + if (!of_property_read_u32(np, "otg-rev", &otg_rev)) { + otg_caps->otg_rev = otg_rev; + if (of_find_property(np, "hnp-disable", NULL)) + otg_caps->hnp_support = false; + if (of_find_property(np, "srp-disable", NULL)) + otg_caps->srp_support = false; + if (of_find_property(np, "adp-disable", NULL)) + otg_caps->adp_support = false; + } +} +EXPORT_SYMBOL_GPL(of_usb_set_otg_caps); + #endif MODULE_LICENSE("GPL"); diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h index cfe0528..6339799 100644 --- a/include/linux/usb/of.h +++ b/include/linux/usb/of.h @@ -15,6 +15,8 @@ enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np); enum usb_device_speed of_usb_get_maximum_speed(struct device_node *np); bool of_usb_host_tpl_support(struct device_node *np); +void of_usb_set_otg_caps(struct device_node *np, + struct usb_otg_caps *otg_caps); #else static inline enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np) { @@ -30,6 +32,11 @@ static inline bool of_usb_host_tpl_support(struct device_node *np) { return false; } +static inline void of_usb_set_otg_caps(struct device_node *np, + struct usb_otg_caps *otg_caps) +{ + +} #endif #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_USB_SUPPORT) -- 1.9.1 -- 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 v5 04/23] usb: add usb_otg_caps to usb_gadget structure.
From: Macpaul Lin Add usb_otg_caps pointer to usb_gadget structure to indicate its otg capabilities. Signed-off-by: Macpaul Lin Signed-off-by: Li Jun Reviewed-by: Roger Quadros --- include/linux/usb/gadget.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 4f3dfb7..6b39087 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -511,6 +511,7 @@ struct usb_gadget_ops { * @dev: Driver model state for this abstract device. * @out_epnum: last used out ep number * @in_epnum: last used in ep number + * @otg_caps: OTG capabilities of this gadget. * @sg_supported: true if we can handle scatter-gather * @is_otg: True if the USB device port uses a Mini-AB jack, so that the * gadget driver must provide a USB OTG descriptor. @@ -559,6 +560,7 @@ struct usb_gadget { struct device dev; unsignedout_epnum; unsignedin_epnum; + struct usb_otg_caps *otg_caps; unsignedsg_supported:1; unsignedis_otg:1; -- 1.9.1 -- 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 v5 08/23] usb: chipidea: set usb gadeget's otg capabilities
Set gadget's otg capabilities according to controller's capability and otg properties in device tree. Signed-off-by: Li Jun --- drivers/usb/chipidea/core.c | 8 drivers/usb/chipidea/udc.c | 7 ++- include/linux/usb/chipidea.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 74fea4f..2abecbc 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -588,6 +588,14 @@ static int ci_get_platdata(struct device *dev, of_usb_host_tpl_support(dev->of_node); } + if (platdata->dr_mode == USB_DR_MODE_OTG) { + /* We can support HNP and SRP */ + platdata->ci_otg_caps.hnp_support = true; + platdata->ci_otg_caps.srp_support = true; + /* Update otg capabilities by DT properties */ + of_usb_set_otg_caps(dev->of_node, &platdata->ci_otg_caps); + } + if (of_usb_get_maximum_speed(dev->of_node) == USB_SPEED_FULL) platdata->flags |= CI_HDRC_FORCE_FULLSPEED; diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 764f668..858bd21 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -1827,6 +1827,7 @@ static irqreturn_t udc_irq(struct ci_hdrc *ci) static int udc_start(struct ci_hdrc *ci) { struct device *dev = ci->dev; + struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps; int retval = 0; spin_lock_init(&ci->lock); @@ -1834,8 +1835,12 @@ static int udc_start(struct ci_hdrc *ci) ci->gadget.ops = &usb_gadget_ops; ci->gadget.speed= USB_SPEED_UNKNOWN; ci->gadget.max_speed= USB_SPEED_HIGH; - ci->gadget.is_otg = ci->is_otg ? 1 : 0; ci->gadget.name = ci->platdata->name; + ci->gadget.otg_caps = otg_caps; + + if (otg_caps->otg_rev && (otg_caps->hnp_support || + otg_caps->srp_support || otg_caps->adp_support)) + ci->gadget.is_otg = 1; INIT_LIST_HEAD(&ci->gadget.ep_list); diff --git a/include/linux/usb/chipidea.h b/include/linux/usb/chipidea.h index ab94f78..e10cefc 100644 --- a/include/linux/usb/chipidea.h +++ b/include/linux/usb/chipidea.h @@ -34,6 +34,7 @@ struct ci_hdrc_platform_data { #define CI_HDRC_CONTROLLER_STOPPED_EVENT 1 void(*notify_event) (struct ci_hdrc *ci, unsigned event); struct regulator*reg_vbus; + struct usb_otg_caps ci_otg_caps; booltpl_support; }; -- 1.9.1 -- 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 v5 09/23] usb: chipidea: update ci_otg_is_fsm_mode conditions
After introduce usb otg properties, update ci_otg_is_fsm_mode conditions to be depending on both usb hardware properties and usb driver config, also resolve a compile issue in debug.c after the API change. Signed-off-by: Li Jun --- drivers/usb/chipidea/ci.h| 5 - drivers/usb/chipidea/debug.c | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h index 6d6200e..f243f0b 100644 --- a/drivers/usb/chipidea/ci.h +++ b/drivers/usb/chipidea/ci.h @@ -406,8 +406,11 @@ static inline u32 hw_test_and_write(struct ci_hdrc *ci, enum ci_hw_regs reg, static inline bool ci_otg_is_fsm_mode(struct ci_hdrc *ci) { #ifdef CONFIG_USB_OTG_FSM + struct usb_otg_caps *otg_caps = &ci->platdata->ci_otg_caps; + return ci->is_otg && ci->roles[CI_ROLE_HOST] && - ci->roles[CI_ROLE_GADGET]; + ci->roles[CI_ROLE_GADGET] && (otg_caps->srp_support || + otg_caps->hnp_support || otg_caps->adp_support); #else return false; #endif diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c index 5b7061a..3869c6d 100644 --- a/drivers/usb/chipidea/debug.c +++ b/drivers/usb/chipidea/debug.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "ci.h" #include "udc.h" -- 1.9.1 -- 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 v5 17/23] usb: gadget: hid: allocate and init otg descriptor by otg capabilities
Allocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged. Signed-off-by: Li Jun --- drivers/usb/gadget/legacy/hid.c | 45 ++--- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/drivers/usb/gadget/legacy/hid.c b/drivers/usb/gadget/legacy/hid.c index 2baa572..da4ebef 100644 --- a/drivers/usb/gadget/legacy/hid.c +++ b/drivers/usb/gadget/legacy/hid.c @@ -68,21 +68,7 @@ static struct usb_device_descriptor device_desc = { .bNumConfigurations = 1, }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength = sizeof otg_descriptor, - .bDescriptorType = USB_DT_OTG, - - /* REVISIT SRP-only hardware is possible, although -* it would not be called "OTG" ... -*/ - .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) &otg_descriptor, - NULL, -}; - +static const struct usb_descriptor_header *otg_desc[2]; /* string IDs are assigned dynamically */ static struct usb_string strings_dev[] = { @@ -111,11 +97,6 @@ static int do_config(struct usb_configuration *c) struct hidg_func_node *e, *n; int status = 0; - if (gadget_is_otg(c->cdev->gadget)) { - c->descriptors = otg_desc; - c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; - } - list_for_each_entry(e, &hidg_func_list, node) { e->f = usb_get_function(e->fi); if (IS_ERR(e->f)) @@ -186,16 +167,34 @@ static int hid_bind(struct usb_composite_dev *cdev) device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; + if (gadget_is_otg(gadget)) { + if (!otg_desc[0]) { + struct usb_descriptor_header *usb_desc; + + usb_desc = usb_otg_descriptor_alloc(gadget); + if (!usb_desc) + goto put; + usb_otg_descriptor_init(gadget, usb_desc); + otg_desc[0] = usb_desc; + otg_desc[1] = NULL; + } + config_driver.descriptors = otg_desc; + config_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; + } + /* register our configuration */ status = usb_add_config(cdev, &config_driver, do_config); if (status < 0) - goto put; + goto free_otg_desc; usb_composite_overwrite_options(cdev, &coverwrite); dev_info(&gadget->dev, DRIVER_DESC ", version: " DRIVER_VERSION "\n"); return 0; +free_otg_desc: + kfree(otg_desc[0]); + otg_desc[0] = NULL; put: list_for_each_entry(m, &hidg_func_list, node) { if (m == n) @@ -213,6 +212,10 @@ static int hid_unbind(struct usb_composite_dev *cdev) usb_put_function(n->f); usb_put_function_instance(n->fi); } + + kfree(otg_desc[0]); + otg_desc[0] = NULL; + return 0; } -- 1.9.1 -- 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 v5 10/23] usb: gadget: add usb otg descriptor allocate and init interface
Allocate usb otg descriptor and initialize it according to gadget's otg capabilities, if usb_otg_caps is not set, keep settings as current gadget drivers. With this 2 new interfaces, gadget can use usb_otg_descriptor for OTG 1.x, and usb_otg20_descriptor for OTG 2.0 or above, and otg features can be decided by the combination of usb hardware property and driver config. Signed-off-by: Li Jun Reviewed-by: Roger Quadros --- drivers/usb/gadget/config.c | 56 + include/linux/usb/gadget.h | 4 2 files changed, 60 insertions(+) diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c index 34e12fc..0fafa7a 100644 --- a/drivers/usb/gadget/config.c +++ b/drivers/usb/gadget/config.c @@ -20,6 +20,7 @@ #include #include #include +#include /** * usb_descriptor_fillbuf - fill buffer with descriptors @@ -195,3 +196,58 @@ void usb_free_all_descriptors(struct usb_function *f) usb_free_descriptors(f->ss_descriptors); } EXPORT_SYMBOL_GPL(usb_free_all_descriptors); + +struct usb_descriptor_header *usb_otg_descriptor_alloc( + struct usb_gadget *gadget) +{ + struct usb_descriptor_header *otg_desc; + unsigned length = 0; + + if (gadget->otg_caps && (gadget->otg_caps->otg_rev >= 0x0200)) + length = sizeof(struct usb_otg20_descriptor); + else + length = sizeof(struct usb_otg_descriptor); + + otg_desc = kzalloc(length, GFP_KERNEL); + return otg_desc; +} +EXPORT_SYMBOL_GPL(usb_otg_descriptor_alloc); + +int usb_otg_descriptor_init(struct usb_gadget *gadget, + struct usb_descriptor_header *otg_desc) +{ + struct usb_otg_descriptor *otg1x_desc; + struct usb_otg20_descriptor *otg20_desc; + struct usb_otg_caps *otg_caps = gadget->otg_caps; + u8 otg_attributes = 0; + + if (!otg_desc) + return -EINVAL; + + if (otg_caps && otg_caps->otg_rev) { + if (otg_caps->hnp_support) + otg_attributes |= USB_OTG_HNP; + if (otg_caps->srp_support) + otg_attributes |= USB_OTG_SRP; + if (otg_caps->adp_support && (otg_caps->otg_rev >= 0x0200)) + otg_attributes |= USB_OTG_ADP; + } else { + otg_attributes = USB_OTG_SRP | USB_OTG_HNP; + } + + if (otg_caps && (otg_caps->otg_rev >= 0x0200)) { + otg20_desc = (struct usb_otg20_descriptor *)otg_desc; + otg20_desc->bLength = sizeof(struct usb_otg20_descriptor); + otg20_desc->bDescriptorType = USB_DT_OTG; + otg20_desc->bmAttributes = otg_attributes; + otg20_desc->bcdOTG = cpu_to_le16(otg_caps->otg_rev); + } else { + otg1x_desc = (struct usb_otg_descriptor *)otg_desc; + otg1x_desc->bLength = sizeof(struct usb_otg_descriptor); + otg1x_desc->bDescriptorType = USB_DT_OTG; + otg1x_desc->bmAttributes = otg_attributes; + } + + return 0; +} +EXPORT_SYMBOL_GPL(usb_otg_descriptor_init); diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 6b39087..5f65bd2 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -1004,6 +1004,10 @@ int usb_assign_descriptors(struct usb_function *f, struct usb_descriptor_header **ss); void usb_free_all_descriptors(struct usb_function *f); +struct usb_descriptor_header *usb_otg_descriptor_alloc( + struct usb_gadget *gadget); +int usb_otg_descriptor_init(struct usb_gadget *gadget, + struct usb_descriptor_header *otg_desc); /*-*/ /* utility to simplify map/unmap of usb_requests to/from DMA */ -- 1.9.1 -- 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 v5 14/23] usb: gadget: audio: allocate and init otg descriptor by otg capabilities
Allocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged. Signed-off-by: Li Jun --- drivers/usb/gadget/legacy/audio.c | 43 +-- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/drivers/usb/gadget/legacy/audio.c b/drivers/usb/gadget/legacy/audio.c index f289caf..cf2bdaf 100644 --- a/drivers/usb/gadget/legacy/audio.c +++ b/drivers/usb/gadget/legacy/audio.c @@ -150,20 +150,7 @@ static struct usb_device_descriptor device_desc = { .bNumConfigurations = 1, }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength = sizeof otg_descriptor, - .bDescriptorType = USB_DT_OTG, - - /* REVISIT SRP-only hardware is possible, although -* it would not be called "OTG" ... -*/ - .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) &otg_descriptor, - NULL, -}; +static const struct usb_descriptor_header *otg_desc[2]; /*-*/ @@ -173,11 +160,6 @@ static int audio_do_config(struct usb_configuration *c) /* FIXME alloc iConfiguration string, set it in c->strings */ - if (gadget_is_otg(c->cdev->gadget)) { - c->descriptors = otg_desc; - c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; - } - #ifdef CONFIG_GADGET_UAC1 f_uac1 = usb_get_function(fi_uac1); if (IS_ERR(f_uac1)) { @@ -259,14 +241,32 @@ static int audio_bind(struct usb_composite_dev *cdev) device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; + if (gadget_is_otg(cdev->gadget)) { + if (!otg_desc[0]) { + struct usb_descriptor_header *usb_desc; + + usb_desc = usb_otg_descriptor_alloc(cdev->gadget); + if (!usb_desc) + goto fail; + usb_otg_descriptor_init(cdev->gadget, usb_desc); + otg_desc[0] = usb_desc; + otg_desc[1] = NULL; + } + audio_config_driver.descriptors = otg_desc; + audio_config_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; + } + status = usb_add_config(cdev, &audio_config_driver, audio_do_config); if (status < 0) - goto fail; + goto fail_otg_desc; usb_composite_overwrite_options(cdev, &coverwrite); INFO(cdev, "%s, version: %s\n", DRIVER_DESC, DRIVER_VERSION); return 0; +fail_otg_desc: + kfree(otg_desc[0]); + otg_desc[0] = NULL; fail: #ifndef CONFIG_GADGET_UAC1 usb_put_function_instance(fi_uac2); @@ -289,6 +289,9 @@ static int audio_unbind(struct usb_composite_dev *cdev) if (!IS_ERR_OR_NULL(fi_uac2)) usb_put_function_instance(fi_uac2); #endif + kfree(otg_desc[0]); + otg_desc[0] = NULL; + return 0; } -- 1.9.1 -- 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 v5 19/23] usb: gadget: multi: allocate and init otg descriptor by otg capabilities
Allocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged. Signed-off-by: Li Jun --- drivers/usb/gadget/legacy/multi.c | 39 --- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/drivers/usb/gadget/legacy/multi.c b/drivers/usb/gadget/legacy/multi.c index b21b51f..938b32c 100644 --- a/drivers/usb/gadget/legacy/multi.c +++ b/drivers/usb/gadget/legacy/multi.c @@ -78,21 +78,7 @@ static struct usb_device_descriptor device_desc = { .idProduct =cpu_to_le16(MULTI_PRODUCT_NUM), }; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) &(struct usb_otg_descriptor){ - .bLength = sizeof(struct usb_otg_descriptor), - .bDescriptorType = USB_DT_OTG, - - /* -* REVISIT SRP-only hardware is possible, although -* it would not be called "OTG" ... -*/ - .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, - }, - NULL, -}; - +static const struct usb_descriptor_header *otg_desc[2]; enum { MULTI_STRING_RNDIS_CONFIG_IDX = USB_GADGET_FIRST_AVAIL_IDX, @@ -155,6 +141,16 @@ static int rndis_do_config(struct usb_configuration *c) int ret; if (gadget_is_otg(c->cdev->gadget)) { + if (!otg_desc[0]) { + struct usb_descriptor_header *usb_desc; + + usb_desc = usb_otg_descriptor_alloc(c->cdev->gadget); + if (!usb_desc) + return -ENOMEM; + usb_otg_descriptor_init(c->cdev->gadget, usb_desc); + otg_desc[0] = usb_desc; + otg_desc[1] = NULL; + } c->descriptors = otg_desc; c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; } @@ -243,6 +239,16 @@ static int cdc_do_config(struct usb_configuration *c) int ret; if (gadget_is_otg(c->cdev->gadget)) { + if (!otg_desc[0]) { + struct usb_descriptor_header *usb_desc; + + usb_desc = usb_otg_descriptor_alloc(c->cdev->gadget); + if (!usb_desc) + return -ENOMEM; + usb_otg_descriptor_init(c->cdev->gadget, usb_desc); + otg_desc[0] = usb_desc; + otg_desc[1] = NULL; + } c->descriptors = otg_desc; c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; } @@ -490,6 +496,9 @@ static int multi_unbind(struct usb_composite_dev *cdev) usb_put_function(f_ecm); usb_put_function_instance(fi_ecm); #endif + kfree(otg_desc[0]); + otg_desc[0] = NULL; + return 0; } -- 1.9.1 -- 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 v5 12/23] usb: gadget: ether: allocate and init otg descriptor by otg capabilities
Allocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations, free it while ether unbind. If otg capability is not defined, keep its otg descriptor unchanged. Signed-off-by: Li Jun --- drivers/usb/gadget/legacy/ether.c | 52 +++ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/drivers/usb/gadget/legacy/ether.c b/drivers/usb/gadget/legacy/ether.c index a3323dc..2595288 100644 --- a/drivers/usb/gadget/legacy/ether.c +++ b/drivers/usb/gadget/legacy/ether.c @@ -171,20 +171,7 @@ static struct usb_device_descriptor device_desc = { .bNumConfigurations = 1, }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength = sizeof otg_descriptor, - .bDescriptorType = USB_DT_OTG, - - /* REVISIT SRP-only hardware is possible, although -* it would not be called "OTG" ... -*/ - .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) &otg_descriptor, - NULL, -}; +static const struct usb_descriptor_header *otg_desc[2]; static struct usb_string strings_dev[] = { [USB_GADGET_MANUFACTURER_IDX].s = "", @@ -228,11 +215,6 @@ static int rndis_do_config(struct usb_configuration *c) /* FIXME alloc iConfiguration string, set it in c->strings */ - if (gadget_is_otg(c->cdev->gadget)) { - c->descriptors = otg_desc; - c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; - } - f_rndis = usb_get_function(fi_rndis); if (IS_ERR(f_rndis)) return PTR_ERR(f_rndis); @@ -270,11 +252,6 @@ static int eth_do_config(struct usb_configuration *c) /* FIXME alloc iConfiguration string, set it in c->strings */ - if (gadget_is_otg(c->cdev->gadget)) { - c->descriptors = otg_desc; - c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; - } - if (use_eem) { f_eem = usb_get_function(fi_eem); if (IS_ERR(f_eem)) @@ -416,17 +393,34 @@ static int eth_bind(struct usb_composite_dev *cdev) device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; + if (gadget_is_otg(gadget)) { + if (!otg_desc[0]) { + struct usb_descriptor_header *usb_desc; + + usb_desc = usb_otg_descriptor_alloc(gadget); + if (!usb_desc) + goto fail1; + usb_otg_descriptor_init(gadget, usb_desc); + otg_desc[0] = usb_desc; + otg_desc[1] = NULL; + } + rndis_config_driver.descriptors = otg_desc; + rndis_config_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; + eth_config_driver.descriptors = otg_desc; + eth_config_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; + } + /* register our configuration(s); RNDIS first, if it's used */ if (has_rndis()) { status = usb_add_config(cdev, &rndis_config_driver, rndis_do_config); if (status < 0) - goto fail1; + goto fail2; } status = usb_add_config(cdev, ð_config_driver, eth_do_config); if (status < 0) - goto fail1; + goto fail2; usb_composite_overwrite_options(cdev, &coverwrite); dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", @@ -434,6 +428,9 @@ static int eth_bind(struct usb_composite_dev *cdev) return 0; +fail2: + kfree(otg_desc[0]); + otg_desc[0] = NULL; fail1: if (has_rndis()) usb_put_function_instance(fi_rndis); @@ -463,6 +460,9 @@ static int eth_unbind(struct usb_composite_dev *cdev) usb_put_function(f_geth); usb_put_function_instance(fi_geth); } + kfree(otg_desc[0]); + otg_desc[0] = NULL; + return 0; } -- 1.9.1 -- 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 v5 15/23] usb: gadget: cdc2: allocate and init otg descriptor by otg capabilities
Allocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged. Signed-off-by: Li Jun --- drivers/usb/gadget/legacy/cdc2.c | 44 +--- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/drivers/usb/gadget/legacy/cdc2.c b/drivers/usb/gadget/legacy/cdc2.c index afd3e37..531b8e0 100644 --- a/drivers/usb/gadget/legacy/cdc2.c +++ b/drivers/usb/gadget/legacy/cdc2.c @@ -60,21 +60,7 @@ static struct usb_device_descriptor device_desc = { .bNumConfigurations = 1, }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength = sizeof otg_descriptor, - .bDescriptorType = USB_DT_OTG, - - /* REVISIT SRP-only hardware is possible, although -* it would not be called "OTG" ... -*/ - .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) &otg_descriptor, - NULL, -}; - +static const struct usb_descriptor_header *otg_desc[2]; /* string IDs are assigned dynamically */ static struct usb_string strings_dev[] = { @@ -108,11 +94,6 @@ static int cdc_do_config(struct usb_configuration *c) { int status; - if (gadget_is_otg(c->cdev->gadget)) { - c->descriptors = otg_desc; - c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; - } - f_ecm = usb_get_function(fi_ecm); if (IS_ERR(f_ecm)) { status = PTR_ERR(f_ecm); @@ -193,10 +174,25 @@ static int cdc_bind(struct usb_composite_dev *cdev) device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; + if (gadget_is_otg(gadget)) { + if (!otg_desc[0]) { + struct usb_descriptor_header *usb_desc; + + usb_desc = usb_otg_descriptor_alloc(gadget); + if (!usb_desc) + goto fail1; + usb_otg_descriptor_init(gadget, usb_desc); + otg_desc[0] = usb_desc; + otg_desc[1] = NULL; + } + cdc_config_driver.descriptors = otg_desc; + cdc_config_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; + } + /* register our configuration */ status = usb_add_config(cdev, &cdc_config_driver, cdc_do_config); if (status < 0) - goto fail1; + goto fail2; usb_composite_overwrite_options(cdev, &coverwrite); dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", @@ -204,6 +200,9 @@ static int cdc_bind(struct usb_composite_dev *cdev) return 0; +fail2: + kfree(otg_desc[0]); + otg_desc[0] = NULL; fail1: usb_put_function_instance(fi_serial); fail: @@ -219,6 +218,9 @@ static int cdc_unbind(struct usb_composite_dev *cdev) usb_put_function(f_ecm); if (!IS_ERR_OR_NULL(fi_ecm)) usb_put_function_instance(fi_ecm); + kfree(otg_desc[0]); + otg_desc[0] = NULL; + return 0; } -- 1.9.1 -- 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 v5 11/23] usb: gadget: configfs: allocate and init otg descriptor by otg capabilities
Allocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations, free it while composite unbind. If otg capability is not defined, keep its otg descriptor unchanged. Signed-off-by: Li Jun Reviewed-by: Roger Quadros --- drivers/usb/gadget/configfs.c | 29 - 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index 0495c94..c7b62ef 100644 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -41,6 +41,8 @@ int check_user_usb_string(const char *name, #define MAX_NAME_LEN 40 #define MAX_USB_STRING_LANGS 2 +static const struct usb_descriptor_header *otg_desc[2]; + struct gadget_info { struct config_group group; struct config_group functions_group; @@ -55,9 +57,6 @@ struct gadget_info { struct list_head available_func; const char *udc_name; -#ifdef CONFIG_USB_OTG - struct usb_otg_descriptor otg; -#endif struct usb_composite_driver composite; struct usb_composite_dev cdev; bool use_os_desc; @@ -1376,6 +1375,19 @@ static int configfs_composite_bind(struct usb_gadget *gadget, memcpy(cdev->qw_sign, gi->qw_sign, OS_STRING_QW_SIGN_LEN); } + if (gadget_is_otg(gadget) && !otg_desc[0]) { + struct usb_descriptor_header *usb_desc; + + usb_desc = usb_otg_descriptor_alloc(gadget); + if (!usb_desc) { + ret = -ENOMEM; + goto err_comp_cleanup; + } + usb_otg_descriptor_init(gadget, usb_desc); + otg_desc[0] = usb_desc; + otg_desc[1] = NULL; + } + /* Go through all configs, attach all functions */ list_for_each_entry(c, &gi->cdev.configs, list) { struct config_usb_cfg *cfg; @@ -1383,6 +1395,9 @@ static int configfs_composite_bind(struct usb_gadget *gadget, struct usb_function *tmp; struct gadget_config_name *cn; + if (gadget_is_otg(gadget)) + c->descriptors = otg_desc; + cfg = container_of(c, struct config_usb_cfg, c); if (!list_empty(&cfg->string_list)) { i = 0; @@ -1437,6 +1452,8 @@ static void configfs_composite_unbind(struct usb_gadget *gadget) cdev = get_gadget_data(gadget); gi = container_of(cdev, struct gadget_info, cdev); + kfree(otg_desc[0]); + otg_desc[0] = NULL; purge_configs_funcs(gi); composite_dev_cleanup(cdev); usb_ep_autoconfig_reset(cdev->gadget); @@ -1510,12 +1527,6 @@ static struct config_group *gadgets_make( if (!gi->composite.gadget_driver.function) goto err; -#ifdef CONFIG_USB_OTG - gi->otg.bLength = sizeof(struct usb_otg_descriptor); - gi->otg.bDescriptorType = USB_DT_OTG; - gi->otg.bmAttributes = USB_OTG_SRP | USB_OTG_HNP; -#endif - config_group_init_type_name(&gi->group, name, &gadget_root_type); return &gi->group; -- 1.9.1 -- 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 v5 16/23] usb: gadget: g_ffs: allocate and init otg descriptor by otg capabilities
Allocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged. Signed-off-by: Li Jun --- drivers/usb/gadget/legacy/g_ffs.c | 42 --- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/drivers/usb/gadget/legacy/g_ffs.c b/drivers/usb/gadget/legacy/g_ffs.c index 7b9ef7e..a52d5b5 100644 --- a/drivers/usb/gadget/legacy/g_ffs.c +++ b/drivers/usb/gadget/legacy/g_ffs.c @@ -88,21 +88,7 @@ MODULE_PARM_DESC(bDeviceProtocol, "USB Device protocol"); module_param_array_named(functions, func_names, charp, &func_num, 0); MODULE_PARM_DESC(functions, "USB Functions list"); -static const struct usb_descriptor_header *gfs_otg_desc[] = { - (const struct usb_descriptor_header *) - &(const struct usb_otg_descriptor) { - .bLength= sizeof(struct usb_otg_descriptor), - .bDescriptorType= USB_DT_OTG, - - /* -* REVISIT SRP-only hardware is possible, although -* it would not be called "OTG" ... -*/ - .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, - }, - - NULL -}; +static const struct usb_descriptor_header *gfs_otg_desc[2]; /* String IDs are assigned dynamically */ static struct usb_string gfs_strings[] = { @@ -410,6 +396,17 @@ static int gfs_bind(struct usb_composite_dev *cdev) goto error_rndis; gfs_dev_desc.iProduct = gfs_strings[USB_GADGET_PRODUCT_IDX].id; + if (gadget_is_otg(cdev->gadget) && !gfs_otg_desc[0]) { + struct usb_descriptor_header *usb_desc; + + usb_desc = usb_otg_descriptor_alloc(cdev->gadget); + if (!usb_desc) + goto error_rndis; + usb_otg_descriptor_init(cdev->gadget, usb_desc); + gfs_otg_desc[0] = usb_desc; + gfs_otg_desc[1] = NULL; + } + for (i = 0; i < ARRAY_SIZE(gfs_configurations); ++i) { struct gfs_configuration *c = gfs_configurations + i; int sid = USB_GADGET_FIRST_AVAIL_IDX + i; @@ -419,6 +416,11 @@ static int gfs_bind(struct usb_composite_dev *cdev) c->c.bConfigurationValue= 1 + i; c->c.bmAttributes = USB_CONFIG_ATT_SELFPOWER; + if (gadget_is_otg(cdev->gadget)) { + c->c.descriptors = gfs_otg_desc; + c->c.bmAttributes |= USB_CONFIG_ATT_WAKEUP; + } + c->num = i; ret = usb_add_config(cdev, &c->c, gfs_do_config); @@ -430,6 +432,8 @@ static int gfs_bind(struct usb_composite_dev *cdev) /* TODO */ error_unbind: + kfree(gfs_otg_desc[0]); + gfs_otg_desc[0] = NULL; error_rndis: #ifdef CONFIG_USB_FUNCTIONFS_RNDIS usb_put_function_instance(fi_rndis); @@ -471,6 +475,9 @@ static int gfs_unbind(struct usb_composite_dev *cdev) for (i = 0; i < N_CONF * func_num; ++i) usb_put_function(*(f_ffs[0] + i)); + kfree(gfs_otg_desc[0]); + gfs_otg_desc[0] = NULL; + return 0; } @@ -488,11 +495,6 @@ static int gfs_do_config(struct usb_configuration *c) if (missing_funcs) return -ENODEV; - if (gadget_is_otg(c->cdev->gadget)) { - c->descriptors = gfs_otg_desc; - c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; - } - if (gc->eth) { ret = gc->eth(c); if (unlikely(ret < 0)) -- 1.9.1 -- 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 v5 18/23] usb: gadget: mass_storage: allocate and init otg descriptor by otg capabilities
Allocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged. Signed-off-by: Li Jun --- drivers/usb/gadget/legacy/mass_storage.c | 44 +--- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/drivers/usb/gadget/legacy/mass_storage.c b/drivers/usb/gadget/legacy/mass_storage.c index e7bfb08..42b4666 100644 --- a/drivers/usb/gadget/legacy/mass_storage.c +++ b/drivers/usb/gadget/legacy/mass_storage.c @@ -64,21 +64,7 @@ static struct usb_device_descriptor msg_device_desc = { .bNumConfigurations = 1, }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength = sizeof otg_descriptor, - .bDescriptorType = USB_DT_OTG, - - /* -* REVISIT SRP-only hardware is possible, although -* it would not be called "OTG" ... -*/ - .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) &otg_descriptor, - NULL, -}; +static const struct usb_descriptor_header *otg_desc[2]; static struct usb_string strings_dev[] = { [USB_GADGET_MANUFACTURER_IDX].s = "", @@ -135,11 +121,6 @@ static int msg_do_config(struct usb_configuration *c) struct fsg_opts *opts; int ret; - if (gadget_is_otg(c->cdev->gadget)) { - c->descriptors = otg_desc; - c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; - } - opts = fsg_opts_from_func_inst(fi_msg); f_msg = usb_get_function(fi_msg); @@ -214,9 +195,24 @@ static int msg_bind(struct usb_composite_dev *cdev) goto fail_string_ids; msg_device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; + if (gadget_is_otg(cdev->gadget)) { + if (!otg_desc[0]) { + struct usb_descriptor_header *usb_desc; + + usb_desc = usb_otg_descriptor_alloc(cdev->gadget); + if (!usb_desc) + goto fail_string_ids; + usb_otg_descriptor_init(cdev->gadget, usb_desc); + otg_desc[0] = usb_desc; + otg_desc[1] = NULL; + } + msg_config_driver.descriptors = otg_desc; + msg_config_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; + } + status = usb_add_config(cdev, &msg_config_driver, msg_do_config); if (status < 0) - goto fail_string_ids; + goto fail_otg_desc; usb_composite_overwrite_options(cdev, &coverwrite); dev_info(&cdev->gadget->dev, @@ -224,6 +220,9 @@ static int msg_bind(struct usb_composite_dev *cdev) set_bit(0, &msg_registered); return 0; +fail_otg_desc: + kfree(otg_desc[0]); + otg_desc[0] = NULL; fail_string_ids: fsg_common_remove_luns(opts->common); fail_set_cdev: @@ -243,6 +242,9 @@ static int msg_unbind(struct usb_composite_dev *cdev) if (!IS_ERR(fi_msg)) usb_put_function_instance(fi_msg); + kfree(otg_desc[0]); + otg_desc[0] = NULL; + return 0; } -- 1.9.1 -- 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 v5 21/23] usb: gadget: printer: allocate and init otg descriptor by otg capabilities
Allocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged. Signed-off-by: Li Jun --- drivers/usb/gadget/legacy/printer.c | 35 +++ 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/usb/gadget/legacy/printer.c b/drivers/usb/gadget/legacy/printer.c index 1ce7df1..1e557c5 100644 --- a/drivers/usb/gadget/legacy/printer.c +++ b/drivers/usb/gadget/legacy/printer.c @@ -82,16 +82,7 @@ static struct usb_device_descriptor device_desc = { .bNumConfigurations = 1 }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength = sizeof otg_descriptor, - .bDescriptorType = USB_DT_OTG, - .bmAttributes = USB_OTG_SRP, -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) &otg_descriptor, - NULL, -}; +static const struct usb_descriptor_header *otg_desc[2]; /*-*/ @@ -135,12 +126,6 @@ static int printer_do_config(struct usb_configuration *c) usb_gadget_set_selfpowered(gadget); - if (gadget_is_otg(gadget)) { - otg_descriptor.bmAttributes |= USB_OTG_HNP; - printer_cfg_driver.descriptors = otg_desc; - printer_cfg_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; - } - f_printer = usb_get_function(fi_printer); if (IS_ERR(f_printer)) return PTR_ERR(f_printer); @@ -182,6 +167,21 @@ static int printer_bind(struct usb_composite_dev *cdev) device_desc.iProduct = strings[USB_GADGET_PRODUCT_IDX].id; device_desc.iSerialNumber = strings[USB_GADGET_SERIAL_IDX].id; + if (gadget_is_otg(cdev->gadget)) { + if (!otg_desc[0]) { + struct usb_descriptor_header *usb_desc; + + usb_desc = usb_otg_descriptor_alloc(cdev->gadget); + if (!usb_desc) + return -ENOMEM; + usb_otg_descriptor_init(cdev->gadget, usb_desc); + otg_desc[0] = usb_desc; + otg_desc[1] = NULL; + } + printer_cfg_driver.descriptors = otg_desc; + printer_cfg_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; + } + ret = usb_add_config(cdev, &printer_cfg_driver, printer_do_config); if (ret) { usb_put_function_instance(fi_printer); @@ -196,6 +196,9 @@ static int printer_unbind(struct usb_composite_dev *cdev) usb_put_function(f_printer); usb_put_function_instance(fi_printer); + kfree(otg_desc[0]); + otg_desc[0] = NULL; + return 0; } -- 1.9.1 -- 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 v5 20/23] usb: gadget: ncm: allocate and init otg descriptor by otg capabilities
Allocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged. Signed-off-by: Li Jun --- drivers/usb/gadget/legacy/ncm.c | 43 ++--- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/drivers/usb/gadget/legacy/ncm.c b/drivers/usb/gadget/legacy/ncm.c index 6ce7421..f65ada8 100644 --- a/drivers/usb/gadget/legacy/ncm.c +++ b/drivers/usb/gadget/legacy/ncm.c @@ -69,20 +69,7 @@ static struct usb_device_descriptor device_desc = { .bNumConfigurations = 1, }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength = sizeof otg_descriptor, - .bDescriptorType = USB_DT_OTG, - - /* REVISIT SRP-only hardware is possible, although -* it would not be called "OTG" ... -*/ - .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) &otg_descriptor, - NULL, -}; +static const struct usb_descriptor_header *otg_desc[2]; /* string IDs are assigned dynamically */ static struct usb_string strings_dev[] = { @@ -113,11 +100,6 @@ static int ncm_do_config(struct usb_configuration *c) /* FIXME alloc iConfiguration string, set it in c->strings */ - if (gadget_is_otg(c->cdev->gadget)) { - c->descriptors = otg_desc; - c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; - } - f_ncm = usb_get_function(f_ncm_inst); if (IS_ERR(f_ncm)) { status = PTR_ERR(f_ncm); @@ -171,16 +153,34 @@ static int gncm_bind(struct usb_composite_dev *cdev) device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; + if (gadget_is_otg(gadget)) { + if (!otg_desc[0]) { + struct usb_descriptor_header *usb_desc; + + usb_desc = usb_otg_descriptor_alloc(gadget); + if (!usb_desc) + goto fail; + usb_otg_descriptor_init(gadget, usb_desc); + otg_desc[0] = usb_desc; + otg_desc[1] = NULL; + } + ncm_config_driver.descriptors = otg_desc; + ncm_config_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; + } + status = usb_add_config(cdev, &ncm_config_driver, ncm_do_config); if (status < 0) - goto fail; + goto fail1; usb_composite_overwrite_options(cdev, &coverwrite); dev_info(&gadget->dev, "%s\n", DRIVER_DESC); return 0; +fail1: + kfree(otg_desc[0]); + otg_desc[0] = NULL; fail: usb_put_function_instance(f_ncm_inst); return status; @@ -192,6 +192,9 @@ static int gncm_unbind(struct usb_composite_dev *cdev) usb_put_function(f_ncm); if (!IS_ERR_OR_NULL(f_ncm_inst)) usb_put_function_instance(f_ncm_inst); + kfree(otg_desc[0]); + otg_desc[0] = NULL; + return 0; } -- 1.9.1 -- 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 v5 13/23] usb: gadget: acm_ms: allocate and init otg descriptor by otg capabilities
Allocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged. Signed-off-by: Li Jun --- drivers/usb/gadget/legacy/acm_ms.c | 44 -- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/drivers/usb/gadget/legacy/acm_ms.c b/drivers/usb/gadget/legacy/acm_ms.c index 1194b09..8c840b9 100644 --- a/drivers/usb/gadget/legacy/acm_ms.c +++ b/drivers/usb/gadget/legacy/acm_ms.c @@ -58,21 +58,7 @@ static struct usb_device_descriptor device_desc = { /*.bNumConfigurations = DYNAMIC*/ }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength = sizeof otg_descriptor, - .bDescriptorType = USB_DT_OTG, - - /* -* REVISIT SRP-only hardware is possible, although -* it would not be called "OTG" ... -*/ - .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) &otg_descriptor, - NULL, -}; +static const struct usb_descriptor_header *otg_desc[2]; /* string IDs are assigned dynamically */ static struct usb_string strings_dev[] = { @@ -126,11 +112,6 @@ static int acm_ms_do_config(struct usb_configuration *c) struct fsg_opts *opts; int status; - if (gadget_is_otg(c->cdev->gadget)) { - c->descriptors = otg_desc; - c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; - } - opts = fsg_opts_from_func_inst(fi_msg); f_acm = usb_get_function(f_acm_inst); @@ -225,10 +206,25 @@ static int acm_ms_bind(struct usb_composite_dev *cdev) device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; + if (gadget_is_otg(gadget)) { + if (!otg_desc[0]) { + struct usb_descriptor_header *usb_desc; + + usb_desc = usb_otg_descriptor_alloc(gadget); + if (!usb_desc) + goto fail_string_ids; + usb_otg_descriptor_init(gadget, usb_desc); + otg_desc[0] = usb_desc; + otg_desc[1] = NULL; + } + acm_ms_config_driver.descriptors = otg_desc; + acm_ms_config_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; + } + /* register our configuration */ status = usb_add_config(cdev, &acm_ms_config_driver, acm_ms_do_config); if (status < 0) - goto fail_string_ids; + goto fail_otg_desc; usb_composite_overwrite_options(cdev, &coverwrite); dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", @@ -236,6 +232,9 @@ static int acm_ms_bind(struct usb_composite_dev *cdev) return 0; /* error recovery */ +fail_otg_desc: + kfree(otg_desc[0]); + otg_desc[0] = NULL; fail_string_ids: fsg_common_remove_luns(opts->common); fail_set_cdev: @@ -255,6 +254,9 @@ static int acm_ms_unbind(struct usb_composite_dev *cdev) usb_put_function_instance(fi_msg); usb_put_function(f_acm); usb_put_function_instance(f_acm_inst); + kfree(otg_desc[0]); + otg_desc[0] = NULL; + return 0; } -- 1.9.1 -- 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 v5 22/23] usb: gadget: serial: allocate and init otg descriptor by otg capabilities
Allocate and initialize usb otg descriptor according to gadget otg capabilities, add it for each usb configurations. If otg capability is not defined, keep its original otg descriptor unchanged. Signed-off-by: Li Jun --- drivers/usb/gadget/legacy/serial.c | 29 +++-- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/usb/gadget/legacy/serial.c b/drivers/usb/gadget/legacy/serial.c index 8b7528f..d1cd025 100644 --- a/drivers/usb/gadget/legacy/serial.c +++ b/drivers/usb/gadget/legacy/serial.c @@ -79,20 +79,7 @@ static struct usb_device_descriptor device_desc = { .bNumConfigurations = 1, }; -static struct usb_otg_descriptor otg_descriptor = { - .bLength = sizeof otg_descriptor, - .bDescriptorType = USB_DT_OTG, - - /* REVISIT SRP-only hardware is possible, although -* it would not be called "OTG" ... -*/ - .bmAttributes = USB_OTG_SRP | USB_OTG_HNP, -}; - -static const struct usb_descriptor_header *otg_desc[] = { - (struct usb_descriptor_header *) &otg_descriptor, - NULL, -}; +static const struct usb_descriptor_header *otg_desc[2]; /*-*/ @@ -191,6 +178,16 @@ static int gs_bind(struct usb_composite_dev *cdev) serial_config_driver.iConfiguration = status; if (gadget_is_otg(cdev->gadget)) { + if (!otg_desc[0]) { + struct usb_descriptor_header *usb_desc; + + usb_desc = usb_otg_descriptor_alloc(cdev->gadget); + if (!usb_desc) + return -ENOMEM; + usb_otg_descriptor_init(cdev->gadget, usb_desc); + otg_desc[0] = usb_desc; + otg_desc[1] = NULL; + } serial_config_driver.descriptors = otg_desc; serial_config_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP; } @@ -227,6 +224,10 @@ static int gs_unbind(struct usb_composite_dev *cdev) usb_put_function(f_serial[i]); usb_put_function_instance(fi_serial[i]); } + + kfree(otg_desc[0]); + otg_desc[0] = NULL; + return 0; } -- 1.9.1 -- 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/1] usb: Fix warning simple_strtoul is obsolete, use kstrtoul instead This patch fixes "simple_strtoul is obsolete, use kstrtoul instead" warning in usb.c.
Hello. On 6/17/2015 2:20 PM, Sunny Kumar wrote: Your summary line and changelog got pasted together into the subject. Signed-off-by: Sunny Kumar WBR, Sergei -- 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 1/1] usb: Fix warning simple_strtoul is obsolete, use kstrtoul instead
This patch fixes "simple_strtoul is obsolete, use kstrtoul instead" warning in usb.c. Signed-off-by: Sunny Kumar --- drivers/usb/storage/usb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index 6c10c88..a0c0f66 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c @@ -485,9 +485,9 @@ void usb_stor_adjust_quirks(struct usb_device *udev, unsigned long *fflags) p = quirks; while (*p) { /* Each entry consists of VID:PID:flags */ - if (vid == simple_strtoul(p, &p, 16) && + if (vid == kstrtoul(p, &p, 16) && *p == ':' && - pid == simple_strtoul(p+1, &p, 16) && + pid == kstrtoul(p+1, &p, 16) && *p == ':') break; -- 2.1.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/1] usb: Fix warning simple_strtoul is obsolete, use kstrtoul instead
On Wed, Jun 17, 2015 at 05:42:57PM +0530, Sunny Kumar wrote: > This patch fixes "simple_strtoul is obsolete, use kstrtoul instead" > warning in usb.c. It's not always a straight substitution, otherwise we would have just converted the whole kernel all at once. Have you verified that the code still works properly after this? 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: ax88179_178a: ethernet to usb dongle disconnect crash
On Wed, Jun 17, 2015 at 10:31:40AM +0530, Vivek Bhagat wrote: > Hi All, > > I have connected my pc and TV board as below - > > PC (network i/f) <> ethernet to usb dongle <---> usb port of TV board > > When I power off my board, i get a kernel crash. > Please have a look at log attached here.I debug and found that > unregister_netdev() in usbnet_disconnect() clears net_device object > and still skb is under processing which tries to access net_device > object and leads to crash.Dongle is using ax88179_178.ko module. > > Backtrace: > [1-11856.1782] [] (fib_compute_spec_dst+0x0/0x17c) from > [] (ipv4_pktinfo_prepare+0x38/0x70) > [1-11856.1880] r6: r5:c5d55800 r4:c5d55800 > [1-11856.1926] [] (ipv4_pktinfo_prepare+0x0/0x70) from > [] (udp_queue_rcv_skb+0x1c8/0x384) > [1-11856.2023] r5:c5d55800 r4:cbdf4380 > [1-11856.2059] [] (udp_queue_rcv_skb+0x0/0x384) from > [] (flush_stack+0x100/0x118) > [1-11856.2148] r7:cd398480 r6: r5:cbdf4380 r4:c5d55800 > [1-11856.2205] [] (flush_stack+0x0/0x118) from [] > (__udp4_lib_mcast_deliver.isra.44+0x308/0x370) > [1-11856.2308] [] > (__udp4_lib_mcast_deliver.isra.44+0x0/0x370) from [] > (__udp4_lib_rcv+0x4b8/0x588) > [1-11856.2413] [] (__udp4_lib_rcv+0x0/0x588) from > [] (udp_rcv+0x20/0x28) > [1-11856.2495] [] (udp_rcv+0x0/0x28) from [] > (ip_local_deliver_finish+0x118/0x27c) > [1-11856.2585] [] (ip_local_deliver_finish+0x0/0x27c) from > [] (ip_local_deliver+0x8c/0x98) > [1-11856.2683] r7:d4b01a40 r6:cd398480 r5: r4:cd398480 > [1-11856.2740] [] (ip_local_deliver+0x0/0x98) from > [] (ip_rcv_finish+0x2c8/0x344) > [1-11856.2829] r4:00295a38 > [1-11856.2855] [] (ip_rcv_finish+0x0/0x344) from > [] (ip_rcv+0x324/0x3f0) > [1-11856.2936] r7:d4b01a40 r6:cd398480 r5:d2e8b720 r4:c0737500 > [1-11856.2993] [] (ip_rcv+0x0/0x3f0) from [] > (__netif_receive_skb_core+0x4d0/0x568) > [1-11856.3084] r7: r6: r5:c0708b34 r4:c070a728 > [1-11856.3141] [] (__netif_receive_skb_core+0x0/0x568) from > [] (__netif_receive_skb+0x20/0x70) > [1-11856.3242] [] (__netif_receive_skb+0x0/0x70) from > [] (process_backlog+0xec/0x1e8) > [1-11856.3335] r5: r4:d7c828c4 > [1-11856.3371] [] (process_backlog+0x0/0x1e8) from > [] (net_rx_action+0x104/0x2b8) > [1-11856.3460] [] (net_rx_action+0x0/0x2b8) from > [] (__do_softirq+0x180/0x304) > [1-11856.3548] [] (__do_softirq+0x0/0x304) from [] > (do_softirq+0x74/0xc4) > [1-11856.3630] [] (do_softirq+0x0/0xc4) from [] > (netif_rx_ni+0x50/0x78) > [1-11856.3711] r7:d1708780 r6:cd399380 r5: r4:c850a020 > [1-11856.3768] [] (netif_rx_ni+0x0/0x78) from [] > (dev_loopback_xmit+0xd4/0xe0) > [1-11856.3855] r5: r4:cd398480 > [1-11856.3891] [] (dev_loopback_xmit+0x0/0xe0) from > [] (ip_mc_output+0x114/0x234) > [1-11856.3980] r5: r4:cd398480 > [1-11856.4016] [] (ip_mc_output+0x0/0x234) from [] > (ip_local_out+0x38/0x3c) > [1-11856.4100] r9:00c6 r8:d2e8b734 r7:cbdf7800 r6:c0737500 r5:c0737500 > r4:cd399380 > [1-11856.4179] [] (ip_local_out+0x0/0x3c) from [] > (ip_send_skb+0x20/0x88) > [1-11856.4261] r5:c0737500 r4:cd399380 > [1-11856.4297] [] (ip_send_skb+0x0/0x88) from [] > (udp_send_skb+0x250/0x314) > [1-11856.4382] r5: r4:cd399380 > [1-11856.4417] [] (udp_send_skb+0x0/0x314) from [] > (udp_sendmsg+0x6a8/0x6d0) > [1-11856.4503] [] (udp_sendmsg+0x0/0x6d0) from [] > (inet_sendmsg+0x94/0xc4) > [1-11856.4586] [] (inet_sendmsg+0x0/0xc4) from [] > (sock_sendmsg+0xa0/0xbc) > [1-11856.4670] r7:c8406e40 r6:c850bf5c r5:00be r4:c4cda300 > [1-11856.4726] [] (sock_sendmsg+0x0/0xbc) from [] > (___sys_sendmsg.part.16+0x1a0/0x244) > [1-11856.4820] r7:c4cda300 r6: r5:c850be7c r4: > [1-11856.4877] [] (___sys_sendmsg.part.16+0x0/0x244) from > [] (__sys_sendmsg+0x5c/0x80) > [1-11856.4971] [] (__sys_sendmsg+0x0/0x80) from [] > (SyS_sendmsg+0x18/0x1c) > [1-11856.5055] r6:bdfda694 r5:bdfda60c r4:002841c0 > [1-11856.5101] [] (SyS_sendmsg+0x0/0x1c) from [] > (ret_fast_syscall+0x0/0x48) 3.10 is really old, please try something more "modern" like 4.0 at the very least to see if the issue is still there. 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 v3 0/6] usb: interface authorization
This patch introduces an interface authorization for USB devices. The kernel supports a device authorization because of wireless USB. But the new interface authorization allows to enable or disable individual interfaces instead allow or deny a whole device. Therefore a authorized attribute is introduced for each interface. Each patch depends on all patches with a lesser number. Stefan Koch (6): usb: interface authorization: Declare authorized attribute usb: interface authorization: Introduces the default interface authorization usb: interface authorization: Control interface probing and claiming usb: interface authorization: Introduces the USB interface authorization. usb: interface authorization: SysFS part of USB interface authorization. usb: interface authorization: Documentation part Documentation/ABI/testing/sysfs-bus-usb | 23 ++ Documentation/usb/authorization.txt | 22 ++ drivers/base/base.h | 1 - drivers/usb/core/driver.c | 11 + drivers/usb/core/hcd.c | 47 drivers/usb/core/hub.c | 77 - drivers/usb/core/message.c | 1 + drivers/usb/core/sysfs.c| 45 ++- drivers/usb/core/usb.h | 2 + include/linux/device.h | 1 + include/linux/usb.h | 1 + include/linux/usb/hcd.h | 1 + 12 files changed, 229 insertions(+), 3 deletions(-) -- 2.1.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
[PATCH v3 1/6] usb: interface authorization: Declare authorized attribute
The attribute authorized shows the authorization state for an interface. Signed-off-by: Stefan Koch --- include/linux/usb.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/usb.h b/include/linux/usb.h index 447fe29..24983dc 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -171,6 +171,7 @@ struct usb_interface { int minor; /* minor number this interface is * bound to */ enum usb_interface_condition condition; /* state of binding */ + unsigned authorized:1; /* used for interface authorization */ unsigned sysfs_files_created:1; /* the sysfs attributes exist */ unsigned ep_devs_created:1; /* endpoint "devices" exist */ unsigned unregistering:1; /* unregistration is in progress */ -- 2.1.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
[PATCH v3 3/6] usb: interface authorization: Control interface probing and claiming
Driver probings and interface claims get rejected if an interface is not authorized. Signed-off-by: Stefan Koch --- drivers/base/base.h | 1 - drivers/usb/core/driver.c | 11 +++ include/linux/device.h| 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/base/base.h b/drivers/base/base.h index 251c5d3..4b304a8 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -102,7 +102,6 @@ extern void container_dev_init(void); struct kobject *virtual_device_parent(struct device *dev); extern int bus_add_device(struct device *dev); -extern void bus_probe_device(struct device *dev); extern void bus_remove_device(struct device *dev); extern int bus_add_driver(struct device_driver *drv); diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 818369a..9d4251f 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c @@ -295,6 +295,13 @@ static int usb_probe_interface(struct device *dev) if (udev->authorized == 0) { dev_err(&intf->dev, "Device is not authorized for usage\n"); return error; + } else if (intf->authorized == 0) { + unsigned intfNr = intf->altsetting->desc.bInterfaceNumber; + + dev_err(&intf->dev, "Interface 0x%02x is not authorized for usage\n", + intfNr); + + return error; } id = usb_match_dynamic_id(intf, driver); @@ -507,6 +514,10 @@ int usb_driver_claim_interface(struct usb_driver *driver, if (dev->driver) return -EBUSY; + /* reject claim if not iterface is not authorized */ + if (!iface->authorized) + return -ENODEV; + udev = interface_to_usbdev(iface); dev->driver = &driver->drvwrap.driver; diff --git a/include/linux/device.h b/include/linux/device.h index 6558af9..598d282 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -976,6 +976,7 @@ extern void device_release_driver(struct device *dev); extern int __must_check device_attach(struct device *dev); extern int __must_check driver_attach(struct device_driver *drv); extern int __must_check device_reprobe(struct device *dev); +extern void bus_probe_device(struct device *dev); /* * Easy functions for dynamically creating devices on the fly -- 2.1.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
[PATCH v3 2/6] usb: interface authorization: Introduces the default interface authorization
Interfaces are allowed per default. This can disabled or enabled (again) by writing 0 or 1 to /sys/bus/usb/devices/usb*/interface_authorized_default Signed-off-by: Stefan Koch --- drivers/usb/core/hcd.c | 47 ++ drivers/usb/core/message.c | 1 + include/linux/usb/hcd.h| 1 + 3 files changed, 49 insertions(+) diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 45a915c..3821532 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c @@ -882,9 +882,53 @@ static ssize_t authorized_default_store(struct device *dev, } static DEVICE_ATTR_RW(authorized_default); +/* + * interface_authorized_default_show - show default authorization status + * for USB interfaces + * + * note: interface_auhorized_default is the default value + * for initializing the authorized attribute of interfaces + */ +static ssize_t interface_authorized_default_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct usb_device *usb_dev = to_usb_device(dev); + struct usb_hcd *hcd = bus_to_hcd(usb_dev->bus); + unsigned def = hcd->interface_authorized_default; + + return sprintf(buf, "%u\n", def); +} + +/* + * interface_authorized_default_store - store default authorization status + * for USB interfaces + * + * note: interface_auhorized_default is the default value + * for initializing the authorized attribute of interfaces + */ +static ssize_t interface_authorized_default_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + struct usb_device *usb_dev = to_usb_device(dev); + struct usb_hcd *hcd = bus_to_hcd(usb_dev->bus); + int rc = count; + unsigned val; + + if (!usb_dev || !hcd) + rc = -ENODEV; + else if (sscanf(buf, "%u\n", &val) != 1) + rc = -EINVAL; + else + hcd->interface_authorized_default = val ? 1 : 0; + + return rc; +} +static DEVICE_ATTR_RW(interface_authorized_default); + /* Group all the USB bus attributes */ static struct attribute *usb_bus_attrs[] = { &dev_attr_authorized_default.attr, + &dev_attr_interface_authorized_default.attr, NULL, }; @@ -2679,6 +2723,9 @@ int usb_add_hcd(struct usb_hcd *hcd, hcd->authorized_default = authorized_default; set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); + /* per default all interfaces are authorized */ + hcd->interface_authorized_default = 1; + /* HC is in reset state, but accessible. Now do the one-time init, * bottom up so that hcds can customize the root hubs before hub_wq * starts talking to them. (Note, bus id is assigned early too.) diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index f368d20..def8db0 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -1807,6 +1807,7 @@ free_interfaces: intfc = cp->intf_cache[i]; intf->altsetting = intfc->altsetting; intf->num_altsetting = intfc->num_altsetting; + intf->authorized = hcd->interface_authorized_default; kref_get(&intfc->ref); alt = usb_altnum_to_altsetting(intf, 0); diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h index 68b1e83..85eff49 100644 --- a/include/linux/usb/hcd.h +++ b/include/linux/usb/hcd.h @@ -142,6 +142,7 @@ struct usb_hcd { unsigneduses_new_polling:1; unsignedwireless:1; /* Wireless USB HCD */ unsignedauthorized_default:1; + unsignedinterface_authorized_default:1; unsignedhas_tt:1; /* Integrated TT in root hub */ unsignedamd_resume_bug:1; /* AMD remote wakeup quirk */ unsignedcan_do_streams:1; /* HC supports streams */ -- 2.1.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
[PATCH v3 4/6] usb: interface authorization: Introduces the USB interface authorization.
The kernel supports the device authorization because of wireless USB. These is usable for wired USB devices, too. These new interface authorization allows to enable or disable individual interfaces instead a whole device. To avoid side effects the driver probing process for the interface and it's siblings is triggered after each authorization. Signed-off-by: Stefan Koch --- drivers/usb/core/hub.c | 77 +- drivers/usb/core/usb.h | 2 ++ 2 files changed, 78 insertions(+), 1 deletion(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 3b71516..6837281 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -2528,6 +2528,82 @@ out_unauthorized: return 0; } +/* + * usb_deauthorize_interface - deauthorize an USB interface + * + * @intf: USB interface structure + * + * Returns: 0 at success, <0 at failure + */ +int usb_deauthorize_interface(struct usb_interface *intf) +{ + struct device *dev = &intf->dev; + + if (!dev || !dev->parent) + return -ENODEV; + + device_lock(dev->parent); + + if (intf->authorized) { + intf->unregistering = 1; + intf->authorized = 0; + usb_forced_unbind_intf(intf); + } + + device_unlock(dev->parent); + + return 0; +} + +/* + * usb_authorize_interface - authorize an USB interface + * + * @intf: USB interface structure + * + * Returns: 0 at success, <0 at failure + */ +int usb_authorize_interface(struct usb_interface *intf) +{ + struct device *dev = &intf->dev; + struct usb_device *usb_pdev; + unsigned i, n; + struct usb_host_config *actconfig; + + if (!dev->parent) + return -ENODEV; + + device_lock(dev->parent); + usb_pdev = to_usb_device(dev->parent); + + if (!usb_pdev || !usb_pdev->actconfig) { + device_unlock(dev->parent); + return -ENODEV; + } + + actconfig = usb_pdev->actconfig; + + if (!intf->authorized) { + intf->authorized = 1; /* authorize interface */ + + /* number of device's interfaces */ + n = actconfig->desc.bNumInterfaces; + + /* +* probe all interfaces to ensure correct binding +* of drivers with multiple interfaces +*/ + for (i = 0; i < n; i++) { + struct usb_interface *intf = actconfig->interface[i]; + + if (intf) + bus_probe_device(&intf->dev); + } + } + + device_unlock(dev->parent); + + return 0; +} int usb_authorize_device(struct usb_device *usb_dev) { @@ -2577,7 +2653,6 @@ out_authorized: return result; } - /* Returns 1 if @hub is a WUSB root hub, 0 otherwise */ static unsigned hub_is_wusb(struct usb_hub *hub) { diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index 7eb1e26..37b0055 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h @@ -27,6 +27,8 @@ extern void usb_release_interface_cache(struct kref *ref); extern void usb_disable_device(struct usb_device *dev, int skip_ep0); extern int usb_deauthorize_device(struct usb_device *); extern int usb_authorize_device(struct usb_device *); +extern int usb_deauthorize_interface(struct usb_interface *); +extern int usb_authorize_interface(struct usb_interface *); extern void usb_detect_quirks(struct usb_device *udev); extern void usb_detect_interface_quirks(struct usb_device *udev); extern int usb_remove_device(struct usb_device *udev); -- 2.1.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
[PATCH v3 6/6] usb: interface authorization: Documentation part
This part adds the documentation for the interface authorization. Signed-off-by: Stefan Koch --- Documentation/ABI/testing/sysfs-bus-usb | 23 +++ Documentation/usb/authorization.txt | 22 ++ 2 files changed, 45 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-usb b/Documentation/ABI/testing/sysfs-bus-usb index e5cc763..2ebca4d 100644 --- a/Documentation/ABI/testing/sysfs-bus-usb +++ b/Documentation/ABI/testing/sysfs-bus-usb @@ -1,3 +1,26 @@ +What: /sys/bus/usb/devices/INTERFACE/authorized +Date: June 2015 +KernelVersion: 4.2 +Description: + This allows to enable or disable individual interfaces + instead a whole device in contrast to + the device authorization. + To avoid side effects the driver probing process + for the interface and it's siblings is triggered + after each authorization. + The attribute allows a boolean value to + allow (1) or deny (0) an interface. + A denied interface cannot used for probing and claiming. + +What: /sys/bus/usb/devices/usbX/interface_authorized_default +Date: June 2015 +KernelVersion: 4.2 +Description: + This is used as default value that determines + if interfaces would allowed per default. + The attribute allows a boolean value to + allow (1) or deny (0) interfaces per default. + What: /sys/bus/usb/device/.../authorized Date: July 2008 KernelVersion: 2.6.26 diff --git a/Documentation/usb/authorization.txt b/Documentation/usb/authorization.txt index c069b68..f274219 100644 --- a/Documentation/usb/authorization.txt +++ b/Documentation/usb/authorization.txt @@ -3,6 +3,9 @@ Authorizing (or not) your USB devices to connect to the system (C) 2007 Inaky Perez-Gonzalez Intel Corporation +Interface authorization part: + (C) 2015 Stefan Koch SUSE LLC + This feature allows you to control if a USB device can be used (or not) in a system. This feature will allow you to implement a lock-down of USB devices, fully controlled by user space. @@ -90,3 +93,22 @@ etc, but you get the idea. Anybody with access to a device gadget kit can fake descriptors and device info. Don't trust that. You are welcome. + +Interface authorization +--- +There is a similar approach to allow or deny specific USB interfaces. +That allows to block only a subset of an USB device. + +Authorize an interface: +$ echo 1 > /sys/bus/usb/devices/INTERFACE/authorized + +Deauthorize an interface: +$ echo 0 > /sys/bus/usb/devices/INTERFACE/authorized + +The default value for new interfaces can be changed, too. + +Allow interfaces per default: +$ echo 1 > /sys/bus/usb/devices/usbX/interface_authorized_default + +Deny interfaces per default: +$ echo 0 > /sys/bus/usb/devices/usbX/interface_authorized_default -- 2.1.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
[PATCH v3 5/6] usb: interface authorization: SysFS part of USB interface authorization.
There is an attribute for each interface to allow (1) or deny (0) it: /sys/bus/usb/devices/*-*:*.*/authorized Signed-off-by: Stefan Koch --- drivers/usb/core/sysfs.c | 45 - 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index d269738..8e25292 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c @@ -622,7 +622,6 @@ usb_descriptor_attr(bDeviceProtocol, "%02x\n"); usb_descriptor_attr(bNumConfigurations, "%d\n"); usb_descriptor_attr(bMaxPacketSize0, "%d\n"); - /* show if the device is authorized (1) or not (0) */ static ssize_t authorized_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -926,6 +925,49 @@ static ssize_t supports_autosuspend_show(struct device *dev, } static DEVICE_ATTR_RO(supports_autosuspend); +/* + * interface_authorized_show - show authorization status of an USB interface + * 1 is authorized, 0 is deauthorized + */ +static ssize_t interface_authorized_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct usb_interface *intf = to_usb_interface(dev); + + if (!intf) + return -ENODEV; + + return sprintf(buf, "%u\n", intf->authorized); +} + +/* + * interface_authorized_store - authorize or deauthorize an USB interface + * 1 is to authorize, 0 is to deauthorize + */ +static ssize_t interface_authorized_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + struct usb_interface *intf = to_usb_interface(dev); + unsigned val; + + if (sscanf(buf, "%u\n", &val) != 1) + return -EINVAL; + + switch (val) { + case 0: + usb_deauthorize_interface(intf); + break; + case 1: + usb_authorize_interface(intf); + break; + } + + return count; +} +static struct device_attribute dev_attr_interface_authorized = + __ATTR_IGNORE_LOCKDEP(authorized, S_IRUGO | S_IWUSR, + interface_authorized_show, interface_authorized_store); + static struct attribute *intf_attrs[] = { &dev_attr_bInterfaceNumber.attr, &dev_attr_bAlternateSetting.attr, @@ -935,6 +977,7 @@ static struct attribute *intf_attrs[] = { &dev_attr_bInterfaceProtocol.attr, &dev_attr_modalias.attr, &dev_attr_supports_autosuspend.attr, + &dev_attr_interface_authorized.attr, NULL, }; static struct attribute_group intf_attr_grp = { -- 2.1.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 v3 3/6] usb: interface authorization: Control interface probing and claiming
On Wed, Jun 17, 2015 at 03:44:43PM +0200, Stefan Koch wrote: > Driver probings and interface claims get rejected > if an interface is not authorized. > > Signed-off-by: Stefan Koch > --- > drivers/base/base.h | 1 - > drivers/usb/core/driver.c | 11 +++ > include/linux/device.h| 1 + > 3 files changed, 12 insertions(+), 1 deletion(-) > > diff --git a/drivers/base/base.h b/drivers/base/base.h > index 251c5d3..4b304a8 100644 > --- a/drivers/base/base.h > +++ b/drivers/base/base.h > @@ -102,7 +102,6 @@ extern void container_dev_init(void); > struct kobject *virtual_device_parent(struct device *dev); > > extern int bus_add_device(struct device *dev); > -extern void bus_probe_device(struct device *dev); > extern void bus_remove_device(struct device *dev); Why are you making this bus_probe_device() change in this patch? 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 v3 5/6] usb: interface authorization: SysFS part of USB interface authorization.
On Wed, Jun 17, 2015 at 03:44:45PM +0200, Stefan Koch wrote: > There is an attribute for each interface to allow (1) or deny (0) it: > /sys/bus/usb/devices/*-*:*.*/authorized > > Signed-off-by: Stefan Koch > --- > drivers/usb/core/sysfs.c | 45 - > 1 file changed, 44 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c > index d269738..8e25292 100644 > --- a/drivers/usb/core/sysfs.c > +++ b/drivers/usb/core/sysfs.c > @@ -622,7 +622,6 @@ usb_descriptor_attr(bDeviceProtocol, "%02x\n"); > usb_descriptor_attr(bNumConfigurations, "%d\n"); > usb_descriptor_attr(bMaxPacketSize0, "%d\n"); > > - > /* show if the device is authorized (1) or not (0) */ > static ssize_t authorized_show(struct device *dev, > struct device_attribute *attr, char *buf) > @@ -926,6 +925,49 @@ static ssize_t supports_autosuspend_show(struct device > *dev, > } > static DEVICE_ATTR_RO(supports_autosuspend); > > +/* > + * interface_authorized_show - show authorization status of an USB interface > + * 1 is authorized, 0 is deauthorized > + */ > +static ssize_t interface_authorized_show(struct device *dev, > + struct device_attribute *attr, char *buf) > +{ > + struct usb_interface *intf = to_usb_interface(dev); > + > + if (!intf) > + return -ENODEV; That's an impossible thing, this will never happen even if dev is NULL so it's pointless to check, please remove. > + > + return sprintf(buf, "%u\n", intf->authorized); > +} > + > +/* > + * interface_authorized_store - authorize or deauthorize an USB interface > + * 1 is to authorize, 0 is to deauthorize > + */ > +static ssize_t interface_authorized_store(struct device *dev, > + struct device_attribute *attr, const char *buf, size_t count) > +{ > + struct usb_interface *intf = to_usb_interface(dev); > + unsigned val; > + > + if (sscanf(buf, "%u\n", &val) != 1) > + return -EINVAL; strtobool()? -- 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 v3 5/6] usb: interface authorization: SysFS part of USB interface authorization.
On Wed, Jun 17, 2015 at 03:44:45PM +0200, Stefan Koch wrote: > There is an attribute for each interface to allow (1) or deny (0) it: > /sys/bus/usb/devices/*-*:*.*/authorized > > Signed-off-by: Stefan Koch > --- > drivers/usb/core/sysfs.c | 45 - > 1 file changed, 44 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c > index d269738..8e25292 100644 > --- a/drivers/usb/core/sysfs.c > +++ b/drivers/usb/core/sysfs.c > @@ -622,7 +622,6 @@ usb_descriptor_attr(bDeviceProtocol, "%02x\n"); > usb_descriptor_attr(bNumConfigurations, "%d\n"); > usb_descriptor_attr(bMaxPacketSize0, "%d\n"); > > - > /* show if the device is authorized (1) or not (0) */ > static ssize_t authorized_show(struct device *dev, > struct device_attribute *attr, char *buf) Unneded whitespace change. -- 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 v2 0/5] usb: Add usb interface authorization
On Tue, 16 Jun 2015, Stefan Koch wrote: > > If autoprobing is disabled, all the user has to do is avoid writing to > > /sys/bus/usb/drivers_probe. > With my test case that works only with bus_probe_device() becaus it > checks the autoprobe status and calls then device_attach(). > > I have compiled the source once with bus_probe_device() and once with > device_attach() only. > > To conclude: bus_probe_device() was required to ensure that if > autoprobing was off that no driver was probed without writing it to > drivers_probe... You don't understand what I mean. Your patches should never do _any_ probing. All probing can be initiated by the user after the interfaces are authorized. If autoprobing is off, the user doesn't have to do anything. Nothing will be probed. If autoprobing is on, the user can tell the kernel to probe the authorized interfaces by writing to /sys/bus/usb/drivers_probe. 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
Re: [linux-usb] how to pass parameters to mass storage kernel module for best host compatibility
On Wed, 17 Jun 2015, Xuebing Wang wrote: > Alan, > > Thank you very much for your help. Using a valid serial number like > below (and without removable=1) can NOT get Win7 to auto-mount it. > modprobe g_mass_storage file=/dev/mmcblk0p4 iSerialNumber=123456789012 > nofua=1 All right. Maybe Windows will only auto-mount devices with removable media. Possibly this behavior can be changed by editing the Windows Registry, but I don't know what item would have to be changed -- I'm not an expert on Windows. > Will mass storage gadget driver convert from ASCII serial number to UNICODE? Yes. > Any ideas? Thanks again. Any ideas about what? 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
Re: [PATCH v3 1/6] usb: interface authorization: Declare authorized attribute
On Wed, 17 Jun 2015, Stefan Koch wrote: > The attribute authorized shows the authorization state for an interface. > > Signed-off-by: Stefan Koch > --- > include/linux/usb.h | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/include/linux/usb.h b/include/linux/usb.h > index 447fe29..24983dc 100644 > --- a/include/linux/usb.h > +++ b/include/linux/usb.h > @@ -171,6 +171,7 @@ struct usb_interface { > int minor; /* minor number this interface is >* bound to */ > enum usb_interface_condition condition; /* state of binding */ > + unsigned authorized:1; /* used for interface authorization */ You might want to copy the alignment of the other comments. For example, see the comment for "minor" above. > unsigned sysfs_files_created:1; /* the sysfs attributes exist */ > unsigned ep_devs_created:1; /* endpoint "devices" exist */ > unsigned unregistering:1; /* unregistration is in progress */ 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
Re: [PATCH] usb: xhci: make USB_XHCI_PLATFORM selectable
On 16.06.2015 23:01, Rafał Miłecki wrote: > On 16 June 2015 at 21:56, Greg Kroah-Hartman > wrote: >> On Tue, Jun 16, 2015 at 09:18:05PM +0200, Rafał Miłecki wrote: >>> Right now xhci-plat-hcd can be built when using one of platform specific >>> drivers only (mvebu/rcar). There shouldn't be such limitation as some >>> platforms may not require any quirks and may want to just use a generic >>> driver ("generic-xhci" / "xhci-hcd"). >> >> Don't you still need some kind of xhci platform driver? On its own, >> xhci-hcd doesn't provide what you need. > > First, I can just "generic-xhci" if the controller doesn't need any > extra setup. See even the example in > Documentation/devicetree/bindings/usb/usb-xhci.txt, there is that: > compatible = "generic-xhci"; > example entry for DT. > > And about "xhci-hcd": if there appears (one day) some platform driver > (e.g. non-DT) registering "xhci-hcd" platform device, it'll most > likely handle initialization on its own, before calling the > platform_device_add. True that there is no way to just select the xhci platform driver if all you need is a driver for a "generic-xhci" platform device with only interrupt and mem resources set in the platform device. Is this fixing some real life issue? I don't have strong opinions about this, for me adding this option is fine, or then wait until it's really needed by someone. -Mathias -- 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 v3 2/6] usb: interface authorization: Introduces the default interface authorization
On Wed, 17 Jun 2015, Stefan Koch wrote: > Interfaces are allowed per default. > This can disabled or enabled (again) by writing 0 or 1 to > /sys/bus/usb/devices/usb*/interface_authorized_default > > Signed-off-by: Stefan Koch > --- a/include/linux/usb/hcd.h > +++ b/include/linux/usb/hcd.h > @@ -142,6 +142,7 @@ struct usb_hcd { > unsigneduses_new_polling:1; > unsignedwireless:1; /* Wireless USB HCD */ > unsignedauthorized_default:1; > + unsignedinterface_authorized_default:1; This is the wrong place to put your new flag. This section is for flags that get set only during HCD registration or removal (see the comment on line 134). > unsignedhas_tt:1; /* Integrated TT in root hub */ > unsignedamd_resume_bug:1; /* AMD remote wakeup quirk */ > unsignedcan_do_streams:1; /* HC supports streams */ 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
Re: [PATCH v3 3/6] usb: interface authorization: Control interface probing and claiming
On Wed, 17 Jun 2015, Stefan Koch wrote: > Driver probings and interface claims get rejected > if an interface is not authorized. > > Signed-off-by: Stefan Koch > --- > drivers/base/base.h | 1 - > drivers/usb/core/driver.c | 11 +++ > include/linux/device.h| 1 + This patch shouldn't modify drivers/base/base.h or include/linux/device.h. > --- a/drivers/usb/core/driver.c > +++ b/drivers/usb/core/driver.c > @@ -295,6 +295,13 @@ static int usb_probe_interface(struct device *dev) > if (udev->authorized == 0) { > dev_err(&intf->dev, "Device is not authorized for usage\n"); > return error; > + } else if (intf->authorized == 0) { > + unsigned intfNr = intf->altsetting->desc.bInterfaceNumber; Please name this variable intf_num or something like that. Don't use CamelCase. Or get rid of the variable entirely and put intf->altsetting->desc.bInterfaceNumber directly into the dev_err() call below. > + > + dev_err(&intf->dev, "Interface 0x%02x is not authorized for > usage\n", > + intfNr); > + > + return error; > } > > id = usb_match_dynamic_id(intf, driver); 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
Re: [PATCH v3 3/6] usb: interface authorization: Control interface probing and claiming
Am Mittwoch, den 17.06.2015, 07:05 -0700 schrieb Greg KH: > On Wed, Jun 17, 2015 at 03:44:43PM +0200, Stefan Koch wrote: > > Driver probings and interface claims get rejected > > if an interface is not authorized. > > > > Signed-off-by: Stefan Koch > > --- > > drivers/base/base.h | 1 - > > drivers/usb/core/driver.c | 11 +++ > > include/linux/device.h| 1 + > > 3 files changed, 12 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/base/base.h b/drivers/base/base.h > > index 251c5d3..4b304a8 100644 > > --- a/drivers/base/base.h > > +++ b/drivers/base/base.h > > @@ -102,7 +102,6 @@ extern void container_dev_init(void); > > struct kobject *virtual_device_parent(struct device *dev); > > > > extern int bus_add_device(struct device *dev); > > -extern void bus_probe_device(struct device *dev); > > extern void bus_remove_device(struct device *dev); > > Why are you making this bus_probe_device() change in this patch? > Because bus_probe_device() is used in usb_authorize_device(). Using device_attach() works without header change. But bus_probe_device() is needed for check the autoprobe status. Example: User disables Autoprobing The default interace authorization is off The user enables an interface Without bus_probe_device() and with device_attach() alone the driver will get probed. With bus_probe_device() this is not done. The user can manually do with probe_device from sysfs. > 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: xhci: make USB_XHCI_PLATFORM selectable
On 17 June 2015 at 17:11, Mathias Nyman wrote: > On 16.06.2015 23:01, Rafał Miłecki wrote: >> On 16 June 2015 at 21:56, Greg Kroah-Hartman >> wrote: >>> On Tue, Jun 16, 2015 at 09:18:05PM +0200, Rafał Miłecki wrote: Right now xhci-plat-hcd can be built when using one of platform specific drivers only (mvebu/rcar). There shouldn't be such limitation as some platforms may not require any quirks and may want to just use a generic driver ("generic-xhci" / "xhci-hcd"). >>> >>> Don't you still need some kind of xhci platform driver? On its own, >>> xhci-hcd doesn't provide what you need. >> >> First, I can just "generic-xhci" if the controller doesn't need any >> extra setup. See even the example in >> Documentation/devicetree/bindings/usb/usb-xhci.txt, there is that: >> compatible = "generic-xhci"; >> example entry for DT. >> >> And about "xhci-hcd": if there appears (one day) some platform driver >> (e.g. non-DT) registering "xhci-hcd" platform device, it'll most >> likely handle initialization on its own, before calling the >> platform_device_add. > > True that there is no way to just select the xhci platform driver if all you > need is a driver for a "generic-xhci" platform device with only interrupt and > mem > resources set in the platform device. > > Is this fixing some real life issue? > > I don't have strong opinions about this, for me adding this option is fine, or > then wait until it's really needed by someone. I am/was trying to use "generic-xhci" for Broadcom's devices, unfortunately I'm still experiencing some stability problems. Not sure if there are related to the controller initialization or some more low-level stuff. Anyway, since "generic-xhci" support is there and not all dts files are part of kernel, it would be nice if you could accept this patch. Please note that there are many dts files living out of kernel source. Also some bootloaders support DT natively (it's not dtb appended to the kernel binary), so there may be ppl interested in using "generic-xhci" even if there isn't any in-kernel dts using that. -- Rafał -- 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 v2 0/5] usb: Add usb interface authorization
Am Mittwoch, den 17.06.2015, 10:43 -0400 schrieb Alan Stern: > On Tue, 16 Jun 2015, Stefan Koch wrote: > > > > If autoprobing is disabled, all the user has to do is avoid writing to > > > /sys/bus/usb/drivers_probe. > > With my test case that works only with bus_probe_device() becaus it > > checks the autoprobe status and calls then device_attach(). > > > > I have compiled the source once with bus_probe_device() and once with > > device_attach() only. > > > > To conclude: bus_probe_device() was required to ensure that if > > autoprobing was off that no driver was probed without writing it to > > drivers_probe... > > You don't understand what I mean. Your patches should never do _any_ > probing. All probing can be initiated by the user after the interfaces > are authorized. > > If autoprobing is off, the user doesn't have to do anything. Nothing > will be probed. > > If autoprobing is on, the user can tell the kernel to probe the > authorized interfaces by writing to /sys/bus/usb/drivers_probe. > > Alan Stern > You write in another mail: "You could probe all the interfaces whenever any interface is authorized. Or there could be a separate mechanism to initiate probing." The first is the actual approach and this works fine. It is regardless in which order the interfaces for USB-Tethering are authorized. Both works. Before probing *all* interfaces it was needed to authorize interface 1 before interface 0. Also btusb works fine. What do you think? -- 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 v3 4/6] usb: interface authorization: Introduces the USB interface authorization.
On Wed, 17 Jun 2015, Stefan Koch wrote: > The kernel supports the device authorization because of wireless USB. > These is usable for wired USB devices, too. > These new interface authorization allows to enable or disable > individual interfaces instead a whole device. > > To avoid side effects the driver probing process > for the interface and it's siblings is triggered after each authorization. No, don't do this. Allow the user to trigger probing, don't do it automatically. > Signed-off-by: Stefan Koch > --- > drivers/usb/core/hub.c | 77 > +- hub.c deals with devices, not interfaces. The new routines belong in message.c, along with all the other routines that manage interfaces. > drivers/usb/core/usb.h | 2 ++ > 2 files changed, 78 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c > index 3b71516..6837281 100644 > --- a/drivers/usb/core/hub.c > +++ b/drivers/usb/core/hub.c > @@ -2528,6 +2528,82 @@ out_unauthorized: > return 0; > } > > +/* > + * usb_deauthorize_interface - deauthorize an USB interface > + * > + * @intf: USB interface structure > + * > + * Returns: 0 at success, <0 at failure > + */ > +int usb_deauthorize_interface(struct usb_interface *intf) > +{ > + struct device *dev = &intf->dev; > + > + if (!dev || !dev->parent) > + return -ENODEV; This can never happen. Get rid of it. > + > + device_lock(dev->parent); > + > + if (intf->authorized) { > + intf->unregistering = 1; Don't set intf->unregistering. You aren't unregistering the interface; you are de-authorizing it. They are different things. > + intf->authorized = 0; > + usb_forced_unbind_intf(intf); > + } > + > + device_unlock(dev->parent); > + > + return 0; > +} 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
Re: [PATCH v3 5/6] usb: interface authorization: SysFS part of USB interface authorization.
On Wed, 17 Jun 2015, Stefan Koch wrote: > There is an attribute for each interface to allow (1) or deny (0) it: > /sys/bus/usb/devices/*-*:*.*/authorized > > Signed-off-by: Stefan Koch > +static struct device_attribute dev_attr_interface_authorized = > + __ATTR_IGNORE_LOCKDEP(authorized, S_IRUGO | S_IWUSR, > + interface_authorized_show, interface_authorized_store); Why did you use _IGNORE_LOCKDEP? Is it really necessary? 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
Re: [PATCH v3 6/6] usb: interface authorization: Documentation part
On Wed, 17 Jun 2015, Stefan Koch wrote: > This part adds the documentation for the interface authorization. > > Signed-off-by: Stefan Koch > --- > Documentation/ABI/testing/sysfs-bus-usb | 23 +++ > Documentation/usb/authorization.txt | 22 ++ > 2 files changed, 45 insertions(+) > > diff --git a/Documentation/ABI/testing/sysfs-bus-usb > b/Documentation/ABI/testing/sysfs-bus-usb > index e5cc763..2ebca4d 100644 > --- a/Documentation/ABI/testing/sysfs-bus-usb > +++ b/Documentation/ABI/testing/sysfs-bus-usb > @@ -1,3 +1,26 @@ > +What:/sys/bus/usb/devices/INTERFACE/authorized > +Date:June 2015 > +KernelVersion: 4.2 > +Description: > + This allows to enable or disable individual interfaces "authorize or de-authorize", not "enable or disable". > + instead a whole device in contrast to > + the device authorization. > + To avoid side effects the driver probing process > + for the interface and it's siblings is triggered > + after each authorization. Please remove this feature (unless other people on the mailing list really think it should be kept). Instead, point out that probing can be triggered by writing INTERFACE to /sys/bus/usb/drivers_probe, after all the authorization settings have been stored. > + The attribute allows a boolean value to > + allow (1) or deny (0) an interface. > + A denied interface cannot used for probing and claiming. "A de-authorized interface cannot be probed or claimed." > + > +What:/sys/bus/usb/devices/usbX/interface_authorized_default > +Date:June 2015 > +KernelVersion: 4.2 > +Description: > + This is used as default value that determines > + if interfaces would allowed per default. "This is used as the default value for /sys/bus/usb/devices/INTERFACE/authorized for interfaces in devices attached to the usbX bus." > + The attribute allows a boolean value to > + allow (1) or deny (0) interfaces per default. Delete this sentence. > + > What:/sys/bus/usb/device/.../authorized > Date:July 2008 > KernelVersion: 2.6.26 > diff --git a/Documentation/usb/authorization.txt > b/Documentation/usb/authorization.txt > index c069b68..f274219 100644 > --- a/Documentation/usb/authorization.txt > +++ b/Documentation/usb/authorization.txt > @@ -3,6 +3,9 @@ Authorizing (or not) your USB devices to connect to the system > > (C) 2007 Inaky Perez-Gonzalez Intel Corporation > > +Interface authorization part: > + (C) 2015 Stefan Koch SUSE LLC > + > This feature allows you to control if a USB device can be used (or > not) in a system. This feature will allow you to implement a lock-down > of USB devices, fully controlled by user space. > @@ -90,3 +93,22 @@ etc, but you get the idea. Anybody with access to a device > gadget kit > can fake descriptors and device info. Don't trust that. You are > welcome. > > + > +Interface authorization > +--- > +There is a similar approach to allow or deny specific USB interfaces. > +That allows to block only a subset of an USB device. > + > +Authorize an interface: > +$ echo 1 > /sys/bus/usb/devices/INTERFACE/authorized > + > +Deauthorize an interface: > +$ echo 0 > /sys/bus/usb/devices/INTERFACE/authorized > + > +The default value for new interfaces can be changed, too. The default value for new interfaces on a particular USB bus can be changed, too. > + > +Allow interfaces per default: > +$ echo 1 > /sys/bus/usb/devices/usbX/interface_authorized_default > + > +Deny interfaces per default: > +$ echo 0 > /sys/bus/usb/devices/usbX/interface_authorized_default > 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
Re: [PATCH v3 2/6] usb: interface authorization: Introduces the default interface authorization
Am Mittwoch, den 17.06.2015, 11:11 -0400 schrieb Alan Stern: > On Wed, 17 Jun 2015, Stefan Koch wrote: > > > Interfaces are allowed per default. > > This can disabled or enabled (again) by writing 0 or 1 to > > /sys/bus/usb/devices/usb*/interface_authorized_default > > > > Signed-off-by: Stefan Koch > > > --- a/include/linux/usb/hcd.h > > +++ b/include/linux/usb/hcd.h > > @@ -142,6 +142,7 @@ struct usb_hcd { > > unsigneduses_new_polling:1; > > unsignedwireless:1; /* Wireless USB HCD */ > > unsignedauthorized_default:1; > > + unsignedinterface_authorized_default:1; > > This is the wrong place to put your new flag. This section is for > flags that get set only during HCD registration or removal (see the > comment on line 134). What would be the best place? (The authorized_default is here, too) > > > unsignedhas_tt:1; /* Integrated TT in root hub */ > > unsignedamd_resume_bug:1; /* AMD remote wakeup quirk */ > > unsignedcan_do_streams:1; /* HC supports streams */ > > 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
Re: [PATCH v2 0/5] usb: Add usb interface authorization
On Wed, 17 Jun 2015, Stefan Koch wrote: > You write in another mail: > "You could probe all the interfaces whenever any interface is > authorized. Or there could be a separate mechanism to initiate probing." > > The first is the actual approach and this works fine. > It is regardless in which order the interfaces for USB-Tethering are > authorized. Both works. > Before probing *all* interfaces it was needed to authorize interface 1 > before interface 0. > > Also btusb works fine. > > What do you think? I think it's inelegant and will cause unnecessary probing with errors whenever a driver needs to claim multiple interfaces. However, I would like to hear what other people on the mailing list think. 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
Re: [PATCH v3 2/6] usb: interface authorization: Introduces the default interface authorization
On Wed, 17 Jun 2015, Stefan Koch wrote: > Am Mittwoch, den 17.06.2015, 11:11 -0400 schrieb Alan Stern: > > On Wed, 17 Jun 2015, Stefan Koch wrote: > > > > > Interfaces are allowed per default. > > > This can disabled or enabled (again) by writing 0 or 1 to > > > /sys/bus/usb/devices/usb*/interface_authorized_default > > > > > > Signed-off-by: Stefan Koch > > > > > --- a/include/linux/usb/hcd.h > > > +++ b/include/linux/usb/hcd.h > > > @@ -142,6 +142,7 @@ struct usb_hcd { > > > unsigneduses_new_polling:1; > > > unsignedwireless:1; /* Wireless USB HCD */ > > > unsignedauthorized_default:1; > > > + unsignedinterface_authorized_default:1; > > > > This is the wrong place to put your new flag. This section is for > > flags that get set only during HCD registration or removal (see the > > comment on line 134). > What would be the best place? (The authorized_default is here, too) They both should be part of hcd->flags. (The comment on lines 62-66 of this file doesn't seem to belong either, and it will be incorrect after your patch.) 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
Re: [PATCH v3 3/6] usb: interface authorization: Control interface probing and claiming
On Wed, Jun 17, 2015 at 05:13:51PM +0200, Stefan Koch wrote: > Am Mittwoch, den 17.06.2015, 07:05 -0700 schrieb Greg KH: > > On Wed, Jun 17, 2015 at 03:44:43PM +0200, Stefan Koch wrote: > > > Driver probings and interface claims get rejected > > > if an interface is not authorized. > > > > > > Signed-off-by: Stefan Koch > > > --- > > > drivers/base/base.h | 1 - > > > drivers/usb/core/driver.c | 11 +++ > > > include/linux/device.h| 1 + > > > 3 files changed, 12 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/base/base.h b/drivers/base/base.h > > > index 251c5d3..4b304a8 100644 > > > --- a/drivers/base/base.h > > > +++ b/drivers/base/base.h > > > @@ -102,7 +102,6 @@ extern void container_dev_init(void); > > > struct kobject *virtual_device_parent(struct device *dev); > > > > > > extern int bus_add_device(struct device *dev); > > > -extern void bus_probe_device(struct device *dev); > > > extern void bus_remove_device(struct device *dev); > > > > Why are you making this bus_probe_device() change in this patch? > > > Because bus_probe_device() is used in usb_authorize_device(). Not in this patch it isn't, so it doesn't belong here. > Using device_attach() works without header change. > But bus_probe_device() is needed for check the autoprobe status. > > Example: > User disables Autoprobing > The default interace authorization is off > The user enables an interface > Without bus_probe_device() and with device_attach() alone the driver > will get probed. With bus_probe_device() this is not done. > The user can manually do with probe_device from sysfs. Don't mess with the driver core, that's a huge sign something is really wrong with your patchset. Nothing is "special" enough in USB to warrant that. 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 v3 1/6] usb: interface authorization: Declare authorized attribute
Am Mittwoch, den 17.06.2015, 11:09 -0400 schrieb Alan Stern: > On Wed, 17 Jun 2015, Stefan Koch wrote: > > > The attribute authorized shows the authorization state for an interface. > > > > Signed-off-by: Stefan Koch > > --- > > include/linux/usb.h | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/include/linux/usb.h b/include/linux/usb.h > > index 447fe29..24983dc 100644 > > --- a/include/linux/usb.h > > +++ b/include/linux/usb.h > > @@ -171,6 +171,7 @@ struct usb_interface { > > int minor; /* minor number this interface is > > * bound to */ > > enum usb_interface_condition condition; /* state of binding */ > > + unsigned authorized:1; /* used for interface authorization */ > > You might want to copy the alignment of the other comments. For > example, see the comment for "minor" above. > > > unsigned sysfs_files_created:1; /* the sysfs attributes exist */ > > unsigned ep_devs_created:1; /* endpoint "devices" exist */ > > unsigned unregistering:1; /* unregistration is in progress */ > > Alan Stern > Should I move this attribute before "minor" or before "dev"? Should I use :1 or not. I could use instead a bool. -- 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 v3 1/6] usb: interface authorization: Declare authorized attribute
On Wed, 17 Jun 2015, Stefan Koch wrote: > > > --- a/include/linux/usb.h > > > +++ b/include/linux/usb.h > > > @@ -171,6 +171,7 @@ struct usb_interface { > > > int minor; /* minor number this interface is > > >* bound to */ > > > enum usb_interface_condition condition; /* state of binding */ > > > + unsigned authorized:1; /* used for interface authorization */ > > > > You might want to copy the alignment of the other comments. For > > example, see the comment for "minor" above. > > > > > unsigned sysfs_files_created:1; /* the sysfs attributes exist */ > > > unsigned ep_devs_created:1; /* endpoint "devices" exist */ > > > unsigned unregistering:1; /* unregistration is in progress */ > > > > Alan Stern > > > Should I move this attribute before "minor" or before "dev"? Should I > use :1 or not. I could use instead a bool. Definitely put this flag adjacent to the other single-bit flags. Definitely use :1. Whether to make it bool or unsigned is up to you -- for a single-bit value there is no difference. Also, you should lock intf->dev when changing intf->authorized. 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
[PATCH v6] usb: common: add API to set usb otg capabilities by device tree
Change for v6: UPdate otg caps by disable flags even if otg_rev is not passed, this is needed in case user wants to disable whole OTG(or just want to ID pin detect). Check property of usb hardware to get otg version and if SRP, HNP and ADP are disabled. Signed-off-by: Li Jun --- drivers/usb/common/common.c | 27 +++ include/linux/usb/of.h | 7 +++ 2 files changed, 34 insertions(+) diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c index b530fd4..12f5d28 100644 --- a/drivers/usb/common/common.c +++ b/drivers/usb/common/common.c @@ -154,6 +154,33 @@ bool of_usb_host_tpl_support(struct device_node *np) return false; } EXPORT_SYMBOL_GPL(of_usb_host_tpl_support); + +/** + * of_usb_get_set_caps - to set usb otg capabilities according to + * the passed properties in DT. + * @np: Pointer to the given device_node + * @otg_caps: Pointer to the target usb_otg_caps to be set + * + * The function gets and sets the otg capabilities + */ +void of_usb_set_otg_caps(struct device_node *np, struct usb_otg_caps *otg_caps) +{ + u32 otg_rev; + + if (!otg_caps) + return; + + if (!of_property_read_u32(np, "otg-rev", &otg_rev)) + otg_caps->otg_rev = otg_rev; + if (of_find_property(np, "hnp-disable", NULL)) + otg_caps->hnp_support = false; + if (of_find_property(np, "srp-disable", NULL)) + otg_caps->srp_support = false; + if (of_find_property(np, "adp-disable", NULL)) + otg_caps->adp_support = false; +} +EXPORT_SYMBOL_GPL(of_usb_set_otg_caps); + #endif MODULE_LICENSE("GPL"); diff --git a/include/linux/usb/of.h b/include/linux/usb/of.h index cfe0528..6339799 100644 --- a/include/linux/usb/of.h +++ b/include/linux/usb/of.h @@ -15,6 +15,8 @@ enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np); enum usb_device_speed of_usb_get_maximum_speed(struct device_node *np); bool of_usb_host_tpl_support(struct device_node *np); +void of_usb_set_otg_caps(struct device_node *np, + struct usb_otg_caps *otg_caps); #else static inline enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np) { @@ -30,6 +32,11 @@ static inline bool of_usb_host_tpl_support(struct device_node *np) { return false; } +static inline void of_usb_set_otg_caps(struct device_node *np, + struct usb_otg_caps *otg_caps) +{ + +} #endif #if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_USB_SUPPORT) -- 1.9.1 -- 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: [ehci-orion] ETIMEOUT with ehci_setup()'s ehci_halt()
> One final update on this topic: the kernel config was missing the > CONFIG_USB_EHCI_ROOT_HUB_TT option. It turns out that the USB IP embeded a > Transaction Translator and there is a check in ehci_halt() that aborts the > routine in case of a Transaction Translator in the ehci controller. The check > however only works in the above option is enabled. Maybe it would be worth detecting this and issuing a warning? Andrew -- 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