Commit Graph

2775 Commits

Author SHA1 Message Date
Dan Carpenter
ceeb010ba2 usb: gadget: uvc: remove an impossible condition
"num" is a u32 so "(num > 0xFFFFFFFF)" is never true.  Also the range
is already checked in kstrtou32().

Acked-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-19 12:53:31 -06:00
Dan Carpenter
df90f83819 usb: gadget: uvc: fix some error codes
We're basically saying ERR_CAST(NULL) and PTR_ERR(NULL) here, which is
nonsensical.

Acked-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-19 10:10:19 -06:00
Felipe Balbi
d1fc4440d7 Linux 3.19-rc5
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQEcBAABAgAGBQJUu0x7AAoJEHm+PkMAQRiGH/8H/14SgHC8A+tGEY1Hmgr7Y6ah
 kAcev/QMIxvtxKK0zdhgSILiBUrbK1CAXFGbueUAHgSaCucry5rpJvhFCIzSaCmm
 60yLZKvNrxXX4Zc1SYxxW+2EfDCNd0tO6uZK30kyzYYmw6fCgLMEXL6pFI0wFJRg
 G41yL7MogjJJP0JFGjwrFTeJ6ZBahErOmMpx1qrHuDN8cbdZvG8w6A0KP7ch6Ct1
 qdwcpOK4L9AXG+fbE7AJCSBkVev4KqwknPSWQ+jWX7ftw3q0P1O6dXY94ob3PqVi
 jsWmraOCd5uJrX9uSiOJCsbwoaHHMTNOsEF71qQKDrQzcGCPJAxd1Mi696JdDAQ=
 =jNTS
 -----END PGP SIGNATURE-----

Merge tag 'v3.19-rc5' into next

Linux 3.19-rc5

Conflicts:
	drivers/usb/dwc2/gadget.c
	drivers/usb/gadget/udc/bdc/bdc_ep.c
2015-01-19 09:57:20 -06:00
Robert Baldyga
18d6b32fca usb: gadget: f_fs: add "no_disconnect" mode
Since we can compose gadgets from many functions, there is the problem
related to gadget breakage while FunctionFS daemon being closed. FFS
function is userspace code so there is no way to know when it will close
files (it doesn't matter what is the reason of this situation, it can
be daemon logic, program breakage, process kill or any other). So when
we have another function in gadget which, for example, sends some amount
of data, does some software update or implements some real-time functionality,
we may want to keep the gadget connected despite FFS function is no longer
functional.

We can't just remove one of functions from gadget since it has been
enumerated, so the only way to keep entire gadget working is to make
broken FFS function deactivated but still visible to host. For this
purpose this patch introduces "no_disconnect" mode. It can be enabled
by setting mount option "no_disconnect=1", and results with defering
function disconnect to the moment of reopen ep0 file or filesystem
unmount. After closing all endpoint files, FunctionFS is set to state
FFS_DEACTIVATED.

When ffs->state == FFS_DEACTIVATED:
- function is still bound and visible to host,
- setup requests are automatically stalled,
- transfers on other endpoints are refused,
- epfiles, except ep0, are deleted from the filesystem,
- opening ep0 causes the function to be closed, and then FunctionFS
  is ready for descriptors and string write,
- altsetting change causes the function to be closed - we want to keep
  function alive until another functions are potentialy used, altsetting
  change means that another configuration is being selected or USB cable
  was unplugged, which indicates that we don't need to stay longer in
  FFS_DEACTIVATED state
- unmounting of the FunctionFS instance causes the function to be closed.

