summaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget
Commit message (Collapse)AuthorAgeFilesLines
...
* | | usb: gadget: composite: add reset API at usb_gadget_driverPeter Chen2014-09-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Add reset API at usb_gadget_driver, it calls disconnect handler currently, but may do different things in future. Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | | usb: gadget: f_fs: signedness bug in __ffs_func_bind_do_descs()Dan Carpenter2014-09-091-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | We need "idx" to be signed for the error handling to work. Fixes: 6d5c1c77bbf9 ('usb: gadget: f_fs: fix the redundant ep files problem') Acked-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | | usb: gadget: f_uvc: use usb_gstrings_attachAndrzej Pietrasiewicz2014-09-091-17/+11Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Attach strings to gadget with usb_strings_attach. It is required for correct instantiation of functions more than once: instead of modifying the local uvc_en_us_strings a function instance specific copy is created with usb_gstrings_attach. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Tested-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | | usb: gadget: f_uvc: remove compatibility layerAndrzej Pietrasiewicz2014-09-092-177/+0Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | There are no users of the old interface left. Remove it. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Tested-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | | usb: gadget: webcam: convert webcam to new interface of f_uvcAndrzej Pietrasiewicz2014-09-093-16/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | Use the new function interface of f_uvc. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Tested-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | | usb: gadget: f_uvc: convert f_uvc to new function interfaceAndrzej Pietrasiewicz2014-09-095-30/+219
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use the new function registration interface. It is required in order to integrate configfs support. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Tested-by: Michael Grzeschik <m.grzeschik@pengutronix.de> [Updated copyright years] Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | | usb: gadget: uvc: separately compile some components of f_uvcAndrzej Pietrasiewicz2014-09-0911-36/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Compile uvc_queue, uvc_v4l2, uvc_video separately so that later they can be all combined in a separately compiled f_uvc. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Tested-by: Michael Grzeschik <m.grzeschik@pengutronix.de> [Make uvc_v4l2_ioctl_ops non-static] [Rename __UVC__V4L2__H__ and __UVC__VIDEO__H__] [Update MAINTAINERS] Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | | usb: gadget: uvc: rename functions to avoid conflicts with host uvcAndrzej Pietrasiewicz2014-09-094-55/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prepare for separate compilation of uvc function's components. Some symbols will have to be exported, so rename to avoid conflicts with functions of the same name in host uvc. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Tested-by: Michael Grzeschik <m.grzeschik@pengutronix.de> [Rename uvc_video_pump and uvc_queue_head as well] [Rename forgotten uvc_queue_cancel instance in a comment] Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | | usb: gadget: zero: Fix warning generated by kbuildAmit Virdi2014-09-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The kbuild test bot generated the warning: drivers/usb/gadget/function/f_sourcesink.c:1498: warning: comparison is always false due to limited range of data type This patch fixes it. Reported-by: kbuild test robot <fengguang.wu@intel.com> Signed-off-by: Amit Virdi <amit.virdi@st.com> CC: Felipe Balbi <balbi@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | | Merge tag 'v3.17-rc4' into nextFelipe Balbi2014-09-089-13/+36
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Merge Linux 3.17-rc4 here so we have all the latest fixes on next too. This also cleans up a few conflicts when applying patches. Signed-off-by: Felipe Balbi <balbi@ti.com> Conflicts: drivers/usb/gadget/Makefile drivers/usb/gadget/function/Makefile drivers/usb/gadget/legacy/Makefile drivers/usb/phy/phy-samsung-usb.h
| * | usb: gadget: remove $(PWD) in ccflags-yPhilippe Reynes2014-08-203-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The variable $(PWD) is useless, and it may break the compilation. For example, it breaks the kernel compilation when it's done with buildroot : /home/trem/Codes/armadeus/armadeus/buildroot/output/host/usr/bin/ccache /home/trem/Codes/armadeus/armadeus/buildroot/output/host/usr/bin/arm-buildroot-linux-uclibcgnueabi-gcc -Wp,-MD,drivers/usb/gadget/legacy/.hid.o.d -nostdinc -isystem /home/trem/Codes/armadeus/armadeus/buildroot/output/host/usr/lib/gcc/arm-buildroot-linux-uclibcgnueabi/4.7.3/include -I./arch/arm/include -Iarch/arm/include/generated -Iinclude -I./arch/arm/include/uapi -Iarch/arm/include/generated/uapi -I./include/uapi -Iinclude/generated/uapi -include ./include/linux/kconfig.h -D__KERNEL__ -mlittle-endian -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-dwarf2-cfi-asm -mabi=aapcs-linux -mno-thumb-interwork -mfpu=vfp -funwind-tables -marm -D__LINUX_ARM_ARCH__=5 -march=armv5te -mtune=arm9tdmi -msoft-float -Uarm -fno-delete-null-pointer-checks -O2 --param=allow-store-data-races=0 -Wframe-larger-than=1024 -fno-stack-protector -Wno-unused-but-set-variable -fomit-frame-pointer -fno-var-tracking-assignments -g -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -DCC_HAVE_ASM_GOTO -I/home/trem/Codes/armadeus/armadeus/buildroot/drivers/usb/gadget/ -I/home/trem/Codes/armadeus/armadeus/buildroot/drivers/usb/gadget/udc/ -I/home/trem/Codes/armadeus/armadeus/buildroot/drivers/usb/gadget/function/ -DMODULE -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(hid)" -D"KBUILD_MODNAME=KBUILD_STR(g_hid)" -c -o drivers/usb/gadget/legacy/hid.o drivers/usb/gadget/legacy/hid.c drivers/usb/gadget/epautoconf.c:23:26: erreur fatale: gadget_chips.h : Aucun fichier ou dossier de ce type This compilation line include : ..../buildroot/driver/usb/gadget but the real path is : ..../buildroot/output/build/linux-3.17-rc1/driver/usb/gadget Signed-off-by: Philippe Reynes <tremyfr@gmail.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
| * | usb: pch_udc: usb gadget device support for Intel Quark X1000Bryan O'Donoghue2014-08-202-4/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is to enable the USB gadget device for Intel Quark X1000 Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@intel.com> Signed-off-by: Bing Niu <bing.niu@intel.com> Signed-off-by: Alvin (Weike) Chen <alvin.chen@intel.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
| * | usb: gadget: uvc: fix possible lockup in uvc gadgetMichael Grzeschik2014-08-191-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the pending buffers in the queue could not be pushed to the udc endpoint we have to cancel the uvc_queue. Otherwise the gadget will get stuck on this error. This patch calls uvc_queue_cancel if usb_ep_queue failed. Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Felipe Balbi <balbi@ti.com>
| * | Revert "usb: gadget: u_ether: synchronize with transmit when stopping queue"Li RongQing2014-08-191-3/+0Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit a9232076374334ca2bc2a448dfde96d38a54349a. It introduced a dead lock, and did not fix anything. it made netif_tx_lock() be called in IRQ context, but in softirq context, the same lock is locked without disabling IRQ. In fact, the commit a923207637 did not fix anything, since netif_stop_queue did not free the any resource [ 10.154920] ================================= [ 10.156026] [ INFO: inconsistent lock state ] [ 10.156026] 3.16.0-rc5+ #13 Not tainted [ 10.156026] --------------------------------- [ 10.156026] inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage. [ 10.156026] swapper/1/0 [HC0[0]:SC1[5]:HE1:SE0] takes: [ 10.156026] (_xmit_ETHER){?.-...}, at: [<80948b6a>] sch_direct_xmit+0x7a/0x250 [ 10.156026] {IN-HARDIRQ-W} state was registered at: [ 10.156026] [<804811f0>] __lock_acquire+0x800/0x17a0 [ 10.156026] [<804828ba>] lock_acquire+0x6a/0xf0 [ 10.156026] [<809ed477>] _raw_spin_lock+0x27/0x40 [ 10.156026] [<8088d508>] gether_disconnect+0x68/0x280 [ 10.156026] [<8088e777>] eem_set_alt+0x37/0xc0 [ 10.156026] [<808847ce>] composite_setup+0x30e/0x1240 [ 10.156026] [<8088b8ae>] pch_udc_isr+0xa6e/0xf50 [ 10.156026] [<8048abe8>] handle_irq_event_percpu+0x38/0x1e0 [ 10.156026] [<8048adc1>] handle_irq_event+0x31/0x50 [ 10.156026] [<8048d94b>] handle_fasteoi_irq+0x6b/0x140 [ 10.156026] [<804040a5>] handle_irq+0x65/0x80 [ 10.156026] [<80403cfc>] do_IRQ+0x3c/0xc0 [ 10.156026] [<809ee6ae>] common_interrupt+0x2e/0x34 [ 10.156026] [<804668c5>] finish_task_switch+0x65/0xd0 [ 10.156026] [<809e89df>] __schedule+0x20f/0x7d0 [ 10.156026] [<809e94aa>] schedule_preempt_disabled+0x2a/0x70 [ 10.156026] [<8047bf03>] cpu_startup_entry+0x143/0x410 [ 10.156026] [<809e2e61>] rest_init+0xa1/0xb0 [ 10.156026] [<80ce2a3b>] start_kernel+0x336/0x33b [ 10.156026] [<80ce22ab>] i386_start_kernel+0x79/0x7d [ 10.156026] irq event stamp: 52070 [ 10.156026] hardirqs last enabled at (52070): [<809375de>] neigh_resolve_output+0xee/0x2a0 [ 10.156026] hardirqs last disabled at (52069): [<809375a8>] neigh_resolve_output+0xb8/0x2a0 [ 10.156026] softirqs last enabled at (52020): [<8044401f>] _local_bh_enable+0x1f/0x50 [ 10.156026] softirqs last disabled at (52021): [<80404036>] do_softirq_own_stack+0x26/0x30 [ 10.156026] [ 10.156026] other info that might help us debug this: [ 10.156026] Possible unsafe locking scenario: [ 10.156026] [ 10.156026] CPU0 [ 10.156026] ---- [ 10.156026] lock(_xmit_ETHER); [ 10.156026] <Interrupt> [ 10.156026] lock(_xmit_ETHER); [ 10.156026] [ 10.156026] *** DEADLOCK *** [ 10.156026] [ 10.156026] 4 locks held by swapper/1/0: [ 10.156026] #0: (((&idev->mc_ifc_timer))){+.-...}, at: [<8044b100>] call_timer_fn+0x0/0x190 [ 10.156026] #1: (rcu_read_lock){......}, at: [<a0577c40>] mld_sendpack+0x0/0x590 [ipv6] [ 10.156026] #2: (rcu_read_lock_bh){......}, at: [<a055680c>] ip6_finish_output2+0x4c/0x7f0 [ipv6] [ 10.156026] #3: (rcu_read_lock_bh){......}, at: [<8092e510>] __dev_queue_xmit+0x0/0x5f0 [ 10.156026] [ 10.156026] stack backtrace: [ 10.156026] CPU: 1 PID: 0 Comm: swapper/1 Not tainted 3.16.0-rc5+ #13 [ 10.156026] 811dbb10 00000000 9e919d10 809e6785 9e8b8000 9e919d3c 809e561e 80b95511 [ 10.156026] 80b9545a 80b9543d 80b95450 80b95441 80b957e4 9e8b84e0 00000002 8047f7b0 [ 10.156026] 9e919d5c 8048043b 00000002 00000000 9e8b8000 00000001 00000004 9e8b8000 [ 10.156026] Call Trace: [ 10.156026] [<809e6785>] dump_stack+0x48/0x69 [ 10.156026] [<809e561e>] print_usage_bug+0x18f/0x19c [ 10.156026] [<8047f7b0>] ? print_shortest_lock_dependencies+0x170/0x170 [ 10.156026] [<8048043b>] mark_lock+0x53b/0x5f0 [ 10.156026] [<804810cf>] __lock_acquire+0x6df/0x17a0 [ 10.156026] [<804828ba>] lock_acquire+0x6a/0xf0 [ 10.156026] [<80948b6a>] ? sch_direct_xmit+0x7a/0x250 [ 10.156026] [<809ed477>] _raw_spin_lock+0x27/0x40 [ 10.156026] [<80948b6a>] ? sch_direct_xmit+0x7a/0x250 [ 10.156026] [<80948b6a>] sch_direct_xmit+0x7a/0x250 [ 10.156026] [<8092e6bf>] __dev_queue_xmit+0x1af/0x5f0 [ 10.156026] [<80947fc0>] ? ether_setup+0x80/0x80 [ 10.156026] [<8092eb0f>] dev_queue_xmit+0xf/0x20 [ 10.156026] [<8093764c>] neigh_resolve_output+0x15c/0x2a0 [ 10.156026] [<a0556927>] ip6_finish_output2+0x167/0x7f0 [ipv6] [ 10.156026] [<a0559b05>] ip6_finish_output+0x85/0x1c0 [ipv6] [ 10.156026] [<a0559cb7>] ip6_output+0x77/0x240 [ipv6] [ 10.156026] [<a0578163>] mld_sendpack+0x523/0x590 [ipv6] [ 10.156026] [<80480501>] ? mark_held_locks+0x11/0x90 [ 10.156026] [<a057947d>] mld_ifc_timer_expire+0x15d/0x280 [ipv6] [ 10.156026] [<8044b168>] call_timer_fn+0x68/0x190 [ 10.156026] [<a0579320>] ? igmp6_group_added+0x150/0x150 [ipv6] [ 10.156026] [<8044b3fa>] run_timer_softirq+0x16a/0x240 [ 10.156026] [<a0579320>] ? igmp6_group_added+0x150/0x150 [ipv6] [ 10.156026] [<80444984>] __do_softirq+0xd4/0x2f0 [ 10.156026] [<804448b0>] ? tasklet_action+0x100/0x100 [ 10.156026] [<80404036>] do_softirq_own_stack+0x26/0x30 [ 10.156026] <IRQ> [<80444d05>] irq_exit+0x65/0x70 [ 10.156026] [<8042d758>] smp_apic_timer_interrupt+0x38/0x50 [ 10.156026] [<809ee91f>] apic_timer_interrupt+0x2f/0x34 [ 10.156026] [<8048007b>] ? mark_lock+0x17b/0x5f0 [ 10.156026] [<8040a912>] ? default_idle+0x22/0xf0 [ 10.156026] [<8040b13e>] arch_cpu_idle+0xe/0x10 [ 10.156026] [<8047bfc6>] cpu_startup_entry+0x206/0x410 [ 10.156026] [<8042bfbd>] start_secondary+0x19d/0x1e0 Acked-by: Tony Lindgren <tony@atomide.com> Reported-by: Thomas Gleixner <tglx@linutronix.de> Cc: Jeff Westfahl <jeff.westfahl@ni.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: <linux-usb@vger.kernel.org> Signed-off-by: Li RongQing <roy.qing.li@gmail.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
| * | usb: gadget: Fix return value check in r8a66597_probe()Wei Yongjun2014-08-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In case of error, the function devm_ioremap_resource() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR(). Acked-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> Signed-off-by: Felipe Balbi <balbi@ti.com>
| * | usb: gadget: Fix return value check in ep_write()Wei Yongjun2014-08-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | In case of error, the function memdup_user() returns ERR_PTR() and never returns NULL. The NULL test in the return value check should be replaced with IS_ERR(). Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> Signed-off-by: Felipe Balbi <balbi@ti.com>
| * | usb: atmel_usba_udc: fix it to deal with final dma channelBo Shen2014-08-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As, the interrupt for DMA is counted from 1, so need to checked the USBA_NR_DMAS, in old way, it only check (USBA_NR_DMAS - 1), so fix it. Reported-by: Max Liao <liaops@embest-tech.com> Signed-off-by: Bo Shen <voice.shen@atmel.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
| * | usb: gadget: fix error return codeJulia Lawall2014-08-191-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Convert a zero return value on error to a negative one, as returned elsewhere in the function. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ identifier ret; expression e1,e2; @@ ( if (\(ret < 0\|ret != 0\)) { ... return ret; } | ret = 0 ) ... when != ret = e1 when != &ret *if(...) { ... when != ret = e2 when forall return ret; } // </smpl> Reviewed-by: Jeff Moyer <jmoyer@redhat.com> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Felipe Balbi <balbi@ti.com>
| * | usb: dbgp gadget: fix use after free in dbgp_unbind()Alexey Khoroshilov2014-08-191-0/+2
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After dbgp_bind()-dbgp_unbind() cycle happens, static variable dbgp contains pointers to already deallocated memory (dbgp.serial and dbgp.req). If the next dbgp_bind() fails, for example in usb_ep_alloc_request(), dbgp_bind() calls dbgp_unbind() on failure path, and dbgp_unbind() frees dbgp.serial that still stores a pointer to already deallocated memory. The patch sets pointers to NULL in dbgp_unbind(). Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: uvc: move module parameters from f_uvcAndrzej Pietrasiewicz2014-09-083-21/+38
| | | | | | | | | | | | | | | | | | | | | | When configfs support is integrated the future uvc function module must not take any parameters. Move parameters to webcam. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Tested-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: f_uvc: Move to video_ioctl2Laurent Pinchart2014-09-082-141/+159
| | | | | | | | | | | | | | | | Simplify ioctl handling by using video_ioctl2. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: f_uvc: Store EP0 control request state during setup stageLaurent Pinchart2014-09-082-18/+7Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To handle class requests received on ep0, the driver needs to access the length and direction of the request after the setup stage. It currently stores them in a v4l2 event during the setup stage, and then copies them from the event structure to the driver internal state structure when the event is dequeued. This two-steps approach isn't necessary. Simplify the driver by storing the needed information in the driver internal state structure directly during the setup stage. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: f_uac2: send reasonably sized packetsDaniel Mack2014-09-021-4/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The UAC2 function driver currently responds to all packets at all times with wMaxPacketSize packets. That results in way too fast audio playback as the function driver (which is in fact supposed to define the audio stream pace) delivers as fast as it can. Fix this by sizing each packet correctly with the following steps: a) Set the packet's size by dividing the nominal data rate by the playback endpoint's interval. b) If there is a residual value from the calculation in a), add it to a accumulator to keep track of it across packets. c) If the accumulator has gathered at least the number of bytes that are needed for one sample frame, increase the packet size. This way, the packet size calculation will get rid of any kind of imprecision that would otherwise occur with a simple division over time. Some of the variables that are needed while processing each packet are pre-computed for performance reasons. Signed-off-by: Daniel Mack <zonque@gmail.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: f_uac2: handle partial dma area wrapDaniel Mack2014-09-021-9/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With packet sizes other than 512, payloads in the packets may wrap around the ALSA dma buffer partially, which leads to memory corruption and audible clicks and pops in the audio stream at the moment, because there is no boundary check before the memcpy(). In preparation to an implementation for smaller and dynamically sized packets, we have to address such cases, and copy the payload in two steps conditionally. The 'src' and 'dst' approach doesn't work here anymore, as different behavior is necessary in playback and capture cases. Thus, this patch open-codes the routine now. Signed-off-by: Daniel Mack <zonque@gmail.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: f_uac2: introduce agdev_to_uac2_optsDaniel Mack2014-09-021-2/+8
| | | | | | | | | | | | | | | | | | Add a simple container_of() wrapper to get a struct f_uac2_opts from a struct struct audio_dev. Use it in two places where it is currently open-coded. Signed-off-by: Daniel Mack <zonque@gmail.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: f_uac2: add short-hand for 'dev'Daniel Mack2014-09-021-18/+11Star
| | | | | | | | | | | | | | | | | | | | | | In afunc_bind() and afunc_set_alt(), &uac2->pdev.dev are used multiple times. Adding a short-hand for them makes lines shorter so we can remove some line wraps. No functional change. Signed-off-by: Daniel Mack <zonque@gmail.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: f_uac2: restructure some code in afunc_set_alt()Daniel Mack2014-09-021-23/+16Star
| | | | | | | | | | | | | | | | | | | | | | Restructure some code to make it easier to read. While at it, return -ENOMEM instead of -EINVAL if usb_ep_alloc_request() fails, and omit the logging in such cases (the mm core will complain loud enough). Signed-off-by: Daniel Mack <zonque@gmail.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: f_mass_storage: simplify start_transfer slightlyMichal Nazarewicz2014-09-021-14/+13Star
| | | | | | | | | | | | | | | | | | | | Flatten the start_transfer function by reversing the if condition and returning early out of the function if everything went fine. It makes the function look less complicated, at least to me, and easier to understand. Signed-off-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: composite: dequeue cdev->req before free its bufferLi Jun2014-09-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | commit f226708(usb: gadget: composite: dequeue cdev->req before free it in composite_dev_cleanup) fixed a bug: free the usb request(i.e. cdev->req) but does not dequeue it beforehand. This fix is not proper enough because it dequeues the request after free its data buffer, considering the hardware can access the buffer's memory anytime before the request's complettion rountine runs, and usb_ep_dequeue always call the complettion rountine before it returns, so the best way is to dequeue the request before free its buffer. Suggested-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Li Jun <b47624@freescale.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: USB_RENESAS_USBHS_UDC should depend on HAS_DMAGeert Uytterhoeven2014-09-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | If NO_DMA=y: drivers/built-in.o: In function `usbhsg_dma_map_ctrl': mod_gadget.c:(.text+0x53b226): undefined reference to `usb_gadget_map_request' mod_gadget.c:(.text+0x53b242): undefined reference to `usb_gadget_unmap_request' Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: use $(srctree) instead of $(PWD) for includesYegor Yefremov2014-08-293-6/+6
| | | | | | | | | | | | | | | | Using $(PWD) breaks builds when make was invoked from outside of the kernel tree. Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: udc: use USB API functions rather than constantsHimangi Saraogi2014-08-291-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduces the use of the functions usb_endpoint_type and usb_endpoint_num. The Coccinelle semantic patch that makes these changes is as follows: @@ struct usb_endpoint_descriptor *epd; @@ - (epd->bEndpointAddress & \(USB_ENDPOINT_NUMBER_MASK\|0x0f\)) + usb_endpoint_num(epd) @@ struct usb_endpoint_descriptor *epd; @@ - (epd->bmAttributes & \(USB_ENDPOINT_XFERTYPE_MASK\|3\)) + usb_endpoint_type(epd) Signed-off-by: Himangi Saraogi <himangi774@gmail.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: zero: Add support for interrupt EPAmit Virdi2014-08-274-22/+526
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Interrupt endpoints behave quite similar to the bulk endpoints with the difference that the endpoints expect data sending/reception request at particular intervals till the whole data has not been transmitted. The interrupt EP support is added to gadget zero. A new alternate setting (=2) has been added. It has 2 interrupt endpoints. The default parameters are set as: bInterval: 1 ms for FS and 8 uFrames (implying 1 ms) for HS/SS wMaxPacketSize: 64 bytes for FS and 1024 bytes for HS/SS However, the same can be overridden through the module parameter interface. The code is tested for HS and SS on a platform having DWC3 controller. Signed-off-by: Amit Virdi <amit.virdi@st.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: serial: remove PREFIX macroRichard Leitner2014-08-271-17/+13Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove the ttyGS PREFIX macro from u_serial.c and replace all occurences with the hardcoded ttyGS string. This macro was mostly used in a few debug/warning messages and a lot of hardcoded ttyGS existed beneath. It may have been used for renaming the tty, but if done so most debug messages would have ignored this. Due to the fact the usage of this PREFIX in all debug calls would have resulted in a hard to read/grep code it is removed completely. Signed-off-by: Richard Leitner <richard.leitner@skidata.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: serial: replace {V,}DBG macro with dev_{v,}dbgRichard Leitner2014-08-273-40/+56
| | | | | | | | | | | | | | | | Replace the VDBG and DBG macro with the kernels "proper" debug macros (dev_vdbg and dev_dbg) in f_acm.c, f_obex.c & f_serial.c Signed-off-by: Richard Leitner <richard.leitner@skidata.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: uvc: remove DRIVER_VERSION{,_NUMBER}Michael Grzeschik2014-08-212-4/+1Star
| | | | | | | | | | | | | | | | As the driver is in mainline we can remove the version numbers. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: f_uvc: fix potential memory leakAndrzej Pietrasiewicz2014-08-211-3/+2Star
| | | | | | | | | | | | | | | | | | | | | | | | If uvc->control_buf is successfuly allocated but uvc->control_req is not, uvc->control_buf is not freed in the error recovery path. With this patch applied uvc->control_buf is freed unconditionally; if it happens to be NULL kfree on it is safe anyway. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: uvc: Add support for DMABUF importingPhilipp Zabel2014-08-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | Activate the videobuf2 DMABUF support. As vb2-vmalloc supports the importer role only, exporting buffers isn't supported yet. When the exporter role will be implemented in vb2-vmalloc the UVC gadget driver will automatically gain support for it. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: uvc: Change KERN_INFO to KERN_DEBUG on request shutdownMichael Grzeschik2014-08-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | The disconnect of the USB Device is a common pattern for an UVC Camera. In many cases this will give us an meaningless information for all buffers that couldn't be enqueued. That patch changes this to KERN_DEBUG. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: f_uac1: add configfs supportAndrzej Pietrasiewicz2014-08-202-1/+164
| | | | | | | | | | | | | | | | | | Add support for using f_uac1 function as a component of a gadget composed with configfs. Tested-by: Sebastian Reimers <sebastian.reimers@googlemail.com> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: f_uac1: use defined constants as defaultsAndrzej Pietrasiewicz2014-08-203-14/+13Star
| | | | | | | | | | | | | | | | | | | | When configfs support is added the values in question will have to be used in two different places. Substitute them with defined constants to avoid duplicating magic numbers. Tested-by: Sebastian Reimers <sebastian.reimers@googlemail.com> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: f_uac1: use usb_gstrings_attachAndrzej Pietrasiewicz2014-08-201-18/+12Star
| | | | | | | | | | | | | | | | Use the new usb_gstring_attach interface. Tested-by: Sebastian Reimers <sebastian.reimers@googlemail.com> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: f_uac1: remove compatibility layerAndrzej Pietrasiewicz2014-08-203-138/+1Star
| | | | | | | | | | | | | | | | There are no users of the old interface left, so it can be removed. Tested-by: Sebastian Reimers <sebastian.reimers@googlemail.com> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: audio: convert to new interface of f_uac1Andrzej Pietrasiewicz2014-08-202-6/+64
| | | | | | | | | | | | | | | | Use the new interface so that the old one can be removed. Tested-by: Sebastian Reimers <sebastian.reimers@googlemail.com> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: f_uac1: convert to new function interface with backward ↵Andrzej Pietrasiewicz2014-08-206-31/+195
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | compatibility Converting uac1 to the new function interface requires converting the USB uac1's function code and its users. This patch converts the f_uac1.c to the new function interface. The file is now compiled into a separate usb_f_uac1.ko module. The old function interface is provided by means of a preprocessor conditional directives. After all users are converted, the old interface can be removed. Tested-by: Sebastian Reimers <sebastian.reimers@googlemail.com> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: f_uac1: prepare for separate compilationAndrzej Pietrasiewicz2014-08-202-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Integrating configfs requires converting f_uac1 to new function interface, which in turn requires converting it to the new function interface, which involves separate compilation of f_uac1.c into usb_f_uac1.ko. u_uac1.c contains some module parameters. After this patch is applied they are still a part of the resulting g_audio.ko, but can be guarded with a compatiblity flag which will be removed when no users of the old function interface of f_uac1 are left. Tested-by: Sebastian Reimers <sebastian.reimers@googlemail.com> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: f_uac1: add function stringsAndrzej Pietrasiewicz2014-08-201-1/+50
| | | | | | | | | | | | | | | | uac1 function is missing strings. Add them. Tested-by: Sebastian Reimers <sebastian.reimers@googlemail.com> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: f_uac2: add configfs supportAndrzej Pietrasiewicz2014-08-202-0/+108
| | | | | | | | | | | | | | | | | | Add support for using f_uac2 function as a component of a gadget composed with configfs. Tested-by: Sebastian Reimers <sebastian.reimers@googlemail.com> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: f_uac2: use defined constants as defaultsAndrzej Pietrasiewicz2014-08-202-8/+15
| | | | | | | | | | | | | | | | | | When configfs is integrated the same values will have to be used as defaults. Use symbolic names in order not to duplicate magic numbers. Tested-by: Sebastian Reimers <sebastian.reimers@googlemail.com> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* | usb: gadget: f_uac2: use usb_gstrings_attachAndrzej Pietrasiewicz2014-08-201-16/+17
| | | | | | | | | | | | | | | | Use the new usb_gstring_attach interface. Tested-by: Sebastian Reimers <sebastian.reimers@googlemail.com> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>