Re: [PATCH v2 1/1] usb: gadget: f_fs: Add support for SuperSpeed Mode
On 9/26/2013 2:10 AM, Felipe Balbi wrote: Hi, (please avoid top-posting) On Tue, Sep 24, 2013 at 03:00:20PM +0530, Manu Gautam wrote: Hi Felipe, I wanted to mention one point with respect to this patch: Below changes in the functionfs.h to add ss_count (super speed descriptors count) in desc_header (which is passed from userspace) make the driver incompatible with existing userspace applications compiled against old header file. Let me know if that is acceptable. We are using this driver with Android for adbd (android debug bridge) and these changes are required to support adb over Super Speed controllers e.g. DWC3 along with changed in adbd to pass SS EP and companion descriptors. Good you mentioned, it saves me the trouble of reviewing this patch :-) It's not acceptable to break userspace ABI at all. If you want SuperSpeed support on function fs, we need to figure out a way to do so without breaking userspace. This might mean adding a separate userspace interface to be used with superspeed. While at that, we might want to add a few bytes of reserved, unused space in our structures for situations where we need to add more data into it, just to make it slightly future proof. Thanks for your reply. As you suggested we can have a different interface for super speed which would be optional to workaround ABI compatibility issue. Let me know if below interface looks fine to you, I will then implement accordingly: diff --git a/include/uapi/linux/usb/functionfs.h b/include/uapi/linux/usb/functionfs.h index d6b0128..b8cb740 100644 --- a/include/uapi/linux/usb/functionfs.h +++ b/include/uapi/linux/usb/functionfs.h @@ -9,8 +9,9 @@ enum { - FUNCTIONFS_DESCRIPTORS_MAGIC = 1, - FUNCTIONFS_STRINGS_MAGIC = 2 + FUNCTIONFS_DESCRIPTORS_MAGIC = 1, + FUNCTIONFS_STRINGS_MAGIC = 2, + FUNCTIONFS_SS_DESCRIPTORS_MAGIC = 3 }; @@ -60,6 +61,25 @@ struct usb_functionfs_descs_head { * | 2 | payload | | descriptor's payload | */ +struct usb_functionfs_ss_descs_head { + __le32 magic; + __le32 length; + __le32 reserved; + __le32 ss_count; +} __attribute__((packed)); + +/* + * SS Descriptors format: + * + * | off | name | type | description | + * |-+---+--+--| + * | 0 | magic | LE32 | FUNCTIONFS_SS_DESCRIPTORS_MAGIC | + * | 4 | length| LE32 | length of the whole data chunk | + * | 8 | ss_count | LE32 | number of super-speed descriptors | + * | 12 | reserved field | + * | 16 | ss_descrs | Descriptor[] | list of super-speed descriptors | + */ + struct usb_functionfs_strings_head { __le32 magic; __le32 length; -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] usb: gadget: Use ERR_CAST inlined function instead of ERR_PTR(PTR_ERR(...))
Signed-off-by: Duan Jiong duanj.f...@cn.fujitsu.com --- drivers/usb/gadget/configfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index 8f0d614..1bfacbf 100644 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -557,7 +557,7 @@ static struct config_group *function_make( fi = usb_get_function_instance(func_name); if (IS_ERR(fi)) - return ERR_PTR(PTR_ERR(fi)); + return ERR_CAST(fi); ret = config_item_set_name(fi-group.cg_item, name); if (ret) { -- 1.8.3.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: [alsa-devel] Cannot load snd-usb-audio on 3.12-rc2
On 09/24/2013 05:52 PM, Daniel Mack wrote: Hi Sarah, On 24.09.2013 01:41, Sarah Sharp wrote: The snd-usb-audio driver no longer loads properly on 3.12-rc2 when I plug in my USB headset. It worked fine on 3.11-rc4 (not sure about vanilla 3.11). Trying to manually load the driver fails: sarah@xanatos:~$ sudo modprobe snd-usb-audio FATAL: Error inserting snd_usb_audio (/lib/modules/3.12.0-rc2/kernel/sound/usb/snd-usb-audio.ko): Invalid argument dmesg shows: [ 44.231668] snd_usb_audio: `-2' invalid for parameter `index' That's really strange. I just tested on an ARM board where I currently run 3.12-rc2 as well, and I can load the module without problems. Also, sound/usb/card.c (where the params are declared) hasn't seen an update in 3.12. I suspect your OS is passing index=-2 from something like /etc/modprobe.d/* or cmdline settings. Could you investigate in that direction? Ubuntu has passed options snd-usb-audio index=-2 ...since ages. It is, AFAIK, a very valid way of trying to make some other card be card 0. This is because card 0 is the default in some apps which are not using PulseAudio, so it's mostly there for historical reasons. -- David Henningsson, Canonical Ltd. https://launchpad.net/~diwic -- 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/5] dma: cppi41: only allocate descriptor memory once
* Daniel Mack | 2013-09-22 16:50:03 [+0200]: cdd-cd and cdd-descs_phys are allocated DESCS_AREAS times from init_descs() and freed as often from purge_descs(). This leads to both memory leaks and double-frees. Fix this by pulling the calls to dma_{alloc,free}_coherent() out of the loops. While at it, remove the intermediate variable mem_decs (I guess it was only there to make the code comply to the 80-chars CodingSytle rule). Signed-off-by: Daniel Mack zon...@gmail.com Please don't merge the memory descriptors. The idea was initially to allocate multiple small descriptors instead one big. The descrriptor turned out to be enough so it looks like the way it looks. If you want to clean this up, please either remove the for loop and allocate only one memory area or please prepare for multiple descripors (I think two is the upper limit). Sebastian -- 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 2/2] net: qmi_wwan: fix checkpatch warnings
Hi Bjørn, thanks for reviewing. On Wed, Sep 25, 2013 at 3:31 PM, Bjørn Mork bj...@mork.no wrote: Sorry, I really don't see the point of this. Yes, the lines are longer than 80 columns, but breaking them don't improve the readability at all. On the contrary, IMHO. So NAK from me for this part. Which changes do you think do not improve the readability? I'm sure that at least some of them actually improve the readability. Best regards Fabio Porcedda Fabio Porcedda fabio.porce...@gmail.com writes: Signed-off-by: Fabio Porcedda fabio.porce...@gmail.com --- drivers/net/usb/qmi_wwan.c | 56 +- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c index 5f6b6fa..0e59f9e 100644 --- a/drivers/net/usb/qmi_wwan.c +++ b/drivers/net/usb/qmi_wwan.c @@ -143,16 +143,22 @@ static const struct net_device_ops qmi_wwan_netdev_ops = { .ndo_validate_addr = eth_validate_addr, }; -/* using a counter to merge subdriver requests with our own into a combined state */ +/* using a counter to merge subdriver requests with our own into a + * combined state + */ static int qmi_wwan_manage_power(struct usbnet *dev, int on) { struct qmi_wwan_state *info = (void *)dev-data; int rv = 0; - dev_dbg(dev-intf-dev, %s() pmcount=%d, on=%d\n, __func__, atomic_read(info-pmcount), on); + dev_dbg(dev-intf-dev, %s() pmcount=%d, on=%d\n, __func__, + atomic_read(info-pmcount), on); - if ((on atomic_add_return(1, info-pmcount) == 1) || (!on atomic_dec_and_test(info-pmcount))) { - /* need autopm_get/put here to ensure the usbcore sees the new value */ + if ((on atomic_add_return(1, info-pmcount) == 1) || + (!on atomic_dec_and_test(info-pmcount))) { + /* need autopm_get/put here to ensure the usbcore sees + * the new value + */ rv = usb_autopm_get_interface(dev-intf); if (rv 0) goto err; @@ -199,7 +205,8 @@ static int qmi_wwan_register_subdriver(struct usbnet *dev) atomic_set(info-pmcount, 0); /* register subdriver */ - subdriver = usb_cdc_wdm_register(info-control, dev-status-desc, 4096, qmi_wwan_cdc_wdm_manage_power); + subdriver = usb_cdc_wdm_register(info-control, dev-status-desc, + 4096, qmi_wwan_cdc_wdm_manage_power); if (IS_ERR(subdriver)) { dev_err(info-control-dev, subdriver registration failed\n); rv = PTR_ERR(subdriver); @@ -228,7 +235,8 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf) struct usb_driver *driver = driver_of(intf); struct qmi_wwan_state *info = (void *)dev-data; - BUILD_BUG_ON((sizeof(((struct usbnet *)0)-data) sizeof(struct qmi_wwan_state))); + BUILD_BUG_ON((sizeof(((struct usbnet *)0)-data) + sizeof(struct qmi_wwan_state))); /* set up initial state */ info-control = intf; @@ -250,7 +258,8 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf) goto err; } if (h-bLength != sizeof(struct usb_cdc_header_desc)) { - dev_dbg(intf-dev, CDC header len %u\n, h-bLength); + dev_dbg(intf-dev, CDC header len %u\n, + h-bLength); goto err; } break; @@ -260,7 +269,8 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf) goto err; } if (h-bLength != sizeof(struct usb_cdc_union_desc)) { - dev_dbg(intf-dev, CDC union len %u\n, h-bLength); + dev_dbg(intf-dev, CDC union len %u\n, + h-bLength); goto err; } cdc_union = (struct usb_cdc_union_desc *)buf; @@ -271,15 +281,15 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf) goto err; } if (h-bLength != sizeof(struct usb_cdc_ether_desc)) { - dev_dbg(intf-dev, CDC ether len %u\n, h-bLength); + dev_dbg(intf-dev, CDC ether len %u\n, + h-bLength); goto err; } cdc_ether = (struct usb_cdc_ether_desc *)buf; break; } - /* - * Remember which CDC functional descriptors we've seen. Works + /*
Re: [PATCH v3 1/2] staging: dwc2: validate urb-actual_length for OUT endpoints
Hi folks, On Tue, Sep 24, 2013 at 11:08:53AM -0500, Felipe Balbi wrote: On Mon, Sep 23, 2013 at 02:23:33PM -0700, Paul Zimmerman wrote: + if ((urb-actual_length 0 || urb-actual_length urb-length) + !dwc2_hcd_is_pipe_in(urb-pipe_info)) + urb-actual_length = urb-length; I assume it was to fix some issue seen by our developers. We don't have detailed commit logs for that driver, so I am unable to say for certain. But since it is part of the downstream RaspberryPi driver, which has seen a lot of testing, I thought it best to include it. Maybe RPi folks can give some details ? Because I really wonder if we'd not be masking a bug somewhere else and this would make it a lot harder to pin-point that bug. Agreed. Perhaps there should be a message printed or a WARN() there so we can pinpoint in which cases this case actually occurs? Paul, did you see if this case actually triggers with your hardware? Gr. Matthijs signature.asc Description: Digital signature
Re: [PATCH v4 1/3] usb: dwc3: msm: Add device tree binding information
On Mon, Sep 23, 2013 at 08:31:48PM +0100, Felipe Balbi wrote: Hi, On Tue, Aug 20, 2013 at 12:56:03PM +0300, Ivan T. Ivanov wrote: From: Ivan T. Ivanov iiva...@mm-sol.com MSM USB3.0 core wrapper consist of USB3.0 IP from Synopsys (SNPS) and HS, SS PHY's control and configuration registers. It could operate in device mode (SS, HS, FS) and host mode (SS, HS, FS, LS). Signed-off-by: Ivan T. Ivanov iiva...@mm-sol.com Any acks for the DT part ? This patch has been pending forever. Apologies for the delay. I have a couple of comments that would be nice to fix up now. --- .../devicetree/bindings/usb/msm-ssusb.txt | 104 1 file changed, 104 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/msm-ssusb.txt diff --git a/Documentation/devicetree/bindings/usb/msm-ssusb.txt b/Documentation/devicetree/bindings/usb/msm-ssusb.txt new file mode 100644 index 000..cacbd3b --- /dev/null +++ b/Documentation/devicetree/bindings/usb/msm-ssusb.txt @@ -0,0 +1,104 @@ +MSM SuperSpeed DWC3 USB SoC controller + + +DWC3 Highspeed USB PHY +== +Required properities : +- compatible : sould be qcom,dwc3-hsphy; s/sould/should/ In general, compatible properties are should contain rather than should be, as we might have backwards compatible hardware in future. +- reg : offset and length of the register set in the memory map +- clocks : phandles to clock instances of the device tree nodes Clocks are referred to be phandle + clock-specifier pairs rather than phandles, it would be nice to fix the terminology here +- clock-names : + xo : External reference clock 19 MHz + sleep_a : Sleep clock, used when USB3 core goes into low + power mode (U3). I think it would be nicer to say: - clocks : A list of phandle + clock-specifier pairs for the clocks listed in clock-names - clock-names: Should contain the following: xo - External reference clock (19MHz) sleep_a - Sleep clock used when USB3 core goes into low power mode (U3). I'm not sure we need to describe the frequency of the xo clock -- either it's a requriement of the IP and thus doesn't need to be a part of the binding, or it's configurable by the driver and thus doesn't need to be documented. +supply-name-supply : phandle to the regulator device tree node +Required supply-name are: + v1p8 : 1.8v supply for HSPHY + v3p3 : 3.3v supply for HSPHY + vbus : vbus supply for host mode + vddcx : vdd supply for HS-PHY digital circuit operation Any reason for the HSPHY/HS-PHY difference? I'd list these separately with their full names: - v1p8-supply: phandle to the regulator for the 1.8v supply to HSPHY. - v3p3-supply: phandle to the regulator for the 3.3v supply to HSPHY. - vbus-supply: phandle to the regulator for the vbus supply for host mode. - vddcx-supply: phandle to the regulator for the vdd supply for HSPHY digital circuit operation. + +DWC3 Superspeed USB PHY +=== +Required properities : +- compatible : sould be qcom,dwc3-ssphy; +- reg : offset and length of the register set in the memory map +- clocks : phandles to clock instances of the device tree nodes +- clock-names : + xo : External reference clock 19 MHz + ref : Reference clock - used in host mode. +supply-name-supply : phandle to the regulator device tree node +Required supply-name are: + v1p8 : 1.8v supply for SS-PHY + vddcx : vdd supply for SS-PHY digital circuit operation The commments on compatible, clocks, clock-names and the regulators apply here. + +DWC3 controller wrapper +=== +Required properties : +- compatible : should be qcom,dwc3 +- reg : offset and length of the register set in the memory map + offset and length of the TCSR register for routing USB + signals to either picoPHY0 or picoPHY1. +- clocks : phandles to clock instances of the device tree nodes +- clock-names : + core : Master/Core clock, have to be = 125 MHz for SS + operation and = 60MHz for HS operation + iface : System bus AXI clock + sleep : Sleep clock, used when USB3 core goes into low + power mode (U3). + utmi : Generated by HS-PHY. Used to clock the low power + parts of thr HS Link layer. +Optional properties : +- gdsc-supply : phandle to the globally distributed switch controller + regulator node to the USB controller. The commments on compatible, clocks, and clock-names apply here too. I see the regulator is defined individually :) I'm fine with the binding itself, I'd just like the documentation fixed up. Cheers, Mark. +Required child node: +A child node must exist to represent the core DWC3 IP block. The name of +the node is not important. The content of the node is defined in dwc3.txt. + +Example device nodes: + +
Re: [PATCH 5/7] staging: usbip: Add encryption support to kernel
Hi, thank you very much for your feedback! On Mon, Sep 23, 2013 at 12:59:29PM +0300, Dan Carpenter wrote: + while (total size) { + uint32_t packetsize; + struct kvec recvvec; + + /* +* We use a global kfifo to buffer unrequested plaintext bytes. +* Flush this buffer first before receiving new data. +*/ + if (kfifo_len(ud-recv_queue)) { + size_t next = min_t(size_t, kfifo_len(ud-recv_queue), + size - total); + /* No error checking necessary - see previous line */ + ret = kfifo_out(ud-recv_queue, ((char *) + vec[0].iov_base)+total, next); The comment assume there is only one reader and one writer at a time, yes? The casting is not needed: Actually, we have not only one reader and one writer, but exactly one thread doing all the work on the fifo. No parallel access is done at all. ret = kfifo_out(ud-recv_queue, vec[0].iov_base + total, next); v + total += next; + continue; + } + + /* See usbip_sendmsg() for the format of one encrypted packet */ + + /* +* Receive size of next crypto packet +*/ + recvvec.iov_base = packetsize; + recvvec.iov_len = sizeof(packetsize); + + ret = kernel_recvmsg(ud-tcp_socket, msg, recvvec, 1, + sizeof(packetsize), flags); + packetsize = be32_to_cpu(packetsize); + if (ret = 0) { I think a return of zero should mean total = -EBADMSG;. In other words this check should be if (ret 0) { and we hit the next else if. Same below again. As we are wrapping kernel_recvmsg here, we wanted to leave the semantics intact as far as possible. The calling code already checks for the correct size. + total = ret; + goto err; + } else if (ret != sizeof(packetsize)) { + total = -EBADMSG; + goto err; + } On Mon, Sep 23, 2013 at 01:35:04PM +0300, Dan Carpenter wrote: On Thu, Sep 19, 2013 at 04:11:57PM +0200, Dominik Paulus wrote: + if (crypto_aead_setkey(ud-tfm_send, sendkey, USBIP_KEYSIZE) != 0 || + crypto_aead_setkey(ud-tfm_recv, recvkey, + USBIP_KEYSIZE) != 0 || + crypto_aead_setauthsize(ud-tfm_send, + USBIP_AUTHSIZE) != 0 || + crypto_aead_setauthsize(ud-tfm_recv, + USBIP_AUTHSIZE)) { + crypto_free_aead(ud-tfm_recv); + crypto_free_aead(ud-tfm_send); + kfifo_free(ud-recv_queue); + } This returns success on error instead of failure. Indeed, that was horribly broken. Thanks. On Mon, Sep 23, 2013 at 01:58:42PM +0300, Dan Carpenter wrote: On Thu, Sep 19, 2013 at 04:11:57PM +0200, Dominik Paulus wrote: +{ + struct crypto_aead *tfm; + struct aead_request *req; + struct tcrypt_result result; + struct scatterlist plain, cipher, assoc; + char iv[16]; + u64 *iv_num; + u64 iv_net; + const int plainsize = packetsize - USBIP_AUTHSIZE; Is it possible that packetsize is less than USBIP_AUTHSIZE? No, currently, the caller (usbip_sendmsg() / usbip_recvmsg() are the only functions calling usbip_crypt(), which itself is static) ensures this. Admittedly, this isn't great design. We added a check for packetsize USBIP_AUTHSIZE and an appropiate return here. + if (encrypt) + ret = crypto_aead_encrypt(req); + else + ret = crypto_aead_decrypt(req); + Good on you for figuring out what crypto_aead_en/decrypt() returns. Where are these functions documented? +switch (ret) { +case 0: /* Success */ +break; +case -EINPROGRESS: +case -EBUSY: +wait_for_completion(result.completion); +break; +default: +aead_request_free(req); +return ret; +} + They aren't, actually. Documentation/crypto/api-intro.txt refers to the regression test module, which uses exactly those return-values in crypto/testmgr.c. We noticed that wait_for_completion might not be the best idea, since it could hang indefinitely, testmgr.c uses wait_for_completion_interruptible. Do we want 'interruptible' or 'killable' here? (Also we forgot to error-check result.err afterwards. We also fixed that.) Regards, Dominik Paulus, Tobias Polzer -- 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 2/2] net: qmi_wwan: fix checkpatch warnings
Fabio Porcedda fabio.porce...@gmail.com writes: Hi Bjørn, thanks for reviewing. On Wed, Sep 25, 2013 at 3:31 PM, Bjørn Mork bj...@mork.no wrote: Sorry, I really don't see the point of this. Yes, the lines are longer than 80 columns, but breaking them don't improve the readability at all. On the contrary, IMHO. So NAK from me for this part. Which changes do you think do not improve the readability? Anything that breaks a previously unbroken argument list will reduce the readability in my opinion. The lines can of course not be unlimited, but there is no need to set the limit as low as 80 columns. Feedback I've got from developers using e.g. 80 column braille devices is that longer lines isn't really a problem for them either. The point is that the properly broken lines aren't that much more readable than a line broken by your terminal, even if you set it to 80 columns. You do of course not get the proper indendation of the broken lines, but you get a terminal hint telling you that it is a continuation line. Which is often better that having to figure it out based on the code. This isn't to say that I don't think writing shorter lines is a goal. I'd really like the code to be nice and compact, avoiding this discussion completely by just keeping every line shorter than 80. But I'm just not that good a programmer :-) I'd surely appreciate any patch moving the code in that direction. I'm sure that at least some of them actually improve the readability. Yes, reformatting the comments improves the readability. I just don't think that makes any sense on it's own, if the surrounding lines are kept longer. If the code can be rewritten to actually *be* shorter than 80 columns instead of just breaking too long code lines, then that is a definite improvement. You didn't have many examples of this, I believe. But reducing the indent level, removing unnecessary function parameters, or splitting declaration and initialization are changes which often reduce the line length while improving the readability at the same time. Breaking lines rarely do. This is the only one of your code changes which I can be convinced to agreeing may improve readability: - if ((on atomic_add_return(1, info-pmcount) == 1) || (!on atomic_dec_and_test(info-pmcount))) { + if ((on atomic_add_return(1, info-pmcount) == 1) || + (!on atomic_dec_and_test(info-pmcount))) { But it mostly points out a piece of code which is too complex in the first place, begging to be rewritten in a more elegant form. Just for the record: All this is of course only my personal opinions, and I am fine with being overridden even if I originally wrote the ugly code :-) David decides. Bjørn -- 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 39/51] DMA-API: others: use dma_set_coherent_mask()
Hi, On Friday 20 September 2013 04:41 AM, Russell King wrote: The correct way for a driver to specify the coherent DMA mask is not to directly access the field in the struct device, but to use dma_set_coherent_mask(). Only arch and bus code should access this member directly. Convert all direct write accesses to using the correct API. Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk --- drivers/ata/pata_ixp4xx_cf.c |5 - drivers/gpu/drm/exynos/exynos_drm_drv.c |6 +- drivers/gpu/drm/omapdrm/omap_dmm_tiler.c |5 +++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c index 1ec53f8..ddf470c 100644 --- a/drivers/ata/pata_ixp4xx_cf.c +++ b/drivers/ata/pata_ixp4xx_cf.c @@ -144,6 +144,7 @@ static int ixp4xx_pata_probe(struct platform_device *pdev) struct ata_host *host; struct ata_port *ap; struct ixp4xx_pata_data *data = dev_get_platdata(pdev-dev); + int ret; cs0 = platform_get_resource(pdev, IORESOURCE_MEM, 0); cs1 = platform_get_resource(pdev, IORESOURCE_MEM, 1); @@ -157,7 +158,9 @@ static int ixp4xx_pata_probe(struct platform_device *pdev) return -ENOMEM; /* acquire resources and fill host */ - pdev-dev.coherent_dma_mask = DMA_BIT_MASK(32); + ret = dma_set_coherent_mask(pdev-dev, DMA_BIT_MASK(32)); + if (ret) + return ret; data-cs0 = devm_ioremap(pdev-dev, cs0-start, 0x1000); data-cs1 = devm_ioremap(pdev-dev, cs1-start, 0x1000); diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c index bb82ef7..81192d0 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c @@ -286,7 +286,11 @@ static struct drm_driver exynos_drm_driver = { static int exynos_drm_platform_probe(struct platform_device *pdev) { - pdev-dev.coherent_dma_mask = DMA_BIT_MASK(32); + int ret; + + ret = dma_set_coherent_mask(pdev-dev, DMA_BIT_MASK(32)); + if (ret) + return ret; return drm_platform_init(exynos_drm_driver, pdev); } diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c index acf6678..701c4c1 100644 --- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c +++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c @@ -664,8 +664,9 @@ static int omap_dmm_probe(struct platform_device *dev) } /* set dma mask for device */ - /* NOTE: this is a workaround for the hwmod not initializing properly */ - dev-dev.coherent_dma_mask = DMA_BIT_MASK(32); + ret = dma_set_coherent_mask(dev-dev, DMA_BIT_MASK(32)); + if (ret) + goto fail; Tested with omapdrm on omap4 panda es board. Thanks, Archit -- 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: gadget: mv_u3d_core: fix memory leaks
On 21 September 2013 12:30, Valentin Ilie valentin.i...@gmail.com wrote: When trb_hw is NULL, trb should be free'd before return. Signed-off-by: Valentin Ilie valentin.i...@gmail.com --- drivers/usb/gadget/mv_u3d_core.c |2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/gadget/mv_u3d_core.c b/drivers/usb/gadget/mv_u3d_core.c index 561b30e..4d31177 100644 --- a/drivers/usb/gadget/mv_u3d_core.c +++ b/drivers/usb/gadget/mv_u3d_core.c @@ -310,6 +310,7 @@ static struct mv_u3d_trb *mv_u3d_build_trb_one(struct mv_u3d_req *req, */ trb_hw = dma_pool_alloc(u3d-trb_pool, GFP_ATOMIC, dma); if (!trb_hw) { + kfree(trb); dev_err(u3d-dev, %s, dma_pool_alloc fail\n, __func__); return NULL; @@ -454,6 +455,7 @@ static int mv_u3d_req_to_trb(struct mv_u3d_req *req) trb_hw = kcalloc(trb_num, sizeof(*trb_hw), GFP_ATOMIC); if (!trb_hw) { + kfree(trb); dev_err(u3d-dev, %s, trb_hw alloc fail\n, __func__); return -ENOMEM; -- 1.7.9.5 Can anyone look into this? Thank you -- Valentin Ilie +(40) 746 188 558 -- 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 2/2] net: qmi_wwan: fix checkpatch warnings
Anything that breaks a previously unbroken argument list will reduce the readability in my opinion. The lines can of course not be unlimited, but there is no need to set the limit as low as 80 columns. Feedback I've got from developers using e.g. 80 column braille devices is that longer lines isn't really a problem for them either. The main reason for limiting the line length is so that things look 'sensible' when you have a lot of screen windows displaying different files. You don't want wrapped code, and you definitely don't want the RHS of long lines hidden. With a 1600x1200 monitor I'll display six 80x40 windows (and probably have some more partially visible ones). Personally I indent continuation lines by 4 chars if using 8 char 'normal' indentation and 8 chars if using 4. This gives a lot more room on the continuation lines than the Linux 'line up with the previous line'. This is the only one of your code changes which I can be convinced to agreeing may improve readability: - if ((on || (!on atomic_dec_and_test(info-pmcount))) { + if ((on atomic_add_return(1, info-pmcount) == 1) || + (!on atomic_dec_and_test(info-pmcount))) { That can be written succinctly as: if (on ? atomic_add_return(1, info-pmcount) == 1) : atomic_dec_and_test(info-pmcount)) { although that construct is somewhat frowned upon! David
Re: [PATCH 5/7] staging: usbip: Add encryption support to kernel
On Thu, Sep 26, 2013 at 12:18:34PM +0200, Dominik Paulus wrote: I think a return of zero should mean total = -EBADMSG;. In other words this check should be if (ret 0) { and we hit the next else if. Same below again. As we are wrapping kernel_recvmsg here, we wanted to leave the semantics intact as far as possible. The calling code already checks for the correct size. Hm... Ok. Sometimes zero is interpretted as a connection closed and sometimes reading less than expected is considered a TCP error. No, currently, the caller (usbip_sendmsg() / usbip_recvmsg() are the only functions calling usbip_crypt(), which itself is static) ensures this. Admittedly, this isn't great design. We added a check for packetsize USBIP_AUTHSIZE and an appropiate return here. + if (encrypt) + ret = crypto_aead_encrypt(req); + else + ret = crypto_aead_decrypt(req); + Good on you for figuring out what crypto_aead_en/decrypt() returns. Where are these functions documented? +switch (ret) { +case 0: /* Success */ +break; +case -EINPROGRESS: +case -EBUSY: +wait_for_completion(result.completion); +break; +default: +aead_request_free(req); +return ret; +} + They aren't, actually. Documentation/crypto/api-intro.txt refers to the regression test module, which uses exactly those return-values in crypto/testmgr.c. Well that sucks. We noticed that wait_for_completion might not be the best idea, since it could hang indefinitely, testmgr.c uses wait_for_completion_interruptible. Do we want 'interruptible' or 'killable' here? I think you want the interruptible one wait_for_completion_interruptible() regards, dan carpenter -- 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: fix substandard locking for the sysfs files
Hi, On 09/24/2013 09:43 PM, Alan Stern wrote: This patch straightens out some locking issues in the USB sysfs interface: Deauthorization will destroy existing configurations. Attributes that read from udev-actconfig need to lock the device to prevent races. Likewise for the rawdescriptor values. Attributes that access an interface's current alternate setting should use ACCESS_ONCE() to obtain the cur_altsetting pointer, to protect against concurrent altsetting changes. The supports_autosuspend() attribute routine accesses values from an interface's driver, so it should lock the interface (rather than the usb_device) to protect against concurrent unbinds. Once this is done, the routine can be simplified considerably. Scalar values that are stored directly in the usb_device structure are always available. They do not require any locking. The same is true of the cached interface string descriptor, because it is not deallocated until the usb_host_interface structure is destroyed. Signed-off-by: Alan Stern st...@rowland.harvard.edu CC: Hans de Goede hdego...@redhat.com Looks good, thanks for fixing this! Regards, Hans -- 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 v4 01/19] usb/gadget: configfs: add a method to unregister the gadget
Add a method to unregister the gadget using its config_item. There can be functions (e.g. mass storage), which in some circumstances need the gadget stopped. Add a method of stopping the gadget. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/configfs.c |8 drivers/usb/gadget/configfs.h |6 ++ 2 files changed, 14 insertions(+), 0 deletions(-) create mode 100644 drivers/usb/gadget/configfs.h diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index 8f0d614..37e475b 100644 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -991,6 +991,14 @@ static struct configfs_subsystem gadget_subsys = { .su_mutex = __MUTEX_INITIALIZER(gadget_subsys.su_mutex), }; +void unregister_gadget_item(struct config_item *item) +{ + struct gadget_info *gi = to_gadget_info(item); + + unregister_gadget(gi); +} +EXPORT_SYMBOL(unregister_gadget_item); + static int __init gadget_cfs_init(void) { int ret; diff --git a/drivers/usb/gadget/configfs.h b/drivers/usb/gadget/configfs.h new file mode 100644 index 000..a7b564a --- /dev/null +++ b/drivers/usb/gadget/configfs.h @@ -0,0 +1,6 @@ +#ifndef USB__GADGET__CONFIGFS__H +#define USB__GADGET__CONFIGFS__H + +void unregister_gadget_item(struct config_item *item); + +#endif /* USB__GADGET__CONFIGFS__H */ -- 1.7.0.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 v4 16/19] usb/gadget: mass_storage: convert to new interface of f_mass_storage
Convert old mass_storage gadget to use the new interface of f_mass_storage so that later the compatibility layer in f_mass_storage can be removed. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/Kconfig|1 + drivers/usb/gadget/mass_storage.c | 107 +++- 2 files changed, 81 insertions(+), 27 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 40adaf0..7d64e47 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -885,6 +885,7 @@ config USB_MASS_STORAGE depends on BLOCK select USB_LIBCOMPOSITE select USB_U_MS + select USB_F_MASS_STORAGE help The Mass Storage Gadget acts as a USB Mass Storage disk drive. As its storage repository it can use a regular file or a block diff --git a/drivers/usb/gadget/mass_storage.c b/drivers/usb/gadget/mass_storage.c index f670251..580f23e 100644 --- a/drivers/usb/gadget/mass_storage.c +++ b/drivers/usb/gadget/mass_storage.c @@ -46,17 +46,7 @@ #define FSG_VENDOR_ID 0x0525 /* NetChip */ #define FSG_PRODUCT_ID 0xa4a5 /* Linux-USB File-backed Storage Gadget */ -/*-*/ - -/* - * kbuild is not very cooperative with respect to linking separately - * compiled library objects into one module. So for now we won't use - * separate compilation ... ensuring init/exit sections work to shrink - * the runtime footprint, and giving us at least some parts of what - * a gcc --combine ... part1.c part2.c part3.c ... build would. - */ -#define USB_FMS_INCLUDED -#include f_mass_storage.c +#include f_mass_storage.h /*-*/ USB_GADGET_COMPOSITE_OPTIONS(); @@ -107,6 +97,9 @@ static struct usb_gadget_strings *dev_strings[] = { NULL, }; +static struct usb_function_instance *fi_msg; +static struct usb_function *f_msg; + /** Configurations **/ static struct fsg_module_parameters mod_data = { @@ -139,13 +132,7 @@ static int msg_thread_exits(struct fsg_common *common) static int __init msg_do_config(struct usb_configuration *c) { - static const struct fsg_operations ops = { - .thread_exits = msg_thread_exits, - }; - static struct fsg_common common; - - struct fsg_common *retp; - struct fsg_config config; + struct fsg_opts *opts; int ret; if (gadget_is_otg(c-cdev-gadget)) { @@ -153,15 +140,24 @@ static int __init msg_do_config(struct usb_configuration *c) c-bmAttributes |= USB_CONFIG_ATT_WAKEUP; } - fsg_config_from_params(config, mod_data, fsg_num_buffers); - config.ops = ops; + opts = container_of(fi_msg, struct fsg_opts, func_inst); + + f_msg = usb_get_function(fi_msg); + if (IS_ERR(f_msg)) + return PTR_ERR(f_msg); - retp = fsg_common_init(common, c-cdev, config); - if (IS_ERR(retp)) - return PTR_ERR(retp); + ret = fsg_common_run_thread(opts-common); + if (ret) + goto put_func; - ret = fsg_bind_config(c-cdev, c, common); - fsg_common_put(common); + ret = usb_add_function(c, f_msg); + if (ret) + goto put_func; + + return 0; + +put_func: + usb_put_function(f_msg); return ret; } @@ -176,23 +172,79 @@ static struct usb_configuration msg_config_driver = { static int __init msg_bind(struct usb_composite_dev *cdev) { + static const struct fsg_operations ops = { + .thread_exits = msg_thread_exits, + }; + struct fsg_opts *opts; + struct fsg_config config; int status; + fi_msg = usb_get_function_instance(mass_storage); + if (IS_ERR(fi_msg)) + return PTR_ERR(fi_msg); + + fsg_config_from_params(config, mod_data, fsg_num_buffers); + opts = container_of(fi_msg, struct fsg_opts, func_inst); + + opts-no_configfs = true; + status = fsg_common_set_num_buffers(opts-common, fsg_num_buffers); + if (status) + goto fail; + + status = fsg_common_set_nluns(opts-common, config.nluns); + if (status) + goto fail_set_nluns; + + fsg_common_set_ops(opts-common, ops); + + status = fsg_common_set_cdev(opts-common, cdev, config.can_stall); + if (status) + goto fail_set_cdev; + + fsg_common_set_sysfs(opts-common, true); + status = fsg_common_create_luns(opts-common, config); + if (status) + goto fail_set_cdev; + + fsg_common_set_inquiry_string(opts-common, config.vendor_name, + config.product_name); + status = usb_string_ids_tab(cdev, strings_dev); if
[PATCH v4 03/19] usb/gadget: f_mass_storage: factor out a header file
In order to prepare for the new function interface the f_mass_storage.c needs to be compiled as a module, and so a header file will be required. This patch factors out some code to a new f_mass_storage.h. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/f_mass_storage.c | 117 ++-- drivers/usb/gadget/f_mass_storage.h | 126 +++ 2 files changed, 133 insertions(+), 110 deletions(-) create mode 100644 drivers/usb/gadget/f_mass_storage.h diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index a7c33c0..c6e34e1 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -229,6 +229,7 @@ static const char fsg_string_interface[] = Mass Storage; #include storage_common.h +#include f_mass_storage.h /* Static strings, in UTF-8 (for simplicity we use only ASCII characters) */ static struct usb_string fsg_strings[] = { @@ -246,18 +247,6 @@ static struct usb_gadget_strings fsg_stringtab = { struct fsg_dev; struct fsg_common; -/* FSF callback functions */ -struct fsg_operations { - /* -* Callback function to call when thread exits. If no -* callback is set or it returns value lower then zero MSF -* will force eject all LUNs it operates on (including those -* marked as non-removable or with prevent_medium_removal flag -* set). -*/ - int (*thread_exits)(struct fsg_common *common); -}; - /* Data shared by all the FSG instances. */ struct fsg_common { struct usb_gadget *gadget; @@ -324,28 +313,6 @@ struct fsg_common { struct kref ref; }; -struct fsg_config { - unsigned nluns; - struct fsg_lun_config { - const char *filename; - char ro; - char removable; - char cdrom; - char nofua; - } luns[FSG_MAX_LUNS]; - - /* Callback functions. */ - const struct fsg_operations *ops; - /* Gadget's private data. */ - void*private_data; - - const char *vendor_name;/* 8 characters or less */ - const char *product_name; /* 16 characters or less */ - - charcan_stall; - unsigned intfsg_num_buffers; -}; - struct fsg_dev { struct usb_function function; struct usb_gadget *gadget;/* Copy of cdev-gadget */ @@ -2642,12 +2609,12 @@ static void fsg_lun_release(struct device *dev) /* Nothing needs to be done */ } -static inline void fsg_common_get(struct fsg_common *common) +void fsg_common_get(struct fsg_common *common) { kref_get(common-ref); } -static inline void fsg_common_put(struct fsg_common *common) +void fsg_common_put(struct fsg_common *common) { kref_put(common-ref, fsg_common_release); } @@ -2662,9 +2629,9 @@ static inline int fsg_num_buffers_validate(unsigned int fsg_num_buffers) return -EINVAL; } -static struct fsg_common *fsg_common_init(struct fsg_common *common, - struct usb_composite_dev *cdev, - struct fsg_config *cfg) +struct fsg_common *fsg_common_init(struct fsg_common *common, + struct usb_composite_dev *cdev, + struct fsg_config *cfg) { struct usb_gadget *gadget = cdev-gadget; struct fsg_buffhd *bh; @@ -3041,62 +3008,8 @@ static int fsg_bind_config(struct usb_composite_dev *cdev, /* Module parameters */ -struct fsg_module_parameters { - char*file[FSG_MAX_LUNS]; - boolro[FSG_MAX_LUNS]; - boolremovable[FSG_MAX_LUNS]; - boolcdrom[FSG_MAX_LUNS]; - boolnofua[FSG_MAX_LUNS]; - - unsigned intfile_count, ro_count, removable_count, cdrom_count; - unsigned intnofua_count; - unsigned intluns; /* nluns */ - boolstall; /* can_stall */ -}; - -#define _FSG_MODULE_PARAM_ARRAY(prefix, params, name, type, desc) \ - module_param_array_named(prefix ## name, params.name, type, \ -prefix ## params.name ## _count, \ -S_IRUGO); \ - MODULE_PARM_DESC(prefix ## name, desc) - -#define _FSG_MODULE_PARAM(prefix, params, name, type, desc)\ - module_param_named(prefix ## name, params.name, type, \ - S_IRUGO);\ - MODULE_PARM_DESC(prefix ## name, desc) - -#define __FSG_MODULE_PARAMETERS(prefix, params) \ -
[PATCH v4 04/19] usb/gadget: f_mass_storage: add a level of indirection for luns storage
This is needed to prepare for configfs integration. So far the luns have been allocated during gadget's initialization, based on the nluns module parameter's value; the exact number is known when the gadget is initialized and that number of luns is allocated in one go; they all will be used. When configfs is in place, the luns will be created one-by-one by the user. Once the user is satisfied with the number of luns, they activate the gadget. The number of luns must be = FSG_MAX_LUN (currently 8), but other than that it is not known up front and the user need not use contiguous numbering (apart from the default lun #0). On the other hand, the function code uses lun numbers to identify them and the number needs to be used as an index into an array. Given the above, an array needs to be allocated, but it might happen that 7 out of its 8 elements will not be used. On my machine sizeof(struct fsg_lun) == 462, so 3k of memory is allocated but not used in the worst case. By adding another level of indirection (allocating an array of pointers to struct fsg_lun and then allocating individual luns instead of an array of struct fsg_luns) at most 7 pointers are wasted, which is much less. This patch also changes some for/while loops to cope with the fact that in the luns array some entries are potentially empty. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/f_mass_storage.c | 60 --- 1 files changed, 41 insertions(+), 19 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index c6e34e1..bc512b1 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -274,7 +274,7 @@ struct fsg_common { unsigned intnluns; unsigned intlun; - struct fsg_lun *luns; + struct fsg_lun **luns; struct fsg_lun *curlun; unsigned intbulk_out_maxpacket; @@ -2151,7 +2151,7 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) common-data_dir = DATA_DIR_NONE; common-lun = cbw-Lun; if (common-lun common-nluns) - common-curlun = common-luns[common-lun]; + common-curlun = common-luns[common-lun]; else common-curlun = NULL; common-tag = cbw-Tag; @@ -2297,7 +2297,9 @@ reset: common-running = 1; for (i = 0; i common-nluns; ++i) - common-luns[i].unit_attention_data = SS_RESET_OCCURRED; + if (common-luns[i]) + common-luns[i]-unit_attention_data = + SS_RESET_OCCURRED; return rc; } @@ -2397,7 +2399,9 @@ static void handle_exception(struct fsg_common *common) common-state = FSG_STATE_STATUS_PHASE; else { for (i = 0; i common-nluns; ++i) { - curlun = common-luns[i]; + curlun = common-luns[i]; + if (!curlun) + continue; curlun-prevent_medium_removal = 0; curlun-sense_data = SS_NO_SENSE; curlun-unit_attention_data = SS_NO_SENSE; @@ -2439,8 +2443,9 @@ static void handle_exception(struct fsg_common *common) * CONFIG_CHANGE cases. */ /* for (i = 0; i common-nluns; ++i) */ - /* common-luns[i].unit_attention_data = */ - /* SS_RESET_OCCURRED; */ + /* if (common-luns[i]) */ + /* common-luns[i]-unit_attention_data = */ + /* SS_RESET_OCCURRED; */ break; case FSG_STATE_CONFIG_CHANGE: @@ -2536,12 +2541,13 @@ static int fsg_main_thread(void *common_) if (!common-ops || !common-ops-thread_exits || common-ops-thread_exits(common) 0) { - struct fsg_lun *curlun = common-luns; + struct fsg_lun **curlun_it = common-luns; unsigned i = common-nluns; down_write(common-filesem); - for (; i--; ++curlun) { - if (!fsg_lun_is_open(curlun)) + for (; i--; ++curlun_it) { + struct fsg_lun *curlun = *curlun_it; + if (!curlun || !fsg_lun_is_open(curlun)) continue; fsg_lun_close(curlun); @@ -2635,7 +2641,7 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, { struct usb_gadget *gadget = cdev-gadget; struct fsg_buffhd *bh; - struct fsg_lun *curlun; + struct fsg_lun **curlun_it; struct fsg_lun_config *lcfg; int nluns, i, rc; char *pathbuf; @@ -2692,16
[PATCH v4 07/19] usb/gadget: f_mass_storage: use fsg_common_setup in fsg_common_init
fsg_common_init is a lengthy function. Now there are helper functions which cover all parts of it. Use them. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/f_mass_storage.c | 19 +++ 1 files changed, 3 insertions(+), 16 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 0bf7503..d94d9d6 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -3051,16 +3051,9 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, return ERR_PTR(-EINVAL); } - /* Allocate? */ - if (!common) { - common = kzalloc(sizeof *common, GFP_KERNEL); - if (!common) - return ERR_PTR(-ENOMEM); - common-free_storage_on_release = 1; - } else { - memset(common, 0, sizeof *common); - common-free_storage_on_release = 0; - } + common = fsg_common_setup(common, !!common); + if (IS_ERR(common)) + return common; common-sysfs = true; common-state = FSG_STATE_IDLE; @@ -3100,8 +3093,6 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, } common-luns = curlun_it; - init_rwsem(common-filesem); - for (i = 0, lcfg = cfg-luns; i nluns; ++i, ++curlun_it, ++lcfg) { struct fsg_lun *curlun; @@ -3201,8 +3192,6 @@ buffhds_first_it: common-can_stall = cfg-can_stall !(gadget_is_at91(common-gadget)); - spin_lock_init(common-lock); - kref_init(common-ref); /* Tell the thread to start working */ common-thread_task = @@ -3211,8 +3200,6 @@ buffhds_first_it: rc = PTR_ERR(common-thread_task); goto error_release; } - init_completion(common-thread_notifier); - init_waitqueue_head(common-fsg_wait); /* Information */ INFO(common, FSG_DRIVER_DESC , version: FSG_DRIVER_VERSION \n); -- 1.7.0.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 v4 00/19] Equivalent of g_mass_storage with configfs
This series aims at integrating configfs into mass storage, the way it has been done for acm, ncm, ecm, eem, ecm subset, rndis, obex and phonet. It contains everything that is required to provide the equivalent of g_mass_storage.ko with configfs. Mass storage itself is quite large, so the resulting patch series is a bit lengthy. However, it is supposed to be done in steps like this: 1) preliminary work, e.g. factoring out a header file, creating a utility u_ms.ko module, use usb_gstrings_attach 2) prepare for initializing the fsg_common structure in smaller steps instead of in one big step 3) usual stuff, similar to functions previously converted to configfs v1..v2: - simpified adding a level of indirection for fsg_lun storing - reworked lun debugging macros in order not to use struct device [both after discussion with Alan, thanks] v2..v3: - implemented changes resulting from Michal's comments [thanks, Michal] - used static inline fsg_common_remove_sysfs wherever possible - some small bugfixes v3..v4: -rebased onto 3.12-rc1 A branch 'usb-gadget-configfs-for-3.12' is available at: git://git.linaro.org/people/mszyprowski/linux-srpol.git BACKWARD COMPATIBILITY == Please note that the old g_mass_storage.ko is still available and works. USING THE NEW GADGET == Please refer to this post: http://www.spinics.net/lists/linux-usb/msg76388.html for general information from Sebastian on how to use configfs-based gadgets (*). With configfs the procedure is as follows, compared to the information mentioned above (*): instead of mkdir functions/acm.ttyS1 do mkdir functions/mass_storage.instance name e.g. mkdir functions/mass_storage.0 In functions/function.instance name there will be the following attribute files: stall - Set to permit function to halt bulk endpoints. Disabled on some USB devices known not to work correctly. You should set it to true. num_buffers - Number of pipeline buffers. Valid numbers are 2..4. Available only if CONFIG_USB_GADGET_DEBUG_FILES is set. and a default lun.0 directory corresponding to SCSI LUN #0. A new lun can be added with mkdir: $ mkdir functions/mass_storage.0/partition.5 Lun numbering does not have to be continuous, except for lun #0 which is created by default. A maximum of 8 luns can be specified and they all must be named following the name.number scheme. The numbers can be 0..8. Probably a good convention is to name the luns lun.number, although it is not mandatory. In each lun directory there are the following attribute files: file- The path to the backing file for the LUN. Required if LUN is not marked as removable. ro - Flag specifying access to the LUN shall be read-only. This is implied if CD-ROM emulation is enabled as well as when it was impossible to open filename in R/W mode. removable - Flag specifying that LUN shall be indicated as being removable. cdrom - Flag specifying that LUN shall be reported as being a CD-ROM. nofua - Flag specifying that FUA flag in SCSI WRITE(10,12) The rest of the procedure (*) remains the same. An example gadget with two luns: $ modprobe libcomposite $ mount none cfg -t configfs $ mkdir cfg/usb_gadget/g1 $ cd cfg/usb_gadget/g1 $ mkdir configs/c.1 $ mkdir functions/mass_storage.0 $ echo /root/lun0.img functions/mass_storage.0/lun.0/file $ mkdir functions/mass_storage.0/lun.1 $ echo /root/lun1.img functions/mass_storage.0/lun.1/file $ mkdir strings/0x409 $ mkdir configs/c.1/strings/0x409 $ echo 0xa4a2 idProduct $ echo 0x0525 idVendor $ echo my-serial-num strings/0x409/serialnumber $ echo my-manufacturer strings/0x409/manufacturer $ echo Mass Storage Gadget strings/0x409/product $ echo Conf 1 configs/c.1/strings/0x409/configuration $ echo 120 configs/c.1/MaxPower $ ln -s functions/mass_storage.0 configs/c.1 $ echo s3c-hsotg UDC After unbinding the gadget with echo UDC the symbolic links in the configuration directory can be removed, the strings/* subdirectories in the configuration directory can be removed, the strings/* subdirectories at the gadget level can be removed and the configs/* subdirectories can be removed. The functions/* subdirectories can be removed. After that the gadget directory can be removed. After that the respective modules can be unloaded. TESTING THE FUNCTIONS (actually there is only one) = mass_storage) device: connect the gadget, enable it host: dmesg, see the USB drives appear (if system configured to automatically mount) Andrzej Pietrasiewicz (19): usb/gadget: configfs: add a method to unregister the gadget
[PATCH v4 10/19] usb/gadget: f_mass_storage: use fsg_common_set_ops/_private_data in fsg_common_init
fsg_common_init is a lengthy function. Now there are helper functions which cover all parts of it. Use them. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/f_mass_storage.c |5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 45b44d7..ab1458b 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -3052,8 +3052,9 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, kfree(common); return ERR_PTR(rc); } - common-ops = cfg-ops; - common-private_data = cfg-private_data; + + fsg_common_set_ops(common, cfg-ops); + fsg_common_set_private_data(common, cfg-private_data); common-gadget = gadget; common-ep0 = gadget-ep0; -- 1.7.0.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 v4 17/19] usb/gadget: storage_common: make attribute operations more generic
Show/store methods for sysfs attributes contain code which can be used also by configfs. Make them abstract the source the lun and rw_semaphore are taken from. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/f_mass_storage.c | 27 +-- drivers/usb/gadget/storage_common.c | 31 ++- drivers/usb/gadget/storage_common.h | 21 +++-- 3 files changed, 38 insertions(+), 41 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index b55b874..50f7612 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -2572,37 +2572,52 @@ static int fsg_main_thread(void *common_) static ssize_t ro_show(struct device *dev, struct device_attribute *attr, char *buf) { - return fsg_show_ro(dev, attr, buf); + struct fsg_lun *curlun = fsg_lun_from_dev(dev); + + return fsg_show_ro(curlun, buf); } static ssize_t nofua_show(struct device *dev, struct device_attribute *attr, char *buf) { - return fsg_show_nofua(dev, attr, buf); + struct fsg_lun *curlun = fsg_lun_from_dev(dev); + + return fsg_show_nofua(curlun, buf); } static ssize_t file_show(struct device *dev, struct device_attribute *attr, char *buf) { - return fsg_show_file(dev, attr, buf); + struct fsg_lun *curlun = fsg_lun_from_dev(dev); + struct rw_semaphore *filesem = dev_get_drvdata(dev); + + return fsg_show_file(curlun, filesem, buf); } static ssize_t ro_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - return fsg_store_ro(dev, attr, buf, count); + struct fsg_lun *curlun = fsg_lun_from_dev(dev); + struct rw_semaphore *filesem = dev_get_drvdata(dev); + + return fsg_store_ro(curlun, filesem, buf, count); } static ssize_t nofua_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - return fsg_store_nofua(dev, attr, buf, count); + struct fsg_lun *curlun = fsg_lun_from_dev(dev); + + return fsg_store_nofua(curlun, buf, count); } static ssize_t file_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - return fsg_store_file(dev, attr, buf, count); + struct fsg_lun *curlun = fsg_lun_from_dev(dev); + struct rw_semaphore *filesem = dev_get_drvdata(dev); + + return fsg_store_file(curlun, filesem, buf, count); } static DEVICE_ATTR_RW(ro); diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c index 3e2500f..969948d 100644 --- a/drivers/usb/gadget/storage_common.c +++ b/drivers/usb/gadget/storage_common.c @@ -31,11 +31,6 @@ #include storage_common.h -static inline struct fsg_lun *fsg_lun_from_dev(struct device *dev) -{ - return container_of(dev, struct fsg_lun, dev); -} - /* There is only one interface. */ struct usb_interface_descriptor fsg_intf_desc = { @@ -324,31 +319,23 @@ EXPORT_SYMBOL(store_cdrom_address); /*-*/ -ssize_t fsg_show_ro(struct device *dev, struct device_attribute *attr, - char *buf) +ssize_t fsg_show_ro(struct fsg_lun *curlun, char *buf) { - struct fsg_lun *curlun = fsg_lun_from_dev(dev); - return sprintf(buf, %d\n, fsg_lun_is_open(curlun) ? curlun-ro : curlun-initially_ro); } EXPORT_SYMBOL(fsg_show_ro); -ssize_t fsg_show_nofua(struct device *dev, struct device_attribute *attr, - char *buf) +ssize_t fsg_show_nofua(struct fsg_lun *curlun, char *buf) { - struct fsg_lun *curlun = fsg_lun_from_dev(dev); - return sprintf(buf, %u\n, curlun-nofua); } EXPORT_SYMBOL(fsg_show_nofua); -ssize_t fsg_show_file(struct device *dev, struct device_attribute *attr, +ssize_t fsg_show_file(struct fsg_lun *curlun, struct rw_semaphore *filesem, char *buf) { - struct fsg_lun *curlun = fsg_lun_from_dev(dev); - struct rw_semaphore *filesem = dev_get_drvdata(dev); char*p; ssize_t rc; @@ -373,12 +360,10 @@ ssize_t fsg_show_file(struct device *dev, struct device_attribute *attr, EXPORT_SYMBOL(fsg_show_file); -ssize_t fsg_store_ro(struct device *dev, struct device_attribute *attr, +ssize_t fsg_store_ro(struct fsg_lun *curlun, struct rw_semaphore *filesem, const char *buf, size_t count) { ssize_t rc; - struct fsg_lun *curlun = fsg_lun_from_dev(dev); - struct rw_semaphore *filesem =
[PATCH v4 09/19] usb/gadget: f_mass_storage: use fsg_common_set_nluns in fsg_common_init
fsg_common_init is a lengthy function. Now there are helper functions which cover all parts of it. Use them. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/f_mass_storage.c | 22 +- 1 files changed, 5 insertions(+), 17 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 1234990..45b44d7 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -3039,12 +3039,6 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, int nluns, i, rc; char *pathbuf; - /* Find out how many LUNs there should be */ - nluns = cfg-nluns; - if (nluns 1 || nluns FSG_MAX_LUNS) { - dev_err(gadget-dev, invalid number of LUNs: %u\n, nluns); - return ERR_PTR(-EINVAL); - } common = fsg_common_setup(common, !!common); if (IS_ERR(common)) @@ -3074,17 +3068,12 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, } fsg_intf_desc.iInterface = us[FSG_STRING_INTERFACE].id; - /* -* Create the LUNs, open their backing files, and register the -* LUN devices in sysfs. -*/ - curlun_it = kcalloc(nluns, sizeof(*curlun_it), GFP_KERNEL); - if (unlikely(!curlun_it)) { - rc = -ENOMEM; - goto error_release; - } - common-luns = curlun_it; + rc = fsg_common_set_nluns(common, cfg-nluns); + if (rc) + goto error_release; + curlun_it = common-luns; + nluns = cfg-nluns; for (i = 0, lcfg = cfg-luns; i nluns; ++i, ++curlun_it, ++lcfg) { struct fsg_lun *curlun; @@ -3148,7 +3137,6 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, goto error_luns; } } - common-nluns = nluns; /* Prepare inquiryString */ -- 1.7.0.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 v4 08/19] usb/gadget: f_mass_storage: use fsg_common_set_num_buffers in fsg_common_init
fsg_common_init is a lengthy function. Now there are helper functions which cover all parts of it. Use them. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/f_mass_storage.c | 29 +++-- 1 files changed, 3 insertions(+), 26 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index d94d9d6..1234990 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -3033,17 +3033,12 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, struct fsg_config *cfg) { struct usb_gadget *gadget = cdev-gadget; - struct fsg_buffhd *bh; struct fsg_lun **curlun_it; struct fsg_lun_config *lcfg; struct usb_string *us; int nluns, i, rc; char *pathbuf; - rc = fsg_num_buffers_validate(cfg-fsg_num_buffers); - if (rc != 0) - return ERR_PTR(rc); - /* Find out how many LUNs there should be */ nluns = cfg-nluns; if (nluns 1 || nluns FSG_MAX_LUNS) { @@ -3057,15 +3052,12 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, common-sysfs = true; common-state = FSG_STATE_IDLE; - common-fsg_num_buffers = cfg-fsg_num_buffers; - common-buffhds = kcalloc(common-fsg_num_buffers, - sizeof *(common-buffhds), GFP_KERNEL); - if (!common-buffhds) { + rc = fsg_common_set_num_buffers(common, cfg-fsg_num_buffers); + if (rc) { if (common-free_storage_on_release) kfree(common); - return ERR_PTR(-ENOMEM); + return ERR_PTR(rc); } - common-ops = cfg-ops; common-private_data = cfg-private_data; @@ -3158,21 +3150,6 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, } common-nluns = nluns; - /* Data buffers cyclic list */ - bh = common-buffhds; - i = common-fsg_num_buffers; - goto buffhds_first_it; - do { - bh-next = bh + 1; - ++bh; -buffhds_first_it: - bh-buf = kmalloc(FSG_BUFLEN, GFP_KERNEL); - if (unlikely(!bh-buf)) { - rc = -ENOMEM; - goto error_release; - } - } while (--i); - bh-next = common-buffhds; /* Prepare inquiryString */ i = get_default_bcdDevice(); -- 1.7.0.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 v4 18/19] usb/gadget: storage_common: add methods to show/store 'cdrom' and 'removable'
This will be required by configfs integration. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/storage_common.c | 42 +++ drivers/usb/gadget/storage_common.h |5 2 files changed, 47 insertions(+), 0 deletions(-) diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c index 969948d..c7b78a1 100644 --- a/drivers/usb/gadget/storage_common.c +++ b/drivers/usb/gadget/storage_common.c @@ -359,6 +359,17 @@ ssize_t fsg_show_file(struct fsg_lun *curlun, struct rw_semaphore *filesem, } EXPORT_SYMBOL(fsg_show_file); +ssize_t fsg_show_cdrom(struct fsg_lun *curlun, char *buf) +{ + return sprintf(buf, %u\n, curlun-cdrom); +} +EXPORT_SYMBOL(fsg_show_cdrom); + +ssize_t fsg_show_removable(struct fsg_lun *curlun, char *buf) +{ + return sprintf(buf, %u\n, curlun-removable); +} +EXPORT_SYMBOL(fsg_show_removable); ssize_t fsg_store_ro(struct fsg_lun *curlun, struct rw_semaphore *filesem, const char *buf, size_t count) @@ -439,4 +450,35 @@ ssize_t fsg_store_file(struct fsg_lun *curlun, struct rw_semaphore *filesem, } EXPORT_SYMBOL(fsg_store_file); +ssize_t fsg_store_cdrom(struct fsg_lun *curlun, const char *buf, size_t count) +{ + unsignedcdrom; + int ret; + + ret = kstrtouint(buf, 2, cdrom); + if (ret) + return ret; + + curlun-cdrom = cdrom; + + return count; +} +EXPORT_SYMBOL(fsg_store_cdrom); + +ssize_t fsg_store_removable(struct fsg_lun *curlun, const char *buf, + size_t count) +{ + unsignedremovable; + int ret; + + ret = kstrtouint(buf, 2, removable); + if (ret) + return ret; + + curlun-removable = removable; + + return count; +} +EXPORT_SYMBOL(fsg_store_removable); + MODULE_LICENSE(GPL); diff --git a/drivers/usb/gadget/storage_common.h b/drivers/usb/gadget/storage_common.h index aa8bf94..ca7b479 100644 --- a/drivers/usb/gadget/storage_common.h +++ b/drivers/usb/gadget/storage_common.h @@ -214,10 +214,15 @@ ssize_t fsg_show_ro(struct fsg_lun *curlun, char *buf); ssize_t fsg_show_nofua(struct fsg_lun *curlun, char *buf); ssize_t fsg_show_file(struct fsg_lun *curlun, struct rw_semaphore *filesem, char *buf); +ssize_t fsg_show_cdrom(struct fsg_lun *curlun, char *buf); +ssize_t fsg_show_removable(struct fsg_lun *curlun, char *buf); ssize_t fsg_store_ro(struct fsg_lun *curlun, struct rw_semaphore *filesem, const char *buf, size_t count); ssize_t fsg_store_nofua(struct fsg_lun *curlun, const char *buf, size_t count); ssize_t fsg_store_file(struct fsg_lun *curlun, struct rw_semaphore *filesem, const char *buf, size_t count); +ssize_t fsg_store_cdrom(struct fsg_lun *curlun, const char *buf, size_t count); +ssize_t fsg_store_removable(struct fsg_lun *curlun, const char *buf, + size_t count); #endif /* USB_STORAGE_COMMON_H */ -- 1.7.0.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 v4 12/19] usb/gadget: f_mass_storage: use fsg_common_create_luns in fsg_common_init
fsg_common_init is a lengthy function. Now there are helper functions which cover all parts of it. Use them. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/f_mass_storage.c | 101 ++- 1 files changed, 4 insertions(+), 97 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 970213f..c55950f 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -3032,12 +3032,7 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, struct usb_composite_dev *cdev, struct fsg_config *cfg) { - struct usb_gadget *gadget = cdev-gadget; - struct fsg_lun **curlun_it; - struct fsg_lun_config *lcfg; - int nluns, i, rc; - char *pathbuf; - + int i, rc; common = fsg_common_setup(common, !!common); if (IS_ERR(common)) @@ -3062,72 +3057,10 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, rc = fsg_common_set_nluns(common, cfg-nluns); if (rc) goto error_release; - curlun_it = common-luns; - nluns = cfg-nluns; - for (i = 0, lcfg = cfg-luns; i nluns; ++i, ++curlun_it, ++lcfg) { - struct fsg_lun *curlun; - - curlun = kzalloc(sizeof(*curlun), GFP_KERNEL); - if (!curlun) { - rc = -ENOMEM; - common-nluns = i; - goto error_release; - } - *curlun_it = curlun; - - curlun-name = kzalloc(MAX_LUN_NAME_LEN, GFP_KERNEL); - if (!curlun-name) { - rc = -ENOMEM; - common-nluns = i; - goto error_release; - } - curlun-cdrom = !!lcfg-cdrom; - curlun-ro = lcfg-cdrom || lcfg-ro; - curlun-initially_ro = curlun-ro; - curlun-removable = lcfg-removable; - curlun-dev.release = fsg_lun_release; - curlun-dev.parent = gadget-dev; - /* curlun-dev.driver = fsg_driver.driver; XXX */ - dev_set_drvdata(curlun-dev, common-filesem); - dev_set_name(curlun-dev, lun%d, i); - strlcpy(curlun-name, dev_name(curlun-dev), MAX_LUN_NAME_LEN); - - rc = device_register(curlun-dev); - if (rc) { - INFO(common, failed to register LUN%d: %d\n, i, rc); - common-nluns = i; - put_device(curlun-dev); - kfree(curlun); - goto error_release; - } - - rc = device_create_file(curlun-dev, - curlun-cdrom - ? dev_attr_ro_cdrom - : dev_attr_ro); - if (rc) - goto error_luns; - rc = device_create_file(curlun-dev, - curlun-removable - ? dev_attr_file - : dev_attr_file_nonremovable); - if (rc) - goto error_luns; - rc = device_create_file(curlun-dev, dev_attr_nofua); - if (rc) - goto error_luns; - - if (lcfg-filename) { - rc = fsg_lun_open(curlun, lcfg-filename); - if (rc) - goto error_luns; - } else if (!curlun-removable) { - ERROR(common, no file given for LUN%d\n, i); - rc = -EINVAL; - goto error_luns; - } - } + rc = fsg_common_create_luns(common, cfg); + if (rc) + goto error_release; /* Prepare inquiryString */ i = get_default_bcdDevice(); @@ -3139,7 +3072,6 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, : File-Stor Gadget), i); - /* Tell the thread to start working */ common-thread_task = kthread_create(fsg_main_thread, common, file-storage); @@ -3152,37 +3084,12 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, INFO(common, FSG_DRIVER_DESC , version: FSG_DRIVER_VERSION \n); INFO(common, Number of LUNs=%d\n, common-nluns); - pathbuf = kmalloc(PATH_MAX, GFP_KERNEL); - for (i = 0, nluns = common-nluns, curlun_it = common-luns; -i nluns; -++curlun_it, ++i) { - struct fsg_lun *curlun = *curlun_it; - char *p = (no medium); - if (fsg_lun_is_open(curlun)) { -
[PATCH v4 13/19] usb/gadget: f_mass_storage: use fsg_common_set_inquiry_string in fsg_common_init
fsg_common_init is a lengthy function. Now there are helper functions which cover all parts of it. Use them. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/f_mass_storage.c | 13 +++-- 1 files changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index c55950f..2e73037 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -3032,7 +3032,7 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, struct usb_composite_dev *cdev, struct fsg_config *cfg) { - int i, rc; + int rc; common = fsg_common_setup(common, !!common); if (IS_ERR(common)) @@ -3062,16 +3062,9 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, if (rc) goto error_release; - /* Prepare inquiryString */ - i = get_default_bcdDevice(); - snprintf(common-inquiry_string, sizeof common-inquiry_string, -%-8s%-16s%04x, cfg-vendor_name ?: Linux, -/* Assume product name dependent on the first LUN */ -cfg-product_name ?: ((*common-luns)-cdrom -? File-CD Gadget -: File-Stor Gadget), -i); + fsg_common_set_inquiry_string(common, cfg-vendor_name, + cfg-product_name); /* Tell the thread to start working */ common-thread_task = kthread_create(fsg_main_thread, common, file-storage); -- 1.7.0.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 v4 05/19] usb/gadget: f_mass_storage: use usb_gstrings_attach
Prepare for handling with configfs. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/f_mass_storage.c | 25 - 1 files changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index bc512b1..e2598f4 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -242,6 +242,11 @@ static struct usb_gadget_strings fsg_stringtab = { .strings= fsg_strings, }; +static struct usb_gadget_strings *fsg_strings_array[] = { + fsg_stringtab, + NULL, +}; + /*-*/ struct fsg_dev; @@ -2643,6 +2648,7 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, struct fsg_buffhd *bh; struct fsg_lun **curlun_it; struct fsg_lun_config *lcfg; + struct usb_string *us; int nluns, i, rc; char *pathbuf; @@ -2685,14 +2691,13 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, common-ep0req = cdev-req; common-cdev = cdev; - /* Maybe allocate device-global string IDs, and patch descriptors */ - if (fsg_strings[FSG_STRING_INTERFACE].id == 0) { - rc = usb_string_id(cdev); - if (unlikely(rc 0)) - goto error_release; - fsg_strings[FSG_STRING_INTERFACE].id = rc; - fsg_intf_desc.iInterface = rc; + us = usb_gstrings_attach(cdev, fsg_strings_array, +ARRAY_SIZE(fsg_strings)); + if (IS_ERR(us)) { + rc = PTR_ERR(us); + goto error_release; } + fsg_intf_desc.iInterface = us[FSG_STRING_INTERFACE].id; /* * Create the LUNs, open their backing files, and register the @@ -2986,11 +2991,6 @@ autoconf_fail: /** ADD FUNCTION **/ -static struct usb_gadget_strings *fsg_strings_array[] = { - fsg_stringtab, - NULL, -}; - static int fsg_bind_config(struct usb_composite_dev *cdev, struct usb_configuration *c, struct fsg_common *common) @@ -3003,7 +3003,6 @@ static int fsg_bind_config(struct usb_composite_dev *cdev, return -ENOMEM; fsg-function.name= FSG_DRIVER_DESC; - fsg-function.strings = fsg_strings_array; fsg-function.bind= fsg_bind; fsg-function.unbind = fsg_unbind; fsg-function.setup = fsg_setup; -- 1.7.0.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 v4 11/19] usb/gadget: f_mass_storage: use fsg_common_set_cdev in fsg_common_init
fsg_common_init is a lengthy function. Now there are helper functions which cover all parts of it. Use them. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/f_mass_storage.c | 23 ++- 1 files changed, 2 insertions(+), 21 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index ab1458b..970213f 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -3035,7 +3035,6 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, struct usb_gadget *gadget = cdev-gadget; struct fsg_lun **curlun_it; struct fsg_lun_config *lcfg; - struct usb_string *us; int nluns, i, rc; char *pathbuf; @@ -3056,19 +3055,9 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, fsg_common_set_ops(common, cfg-ops); fsg_common_set_private_data(common, cfg-private_data); - common-gadget = gadget; - common-ep0 = gadget-ep0; - common-ep0req = cdev-req; - common-cdev = cdev; - - us = usb_gstrings_attach(cdev, fsg_strings_array, -ARRAY_SIZE(fsg_strings)); - if (IS_ERR(us)) { - rc = PTR_ERR(us); + rc = fsg_common_set_cdev(common, cdev, cfg-can_stall); + if (rc) goto error_release; - } - fsg_intf_desc.iInterface = us[FSG_STRING_INTERFACE].id; - rc = fsg_common_set_nluns(common, cfg-nluns); if (rc) @@ -3150,14 +3139,6 @@ struct fsg_common *fsg_common_init(struct fsg_common *common, : File-Stor Gadget), i); - /* -* Some peripheral controllers are known not to be able to -* halt bulk endpoints correctly. If one of them is present, -* disable stalls. -*/ - common-can_stall = cfg-can_stall - !(gadget_is_at91(common-gadget)); - /* Tell the thread to start working */ common-thread_task = -- 1.7.0.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 v4 06/19] usb/gadget: f_mass_storage: split fsg_common initialization into a number of functions
When configfs is in place, the things related to intialization of struct fsg_common will be split over a number of places. This patch adds several functions which together cover the former intialization routine fsg_common_init. When configfs is in place, the luns will not be represented in sysfs, so there will be no struct device associated with a lun. To prepare for this some debug macros need to be adjusted. Two new fields are added to struct fsg_lun: name and name_pfx. The name is for storing a string which is presented to the user instead of the dev_name. The name_pfx, if non-NULL, is prepended to the name at printing time. The name_pfx is for a future lun.0, which will be a default group in mass_storage.name. By design at USB function configfs group's creation time its name is not known (but instead set a bit later in drivers/usb/gadget/configfs.c:function_make) and it is this name that serves the purpose of the said name prefix. So instead of copying a yet-unknown string a pointer to it is stored in struct fsg_lun. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/f_mass_storage.c | 424 +-- drivers/usb/gadget/f_mass_storage.h | 33 +++ drivers/usb/gadget/storage_common.h | 20 ++- 3 files changed, 454 insertions(+), 23 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index e2598f4..0bf7503 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -299,6 +299,7 @@ struct fsg_common { unsigned intshort_packet_received:1; unsigned intbad_lun_okay:1; unsigned intrunning:1; + unsigned intsysfs:1; int thread_wakeup_needed; struct completion thread_notifier; @@ -2640,6 +2641,393 @@ static inline int fsg_num_buffers_validate(unsigned int fsg_num_buffers) return -EINVAL; } +static struct fsg_common *fsg_common_setup(struct fsg_common *common, bool zero) +{ + if (!common) { + common = kzalloc(sizeof(*common), GFP_KERNEL); + if (!common) + return ERR_PTR(-ENOMEM); + common-free_storage_on_release = 1; + } else { + if (zero) + memset(common, 0, sizeof(*common)); + common-free_storage_on_release = 0; + } + init_rwsem(common-filesem); + spin_lock_init(common-lock); + kref_init(common-ref); + init_completion(common-thread_notifier); + init_waitqueue_head(common-fsg_wait); + common-state = FSG_STATE_TERMINATED; + + return common; +} + +void fsg_common_set_sysfs(struct fsg_common *common, bool sysfs) +{ + common-sysfs = sysfs; +} + +static void _fsg_common_free_buffers(struct fsg_buffhd *buffhds, unsigned n) +{ + if (buffhds) { + struct fsg_buffhd *bh = buffhds; + while (n--) { + kfree(bh-buf); + ++bh; + } + kfree(buffhds); + } +} + +int fsg_common_set_num_buffers(struct fsg_common *common, unsigned int n) +{ + struct fsg_buffhd *bh, *new_buffhds; + int i, rc; + + rc = fsg_num_buffers_validate(n); + if (rc != 0) + return rc; + + new_buffhds = kcalloc(n, sizeof *(new_buffhds), GFP_KERNEL); + if (!new_buffhds) + return -ENOMEM; + + /* Data buffers cyclic list */ + bh = new_buffhds; + i = n; + goto buffhds_first_it; + do { + bh-next = bh + 1; + ++bh; +buffhds_first_it: + bh-buf = kmalloc(FSG_BUFLEN, GFP_KERNEL); + if (unlikely(!bh-buf)) + goto error_release; + } while (--i); + bh-next = new_buffhds; + + _fsg_common_free_buffers(common-buffhds, common-fsg_num_buffers); + common-fsg_num_buffers = n; + common-buffhds = new_buffhds; + + return 0; + +error_release: + _fsg_common_free_buffers(new_buffhds, n - i); + + return -ENOMEM; +} + +void fsg_common_free_buffers(struct fsg_common *common) +{ + _fsg_common_free_buffers(common-buffhds, common-fsg_num_buffers); + common-buffhds = NULL; +} + +int fsg_common_set_nluns(struct fsg_common *common, int nluns) +{ + struct fsg_lun **curlun; + + /* Find out how many LUNs there should be */ + if (nluns 1 || nluns FSG_MAX_LUNS) { + pr_err(invalid number of LUNs: %u\n, nluns); + return -EINVAL; + } + + curlun = kcalloc(nluns, sizeof(*curlun), GFP_KERNEL); + if (unlikely(!curlun)) + return -ENOMEM; + + if (common-luns) + fsg_common_free_luns(common); + + common-luns = curlun; + common-nluns = nluns; + +
[PATCH v4 19/19] usb/gadget: f_mass_storage: add configfs support
From this commit on f_mass_storage is available through configfs. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- .../ABI/testing/configfs-usb-gadget-mass-storage | 31 ++ drivers/usb/gadget/Kconfig | 11 + drivers/usb/gadget/f_mass_storage.c| 368 drivers/usb/gadget/f_mass_storage.h| 17 + 4 files changed, 427 insertions(+), 0 deletions(-) create mode 100644 Documentation/ABI/testing/configfs-usb-gadget-mass-storage diff --git a/Documentation/ABI/testing/configfs-usb-gadget-mass-storage b/Documentation/ABI/testing/configfs-usb-gadget-mass-storage new file mode 100644 index 000..e1e918e --- /dev/null +++ b/Documentation/ABI/testing/configfs-usb-gadget-mass-storage @@ -0,0 +1,31 @@ +What: /config/usb-gadget/gadget/functions/mass_storage.name +Date: Jul 2013 +KenelVersion: 3.12 +Description: + The attributes: + + stall - Set to permit function to halt bulk endpoints. + Disabled on some USB devices known not to work + correctly. You should set it to true. + num_buffers - Number of pipeline buffers. Valid numbers + are 2..4. Available only if + CONFIG_USB_GADGET_DEBUG_FILES is set. + +What: /config/usb-gadget/gadget/functions/mass_storage.name/lun.name +Date: Jul 2013 +KenelVersion: 3.12 +Description: + The attributes: + + file- The path to the backing file for the LUN. + Required if LUN is not marked as removable. + ro - Flag specifying access to the LUN shall be + read-only. This is implied if CD-ROM emulation + is enabled as well as when it was impossible + to open filename in R/W mode. + removable - Flag specifying that LUN shall be indicated as + being removable. + cdrom - Flag specifying that LUN shall be reported as + being a CD-ROM. + nofua - Flag specifying that FUA flag + in SCSI WRITE(10,12) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 7d64e47..bc5dea2 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -668,6 +668,17 @@ config USB_CONFIGFS_PHONET help The Phonet protocol implementation for USB device. +config USB_CONFIGFS_MASS_STORAGE + boolean Mass storage + depends on USB_CONFIGFS + select USB_U_MS + select USB_F_MASS_STORAGE + help + The Mass Storage Gadget acts as a USB Mass Storage disk drive. + As its storage repository it can use a regular file or a block + device (in much the same way as the loop device driver), + specified as a module parameter or sysfs option. + config USB_ZERO tristate Gadget Zero (DEVELOPMENT) select USB_LIBCOMPOSITE diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 50f7612..fb43a49 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -220,6 +220,7 @@ #include linux/usb/composite.h #include gadget_chips.h +#include configfs.h /**/ @@ -3324,6 +3325,350 @@ static int fsg_bind_config(struct usb_composite_dev *cdev, #else +static inline struct fsg_lun_opts *to_fsg_lun_opts(struct config_item *item) +{ + return container_of(to_config_group(item), struct fsg_lun_opts, group); +} + +static inline struct fsg_opts *to_fsg_opts(struct config_item *item) +{ + return container_of(to_config_group(item), struct fsg_opts, + func_inst.group); +} + +CONFIGFS_ATTR_STRUCT(fsg_lun_opts); +CONFIGFS_ATTR_OPS(fsg_lun_opts); + +static void fsg_lun_attr_release(struct config_item *item) +{ + struct fsg_lun_opts *lun_opts; + + lun_opts = to_fsg_lun_opts(item); + kfree(lun_opts); +} + +static struct configfs_item_operations fsg_lun_item_ops = { + .release= fsg_lun_attr_release, + .show_attribute = fsg_lun_opts_attr_show, + .store_attribute = fsg_lun_opts_attr_store, +}; + +static ssize_t fsg_lun_opts_file_show(struct fsg_lun_opts *opts, char *page) +{ + struct fsg_opts *fsg_opts; + + fsg_opts = to_fsg_opts(opts-group.cg_item.ci_parent); + + return fsg_show_file(opts-lun, fsg_opts-common-filesem, page); +} + +static ssize_t fsg_lun_opts_file_store(struct fsg_lun_opts *opts, + const char *page, size_t len) +{ + struct fsg_opts
[PATCH v4 02/19] usb/gadget: create a utility module for mass_storage
Converting to configfs requires making the f_mass_storage.c a module. But first we need to get rid of #include storage_common.c. This patch makes storage_common.c a separately compiled file, which is built as a utility module named u_ms.ko. After all mass storage users are converted to the new function interface this module can be eliminated by merging it with the mass storage function's module. USB descriptors are exported so that they can be accessed from f_mass_storage. FSG_VENDOR_ID and FSG_PRODUCT_ID are moved to their only user. Handling of CONFIG_USB_GADGET_DEBUG_FILES is moved to f_mass_storage.c. The fsg_num_buffers static is moved to FSG_MODULE_PARAMETER users, so instead of using a global variable the f_mass_storage introduces fsg_num_buffers member in fsg_common (and fsg_config). fsg_strings and fsg_stringtab are moved to f_mass_storage.c. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/Kconfig |6 + drivers/usb/gadget/Makefile |2 + drivers/usb/gadget/acm_ms.c | 17 ++- drivers/usb/gadget/f_mass_storage.c | 106 ++-- drivers/usb/gadget/mass_storage.c | 25 +++- drivers/usb/gadget/multi.c | 17 ++- drivers/usb/gadget/storage_common.c | 331 ++- drivers/usb/gadget/storage_common.h | 210 ++ 8 files changed, 423 insertions(+), 291 deletions(-) create mode 100644 drivers/usb/gadget/storage_common.h diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 48cddf3..98220dc 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -525,6 +525,9 @@ config USB_F_SUBSET config USB_F_RNDIS tristate +config USB_U_MS + tristate + choice tristate USB Gadget Drivers default USB_ETH @@ -878,6 +881,7 @@ config USB_MASS_STORAGE tristate Mass Storage Gadget depends on BLOCK select USB_LIBCOMPOSITE + select USB_U_MS help The Mass Storage Gadget acts as a USB Mass Storage disk drive. As its storage repository it can use a regular file or a block @@ -1001,6 +1005,7 @@ config USB_G_ACM_MS select USB_LIBCOMPOSITE select USB_U_SERIAL select USB_F_ACM + select USB_U_MS help This driver provides two functions in one configuration: a mass storage, and a CDC ACM (serial port) link. @@ -1017,6 +1022,7 @@ config USB_G_MULTI select USB_U_ETHER select USB_U_RNDIS select USB_F_ACM + select USB_U_MS help The Multifunction Composite Gadget provides Ethernet (RNDIS and/or CDC Ethernet), mass storage and ACM serial link diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile index 386db9d..d90a0b0 100644 --- a/drivers/usb/gadget/Makefile +++ b/drivers/usb/gadget/Makefile @@ -60,6 +60,8 @@ usb_f_ecm_subset-y:= f_subset.o obj-$(CONFIG_USB_F_SUBSET) += usb_f_ecm_subset.o usb_f_rndis-y := f_rndis.o obj-$(CONFIG_USB_F_RNDIS) += usb_f_rndis.o +u_ms-y := storage_common.o +obj-$(CONFIG_USB_U_MS) += u_ms.o # # USB gadget drivers diff --git a/drivers/usb/gadget/acm_ms.c b/drivers/usb/gadget/acm_ms.c index 4b947bb..992ffb0 100644 --- a/drivers/usb/gadget/acm_ms.c +++ b/drivers/usb/gadget/acm_ms.c @@ -104,6 +104,20 @@ static struct usb_gadget_strings *dev_strings[] = { /** Configurations **/ static struct fsg_module_parameters fsg_mod_data = { .stall = 1 }; +#ifdef CONFIG_USB_GADGET_DEBUG_FILES + +static unsigned int fsg_num_buffers = CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS; + +#else + +/* + * Number of buffers we will use. + * 2 is usually enough for good buffering pipeline + */ +#define fsg_num_buffersCONFIG_USB_GADGET_STORAGE_NUM_BUFFERS + +#endif /* CONFIG_USB_DEBUG */ + FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data); static struct fsg_common fsg_common; @@ -167,7 +181,8 @@ static int __init acm_ms_bind(struct usb_composite_dev *cdev) void*retp; /* set up mass storage function */ - retp = fsg_common_from_params(fsg_common, cdev, fsg_mod_data); + retp = fsg_common_from_params(fsg_common, cdev, fsg_mod_data, + fsg_num_buffers); if (IS_ERR(retp)) { status = PTR_ERR(retp); return PTR_ERR(retp); diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index 313b835..a7c33c0 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -228,8 +228,18 @@ static const char fsg_string_interface[] = Mass Storage; -#include storage_common.c +#include storage_common.h +/* Static strings, in UTF-8 (for simplicity we use only ASCII characters) */
[PATCH v3 0/1] Equivalent of g_acm_ms.ko with configfs
Here I present the conversion of everything that is required to provide the equivalent of g_acm_ms.ko with configfs. In fact this series consists of just one patch; everything required to provide the equivalent of g_acm_ms.ko with configfs has been done in the series related to the g_mass_storage.ko. The current series just moves the g_acm_ms to the new function interface of f_mass_storage. v1..v2: - removed the cause of Felipe returning -ENOLOG - moved fsg_common_set_sysfs invocation after the lun number is set, so that the latter operation does not try freeing nonexistent sysfs entries v2..v3: - rebased onto 3.12-rc1 A branch 'usb-gadget-configfs-for-3.12' is available at: git://git.linaro.org/people/mszyprowski/linux-srpol.git This series depends on the [PATCH v4 ] Equivalent of g_mass_storage with configfs which has just been sent. BACKWARD COMPATIBILITY == Please note that the old g_acm_ms.ko is still available and works. USING THE NEW GADGET == Please refer to this post: http://www.spinics.net/lists/linux-usb/msg76388.html for general information from Sebastian on how to use configfs-based gadgets (*). The g_acm_ms.ko provides 2 functions: - acm (described in (*)) - mass storage (described in a series preceding the current one, I will reply to this post to send a link when spinics or gmane has indexed the series in question) The procedure of setting up such a gadget with configfs is given below with an example: $ modprobe libcomposite $ mount none cfg -t configfs $ mkdir cfg/usb_gadget/g1 $ cd cfg/usb_gadget/g1 $ echo 0x0106 idProduct $ echo 0x04e8 idVendor $ mkdir strings/0x409 $ echo my-serial-number strings/0x409/serialnumber $ echo my-manufacturer strings/0x409/manufacturer $ echo ACM/MS Gadget strings/0x409/product $ mkdir configs/c.1 $ echo 120 configs/c.1/MaxPower $ mkdir configs/c.1/strings/0x409 $ echo Conf 1 configs/c.1/strings/0x409/configuration $ mkdir functions/mass_storage.0 $ echo /root/lun0.img functions/mass_storage.0/lun.0/file $ mkdir functions/mass_storage.0/lun.1 $ echo /root/lun1.img functions/mass_storage.0/lun.1/file $ mkdir functions/acm.usb0 $ ln -s functions/mass_storage.0 configs/c.1 $ ln -s functions/acm.usb0 configs/c.1 $ echo s3c-hsotg UDC After unbinding the gadget with echo UDC the symbolic links in the configuration directory can be removed, the strings/* subdirectories in the configuration directory can be removed, the strings/* subdirectories at the gadget level can be removed and the configs/* subdirectories can be removed. The functions/* subdirectories can be removed. After that the gadget directory can be removed. After that the respective modules can be unloaded. TESTING THE FUNCTIONS acm) On the host: cat /dev/ttyACM0 On the device: cat /dev/ttyGS0 and then the other way round: cat /dev/ttyGS0 cat /dev/ttyACM0 mass storage) device: connect the gadget, enable it host: dmesg, see the USB drives appear (if system configured to automatically mount) Andrzej Pietrasiewicz (1): usb/gadget: acm_ms: convert to new interface of f_mass_storage drivers/usb/gadget/Kconfig |1 + drivers/usb/gadget/acm_ms.c | 113 --- 2 files changed, 75 insertions(+), 39 deletions(-) -- 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/1] usb/gadget: acm_ms: convert to new interface of f_mass_storage
Convert the legacy acm_ms gadget to use the new function interface of f_mass_storage, so that later the compatibility layer in f_mass_storage can be removed. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/Kconfig |1 + drivers/usb/gadget/acm_ms.c | 113 --- 2 files changed, 75 insertions(+), 39 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index bc5dea2..886db6a 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -1021,6 +1021,7 @@ config USB_G_ACM_MS select USB_U_SERIAL select USB_F_ACM select USB_U_MS + select USB_F_MASS_STORAGE help This driver provides two functions in one configuration: a mass storage, and a CDC ACM (serial port) link. diff --git a/drivers/usb/gadget/acm_ms.c b/drivers/usb/gadget/acm_ms.c index 31aae8f..b405bc4 100644 --- a/drivers/usb/gadget/acm_ms.c +++ b/drivers/usb/gadget/acm_ms.c @@ -31,17 +31,7 @@ #define ACM_MS_VENDOR_NUM 0x1d6b /* Linux Foundation */ #define ACM_MS_PRODUCT_NUM 0x0106 /* Composite Gadget: ACM + MS*/ -/*-*/ - -/* - * Kbuild is not very cooperative with respect to linking separately - * compiled library objects into one module. So for now we won't use - * separate compilation ... ensuring init/exit sections work to shrink - * the runtime footprint, and giving us at least some parts of what - * a gcc --combine ... part1.c part2.c part3.c ... build would. - */ -#define USB_FMS_INCLUDED -#include f_mass_storage.c +#include f_mass_storage.h /*-*/ USB_GADGET_COMPOSITE_OPTIONS(); @@ -121,16 +111,19 @@ static unsigned int fsg_num_buffers = CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS; FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data); -static struct fsg_common fsg_common; - /*-*/ static struct usb_function *f_acm; static struct usb_function_instance *f_acm_inst; + +static struct usb_function_instance *fi_msg; +static struct usb_function *f_msg; + /* * We _always_ have both ACM and mass storage functions. */ static int __init acm_ms_do_config(struct usb_configuration *c) { + struct fsg_opts *opts; int status; if (gadget_is_otg(c-cdev-gadget)) { @@ -138,31 +131,37 @@ static int __init acm_ms_do_config(struct usb_configuration *c) c-bmAttributes |= USB_CONFIG_ATT_WAKEUP; } - f_acm_inst = usb_get_function_instance(acm); - if (IS_ERR(f_acm_inst)) - return PTR_ERR(f_acm_inst); + opts = container_of(fi_msg, struct fsg_opts, func_inst); f_acm = usb_get_function(f_acm_inst); - if (IS_ERR(f_acm)) { - status = PTR_ERR(f_acm); - goto err_func; + if (IS_ERR(f_acm)) + return PTR_ERR(f_acm); + + f_msg = usb_get_function(fi_msg); + if (IS_ERR(f_msg)) { + status = PTR_ERR(f_msg); + goto put_acm; } status = usb_add_function(c, f_acm); if (status 0) - goto err_conf; + goto put_msg; - status = fsg_bind_config(c-cdev, c, fsg_common); - if (status 0) - goto err_fsg; + status = fsg_common_run_thread(opts-common); + if (status) + goto remove_acm; + + status = usb_add_function(c, f_msg); + if (status) + goto remove_acm; return 0; -err_fsg: +remove_acm: usb_remove_function(c, f_acm); -err_conf: +put_msg: + usb_put_function(f_msg); +put_acm: usb_put_function(f_acm); -err_func: - usb_put_function_instance(f_acm_inst); return status; } @@ -178,46 +177,82 @@ static struct usb_configuration acm_ms_config_driver = { static int __init acm_ms_bind(struct usb_composite_dev *cdev) { struct usb_gadget *gadget = cdev-gadget; + struct fsg_opts *opts; + struct fsg_config config; int status; - void*retp; - /* set up mass storage function */ - retp = fsg_common_from_params(fsg_common, cdev, fsg_mod_data, - fsg_num_buffers); - if (IS_ERR(retp)) { - status = PTR_ERR(retp); - return PTR_ERR(retp); + f_acm_inst = usb_get_function_instance(acm); + if (IS_ERR(f_acm_inst)) + return PTR_ERR(f_acm_inst); + + fi_msg = usb_get_function_instance(mass_storage); + if (IS_ERR(fi_msg)) { + status = PTR_ERR(fi_msg); + goto fail_get_msg; } + /* set up mass storage function */ +
[PATCH v3 0/5] Equivalent of g_multi.ko with configfs
Here I present the conversion of everything that is required to provide the equivalent of g_multi.ko with configfs. v1..v2: - removed the cause of Felipe returning -ENOLOG - moved fsg_common_set_sysfs invocation after the lun number is set, so that the latter operation does not try freeing nonexistent sysfs entries - adapted to earlier changes in multi.c (*_do_config) v2..v3: - rebased onto 3.12-rc1 A branch 'usb-gadget-configfs-for-3.12' is available at: git://git.linaro.org/people/mszyprowski/linux-srpol.git This series depends on a [PATCH v3] Equivalent of g_acm_ms with configfs, which has just been sent. BACKWARD COMPATIBILITY == Please note that the old g_multi.ko is still available and works. USING THE NEW GADGET == Please refer to this post: http://www.spinics.net/lists/linux-usb/msg76388.html for general information from Sebastian on how to use configfs-based gadgets (*). The g_multi.ko provides 4 functions: - acm (described in (*)) - ecm (http://www.spinics.net/lists/linux-usb/msg86561.html) - rndis (http://www.spinics.net/lists/linux-usb/msg86561.html) - mass storage (described in a series preceding the current one, I will reply to this post to send a link when spinics or gmane has indexed the series in question) and using all of them with configfs has already been described. The procedure of setting up a new multi gadget with configfs is given below with an example: $ modprobe libcomposite $ mount none cfg -t configfs $ mkdir cfg/usb_gadget/g1 $ cd cfg/usb_gadget/g1 $ echo 0x0106 idProduct $ echo 0x04e8 idVendor $ mkdir strings/0x409 $ echo my-serial-num strings/0x409/serialnumber $ echo my-manufacturer strings/0x409/manufacturer $ echo Multi Gadget strings/0x409/product $ mkdir configs/c.1 $ echo 120 configs/c.1/MaxPower $ mkdir configs/c.1/strings/0x409 $ echo Conf 1 configs/c.1/strings/0x409/configuration $ mkdir configs/c.2 $ echo 120 configs/c.2/MaxPower $ mkdir configs/c.2/strings/0x409 $ echo Conf 2 configs/c.2/strings/0x409/configuration $ mkdir functions/mass_storage.0 $ echo /root/lun0.img functions/mass_storage.0/lun.0/file $ mkdir functions/mass_storage.0/lun.1 $ echo /root/lun1.img functions/mass_storage.0/lun.1/file $ mkdir functions/acm.0 $ mkdir functions/ecm.0 $ mkdir functions/rndis.0 $ ln -s functions/rndis.0 configs/c.1 $ ln -s functions/acm.0 configs/c.1 $ ln -s functions/mass_storage.0 configs/c.1 $ ln -s functions/ecm.0 configs/c.2 $ ln -s functions/acm.0 configs/c.2 $ ln -s functions/mass_storage.0 configs/c.2 After unbinding the gadget with echo UDC the symbolic links in the configuration directory can be removed, the strings/* subdirectories in the configuration directory can be removed, the strings/* subdirectories at the gadget level can be removed and the configs/* subdirectories can be removed. The functions/* subdirectories can be removed. After that the gadget directory can be removed. After that the respective modules can be unloaded. TESTING THE FUNCTIONS acm) On the host: cat /dev/ttyACM0 On the device: cat /dev/ttyGS0 and then the other way round: cat /dev/ttyGS0 cat /dev/ttyACM0 mass storage) device: connect the gadget, enable it host: dmesg, see the USB drives appear (if system configured to automatically mount) ecm, rndis) On the device: ping host's IP On the host: ping device's IP Andrzej Pietrasiewicz (5): usb/gadget: multi: convert to new interface of f_ecm usb/gadget: multi: convert to new interface of f_rndis usb/gadget: multi: convert to new interface of f_mass_storage usb/gadget: f_mass_storage: remove compatibility layer usb/gadget: mass_storage: merge usb_f_mass_storage module with u_ms module drivers/usb/gadget/Kconfig | 12 +-- drivers/usb/gadget/Makefile |4 +- drivers/usb/gadget/f_mass_storage.c | 154 +-- drivers/usb/gadget/f_mass_storage.h | 21 --- drivers/usb/gadget/multi.c | 237 +++ 5 files changed, 190 insertions(+), 238 deletions(-) -- 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/5] usb/gadget: multi: convert to new interface of f_mass_storage
Convert the legacy multi gadget to the new interface of f_mass_storage, so that later the compatibility layer in f_mass_storage can be removed. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/Kconfig |1 + drivers/usb/gadget/multi.c | 112 2 files changed, 83 insertions(+), 30 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index bbcc313..4b0c456 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -1038,6 +1038,7 @@ config USB_G_MULTI select USB_U_ETHER select USB_F_ACM select USB_U_MS + select USB_F_MASS_STORAGE help The Multifunction Composite Gadget provides Ethernet (RNDIS and/or CDC Ethernet), mass storage and ACM serial link diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c index be62bea..7f84efa 100644 --- a/drivers/usb/gadget/multi.c +++ b/drivers/usb/gadget/multi.c @@ -33,17 +33,7 @@ MODULE_AUTHOR(Michal Nazarewicz); MODULE_LICENSE(GPL); -/* All the files... */ - -/* - * kbuild is not very cooperative with respect to linking separately - * compiled library objects into one module. So for now we won't use - * separate compilation ... ensuring init/exit sections work to shrink - * the runtime footprint, and giving us at least some parts of what - * a gcc --combine ... part1.c part2.c part3.c ... build would. - */ -#define USB_FMS_INCLUDED -#include f_mass_storage.c +#include f_mass_storage.h #include u_ecm.h #ifdef USB_ETH_RNDIS @@ -148,9 +138,8 @@ static unsigned int fsg_num_buffers = CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS; FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data); -static struct fsg_common fsg_common; - static struct usb_function_instance *fi_acm; +static struct usb_function_instance *fi_msg; /** RNDIS **/ @@ -158,9 +147,11 @@ static struct usb_function_instance *fi_acm; static struct usb_function_instance *fi_rndis; static struct usb_function *f_acm_rndis; static struct usb_function *f_rndis; +static struct usb_function *f_msg_rndis; static __init int rndis_do_config(struct usb_configuration *c) { + struct fsg_opts *fsg_opts; int ret; if (gadget_is_otg(c-cdev-gadget)) { @@ -186,11 +177,24 @@ static __init int rndis_do_config(struct usb_configuration *c) if (ret) goto err_conf; - ret = fsg_bind_config(c-cdev, c, fsg_common); - if (ret 0) + f_msg_rndis = usb_get_function(fi_msg); + if (IS_ERR(f_msg_rndis)) { + ret = PTR_ERR(f_msg_rndis); goto err_fsg; + } + + fsg_opts = container_of(fi_msg, struct fsg_opts, func_inst); + ret = fsg_common_run_thread(fsg_opts-common); + if (ret) + goto err_run; + + ret = usb_add_function(c, f_msg_rndis); + if (ret) + goto err_run; return 0; +err_run: + usb_put_function(f_msg_rndis); err_fsg: usb_remove_function(c, f_acm_rndis); err_conf: @@ -231,9 +235,11 @@ static int rndis_config_register(struct usb_composite_dev *cdev) static struct usb_function_instance *fi_ecm; static struct usb_function *f_acm_multi; static struct usb_function *f_ecm; +static struct usb_function *f_msg_multi; static __init int cdc_do_config(struct usb_configuration *c) { + struct fsg_opts *fsg_opts; int ret; if (gadget_is_otg(c-cdev-gadget)) { @@ -260,11 +266,24 @@ static __init int cdc_do_config(struct usb_configuration *c) if (ret) goto err_conf; - ret = fsg_bind_config(c-cdev, c, fsg_common); - if (ret 0) + f_msg_multi = usb_get_function(fi_msg); + if (IS_ERR(f_msg_multi)) { + ret = PTR_ERR(f_msg_multi); goto err_fsg; + } + + fsg_opts = container_of(fi_msg, struct fsg_opts, func_inst); + ret = fsg_common_run_thread(fsg_opts-common); + if (ret) + goto err_run; + + ret = usb_add_function(c, f_msg_multi); + if (ret) + goto err_run; return 0; +err_run: + usb_put_function(f_msg_multi); err_fsg: usb_remove_function(c, f_acm_multi); err_conf: @@ -311,6 +330,8 @@ static int __ref multi_bind(struct usb_composite_dev *cdev) #ifdef USB_ETH_RNDIS struct f_rndis_opts *rndis_opts; #endif + struct fsg_opts *fsg_opts; + struct fsg_config config; int status; if (!can_support_ecm(cdev-gadget)) { @@ -373,41 +394,65 @@ static int __ref multi_bind(struct usb_composite_dev *cdev) } /* set up mass storage function */ - { - void *retp; - retp = fsg_common_from_params(fsg_common, cdev, fsg_mod_data, -
[PATCH v3 5/5] usb/gadget: mass_storage: merge usb_f_mass_storage module with u_ms module
u_ms.ko is needed only together with usb_f_mass_storage.ko. Merge them. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/Kconfig |7 --- drivers/usb/gadget/Makefile |4 +--- 2 files changed, 1 insertions(+), 10 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 4b0c456..604f885 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -525,9 +525,6 @@ config USB_F_SUBSET config USB_F_RNDIS tristate -config USB_U_MS - tristate - config USB_F_MASS_STORAGE tristate @@ -671,7 +668,6 @@ config USB_CONFIGFS_PHONET config USB_CONFIGFS_MASS_STORAGE boolean Mass storage depends on USB_CONFIGFS - select USB_U_MS select USB_F_MASS_STORAGE help The Mass Storage Gadget acts as a USB Mass Storage disk drive. @@ -895,7 +891,6 @@ config USB_MASS_STORAGE tristate Mass Storage Gadget depends on BLOCK select USB_LIBCOMPOSITE - select USB_U_MS select USB_F_MASS_STORAGE help The Mass Storage Gadget acts as a USB Mass Storage disk drive. @@ -1020,7 +1015,6 @@ config USB_G_ACM_MS select USB_LIBCOMPOSITE select USB_U_SERIAL select USB_F_ACM - select USB_U_MS select USB_F_MASS_STORAGE help This driver provides two functions in one configuration: @@ -1037,7 +1031,6 @@ config USB_G_MULTI select USB_U_SERIAL select USB_U_ETHER select USB_F_ACM - select USB_U_MS select USB_F_MASS_STORAGE help The Multifunction Composite Gadget provides Ethernet (RNDIS diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile index 4a86b0c..f1bd42a 100644 --- a/drivers/usb/gadget/Makefile +++ b/drivers/usb/gadget/Makefile @@ -60,9 +60,7 @@ usb_f_ecm_subset-y:= f_subset.o obj-$(CONFIG_USB_F_SUBSET) += usb_f_ecm_subset.o usb_f_rndis-y := f_rndis.o obj-$(CONFIG_USB_F_RNDIS) += usb_f_rndis.o -u_ms-y := storage_common.o -obj-$(CONFIG_USB_U_MS) += u_ms.o -usb_f_mass_storage-y := f_mass_storage.o +usb_f_mass_storage-y := f_mass_storage.o storage_common.o obj-$(CONFIG_USB_F_MASS_STORAGE)+= usb_f_mass_storage.o # -- 1.7.0.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/5] usb/gadget: multi: convert to new interface of f_ecm
Convert the legacy multi gadget to the new interface of f_ecm, so that later the compatibility layer in f_ecm can be removed. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/Kconfig |1 + drivers/usb/gadget/multi.c | 68 ++- 2 files changed, 61 insertions(+), 8 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 886db6a..92a8966 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -1070,6 +1070,7 @@ config USB_G_MULTI_CDC bool CDC Ethernet + CDC Serial + Storage configuration depends on USB_G_MULTI default n + select USB_F_ECM help This option enables a configuration with CDC Ethernet (ECM), CDC Serial and Mass Storage functions available in the Multifunction diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c index c232f76..0d1d132 100644 --- a/drivers/usb/gadget/multi.c +++ b/drivers/usb/gadget/multi.c @@ -15,6 +15,7 @@ #include linux/kernel.h #include linux/module.h +#include linux/netdevice.h #include u_serial.h #if defined USB_ETH_RNDIS @@ -44,8 +45,7 @@ MODULE_LICENSE(GPL); #define USB_FMS_INCLUDED #include f_mass_storage.c -#define USBF_ECM_INCLUDED -#include f_ecm.c +#include u_ecm.h #ifdef USB_ETH_RNDIS # define USB_FRNDIS_INCLUDED # include f_rndis.c @@ -151,14 +151,14 @@ FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data); static struct fsg_common fsg_common; -static u8 host_mac[ETH_ALEN]; - static struct usb_function_instance *fi_acm; static struct eth_dev *the_dev; /** RNDIS **/ #ifdef USB_ETH_RNDIS +static u8 host_mac[ETH_ALEN]; + static struct usb_function *f_acm_rndis; static __init int rndis_do_config(struct usb_configuration *c) @@ -220,7 +220,9 @@ static int rndis_config_register(struct usb_composite_dev *cdev) /** CDC ECM **/ #ifdef CONFIG_USB_G_MULTI_CDC +static struct usb_function_instance *fi_ecm; static struct usb_function *f_acm_multi; +static struct usb_function *f_ecm; static __init int cdc_do_config(struct usb_configuration *c) { @@ -231,14 +233,20 @@ static __init int cdc_do_config(struct usb_configuration *c) c-bmAttributes |= USB_CONFIG_ATT_WAKEUP; } - ret = ecm_bind_config(c, host_mac, the_dev); + f_ecm = usb_get_function(fi_ecm); + if (IS_ERR(f_ecm)) + return PTR_ERR(f_ecm); + + ret = usb_add_function(c, f_ecm); if (ret 0) - return ret; + goto err_func_ecm; /* implicit port_num is zero */ f_acm_multi = usb_get_function(fi_acm); - if (IS_ERR(f_acm_multi)) - return PTR_ERR(f_acm_multi); + if (IS_ERR(f_acm_multi)) { + ret = PTR_ERR(f_acm_multi); + goto err_func_acm; + } ret = usb_add_function(c, f_acm_multi); if (ret) @@ -253,6 +261,10 @@ err_fsg: usb_remove_function(c, f_acm_multi); err_conf: usb_put_function(f_acm_multi); +err_func_acm: + usb_remove_function(c, f_ecm); +err_func_ecm: + usb_put_function(f_ecm); return ret; } @@ -285,6 +297,9 @@ static int cdc_config_register(struct usb_composite_dev *cdev) static int __ref multi_bind(struct usb_composite_dev *cdev) { struct usb_gadget *gadget = cdev-gadget; +#ifdef CONFIG_USB_G_MULTI_CDC + struct f_ecm_opts *ecm_opts; +#endif int status; if (!can_support_ecm(cdev-gadget)) { @@ -293,11 +308,39 @@ static int __ref multi_bind(struct usb_composite_dev *cdev) return -EINVAL; } +#ifdef CONFIG_USB_G_MULTI_CDC + fi_ecm = usb_get_function_instance(ecm); + if (IS_ERR(fi_ecm)) + return PTR_ERR(fi_ecm); + + ecm_opts = container_of(fi_ecm, struct f_ecm_opts, func_inst); + + gether_set_qmult(ecm_opts-net, qmult); + if (!gether_set_host_addr(ecm_opts-net, host_addr)) + pr_info(using host ethernet address: %s, host_addr); + if (!gether_set_dev_addr(ecm_opts-net, dev_addr)) + pr_info(using self ethernet address: %s, dev_addr); + + the_dev = netdev_priv(ecm_opts-net); + +#elif defined USB_ETH_RNDIS + /* set up network link layer */ the_dev = gether_setup(cdev-gadget, dev_addr, host_addr, host_mac, qmult); if (IS_ERR(the_dev)) return PTR_ERR(the_dev); +#endif + +#if (defined CONFIG_USB_G_MULTI_CDC defined USB_ETH_RNDIS) + gether_set_gadget(ecm_opts-net, cdev-gadget); + status = gether_register_netdev(ecm_opts-net); + if (status) + goto fail0; + ecm_opts-bound = true; + + gether_get_host_addr_u8(ecm_opts-net, host_mac); +#endif /* set up serial link layer */ fi_acm =
[PATCH v3 2/5] usb/gadget: multi: convert to new interface of f_rndis
Convert the legacy multi gadget to the new interface of f_rndis, so that later the compatibility layer in f_rndis can be removed. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/Kconfig |3 +- drivers/usb/gadget/multi.c | 73 ++-- 2 files changed, 52 insertions(+), 24 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 92a8966..bbcc313 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -1036,7 +1036,6 @@ config USB_G_MULTI select USB_LIBCOMPOSITE select USB_U_SERIAL select USB_U_ETHER - select USB_U_RNDIS select USB_F_ACM select USB_U_MS help @@ -1057,6 +1056,8 @@ config USB_G_MULTI config USB_G_MULTI_RNDIS bool RNDIS + CDC Serial + Storage configuration depends on USB_G_MULTI + select USB_U_RNDIS + select USB_F_RNDIS default y help This option enables a configuration with RNDIS, CDC Serial and diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c index 0d1d132..be62bea 100644 --- a/drivers/usb/gadget/multi.c +++ b/drivers/usb/gadget/multi.c @@ -47,8 +47,7 @@ MODULE_LICENSE(GPL); #include u_ecm.h #ifdef USB_ETH_RNDIS -# define USB_FRNDIS_INCLUDED -# include f_rndis.c +# include u_rndis.h # include rndis.h #endif #include u_ether.h @@ -152,14 +151,13 @@ FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data); static struct fsg_common fsg_common; static struct usb_function_instance *fi_acm; -static struct eth_dev *the_dev; /** RNDIS **/ #ifdef USB_ETH_RNDIS -static u8 host_mac[ETH_ALEN]; - +static struct usb_function_instance *fi_rndis; static struct usb_function *f_acm_rndis; +static struct usb_function *f_rndis; static __init int rndis_do_config(struct usb_configuration *c) { @@ -170,13 +168,19 @@ static __init int rndis_do_config(struct usb_configuration *c) c-bmAttributes |= USB_CONFIG_ATT_WAKEUP; } - ret = rndis_bind_config(c, host_mac, the_dev); + f_rndis = usb_get_function(fi_rndis); + if (IS_ERR(f_rndis)) + return PTR_ERR(f_rndis); + + ret = usb_add_function(c, f_rndis); if (ret 0) - return ret; + goto err_func_rndis; f_acm_rndis = usb_get_function(fi_acm); - if (IS_ERR(f_acm_rndis)) - return PTR_ERR(f_acm_rndis); + if (IS_ERR(f_acm_rndis)) { + ret = PTR_ERR(f_acm_rndis); + goto err_func_acm; + } ret = usb_add_function(c, f_acm_rndis); if (ret) @@ -191,6 +195,10 @@ err_fsg: usb_remove_function(c, f_acm_rndis); err_conf: usb_put_function(f_acm_rndis); +err_func_acm: + usb_remove_function(c, f_rndis); +err_func_rndis: + usb_put_function(f_rndis); return ret; } @@ -300,11 +308,14 @@ static int __ref multi_bind(struct usb_composite_dev *cdev) #ifdef CONFIG_USB_G_MULTI_CDC struct f_ecm_opts *ecm_opts; #endif +#ifdef USB_ETH_RNDIS + struct f_rndis_opts *rndis_opts; +#endif int status; if (!can_support_ecm(cdev-gadget)) { dev_err(gadget-dev, controller '%s' not usable\n, - gadget-name); + gadget-name); return -EINVAL; } @@ -320,26 +331,38 @@ static int __ref multi_bind(struct usb_composite_dev *cdev) pr_info(using host ethernet address: %s, host_addr); if (!gether_set_dev_addr(ecm_opts-net, dev_addr)) pr_info(using self ethernet address: %s, dev_addr); +#endif - the_dev = netdev_priv(ecm_opts-net); +#ifdef USB_ETH_RNDIS + fi_rndis = usb_get_function_instance(rndis); + if (IS_ERR(fi_rndis)) { + status = PTR_ERR(fi_rndis); + goto fail; + } -#elif defined USB_ETH_RNDIS + rndis_opts = container_of(fi_rndis, struct f_rndis_opts, func_inst); - /* set up network link layer */ - the_dev = gether_setup(cdev-gadget, dev_addr, host_addr, host_mac, - qmult); - if (IS_ERR(the_dev)) - return PTR_ERR(the_dev); + gether_set_qmult(rndis_opts-net, qmult); + if (!gether_set_host_addr(rndis_opts-net, host_addr)) + pr_info(using host ethernet address: %s, host_addr); + if (!gether_set_dev_addr(rndis_opts-net, dev_addr)) + pr_info(using self ethernet address: %s, dev_addr); #endif #if (defined CONFIG_USB_G_MULTI_CDC defined USB_ETH_RNDIS) + /* +* If both ecm and rndis are selected then: +* 1) rndis borrows the net interface from ecm +* 2) since the interface is shared it must not be bound +* twice - in ecm's _and_ rndis' binds, so do it here. +*/
[PATCH v3 4/5] usb/gadget: f_mass_storage: remove compatibility layer
There are no more old interface users left. Remove it. Signed-off-by: Andrzej Pietrasiewicz andrze...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/usb/gadget/f_mass_storage.c | 154 +-- drivers/usb/gadget/f_mass_storage.h | 21 - 2 files changed, 1 insertions(+), 174 deletions(-) diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index fb43a49..8700479 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -2642,17 +2642,13 @@ void fsg_common_get(struct fsg_common *common) { kref_get(common-ref); } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_get); -#endif void fsg_common_put(struct fsg_common *common) { kref_put(common-ref, fsg_common_release); } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_put); -#endif /* check if fsg_num_buffers is within a valid range */ static inline int fsg_num_buffers_validate(unsigned int fsg_num_buffers) @@ -2690,9 +2686,7 @@ void fsg_common_set_sysfs(struct fsg_common *common, bool sysfs) { common-sysfs = sysfs; } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_set_sysfs); -#endif static void _fsg_common_free_buffers(struct fsg_buffhd *buffhds, unsigned n) { @@ -2744,18 +2738,14 @@ error_release: return -ENOMEM; } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_set_num_buffers); -#endif void fsg_common_free_buffers(struct fsg_common *common) { _fsg_common_free_buffers(common-buffhds, common-fsg_num_buffers); common-buffhds = NULL; } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_free_buffers); -#endif int fsg_common_set_nluns(struct fsg_common *common, int nluns) { @@ -2781,9 +2771,7 @@ int fsg_common_set_nluns(struct fsg_common *common, int nluns) return 0; } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_set_nluns); -#endif void fsg_common_free_luns(struct fsg_common *common) { @@ -2791,26 +2779,20 @@ void fsg_common_free_luns(struct fsg_common *common) kfree(common-luns); common-luns = NULL; } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_free_luns); -#endif void fsg_common_set_ops(struct fsg_common *common, const struct fsg_operations *ops) { common-ops = ops; } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_set_ops); -#endif void fsg_common_set_private_data(struct fsg_common *common, void *priv) { common-private_data = priv; } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_set_private_data); -#endif int fsg_common_set_cdev(struct fsg_common *common, struct usb_composite_dev *cdev, bool can_stall) @@ -2840,9 +2822,7 @@ int fsg_common_set_cdev(struct fsg_common *common, return 0; } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_set_cdev); -#endif static inline int fsg_common_add_sysfs(struct fsg_common *common, struct fsg_lun *lun) @@ -2907,9 +2887,7 @@ void fsg_common_remove_lun(struct fsg_lun *lun, bool sysfs) kfree(lun-name); kfree(lun); } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_remove_lun); -#endif void _fsg_common_remove_luns(struct fsg_common *common, int n) { @@ -2926,9 +2904,7 @@ void fsg_common_remove_luns(struct fsg_common *common) { _fsg_common_remove_luns(common, common-nluns); } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_remove_luns); -#endif #define MAX_LUN_NAME_LEN 80 @@ -3025,9 +3001,7 @@ error_name: kfree(lun); return rc; } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_create_lun); -#endif int fsg_common_create_luns(struct fsg_common *common, struct fsg_config *cfg) { @@ -3049,9 +3023,7 @@ fail: _fsg_common_remove_luns(common, i); return rc; } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_create_luns); -#endif void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn, const char *pn) @@ -3068,9 +3040,7 @@ void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn, : File-Stor Gadget), i); } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_set_inquiry_string); -#endif int fsg_common_run_thread(struct fsg_common *common) { @@ -3089,66 +3059,7 @@ int fsg_common_run_thread(struct fsg_common *common) return 0; } -#ifndef USB_FMS_INCLUDED EXPORT_SYMBOL(fsg_common_run_thread); -#endif - -struct fsg_common *fsg_common_init(struct fsg_common *common, - struct usb_composite_dev *cdev, - struct fsg_config *cfg) -{ - int rc; - - common = fsg_common_setup(common, !!common); - if (IS_ERR(common)) - return common; - common-sysfs = true; - common-state = FSG_STATE_IDLE; - - rc =
[PATCH 3/4] usb: musb: conditionally restore and resume the context on resume
It appears not all platforms featuring a musb core need to save the musb core registers at suspend time and restore them on resume. The dsps platform does, however. So add a bit in struct musb_hdrc_platform_data to let platforms specify their need of such action being taken. Signed-off-by: Daniel Mack zon...@gmail.com --- drivers/usb/musb/musb_core.c | 17 - include/linux/usb/musb.h | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 2b9f4b4..f17604e 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -2152,6 +2152,7 @@ static int musb_suspend(struct device *dev) { struct musb *musb = dev_to_musb(dev); unsigned long flags; + struct musb_hdrc_platform_data *plat = dev_get_platdata(dev); spin_lock_irqsave(musb-lock, flags); @@ -2165,16 +2166,30 @@ static int musb_suspend(struct device *dev) */ } + if (plat-restore_after_suspend) + musb_save_context(musb); + spin_unlock_irqrestore(musb-lock, flags); return 0; } static int musb_resume_noirq(struct device *dev) { - /* for static cmos like DaVinci, register values were preserved + struct musb *musb = dev_to_musb(dev); + struct musb_hdrc_platform_data *plat = dev_get_platdata(dev); + + /* +* For static cmos like DaVinci, register values were preserved * unless for some reason the whole soc powered down or the USB * module got reset through the PSC (vs just being disabled). +* +* The plaform data tells us about the necessity of saving and +* restoring the context across a suspend cycle. */ + + if (plat-restore_after_suspend) + musb_restore_context(musb); + return 0; } diff --git a/include/linux/usb/musb.h b/include/linux/usb/musb.h index 053c268..296be6c 100644 --- a/include/linux/usb/musb.h +++ b/include/linux/usb/musb.h @@ -100,6 +100,7 @@ struct musb_hdrc_platform_data { u8 mode; u8 has_mailbox:1; + u8 restore_after_suspend:1; /* for clk_get() */ const char *clock; -- 1.8.3.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 1/4] usb: musb: move port reset to worker
musb_port_reset() sleeps, so we can't call it from atomic context. It is, however, called from places inside musb_hub_control() while musb-lock is held, which leads to a scheduling while atomic warning. Fix this by moving the logic into a worker, and call it where the function was previously called directly. Signed-off-by: Daniel Mack zon...@gmail.com --- drivers/usb/musb/musb_core.c| 7 +++ drivers/usb/musb/musb_core.h| 3 +++ drivers/usb/musb/musb_host.h| 2 ++ drivers/usb/musb/musb_virthub.c | 13 - 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 18e877f..2b9f4b4 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -1699,6 +1699,12 @@ static void musb_irq_work(struct work_struct *data) } } +static void musb_port_reset_work(struct work_struct *data) +{ + struct musb *musb = container_of(data, struct musb, port_reset_work); + musb_port_reset(musb); +} + /* -- * Init support */ @@ -1857,6 +1863,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) /* Init IRQ workqueue before request_irq */ INIT_WORK(musb-irq_work, musb_irq_work); + INIT_WORK(musb-port_reset_work, musb_port_reset_work); /* attach to the IRQ */ if (request_irq(nIrq, musb-isr, 0, dev_name(dev), musb)) { diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 65f3917..9529512 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -294,6 +294,9 @@ struct musb { irqreturn_t (*isr)(int, void *); struct work_struct irq_work; + struct work_struct port_reset_work; + boolport_reset_state; + u16 hwvers; u16 intrrxe; diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h index 960d735..843f48e 100644 --- a/drivers/usb/musb/musb_host.h +++ b/drivers/usb/musb/musb_host.h @@ -92,6 +92,7 @@ extern void musb_host_rx(struct musb *, u8); extern void musb_root_disconnect(struct musb *musb); extern void musb_host_resume_root_hub(struct musb *musb); extern void musb_host_poke_root_hub(struct musb *musb); +extern void musb_port_reset(struct musb *musb); #else static inline struct musb *hcd_to_musb(struct usb_hcd *hcd) { @@ -121,6 +122,7 @@ static inline void musb_root_disconnect(struct musb *musb) {} static inline void musb_host_resume_root_hub(struct musb *musb){} static inline void musb_host_poll_rh_status(struct musb *musb) {} static inline void musb_host_poke_root_hub(struct musb *musb) {} +static inline void musb_port_reset(struct musb *musb) {} #endif struct usb_hcd; diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c index a523950..30b43a1 100644 --- a/drivers/usb/musb/musb_virthub.c +++ b/drivers/usb/musb/musb_virthub.c @@ -155,7 +155,7 @@ static void musb_port_suspend(struct musb *musb, bool do_suspend) } } -static void musb_port_reset(struct musb *musb, bool do_reset) +void musb_port_reset(struct musb *musb) { u8 power; void __iomem*mbase = musb-mregs; @@ -173,7 +173,7 @@ static void musb_port_reset(struct musb *musb, bool do_reset) * the appropriate amount of time has passed */ power = musb_readb(mbase, MUSB_POWER); - if (do_reset) { + if (musb-port_reset_state) { /* * If RESUME is set, we must make sure it stays minimum 20 ms. @@ -356,8 +356,10 @@ int musb_hub_control( /* finish RESET signaling? */ if ((musb-port1_status USB_PORT_STAT_RESET) -time_after_eq(jiffies, musb-rh_timer)) - musb_port_reset(musb, false); +time_after_eq(jiffies, musb-rh_timer)) { + musb-port_reset_state = false; + schedule_work(musb-port_reset_work); + } /* finish RESUME signaling? */ if ((musb-port1_status MUSB_PORT_STAT_RESUME) @@ -412,7 +414,8 @@ int musb_hub_control( musb_start(musb); break; case USB_PORT_FEAT_RESET: - musb_port_reset(musb, true); + musb-port_reset_state = true; + schedule_work(musb-port_reset_work); break; case USB_PORT_FEAT_SUSPEND: musb_port_suspend(musb, true); -- 1.8.3.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 4/4] usb: musb: dsps: add support for suspend and resume
The dsps platform needs to save save some registers at suspend time and restore them after resume. This patch adds a struct for these registers, and also lets the musb core know that the core registers need to be saved as well. Signed-off-by: Daniel Mack zon...@gmail.com --- drivers/usb/musb/musb_dsps.c | 54 1 file changed, 54 insertions(+) diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 4047cbb..c93c365 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -110,6 +110,17 @@ struct dsps_musb_wrapper { u8 poll_seconds; }; +/* + * register shadow for suspend + */ +struct dsps_context { + u32 control; + u32 epintr; + u32 coreintr; + u32 phy_utmi; + u32 mode; +}; + /** * DSPS glue structure. */ @@ -119,6 +130,8 @@ struct dsps_glue { const struct dsps_musb_wrapper *wrp; /* wrapper register offsets */ struct timer_list timer;/* otg_workaround timer */ unsigned long last_timer;/* last timer data for each instance */ + + struct dsps_context context; }; /** @@ -502,6 +515,7 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue, } pdata.config = config; pdata.platform_ops = dsps_ops; + pdata.restore_after_suspend = 1; config-num_eps = get_int_prop(dn, mentor,num-eps); config-ram_bits = get_int_prop(dn, mentor,ram-bits); @@ -623,11 +637,51 @@ static const struct of_device_id musb_dsps_of_match[] = { }; MODULE_DEVICE_TABLE(of, musb_dsps_of_match); +#ifdef CONFIG_PM +static int dsps_suspend(struct device *dev) +{ + struct dsps_glue *glue = dev_get_drvdata(dev); + const struct dsps_musb_wrapper *wrp = glue-wrp; + struct musb *musb = platform_get_drvdata(glue-musb); + void __iomem *mbase = musb-ctrl_base; + + glue-context.control = dsps_readl(mbase, wrp-control); + glue-context.epintr = dsps_readl(mbase, wrp-epintr_set); + glue-context.coreintr = dsps_readl(mbase, wrp-coreintr_set); + glue-context.phy_utmi = dsps_readl(mbase, wrp-phy_utmi); + glue-context.mode = dsps_readl(mbase, wrp-mode); + + return 0; +} + +static int dsps_resume(struct device *dev) +{ + struct dsps_glue *glue = dev_get_drvdata(dev); + const struct dsps_musb_wrapper *wrp = glue-wrp; + struct musb *musb = platform_get_drvdata(glue-musb); + void __iomem *mbase = musb-ctrl_base; + + dsps_writel(mbase, wrp-control, glue-context.control); + dsps_writel(mbase, wrp-epintr_set, glue-context.epintr); + dsps_writel(mbase, wrp-coreintr_set, glue-context.coreintr); + dsps_writel(mbase, wrp-phy_utmi, glue-context.phy_utmi); + dsps_writel(mbase, wrp-mode, glue-context.mode); + + musb-port_reset_state = false; + schedule_work(musb-port_reset_work); + + return 0; +} +#endif + +static SIMPLE_DEV_PM_OPS(dsps_pm_ops, dsps_suspend, dsps_resume); + static struct platform_driver dsps_usbss_driver = { .probe = dsps_probe, .remove = dsps_remove, .driver = { .name = musb-dsps, + .pm = dsps_pm_ops, .of_match_table = of_match_ptr(musb_dsps_of_match), }, }; -- 1.8.3.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 0/4] usb: musb: support for suspend and resume
I've been working on some patches that allow suspending and resuming the musb-dsps platform. This was tested for host mode only. With these patches applied, I can successfully bring an AM335x board to suspend with a USB media connected, and access it again after resume. Note that this currently only works with CONFIG_MUSB_PIO_ONLY set. The cppi41 driver needs some more love to make this work. I'll work on that next. Thanks, Daniel Daniel Mack (4): usb: musb: move port reset to worker usb: musb: call musb_port_suspend from musb_bus_suspend usb: musb: conditionally restore and resume the context on resume usb: musb: dsps: add support for suspend and resume drivers/usb/musb/musb_core.c| 24 +- drivers/usb/musb/musb_core.h| 3 +++ drivers/usb/musb/musb_dsps.c| 54 + drivers/usb/musb/musb_host.c| 2 ++ drivers/usb/musb/musb_host.h| 4 +++ drivers/usb/musb/musb_virthub.c | 15 +++- include/linux/usb/musb.h| 1 + 7 files changed, 96 insertions(+), 7 deletions(-) -- 1.8.3.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 2/4] usb: musb: call musb_port_suspend from musb_bus_suspend
Make musb_port_suspend() externally available, and call it when to host goes into suspend. This allows the core to go into suspend while a device is connected. Signed-off-by: Daniel Mack zon...@gmail.com --- drivers/usb/musb/musb_host.c| 2 ++ drivers/usb/musb/musb_host.h| 2 ++ drivers/usb/musb/musb_virthub.c | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c index 9a2b8c8..2b60596 100644 --- a/drivers/usb/musb/musb_host.c +++ b/drivers/usb/musb/musb_host.c @@ -2433,6 +2433,8 @@ static int musb_bus_suspend(struct usb_hcd *hcd) struct musb *musb = hcd_to_musb(hcd); u8 devctl; + musb_port_suspend(musb, true); + if (!is_host_active(musb)) return 0; diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h index 843f48e..dcffea7 100644 --- a/drivers/usb/musb/musb_host.h +++ b/drivers/usb/musb/musb_host.h @@ -93,6 +93,7 @@ extern void musb_root_disconnect(struct musb *musb); extern void musb_host_resume_root_hub(struct musb *musb); extern void musb_host_poke_root_hub(struct musb *musb); extern void musb_port_reset(struct musb *musb); +extern void musb_port_suspend(struct musb *musb, bool do_suspend); #else static inline struct musb *hcd_to_musb(struct usb_hcd *hcd) { @@ -123,6 +124,7 @@ static inline void musb_host_resume_root_hub(struct musb *musb) {} static inline void musb_host_poll_rh_status(struct musb *musb) {} static inline void musb_host_poke_root_hub(struct musb *musb) {} static inline void musb_port_reset(struct musb *musb) {} +static inline void musb_port_suspend(struct musb *musb, bool do_suspend) {} #endif struct usb_hcd; diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c index 30b43a1..9f3a0f3 100644 --- a/drivers/usb/musb/musb_virthub.c +++ b/drivers/usb/musb/musb_virthub.c @@ -90,7 +90,7 @@ static void musb_start(struct musb *musb) musb_writeb(regs, MUSB_DEVCTL, devctl); } -static void musb_port_suspend(struct musb *musb, bool do_suspend) +void musb_port_suspend(struct musb *musb, bool do_suspend) { struct usb_otg *otg = musb-xceiv-otg; u8 power; -- 1.8.3.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: problematic device
In this logging I plugged-in the device and waited for it to disconnect and reconnect again. I googled but did not find something that translates this logging into human readable format. Are there any that you know of? No. But I can interpret it for you. thanks! Almost 7 seconds later, this shows the device disconnecting itself from the bus. There's no obvious reason. The rest of the trace is just the same thing repeated. Ok thank you. I contacted my contact at Cleware and he told me it is a workaround for windows 8. He's going to see if he can find a different solution. Thanks for your help! Folkert van Heusden -- MultiTail er et flexible tool for å kontrolere Logfiles og commandoer. Med filtrer, farger, sammenføringer, forskeliger ansikter etc. http://www.vanheusden.com/multitail/ -- Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com -- 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] net: qmi_wwan: fix Cinterion PLXX product ID
Aleksander Morgado aleksan...@lanedo.com writes: Cinterion PLXX LTE devices have a 0x0060 product ID, not 0x12d1. The blacklisting in the serial/option driver does actually use the correct PID, as per commit 8ff10bdb14a52e3f25d4ce09e0582a8684c1a6db ('USB: Blacklisted Cinterion's PLxx WWAN Interface'). Thanks for patching Acked-by: Christian Schmiedl christian.schmi...@gemalto.com Chris This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited. E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender. Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 10/27] mmc: vub300: Remove redundant suspend and resume callbacks
Suspend and resume of cards are handled by the protocol layer and consequently the mmc_suspend|resume_host APIs are marked as deprecated. While moving away from using the deprecated APIs, there are nothing left to be done for the suspend and resume callbacks, so remove them. Cc: Tony Olech tony.ol...@elandigitalsystems.com Cc: linux-usb@vger.kernel.org Signed-off-by: Ulf Hansson ulf.hans...@linaro.org --- drivers/mmc/host/vub300.c | 30 -- 1 file changed, 30 deletions(-) diff --git a/drivers/mmc/host/vub300.c b/drivers/mmc/host/vub300.c index e9028ad..db99edc 100644 --- a/drivers/mmc/host/vub300.c +++ b/drivers/mmc/host/vub300.c @@ -2389,34 +2389,6 @@ static void vub300_disconnect(struct usb_interface *interface) } } -#ifdef CONFIG_PM -static int vub300_suspend(struct usb_interface *intf, pm_message_t message) -{ - struct vub300_mmc_host *vub300 = usb_get_intfdata(intf); - if (!vub300 || !vub300-mmc) { - return 0; - } else { - struct mmc_host *mmc = vub300-mmc; - mmc_suspend_host(mmc); - return 0; - } -} - -static int vub300_resume(struct usb_interface *intf) -{ - struct vub300_mmc_host *vub300 = usb_get_intfdata(intf); - if (!vub300 || !vub300-mmc) { - return 0; - } else { - struct mmc_host *mmc = vub300-mmc; - mmc_resume_host(mmc); - return 0; - } -} -#else -#define vub300_suspend NULL -#define vub300_resume NULL -#endif static int vub300_pre_reset(struct usb_interface *intf) { /* NOT irq */ struct vub300_mmc_host *vub300 = usb_get_intfdata(intf); @@ -2437,8 +2409,6 @@ static struct usb_driver vub300_driver = { .name = vub300, .probe = vub300_probe, .disconnect = vub300_disconnect, - .suspend = vub300_suspend, - .resume = vub300_resume, .pre_reset = vub300_pre_reset, .post_reset = vub300_post_reset, .id_table = vub300_table, -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-usb in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/2] usb: wusbcore: rename data fields
Hi, This set of patches renames various data fields in wa_seg and wahc to more clearly specify their purpose. I plan to add isochronous support to wusbcore soon and these changes will make that patch easier to comprehend. Thomas Pugliese (2): usb: wusbcore: rename urb to tr_urb in struct wa_seg usb: wusbcore: rename xfer_result to dti_buf and xfer_result_size to dti_buf_size in struct wahc. drivers/usb/wusbcore/wa-hc.c | 14 ++-- drivers/usb/wusbcore/wa-hc.h |4 ++-- drivers/usb/wusbcore/wa-xfer.c | 48 +--- 3 files changed, 34 insertions(+), 32 deletions(-) -- 1.7.10.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 1/2] usb: wusbcore: rename urb to tr_urb in struct wa_seg
Rename urb to tr_urb in struct wa_seg to make it clear that the urb is used for the transfer request. Signed-off-by: Thomas Pugliese thomas.pugli...@gmail.com --- drivers/usb/wusbcore/wa-xfer.c | 30 -- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c index 6ad02f5..3718847 100644 --- a/drivers/usb/wusbcore/wa-xfer.c +++ b/drivers/usb/wusbcore/wa-xfer.c @@ -114,8 +114,8 @@ static void wa_xfer_delayed_run(struct wa_rpipe *); * struct). */ struct wa_seg { - struct urb urb; - struct urb *dto_urb;/* for data output? */ + struct urb tr_urb; /* transfer request urb. */ + struct urb *dto_urb;/* for data output. */ struct list_head list_node; /* for rpipe-req_list */ struct wa_xfer *xfer; /* out xfer */ u8 index; /* which segment we are */ @@ -127,11 +127,11 @@ struct wa_seg { static inline void wa_seg_init(struct wa_seg *seg) { - usb_init_urb(seg-urb); + usb_init_urb(seg-tr_urb); /* set the remaining memory to 0. */ - memset(((void *)seg) + sizeof(seg-urb), 0, - sizeof(*seg) - sizeof(seg-urb)); + memset(((void *)seg) + sizeof(seg-tr_urb), 0, + sizeof(*seg) - sizeof(seg-tr_urb)); } /* @@ -179,7 +179,7 @@ static void wa_xfer_destroy(struct kref *_xfer) unsigned cnt; for (cnt = 0; cnt xfer-segs; cnt++) { usb_free_urb(xfer-seg[cnt]-dto_urb); - usb_free_urb(xfer-seg[cnt]-urb); + usb_free_urb(xfer-seg[cnt]-tr_urb); } } kfree(xfer); @@ -494,12 +494,12 @@ static void __wa_xfer_setup_hdr0(struct wa_xfer *xfer, /* * Callback for the OUT data phase of the segment request * - * Check wa_seg_cb(); most comments also apply here because this + * Check wa_seg_tr_cb(); most comments also apply here because this * function does almost the same thing and they work closely * together. * * If the seg request has failed but this DTO phase has succeeded, - * wa_seg_cb() has already failed the segment and moved the + * wa_seg_tr_cb() has already failed the segment and moved the * status to WA_SEG_ERROR, so this will go through 'case 0' and * effectively do nothing. */ @@ -576,7 +576,7 @@ static void wa_seg_dto_cb(struct urb *urb) * as in that case, wa_seg_dto_cb will do it when the OUT data phase * finishes. */ -static void wa_seg_cb(struct urb *urb) +static void wa_seg_tr_cb(struct urb *urb) { struct wa_seg *seg = urb-context; struct wa_xfer *xfer = seg-xfer; @@ -740,11 +740,11 @@ static int __wa_xfer_setup_segs(struct wa_xfer *xfer, size_t xfer_hdr_size) wa_seg_init(seg); seg-xfer = xfer; seg-index = cnt; - usb_fill_bulk_urb(seg-urb, usb_dev, + usb_fill_bulk_urb(seg-tr_urb, usb_dev, usb_sndbulkpipe(usb_dev, dto_epd-bEndpointAddress), seg-xfer_hdr, xfer_hdr_size, - wa_seg_cb, seg); + wa_seg_tr_cb, seg); buf_itr_size = min(buf_size, xfer-seg_size); if (xfer-is_inbound == 0 buf_size 0) { /* outbound data. */ @@ -888,12 +888,14 @@ static int __wa_seg_submit(struct wa_rpipe *rpipe, struct wa_xfer *xfer, struct wa_seg *seg) { int result; - result = usb_submit_urb(seg-urb, GFP_ATOMIC); + /* submit the transfer request. */ + result = usb_submit_urb(seg-tr_urb, GFP_ATOMIC); if (result 0) { printk(KERN_ERR xfer %p#%u: REQ submit failed: %d\n, xfer, seg-index, result); goto error_seg_submit; } + /* submit the out data if this is an out request. */ if (seg-dto_urb) { result = usb_submit_urb(seg-dto_urb, GFP_ATOMIC); if (result 0) { @@ -907,7 +909,7 @@ static int __wa_seg_submit(struct wa_rpipe *rpipe, struct wa_xfer *xfer, return 0; error_dto_submit: - usb_unlink_urb(seg-urb); + usb_unlink_urb(seg-tr_urb); error_seg_submit: seg-status = WA_SEG_ERROR; seg-result = result; @@ -1313,7 +1315,7 @@ int wa_urb_dequeue(struct wahc *wa, struct urb *urb) break; case WA_SEG_SUBMITTED: seg-status = WA_SEG_ABORTED; - usb_unlink_urb(seg-urb); + usb_unlink_urb(seg-tr_urb); if (xfer-is_inbound == 0) usb_unlink_urb(seg-dto_urb); xfer-segs_done++; -- 1.7.10.4 -- To unsubscribe
[PATCH 2/2] usb: wusbcore: rename fields in struct wahc
Rename xfer_result to dti_buf and xfer_result_size to dti_buf_size in struct wahc. The dti buffer will also be used for isochronous status packets once isochronous transfers are supported. Signed-off-by: Thomas Pugliese thomas.pugli...@gmail.com --- drivers/usb/wusbcore/wa-hc.c | 14 +++--- drivers/usb/wusbcore/wa-hc.h |4 ++-- drivers/usb/wusbcore/wa-xfer.c | 18 +- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/usb/wusbcore/wa-hc.c b/drivers/usb/wusbcore/wa-hc.c index a09b65e..6c09b0e 100644 --- a/drivers/usb/wusbcore/wa-hc.c +++ b/drivers/usb/wusbcore/wa-hc.c @@ -44,11 +44,11 @@ int wa_create(struct wahc *wa, struct usb_interface *iface) /* Fill up Data Transfer EP pointers */ wa-dti_epd = iface-cur_altsetting-endpoint[1].desc; wa-dto_epd = iface-cur_altsetting-endpoint[2].desc; - wa-xfer_result_size = usb_endpoint_maxp(wa-dti_epd); - wa-xfer_result = kmalloc(wa-xfer_result_size, GFP_KERNEL); - if (wa-xfer_result == NULL) { + wa-dti_buf_size = usb_endpoint_maxp(wa-dti_epd); + wa-dti_buf = kmalloc(wa-dti_buf_size, GFP_KERNEL); + if (wa-dti_buf == NULL) { result = -ENOMEM; - goto error_xfer_result_alloc; + goto error_dti_buf_alloc; } result = wa_nep_create(wa, iface); if (result 0) { @@ -59,8 +59,8 @@ int wa_create(struct wahc *wa, struct usb_interface *iface) return 0; error_nep_create: - kfree(wa-xfer_result); -error_xfer_result_alloc: + kfree(wa-dti_buf); +error_dti_buf_alloc: wa_rpipes_destroy(wa); error_rpipes_create: return result; @@ -76,7 +76,7 @@ void __wa_destroy(struct wahc *wa) usb_kill_urb(wa-buf_in_urb); usb_put_urb(wa-buf_in_urb); } - kfree(wa-xfer_result); + kfree(wa-dti_buf); wa_nep_destroy(wa); wa_rpipes_destroy(wa); } diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h index cf250c2..ab39934 100644 --- a/drivers/usb/wusbcore/wa-hc.h +++ b/drivers/usb/wusbcore/wa-hc.h @@ -184,8 +184,8 @@ struct wahc { struct urb *dti_urb;/* URB for reading xfer results */ struct urb *buf_in_urb; /* URB for reading data in */ struct edc dti_edc; /* DTI error density counter */ - struct wa_xfer_result *xfer_result; /* real size = dti_ep maxpktsize */ - size_t xfer_result_size; + void *dti_buf; + size_t dti_buf_size; s32 status; /* For reading status */ diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c index 3718847..11d684c 100644 --- a/drivers/usb/wusbcore/wa-xfer.c +++ b/drivers/usb/wusbcore/wa-xfer.c @@ -1418,7 +1418,8 @@ static int wa_xfer_status_to_errno(u8 status) * * FIXME: this function needs to be broken up in parts */ -static void wa_xfer_result_chew(struct wahc *wa, struct wa_xfer *xfer) +static void wa_xfer_result_chew(struct wahc *wa, struct wa_xfer *xfer, + struct wa_xfer_result *xfer_result) { int result; struct device *dev = wa-usb_iface-dev; @@ -1426,8 +1427,7 @@ static void wa_xfer_result_chew(struct wahc *wa, struct wa_xfer *xfer) u8 seg_idx; struct wa_seg *seg; struct wa_rpipe *rpipe; - struct wa_xfer_result *xfer_result = wa-xfer_result; - u8 done = 0; + unsigned done = 0; u8 usb_status; unsigned rpipe_ready = 0; @@ -1689,7 +1689,7 @@ static void wa_buf_in_cb(struct urb *urb) * We go back to OFF when we detect a ENOENT or ESHUTDOWN (or too many * errors) in the URBs. */ -static void wa_xfer_result_cb(struct urb *urb) +static void wa_dti_cb(struct urb *urb) { int result; struct wahc *wa = urb-context; @@ -1711,7 +1711,7 @@ static void wa_xfer_result_cb(struct urb *urb) urb-actual_length, sizeof(*xfer_result)); break; } - xfer_result = wa-xfer_result; + xfer_result = (struct wa_xfer_result *)(wa-dti_buf); if (xfer_result-hdr.bLength != sizeof(*xfer_result)) { dev_err(dev, DTI Error: xfer result-- bad header length %u\n, @@ -1737,7 +1737,7 @@ static void wa_xfer_result_cb(struct urb *urb) xfer_id, usb_status); break; } - wa_xfer_result_chew(wa, xfer); + wa_xfer_result_chew(wa, xfer, xfer_result); wa_xfer_put(xfer); break; case -ENOENT: /* (we killed the URB)...so, no broadcast */ @@ -1779,7 +1779,7 @@ out: * don't really set it up and start it until the first xfer complete * notification arrives, which is what we do here. * - * Follow up in wa_xfer_result_cb(), as that's where the whole
Re: [help] imx27 - isp1504 : unable to init transceiver, probably missing
Hi, Le Thu, 26 Sep 2013 17:59:39 +0200, Christoph Fritz chf.fr...@googlemail.com a écrit : On Wed, 2013-09-25 at 16:00 +0200, Eric Bénard wrote: Le Wed, 25 Sep 2013 12:17:40 +0200, Christoph Fritz chf.fr...@googlemail.com a écrit : On Tue, 2013-04-09 at 14:28 -0300, Fabio Estevam wrote: On Mon, Apr 8, 2013 at 9:09 PM, Fabio Estevam feste...@gmail.com wrote: I know that I have to use the driver ULPI but with my configuration, I get these errors : ehci-mxc: Freescale On-Chip EHCI Host driver mxc-ehci mxc-ehci.0: initializing i.MX USB Controller timeout polling for ULPI device mxc-ehci mxc-ehci.0: unable to init transceiver, probably missing Just tested mx31pdk on a 3.8.6 kernel and I got: ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver ehci-mxc: Freescale On-Chip EHCI Host driver mxc-ehci mxc-ehci.0: initializing i.MX USB Controller ULPI transceiver vendor/product ID 0x04cc/0x1504 Found NXP ISP1504 ULPI transceiver. ULPI integrity check: passed. mxc-ehci mxc-ehci.0: EHCI Host Controller mxc-ehci mxc-ehci.0: new USB bus registered, assigned bus number 1 mxc-ehci mxc-ehci.0: irq 53, io mem 0x43f88000 mxc-ehci mxc-ehci.0: USB 2.0 started, EHCI 1.00 hub 1-0:1.0: USB hub found hub 1-0:1.0: 1 port detected mxc-ehci mxc-ehci.2: initializing i.MX USB Controller timeout polling for ULPI device mxc-ehci mxc-ehci.2: unable to init transceiver, probably missing Any updates on this? I'm facing the same kind of issue with an SMSC3340 phy connected to an imx.27: After some minutes in power-off state, the first boot fails to detect the ULPI device connected to USBOTG-Pins, no matter if host- or device-mode is configured. But the strange thing is that then, after a reboot or reset the phy gets detected. are you sure some pins on the ULPI interface don't change their level between the time where you release the PHY's reset and when the ULPI access occurs ? I'm pretty sure that there are, but not intended by software I could control (bootloader+kernel). from memory we had this problem with ISP1504 a few years ago and this only real fix was to switch to an other PHY with a reset to unlock it when bad things happen. Eric -- 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 2/2] USB: unexport usb_bus_list_lock and update comments
On Fri, Sep 13, 2013 at 01:57:42PM -0600, Bjorn Helgaas wrote: usb_bus_list_lock is used by usbfs, but that's in the same module as hcd.c, so there's no need to export it. Update the comment to show that it protects the set of root hubs as well as the list of buses. usbmon also uses this, so this patch breaks the build: ERROR: usb_bus_list_lock [drivers/usb/mon/usbmon.ko] undefined! So I can't take this patch, sorry. 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 V5 1/9] USB: OHCI: make ohci-exynos a separate driver
On Sat, Sep 21, 2013 at 04:38:38PM +0530, Manjunath Goudar wrote: Separate the Samsung OHCI EXYNOS host controller driver from ohci-hcd host code so that it can be built as a separate driver module. This work is part of enabling multi-platform kernels on ARM. Signed-off-by: Manjunath Goudar manjunath.gou...@linaro.org Signed-off-by: Deepak Saxena dsax...@linaro.org Acked-by: Alan Stern st...@rowland.harvard.edu Acked-by: Jingoo Han jg1@samsung.com Cc: Vivek Gautam gautam.vi...@samsung.com Cc: Arnd Bergmann a...@arndb.de Cc: Kukjin Kim kgene@samsung.com Cc: Greg KH g...@kroah.com Cc: linux-usb@vger.kernel.org V2-V3: -No major changes only exynos written in capital letters in OHCI exynos driver. V1-V2: -exynos_ohci_hcd structure assignment error fixed. -Removed multiple usb_create_hcd() from prob funtion. -platform_set_drvdata() called before exynos_ohci_phy_enable(). -ohci_setup() removed because it is called in .reset member of the ohci_hc_driver structure --- In the future, these version lines need to go below the cut (---), not above it, as I need to edit these patches by hand to remove them now :( 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 v2 2/2] USB: unexport usb_bus_list_lock and update comments
On Thu, Sep 26, 2013 at 10:45 AM, Greg Kroah-Hartman gre...@linuxfoundation.org wrote: On Fri, Sep 13, 2013 at 01:57:42PM -0600, Bjorn Helgaas wrote: usb_bus_list_lock is used by usbfs, but that's in the same module as hcd.c, so there's no need to export it. Update the comment to show that it protects the set of root hubs as well as the list of buses. usbmon also uses this, so this patch breaks the build: ERROR: usb_bus_list_lock [drivers/usb/mon/usbmon.ko] undefined! Oops, sorry, I should have noticed that, sorry. Bjorn -- 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 v11 2/8] usb: phy: omap-usb2: use the new generic PHY framework
On Wed, Aug 21, 2013 at 11:16:07AM +0530, Kishon Vijay Abraham I wrote: Used the generic PHY framework API to create the PHY. Now the power off and power on are done in omap_usb_power_off and omap_usb_power_on respectively. The omap-usb2 driver is also moved to driver/phy. However using the old USB PHY library cannot be completely removed because OTG is intertwined with PHY and moving to the new framework will break OTG. Once we have a separate OTG state machine, we can get rid of the USB PHY library. Signed-off-by: Kishon Vijay Abraham I kis...@ti.com Reviewed-by: Sylwester Nawrocki s.nawro...@samsung.com Acked-by: Felipe Balbi ba...@ti.com --- drivers/phy/Kconfig | 12 + drivers/phy/Makefile |1 + drivers/{usb = }/phy/phy-omap-usb2.c | 45 ++--- drivers/usb/phy/Kconfig | 10 drivers/usb/phy/Makefile |1 - 5 files changed, 54 insertions(+), 15 deletions(-) rename drivers/{usb = }/phy/phy-omap-usb2.c (88%) I tried to apply this to my USB branch, but it fails. Kishon, you were going to refresh this patch series, right? Please do, because as-is, I can't take it. 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 0/4] usb: wusbcore: resource cleanup fixes
This set of patches fixes a few cases where objects were being incompletely cleaned up by error handlers which could cause double free conditions or NULL dereferences in those cases. There is also a memory leak fix for out transfers on the HWA. These should be applied after the struct field rename patches I sent earlier since this set references some of those renamed objects. Thomas Pugliese (4): usb: wusbcore: allow wa_xfer_destroy to clean up partially constructed xfers usb: wusbcore: resource cleanup fix in __wa_xfer_setup_segs usb: wusbcore: clean up the sg list that was created for out transfers usb: wusbcore: set pointers to NULL after freeing in error cases drivers/usb/wusbcore/wa-xfer.c | 137 1 file changed, 81 insertions(+), 56 deletions(-) -- 1.7.10.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 1/4] usb: wusbcore: allow wa_xfer_destroy to clean up partially constructed xfers
If __wa_xfer_setup fails, it can leave a partially constructed wa_xfer object. The error handling code eventually calls wa_xfer_destroy which does not check for NULL before dereferencing xfer-seg which could cause a kernel panic. This change also makes sure to free xfer-seg which was being leaked for all transfers before this change. Signed-off-by: Thomas Pugliese thomas.pugli...@gmail.com --- drivers/usb/wusbcore/wa-xfer.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c index 11d684c..dfb11bf 100644 --- a/drivers/usb/wusbcore/wa-xfer.c +++ b/drivers/usb/wusbcore/wa-xfer.c @@ -178,9 +178,15 @@ static void wa_xfer_destroy(struct kref *_xfer) if (xfer-seg) { unsigned cnt; for (cnt = 0; cnt xfer-segs; cnt++) { - usb_free_urb(xfer-seg[cnt]-dto_urb); - usb_free_urb(xfer-seg[cnt]-tr_urb); + if (xfer-seg[cnt]) { + if (xfer-seg[cnt]-dto_urb) { + kfree(xfer-seg[cnt]-dto_urb-sg); + usb_free_urb(xfer-seg[cnt]-dto_urb); + } + usb_free_urb(xfer-seg[cnt]-tr_urb); + } } + kfree(xfer-seg); } kfree(xfer); } -- 1.7.10.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 4/4] usb: wusbcore: set pointers to NULL after freeing in error cases
This patch fixes two cases where error handling code was freeing memory but not setting the pointer to NULL. This could lead to a double free in the HWA shutdown code. Signed-off-by: Thomas Pugliese thomas.pugli...@gmail.com --- drivers/usb/wusbcore/wa-xfer.c |2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c index 78b7ae0..08bf21d 100644 --- a/drivers/usb/wusbcore/wa-xfer.c +++ b/drivers/usb/wusbcore/wa-xfer.c @@ -1560,6 +1560,7 @@ error_submit_buf_in: xfer, seg_idx, result); seg-result = result; kfree(wa-buf_in_urb-sg); + wa-buf_in_urb-sg = NULL; error_sg_alloc: __wa_xfer_abort(xfer); error_complete: @@ -1861,6 +1862,7 @@ out: error_dti_urb_submit: usb_put_urb(wa-buf_in_urb); + wa-buf_in_urb = NULL; error_buf_in_urb_alloc: usb_put_urb(wa-dti_urb); wa-dti_urb = NULL; -- 1.7.10.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 3/4] usb: wusbcore: clean up the sg list that was created for out transfers
Clean up the SG list after transfer completetion for out transfers if one was created by the HWA. Signed-off-by: Thomas Pugliese thomas.pugli...@gmail.com --- drivers/usb/wusbcore/wa-xfer.c |4 1 file changed, 4 insertions(+) diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c index 4531752..78b7ae0 100644 --- a/drivers/usb/wusbcore/wa-xfer.c +++ b/drivers/usb/wusbcore/wa-xfer.c @@ -520,6 +520,10 @@ static void wa_seg_dto_cb(struct urb *urb) unsigned rpipe_ready = 0; u8 done = 0; + /* free the sg if it was used. */ + kfree(urb-sg); + urb-sg = NULL; + switch (urb-status) { case 0: spin_lock_irqsave(xfer-lock, flags); -- 1.7.10.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] usb: dwc3: add support for Merrifield
Add PCI id for Intel Merrifield Signed-off-by: David Cohen david.a.co...@linux.intel.com --- drivers/usb/dwc3/dwc3-pci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c index 997ebe4..2e252aa 100644 --- a/drivers/usb/dwc3/dwc3-pci.c +++ b/drivers/usb/dwc3/dwc3-pci.c @@ -29,6 +29,7 @@ #define PCI_VENDOR_ID_SYNOPSYS 0x16c3 #define PCI_DEVICE_ID_SYNOPSYS_HAPSUSB30xabcd #define PCI_DEVICE_ID_INTEL_BYT0x0f37 +#define PCI_DEVICE_ID_INTEL_MRFLD 0x119e struct dwc3_pci { struct device *dev; @@ -189,6 +190,7 @@ static DEFINE_PCI_DEVICE_TABLE(dwc3_pci_id_table) = { PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3), }, { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BYT), }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MRFLD), }, { }/* Terminating Entry */ }; MODULE_DEVICE_TABLE(pci, dwc3_pci_id_table); -- 1.8.4.rc3 -- 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: dwc3: add support for Merrifield
On Thu, Sep 26, 2013 at 01:01:44PM -0700, David Cohen wrote: Add PCI id for Intel Merrifield Signed-off-by: David Cohen david.a.co...@linux.intel.com --- drivers/usb/dwc3/dwc3-pci.c | 2 ++ 1 file changed, 2 insertions(+) Nice, Felipe, mind if I just pick this up now, as I'm applying USB patches at the moment... David, this should go to older kernels as well, right? 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 00/51] DMA mask changes
2013/9/19 Russell King - ARM Linux li...@arm.linux.org.uk: This email is only being sent to the mailing lists in question, not to anyone personally. The list of individuals is far to great to do that. I'm hoping no mailing lists reject the patches based on the number of recipients. Huh, I think it was enough to send only 3 patches to the b43-dev@. Like: [PATCH 01/51] DMA-API: provide a helper to set both DMA and coherent DMA masks [PATCH 14/51] DMA-API: net: b43: (...) [PATCH 15/51] DMA-API: net: b43legacy: (...) ;) I believe Joe has some nice script for doing it that way. When fixing some coding style / formatting, he sends only related patches to the given ML. -- 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] usb: dwc3: add support for Merrifield
Hi Greg, On 09/26/2013 01:14 PM, Greg KH wrote: On Thu, Sep 26, 2013 at 01:01:44PM -0700, David Cohen wrote: Add PCI id for Intel Merrifield Signed-off-by: David Cohen david.a.co...@linux.intel.com --- drivers/usb/dwc3/dwc3-pci.c | 2 ++ 1 file changed, 2 insertions(+) Nice, Felipe, mind if I just pick this up now, as I'm applying USB patches at the moment... David, this should go to older kernels as well, right? This was first tested on kernel 3.10. So I can't ack any older kernel at this moment. Br, David Cohen 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: dwc3: add support for Merrifield
On Thu, Sep 26, 2013 at 01:39:04PM -0700, David Cohen wrote: Hi Greg, On 09/26/2013 01:14 PM, Greg KH wrote: On Thu, Sep 26, 2013 at 01:01:44PM -0700, David Cohen wrote: Add PCI id for Intel Merrifield Signed-off-by: David Cohen david.a.co...@linux.intel.com --- drivers/usb/dwc3/dwc3-pci.c | 2 ++ 1 file changed, 2 insertions(+) Nice, Felipe, mind if I just pick this up now, as I'm applying USB patches at the moment... David, this should go to older kernels as well, right? This was first tested on kernel 3.10. So I can't ack any older kernel at this moment. 3.10+ is good enough for me, that's all that really has dwc3 support anyway that I care about :) 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 v2 2/2] USB: unexport usb_bus_list_lock and update comments
On Thu, 26 Sep 2013, Bjorn Helgaas wrote: On Thu, Sep 26, 2013 at 10:45 AM, Greg Kroah-Hartman gre...@linuxfoundation.org wrote: On Fri, Sep 13, 2013 at 01:57:42PM -0600, Bjorn Helgaas wrote: usb_bus_list_lock is used by usbfs, but that's in the same module as hcd.c, so there's no need to export it. Update the comment to show that it protects the set of root hubs as well as the list of buses. usbmon also uses this, so this patch breaks the build: ERROR: usb_bus_list_lock [drivers/usb/mon/usbmon.ko] undefined! Oops, sorry, I should have noticed that, sorry. Me too. :-( I guess the comment in the definition needs to be changed. It should say that usb_bus_list_lock is exported for usbmon, not usbfs. 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 0/2] USB 2.0 Link PM is broken
That behavior was seen on the Synopsys host, not the Intel host, correct? Yes. Looks like the L1 transitions that are not fatal on the Intel host are much longer in my trace, usually above 100ms. This would be another indication that in the Synopsys case the L1 resume is host-triggered. Ok. Mathias has a patch to enable it for internal devices and BESL devices. I'll send out the updated patchset shortly. Can you run lsusb on your Intel system, and see if the webcam supports Link PM? If so, it would be great if you could add the patches, disable auto-suspend, and double check that the latest version of lsusb shows that the device goes into L1. I don't have access to a system today or tomorrow, but I can check next week if necessary. Unfortunately, none of the internal devices on our current Haswell system support LPM. Our firmware also doesn't set the right ACPI table entries to mark ports as removable. I think the easiest way to verify your patch would be a small kernel hack that would force an inserted device to look non-removable. -- 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
rndis_host: rndis device enumeration
Hi, Sorry if I missed any previous discussion on this topic. The msdn link [1] says that The host does not continuously poll the USB Control endpoint for input control messages. Upon placing a control message on its Control endpoint, the device must return a notification on the Communication Class interface's Interrupt IN endpoint, which is polled by the host whenever the device can return control messages. Which means the following transfer sequence from the host: - SETUP xfer: SET_ENCAPSULATED_COMMAND - INT xfer - SETUP xfer: GET_ENCAPSULATED_RESPONSE But in rndis_command() in rndis_host.c, the INT xfer between SET_ENCAPSULATED_COMMAND and GET_ENCAPSULATED_RESPONSE has a if condition check, so the INT xfer is not sent for some (most) rndis devices. Is there any reason why the INT xfer has this if condition? Thanks, -Bin. [1]: http://msdn.microsoft.com/en-us/library/aa447434.aspx -- 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 31/51] DMA-API: media: omap3isp: use dma_coerce_mask_and_coherent()
Hi Russell, Thank you for the patch. On Thursday 19 September 2013 22:56:02 Russell King wrote: The code sequence: isp-raw_dmamask = DMA_BIT_MASK(32); isp-dev-dma_mask = isp-raw_dmamask; isp-dev-coherent_dma_mask = DMA_BIT_MASK(32); bypasses the architectures check on the DMA mask. It can be replaced with dma_coerce_mask_and_coherent(), avoiding the direct initialization of this mask. Signed-off-by: Russell King rmk+ker...@arm.linux.org.uk Acked-by: Laurent Pinchart laurent.pinch...@ideasonboard.com --- drivers/media/platform/omap3isp/isp.c |6 +++--- drivers/media/platform/omap3isp/isp.h |3 --- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c index df3a0ec..1c36080 100644 --- a/drivers/media/platform/omap3isp/isp.c +++ b/drivers/media/platform/omap3isp/isp.c @@ -2182,9 +2182,9 @@ static int isp_probe(struct platform_device *pdev) isp-pdata = pdata; isp-ref_count = 0; - isp-raw_dmamask = DMA_BIT_MASK(32); - isp-dev-dma_mask = isp-raw_dmamask; - isp-dev-coherent_dma_mask = DMA_BIT_MASK(32); + ret = dma_coerce_mask_and_coherent(isp-dev, DMA_BIT_MASK(32)); + if (ret) + return ret; platform_set_drvdata(pdev, isp); diff --git a/drivers/media/platform/omap3isp/isp.h b/drivers/media/platform/omap3isp/isp.h index cd3eff4..ce65d3a 100644 --- a/drivers/media/platform/omap3isp/isp.h +++ b/drivers/media/platform/omap3isp/isp.h @@ -152,7 +152,6 @@ struct isp_xclk { * @mmio_base_phys: Array with physical L4 bus addresses for ISP register * regions. * @mmio_size: Array with ISP register regions size in bytes. - * @raw_dmamask: Raw DMA mask * @stat_lock: Spinlock for handling statistics * @isp_mutex: Mutex for serializing requests to ISP. * @crashed: Bitmask of crashed entities (indexed by entity ID) @@ -190,8 +189,6 @@ struct isp_device { unsigned long mmio_base_phys[OMAP3_ISP_IOMEM_LAST]; resource_size_t mmio_size[OMAP3_ISP_IOMEM_LAST]; - u64 raw_dmamask; - /* ISP Obj */ spinlock_t stat_lock; /* common lock for statistic drivers */ struct mutex isp_mutex; /* For handling ref_count field */ -- Regards, Laurent Pinchart -- 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