Tested-by: David Cohen <david.a.cohen@linux.intel.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-15 09:41:50 -06:00
kbuild test robot
f093a2d465 usb: gadget: uvc: to_uvcg_control_header() can be static
drivers/usb/gadget/function/uvc_configfs.c:46:28: sparse: symbol 'to_uvcg_control_header' was not declared. Should it be static?
drivers/usb/gadget/function/uvc_configfs.c:138:25: sparse: symbol 'uvcg_control_header_type' was not declared. Should it be static?
drivers/usb/gadget/function/uvc_configfs.c:164:6: sparse: symbol 'uvcg_control_header_drop' was not declared. Should it be static?
drivers/usb/gadget/function/uvc_configfs.c:721:20: sparse: symbol 'to_uvcg_format' was not declared. Should it be static?
drivers/usb/gadget/function/uvc_configfs.c:798:30: sparse: symbol 'to_uvcg_streaming_header' was not declared. Should it be static?
drivers/usb/gadget/function/uvc_configfs.c:950:25: sparse: symbol 'uvcg_streaming_header_type' was not declared. Should it be static?
drivers/usb/gadget/function/uvc_configfs.c:976:6: sparse: symbol 'uvcg_streaming_header_drop' was not declared. Should it be static?
drivers/usb/gadget/function/uvc_configfs.c:1020:19: sparse: symbol 'to_uvcg_frame' was not declared. Should it be static?
drivers/usb/gadget/function/uvc_configfs.c:1265:25: sparse: symbol 'uvcg_frame_type' was not declared. Should it be static?
drivers/usb/gadget/function/uvc_configfs.c:1315:6: sparse: symbol 'uvcg_frame_drop' was not declared. Should it be static?
drivers/usb/gadget/function/uvc_configfs.c:1338:26: sparse: symbol 'to_uvcg_uncompressed' was not declared. Should it be static?
drivers/usb/gadget/function/uvc_configfs.c:1548:25: sparse: symbol 'uvcg_uncompressed_type' was not declared. Should it be static?
drivers/usb/gadget/function/uvc_configfs.c:1586:6: sparse: symbol 'uvcg_uncompressed_drop' was not declared. Should it be static?
drivers/usb/gadget/function/uvc_configfs.c:1610:19: sparse: symbol 'to_uvcg_mjpeg' was not declared. Should it be static?
drivers/usb/gadget/function/uvc_configfs.c:1761:25: sparse: symbol 'uvcg_mjpeg_type' was not declared. Should it be static?
drivers/usb/gadget/function/uvc_configfs.c:1793:6: sparse: symbol 'uvcg_mjpeg_drop' was not declared. Should it be static?

Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-15 09:41:49 -06:00
Ricardo Ribalda Delgado
fc12c68b4f usb: gadget: net2280: Dont use 0 as NULL pointer
Fix sparse warning

Fixes: cb442ee159 (usb: gadget: udc: net2280: Re-enable dynamic debug messages)
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-15 09:41:49 -06:00
Peter Chen
c76abecc42 usb: gadget: u_uac1: fix one code style problem
Fix one code style problem.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-15 09:41:48 -06:00
Peter Chen
3703cfe782 usb: gadget: uac1: struct gaudio is useless for struct f_uac1_opts
Since we call gaudio_cleanup at f_audio_free, the f_uac1_opts
doesn't need to use gaudio any more.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-15 09:41:48 -06:00
Greg Kroah-Hartman
06087cb42d usb: fixes for v3.19-rc5
Just three fixes this time. An oops fix in ep_write() from gadgetfs,
 another oops for the Atmel UDC when unloading a gadget driver and
 the fix for PHY deferred probing.
 
 Signed-off-by: Felipe Balbi <balbi@ti.com>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJUtAxnAAoJEIaOsuA1yqRErBcP/RzyenZEkuw8A6nNbGHmAi8p
 eYYRPfWDdVLFyouvDcSevz2YR6PTviRfuTUu45yFlMLPQLOY00IQtwy4F+DTCB3A
 Ce0QUVFTvzvXbyHteG5VaYIWvDtJQnXrhTjv8XVsvW/UXtbzCE0RWWtNGbKsvCv8
 WRj/nFqymkCYhB1qqy/2b8Kdp1k8e/m1RzvaNusBaWzu73ejExme338tx6vfepQi
 MSjguviCAybSgbbZbvDGfd0D1LVDnrS78gLGm/JGGU1M+mcOnv3EGY00bgnlCB9o
 ydNIL+UkQTNTi6qrJQxNomwKexF9QkCrrKazMLA8lunTIt7yYuvxes01DZuLrSuN
 4vXjMlyiDFjtu7tA4Fe/k1rCPwRmpKQlr2uqcMcExcSeDJ7zwsUNYsFyzDnk1JMx
 nPmcuyCkP/S8QNY6w4LqcTb++cTKdH5A73nVoVHaPA5DUEAcmyMFdwm8N/R9V+PX
 yvzpPwAtkLeJPkjJwt0Bg6jcJ+FfNAfnXXrIHxFYXcKnud2VmqYtSJNMhrwdbdAh
 WG/jsdCtRJFAoMZzNEEPzFwQU+UW0c9ux9+jhzKFV1ognzqQALlREc5dGK2qoxDt
 5yWXqD6EymsWMLKo6vuYmIzoR5WXzIdzjgSvTJQNqEafCUMBAhIRKUxq4IVoX95d
 mwxe5ePPjww1tIM+8fjs
 =7Fj7
 -----END PGP SIGNATURE-----

Merge tag 'fixes-for-v3.19-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into usb-linus

Felipe writes:

usb: fixes for v3.19-rc5

Just three fixes this time. An oops fix in ep_write() from gadgetfs,
another oops for the Atmel UDC when unloading a gadget driver and
the fix for PHY deferred probing.

Signed-off-by: Felipe Balbi <balbi@ti.com>

Conflicts:
	drivers/usb/phy/phy.c
2015-01-12 10:51:04 -08:00
Peter Chen
487d60cc09 usb: gadget: mv_udc_core: delete pullup operation at .udc_start
UDC core has already done it after .udc_start.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:24:29 -06:00
Peter Chen
14d19d9f05 usb: gadget: pxa27x_udc: delete pullup operation at .udc_start and .udc_stop
UDC core has already done it before .udc_stop and after .udc_start.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:24:22 -06:00
Peter Chen
42c1ecff0e usb: gadget: pxa27x_udc: delete pullup operation at .udc_start and .udc_stop
UDC core has already done it before .udc_stop and after .udc_start.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:24:15 -06:00
Michal Nazarewicz
67913bbd0b usb: gadget: f_fs: refactor and document __ffs_ep0_read_events better
Instead of using variable length array, use a static length equal to
the size of the ffs->ev.types array.  This gets rid of a sparse warning:

	drivers/usb/gadget/function/f_fs.c:401:44: warning:
	Variable length array is used.

and makes it more explicit that the array has a very tight upper size
limit.  Also add some more documentation about the ev.types array and
how its size is limited and affects the rest of the code.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reported-by: Rohith Seelaboyina <rseelaboyina@nvidia.com>
Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:29 -06:00
Boris Brezillon
e3a912a124 usb: gadget: atmel_usba: Cache INT_ENB register value
Cache INT_ENB register value in order to avoid uncached iomem access, and
thus improve access time to INT_ENB value.

Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:29 -06:00
Boris Brezillon
9870d895ad usb: atmel_usba_udc: Mask status with enabled irqs
Avoid interpreting useless status flags when we're not waiting for such
events by masking the status variable with the interrupt enabled register
value.

Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Reported-by: Patrice VILCHEZ <patrice.vilchez@atmel.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:29 -06:00
Boris Brezillon
258e2ddd63 usb: atmel_usba_udc: Add at91sam9g45 and at91sam9x5 errata handling
at91sam9g45 and at91sam9x5 SoCs have an hardware bug forcing us to
generate a pulse on the BIAS signal on "USB end of reset” and
“USB end of resume" events.

Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Reported-by: Patrice VILCHEZ <patrice.vilchez@atmel.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:29 -06:00
Boris Brezillon
3280e67536 usb: atmel_usba_udc: Rework at91sam9rl errata handling
at91sam9rl SoC has an erratum forcing us to toggle the BIAS on USB
suspend/resume events.

This specific handling is only activated when CONFIG_ARCH_AT91SAM9RL is
set and this option is only set when building a non-DT kernel, which is
problematic since non-DT support for at91sam9rl SoC has been removed.

Rework the toggle_bias implementation to attach it to the "at91sam9rl-udc"
compatible string.

Add new compatible strings to avoid executing at91sam9rl erratum handling
on other SoCs.

Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:29 -06:00
Ricardo Ribalda Delgado
cb442ee159 usb: gadget: udc: net2280: Re-enable dynamic debug messages
Some debug messages were not build due to unconditional #if 0.

These messages are very useful for debugging and the user can enable
them on demand via dynamic debug.

If they are not enabled the performance is not affected.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:28 -06:00
Ricardo Ribalda Delgado
d82f3db266 usb: gadget: udc: net2280: Move ASSERT_OUT_NAKING into out_flush
ASSERT_OUT_NAKING was only called by out_flush and was hidden behind a
ifdef.

This patch moves the inline function into out_flush and remove the
ifdef. The user can decide to print the debug message or not via dynamic
printk

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:28 -06:00
Ricardo Ribalda Delgado
43780aaa1c usb: gadget: udc: net2280: Simplify scan_dma_completions
After fix superspeed dma_done was applied we can simplify the code by
removing the duplicated dma_done and letting the function check if there
are more completed dma transactions.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:28 -06:00
Ricardo Ribalda Delgado
6897d4b2ba usb: gadget: udc: net2280: Declare allow_status_338x as inline
The function is very simple, does not declare any variable and it is
called in the irq path.

The counterpart for net228x is already declared as inline.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:28 -06:00
Ricardo Ribalda Delgado
5153c219e7 usb: gadget: udc: net2280: Remove function resume_dma
Function resume_dma is not used, remove it.

The reason the compiler did not catch this dead code is the inline
modifier.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:28 -06:00
Ricardo Ribalda Delgado
5517525e05 usb: gadget: udc: net2280: Improve patching of defect 7374
Once the defect 7374 is patched, there is no reason the keep reading the
idx scratch register.

Cache the content of the scratch idx register on device flag.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:28 -06:00
Ricardo Ribalda Delgado
485f44d06b usb: gadget: udc: net2280: Clean function net2280_queue
Do not duplicate the code for the else branch of the condition.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:28 -06:00
Ricardo Ribalda Delgado
e721c4575d usb: gadget: udc: net2280: Merge abort_dma for 228x and 338x
We can use the same function for both families of chips and also remove
the ep_stop_dma() function.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:28 -06:00
Ricardo Ribalda Delgado
e0cbb04627 usb: gadget: udc: net2280: Remove function ep_stall
irqs_superspeed calls ep_stall instead of set/clear_halt, due to a
workaround for SS seqnum. Create a function with the workaround and
call set/clear_halt instead.

This way we can compare the code of super/normal speed and it is easier
to follow the code.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:27 -06:00
Ricardo Ribalda Delgado
5d1b6840fd usb: gadget: udc: net2280: Remove field is_halt
Field is_halt is never used by any function.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:27 -06:00
Ricardo Ribalda Delgado
cf8b1cdeba usb: gadget: udc: net2280: Code cleanout remove ep_stdrsp function
ep_stdrsp was only called by handle_stat0_irqs_superspeed and with
always the same flags.

Remove the function and replace the call by the code inside the
function, since it is very simple once the dead code is removed.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:27 -06:00
Ricardo Ribalda Delgado
61e72dc65a usb: gadget: udc: net2280: Remove restart_dma inline function definition
restart_dma is not used before it is declaration. Therefore we can
remove this definition.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:27 -06:00
Ricardo Ribalda Delgado
cb52c698c6 usb: gadget: udc: net2280: Remove dma_started field
Remove dma_started field from net2280_ep structure, since it is not used
by any function.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:27 -06:00
Ricardo Ribalda Delgado
d588ff58c2 usb: gadget: udc: net2280: Remove use_dma module parameter
use_dma parameter was designed to enable the dma on the chip. It was
enabled by default.

It comes from the time when the dma was not reliable. Now it has been
working ok in production.

This patch removes this parameter.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:27 -06:00
Ricardo Ribalda Delgado
9c864c2342 usb: gadget: udc: net2280: Remove module parameter use_msi
Parameter use_msi was used to enable msi irq on usb338x chips, it was
enabled by default.

There is no reason to prefer non-msi irq on usb338x, and it falls back
to non msi on error.

Therefore remove this option.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:27 -06:00
Ricardo Ribalda Delgado
7a74c48172 usb: gadget: udc: net2280: remove full_speed module parameter
This patch removes the full_speed parameter used force full-speed
operation.

It was designed exclusively for testing purposes, and there is no
reason to maintain this in a production kernel.

Reverts: 2f07607747
Suggested-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:27 -06:00
Ricardo Ribalda Delgado
906641980c usb: gadget: udc: net2280: Remove obsolete module param use_dma_chaining
use_dma_chaining module parameter was designed to avoid creating one irq
per package on a group of packages (with the help of the driver's flag
no_interrupt).

Unfortunately, when this parameter is enabled, the driver fails to work
on both net2280 and 3380 chips.

This patch removes this parameter, which was disabled by default.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:27 -06:00
Nicholas Mc Guire
9f56ce075d usb: gadget: cleanup on stack DECLARE_COMPLETIONs
fixups for incorrect use of DECLARE_COMPLETION. see also commit
6e9a4738 ("completions: lockdep annotate on stack completions")

patch is against 3.18.0 linux-next

This was only code reviewed and compile tested

Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:27 -06:00
Xuebing Wang
8d252db174 usb: gadget: f_uac1: update Class-Specific AudioControl Interface Header Descriptor
Update this according to USB Audio Class 1.0 spec. This fixes the Windows 7
detection issue.

Cc: Rafael Brune <mail@rbrune.de>
Signed-off-by: Xuebing Wang <xbing6@gmail.com>
Signed-off-by: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
(Fixed some code style issues)
Tested-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:27 -06:00
Xuebing Wang
625763d101 usb: gadget: f_uac1: configure endpoint before using it
UAC1 forget to do it.

Signed-off-by: Xuebing Wang <xbing6@gmail.com>
Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:26 -06:00
Julia Lawall
90f9e53345 usb: gadget: fix platform_no_drv_owner.cocci warnings
Remove .owner field if calls are used which set it automatically

Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

Signed-off-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:26 -06:00
Dan Carpenter
d71b0d7764 usb: gadget: udc: remove bogus NULL check
"ep" isn't NULL here, and static checkers complain because we
dereferenced it on the previous line.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:26 -06:00
Dan Carpenter
5e841efef7 usb: gadget: udc: clean up a printk
We already know what "value" is, so there is no need to check.  It
puzzles static checkers to have the unneeded condition.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:26 -06:00
Andrzej Pietrasiewicz
46919a23ee usb: gadget: uvc: configfs support in uvc function
Add support for using the uvc function as a component of USB gadgets composed
with configfs.

Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:26 -06:00
Andrzej Pietrasiewicz
6c25955ed6 usb: gadget: uvc: verify descriptors presence
If the caller of uvc_alloc() does not provide enough
descriptors, binding the function should fail, so appropriate
code is returned from uvc_copy_descriptors().

uvc_function_bind() is modified accordingly to account for possible
errors from uvc_copy_descriptors().

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:26 -06:00
Andrzej Pietrasiewicz
bbea6de1bd usb: gadget: f_uvc: rename a macro to avoid conflicts
When configfs is integrated, CONFIGFS_ATTR_STRUCT and CONFIGFS_ATTR_OPS
macros should be used, but the latter expects that tere is a to_f_uvc_opts
function accepting a config_item, whereas the macro being changed
can be applied to a different type of argument.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:26 -06:00
Andrzej Pietrasiewicz
39a2ac2738 usb: gadget: hid: consistently use 2^n - 1 for max values
A maximum value which fits in 16 bits, unsigned, is 65535.

Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:26 -06:00
Rickard Strandqvist
d16cd0b8f7 usb: gadget: udc: s3c2410_udc.c: Remove some unused functions
Removes some functions that are not used anywhere:
s3c2410_udc_clear_ep_state() s3c2410_udc_set_ep0_sse_out()

This was partially found by using a static code analysis program called cppcheck.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-12 12:13:24 -06:00
Songjun Wu
5fb694f96e usb: gadget: udc: atmel: fix possible oops when unloading module
When unloading the module 'g_hid.ko', the urb request will be dequeued and the
completion routine will be excuted. If there is no urb packet, the urb request
will not be added to the endpoint queue and the completion routine pointer in
urb request is NULL.

Accessing to this NULL function pointer will cause the Oops issue reported
below.

Add the code to check if the urb request is in the endpoint queue
or not. If the urb request is not in the endpoint queue, a negative
error code will be returned.

Here is the Oops log:

Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = dedf0000
[00000000] *pgd=3ede5831, *pte=00000000, *ppte=00000000
Internal error: Oops: 80000007 [#1] ARM
Modules linked in: g_hid(-) usb_f_hid libcomposite
CPU: 0 PID: 923 Comm: rmmod Not tainted 3.18.0+ #2
Hardware name: Atmel SAMA5 (Device Tree)
task: df6b1100 ti: dedf6000 task.ti: dedf6000
PC is at 0x0
LR is at usb_gadget_giveback_request+0xc/0x10
pc : [<00000000>]    lr : [<c02ace88>]    psr: 60000093
sp : dedf7eb0  ip : df572634  fp : 00000000
r10: 00000000  r9 : df52e210  r8 : 60000013
r7 : df6a9858  r6 : df52e210  r5 : df6a9858  r4 : df572600
r3 : 00000000  r2 : ffffff98  r1 : df572600  r0 : df6a9868
Flags: nZCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment user
Control: 10c53c7d  Table: 3edf0059  DAC: 00000015
Process rmmod (pid: 923, stack limit = 0xdedf6230)
Stack: (0xdedf7eb0 to 0xdedf8000)
7ea0:                                     00000000 c02adbbc df572580 deced608
7ec0: df572600 df6a9868 df572634 c02aed3c df577c00 c01b8608 00000000 df6be27c
7ee0: 00200200 00100100 bf0162f4 c000e544 dedf6000 00000000 00000000 bf010c00
7f00: bf0162cc bf00159c 00000000 df572980 df52e218 00000001 df5729b8 bf0031d0
[..]
[<c02ace88>] (usb_gadget_giveback_request) from [<c02adbbc>] (request_complete+0x64/0x88)
[<c02adbbc>] (request_complete) from [<c02aed3c>] (usba_ep_dequeue+0x70/0x128)
[<c02aed3c>] (usba_ep_dequeue) from [<bf010c00>] (hidg_unbind+0x50/0x7c [usb_f_hid])
[<bf010c00>] (hidg_unbind [usb_f_hid]) from [<bf00159c>] (remove_config.isra.6+0x98/0x9c [libcomposite])
[<bf00159c>] (remove_config.isra.6 [libcomposite]) from [<bf0031d0>] (__composite_unbind+0x34/0x98 [libcomposite])
[<bf0031d0>] (__composite_unbind [libcomposite]) from [<c02acee0>] (usb_gadget_remove_driver+0x50/0x78)
[<c02acee0>] (usb_gadget_remove_driver) from [<c02ad570>] (usb_gadget_unregister_driver+0x64/0x94)
[<c02ad570>] (usb_gadget_unregister_driver) from [<bf0160c0>] (hidg_cleanup+0x10/0x34 [g_hid])
[<bf0160c0>] (hidg_cleanup [g_hid]) from [<c0056748>] (SyS_delete_module+0x118/0x19c)
[<c0056748>] (SyS_delete_module) from [<c000e3c0>] (ret_fast_syscall+0x0/0x30)
Code: bad PC value

Signed-off-by: Songjun Wu <songjun.wu@atmel.com>
[nicolas.ferre@atmel.com: reworked the commit message]
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Fixes: 914a3f3b37 ("USB: add atmel_usba_udc driver")
Cc: <stable@vger.kernel.org> # 2.6.x-ish
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-09 18:15:11 -06:00
Dan Carpenter
42d6cfa0ca usb: gadget: gadgetfs: fix an oops in ep_write()
We try to free an ERR_PTR on this error path.

Fixes: b44be2462d ('usb: gadget: gadgetfs: Free memory allocated by memdup_user()')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2015-01-09 18:15:11 -06:00
John W. Linville
f26d29e34e usb: gadget: udc: avoid dereference before NULL check in ep_queue
Coverity: CID 1260069

Signed-off-by: John W. Linville <linville@tuxdriver.com>
Cc: Felipe Balbi <balbi@ti.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-01-09 10:01:46 -08:00
Bo Shen
6785a10344 usb: gadget: udc: atmel: fix possible IN hang issue
When receive data, the RXRDY in status register set by hardware
after a new packet has been stored in the endpoint FIFO. When it
is copied from FIFO, this bit is cleared which make the FIFO can
be accessed again.

In the receive_data() function, this bit RXRDY has been cleared.
So, after the receive_data() function return, this bit should
not be cleared again, or else it may cause the accessing FIFO
corrupt, which will make the data loss.

Fixes: 914a3f3b37 (USB: add atmel_usba_udc driver)
Cc: <stable@vger.kernel.org> # 2.6.24+
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Bo Shen <voice.shen@atmel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-12-22 10:41:15 -06:00
Bo Shen
f40afdddeb usb: gadget: udc: atmel: change setting for DMA
According to the datasheet, when transfer using DMA, the control
setting for IN packet only need END_BUF_EN, END_BUF_IE, CH_EN,
while for OUT packet, need more two bits END_TR_EN and END_TR_IE
to be configured.

Fixes: 914a3f3b37 (USB: add atmel_usba_udc driver)
Cc: <stable@vger.kernel.org> # 2.6.24+
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Bo Shen <voice.shen@atmel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2014-12-22 10:41:05 -06:00