aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAge
* usb: gadget: printer: add container_of helper for printer_devAndrzej Pietrasiewicz2015-03-10
| | | | | | | | 5 uses of container_of() in the same context justify wrapping it in a static inline function. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: printer: don't access file global usb_printer_gadget in ↵Andrzej Pietrasiewicz2015-03-10
| | | | | | | | | | function's code The printer_dev can be recovered from printer_func_unbind() function's parameters. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: printer: eliminate file global printer_mutexAndrzej Pietrasiewicz2015-03-10
| | | | | | | | The mutex is a legacy after semi-automatic Big Kernel Lock removal. printer_open() does its own locking, so no need to duplicate it. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: printer: call gprinter_setup() from gadget's bindAndrzej Pietrasiewicz2015-03-10
| | | | | | | | | Call gprinter_setup() from gadget's bind instead of module's init. Call gprinter_cleaup() corerspondingly. This detaches printer function's logic from legacy printer gadget's implementation. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: printer: add setup and cleanup functionsAndrzej Pietrasiewicz2015-03-10
| | | | | | | | Factor out gprinter_setup() and gprinter_cleanup() so that it is easy to change the place they are called from. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: printer: don't access file global pnp_string in function's codeAndrzej Pietrasiewicz2015-03-10
| | | | | | | | | In order to factor out a reusable f_printer, the function's code should not use file global variables related to legacy printer gadget's implementation. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: printer: define pnp string buffer lengthAndrzej Pietrasiewicz2015-03-10
| | | | | | | Avoid using magic numbers. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: printer: move function-related unbind code to function's unbindAndrzej Pietrasiewicz2015-03-10
| | | | | | | | | | In order to factor out a reusable f_printer.c, the code related to the function should be placed in functions related to the function. printer_cfg_unbind() becomes empty, so it is removed. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: printer: call usb_add_function() lastAndrzej Pietrasiewicz2015-03-10
| | | | | | | | | | | Conversion to the new function interface requires splitting a <something>_bind_config() function into two parts: allocation of container_of struct usb_function and invocation of usb_add_function(). This patch moves the latter to the end of the f_printer_bind_config() in order to enable conversion to the new interface. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: printer: move function-related bind code to function's bindAndrzej Pietrasiewicz2015-03-10
| | | | | | | | In order to factor out a reusable f_printer.c, the code related to the function should be placed in functions related to the function. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: printer: standardize printer_do_configAndrzej Pietrasiewicz2015-03-10
| | | | | | | | Follow the convention of distributing source code between <something>_do_config() and <something>_bind_config(). Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: printer: follow the naming convention for usb_add_config callbackAndrzej Pietrasiewicz2015-03-10
| | | | | | | | | | | | Legacy gadgets, before converting them to the new function framework, used to use the name <something>_do_config() for usb_add_config()'s callback. This patch changes the name so that it is easier to follow the convention. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: printer: eliminate pdev member of struct printer_devAndrzej Pietrasiewicz2015-03-10
| | | | | | | | The pdev member of struct printer_dev is not used outside printer_bind_config(), so it can just as well be a local variable there. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: printer: add missing error handlingAndrzej Pietrasiewicz2015-03-10
| | | | | | | | | | | | | | If cdev_add() in printer_bind_config() fails, care is taken to reverse the effects of initializations completed until the fail happens. But if printer_req_alloc() fails, it is just one of the two lists that is cleaned up while the effects of cdev_add() and device_create() are not reverted. This patch changes error handling so that at least as much cleanup is done as when a failure happens before printer_req_alloc() invocations. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: printer: revert usb_add_function() effect in error recoveryAndrzej Pietrasiewicz2015-03-10
| | | | | | | | Whenever the "goto fail" branch is taken, the effect of usb_add_function() should be reverted. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: printer: eliminate random pointer dereferenceAndrzej Pietrasiewicz2015-03-10
| | | | | | | | | | | | | | | | | | | | | | | | struct printer_dev contains 3 list heads: tx_reqs, rx_reqs and rx_buffers. There is just one instance of this structure in the driver and it is file static, and as such initialized with all zeros. If device_create() or cdev_add() fails then "goto fail" branch is taken, which results in printer_cfg_unbind() call. The latter checks if tx_reqs, rx_reqs and rx_buffers lists are empty. The check for emptiness is in fact a check whether the "next" member of struct list_head points to the head of the list. But the heads of the lists in question have not been initialized yet and, as mentioned above, contain all zeros, so list_empty() returns false and respective "while" loop body starts executing. Here, container_of() just subtracts the offset of a struct usb_request member from an address of this same member, which results in a value somewhere near 0 or 0xfff...ff. And the argument to list_del() dereferences such a pointer which causes a disaster. This patch moves respective INIT_LIST_HEAD() invocations to a point before "goto fail" branch can be taken. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: printer: remove unused and empty printer_unbindAndrzej Pietrasiewicz2015-03-10
| | | | | | | | The unbind() method is optional is usb_composite_driver. In this particular driver the method does nothing so it can be removed. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: printer: enqueue printer's response for setup requestAndrzej Pietrasiewicz2015-03-10
| | | | | | | | | | | | | | | | | | | Function-specific setup requests should be handled in such a way, that apart from filling in the data buffer, the requests are also actually enqueued: if function-specific setup is called from composte_setup(), the "usb_ep_queue()" block of code in composite_setup() is skipped. The printer function lacks this part and it results in e.g. get device id requests failing: the host expects some response, the device prepares it but does not equeue it for sending to the host, so the host finally asserts timeout. This patch adds enqueueing the prepared responses. Cc: <stable@vger.kernel.org> # v3.4+ Fixes: 2e87edf49227: "usb: gadget: make g_printer use composite" Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: composite: don't try standard handling for non-standard requestsAndrzej Pietrasiewicz2015-03-10
| | | | | | | | | | If a non-standard request is processed and its parameters just happen to match those of some standard request, the logic of composite_setup() can be fooled, so don't even try any switch cases, just go to the proper place where unknown requests are handled. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: dwc3: make LPM configurable in DTRobert Baldyga2015-03-10
| | | | | | | | | | | | This patch removes "Enable USB3 LPM Capability" option from Kconfig and adds snps,usb3_lpm_capable devicetree property instead of it. USB3 LPM (Link Power Management) capability is hardware property, and it's platform dependent, so if our hardware supports this feature, we want rather to configure it in devicetree than having it as Kconfig option. Signed-off-by: Robert Baldyga <r.baldyga@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: dsps: just start polling alreadyFelipe Balbi2015-03-10
| | | | | | | there's no need to fake an IRQ, just check if VBUS is valid already. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: dsps: use msecs_to_jiffies insteadFelipe Balbi2015-03-10
| | | | | | | | | | | | | when polling, we were using n * HZ (where n is an integer in seconds), however HZ isn't always correct if we're using cpufreq. A better way is to use msecs_to_jiffies(n) (where n is now an integer in miliseconds). while at that, also rename poll_seconds to poll_timeout and change its type to unsigned int. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: cppi41: do not call udelay()Felipe Balbi2015-03-10
| | | | | | | | | according to comment in code, HS completion will happen pretty fast, instead of using udelay(), let's just busy loop and drop a cpu_relax() where udelay() was. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: cppi41: exit early when tx fifo is emptyFelipe Balbi2015-03-10
| | | | | | | | | as soon as we find out tx fifo is empty, there's no need to break out of the loop just to have another branch to complete the transfer. We can just complete transfer and exit early. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: cppi41: decrease indentation levelFelipe Balbi2015-03-10
| | | | | | no functional changes, clean up only. Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: net2280: silence sparse warningFelipe Balbi2015-03-10
| | | | | | | | | Silence the following warning: drivers/usb/gadget/udc/net2280.c:3176:33: warning: context imbalance in 'handle_stat1_irqs' - unexpected unlock Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: net2280: don't connect from udc_startMian Yousaf Kaukab2015-03-10
| | | | | | | | net2280_start can be called with pullup disabled. Don't set softconnect flag in it. Let net2280_pullup handle the connection part. Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: net2280: print error in ep_ops error pathsMian Yousaf Kaukab2015-03-10
| | | | | | | | | Hopefully, these prints will help localize the problems faster. [ balbi@ti.com: removed 2 unnecessary OOM error messages ] Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: net2280: remove fiforegs as it is unusedMian Yousaf Kaukab2015-03-10
| | | | | | | | | | Remove fiforegs from struct net2280 and net2280_ep as it is unused. By the way, ep->fiforegs = &dev->fiforegs[i] assignment is incorrect. It should be ep->fiforegs = &dev->fiforegs[ne[i]], but it doesn't matter now. Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: gadget: net2280: use ep_autoconfig compatible names in advance modeMian Yousaf Kaukab2015-03-10
| | | | | | | | | | | | | Each struct usb_ep added for net2280 can be used in either direction. Whereas, each struct usb_ep for usb3380 has fixed direction. Use ep_autoconf compatible names so that endpoint with correct direction can be selected. Name sequence is due to the logic in usb_reinit_338x() in ne[] and ep_reg_addr[]. Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: core: always try to recover from babbleFelipe Balbi2015-03-10
| | | | | | | | | | | we can also have babble conditions with LS/FS and we also want to recover in that case. Because of that we will drop the check of HSMODE and always try to run babble recovery. Suggested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: core: disable irqs inside babble recoveryFelipe Balbi2015-03-10
| | | | | | | | | | There's no point is splitting those anymore. We're now also able to drop another forward declaration. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: core: remove unnecessary forward declarationFelipe Balbi2015-03-10
| | | | | | | no functional changes, cleanup only. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: core: drop recover_workFelipe Balbi2015-03-10
| | | | | | | | | that's not needed anymore. Everything that we call is irq-safe, so we might as well not have a delayed work for babble recovery. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: rename ->reset() to ->recover()Felipe Balbi2015-03-10
| | | | | | | | | | | | recover is a much better name than reset, considering we don't really reset the IP, just run platform-specific babble recovery algorithm. while at that, also fix a typo in comment and add kdoc for recover memeber of platform_ops. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: core: simplify musb_recover_work()Felipe Balbi2015-03-10
| | | | | | | | | | | | | | we're not resetting musb at all, just restarting the session. This means we don't need to touch PHYs or VBUS or anything like that. Just make sure session bit is reenabled after MUSB dropped it. while at that, make sure to tell usbcore that we're dropping the session and, thus, disconnecting the device. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: dsps: do not reset musb on babbleFelipe Balbi2015-03-10
| | | | | | | | | | | All we have to do is, really, drop session bit and let the session restart. Big thanks goes to Bin Liu <b-liu@ti.com> for inspiring this work. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: core: decrease delayed_work timeFelipe Balbi2015-03-10
| | | | | | | | | | When babble IRQ happens, we need to wait only 5.3us (320 cycles of 60MHz clock), we will give it some slack and schedule our work a 10 usecs into the future. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: don't touch devctl from babble recoveryFelipe Balbi2015-03-10
| | | | | | | | | | | We do *not* want to touch devctl at all when trying to recover from babble. All we want to do is mask IRQs until we're done without our babble recovery, at which point we will unmask IRQs. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: core: refactor IRQ enable/disable to separate functionsFelipe Balbi2015-03-10
| | | | | | | | | | sometimes we want to just mask/unmask interrupts without touching devctl register. For those cases, let's introduce musb_enable_interrupts and musb_disable_interrupts() Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: dsps: add dsps_ prefix to sw_babble_controlFelipe Balbi2015-03-10
| | | | | | | | this makes it easier to filter function traces. No functional changes. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: core: controller drops session automaticallyFelipe Balbi2015-03-10
| | | | | | | | | | | | | | Whenever babble happens, MUSB controller will drop session automatically. The only case where it won't drop the session, is when we're running on AM335x and SW_SESSION_CTRL bit has been set. In that case, controller will not touch session bit so SW has a chance to recover from babble condition. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: dsps: check for the single bitFelipe Balbi2015-03-10
| | | | | | | | | | | We want to check if that particular bit is set. It could very well be that bootloader (or romcode) has fiddled with MUSB before us which could leave other bits set in this register. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: dsps: remove babble check from dsps irq handlerFelipe Balbi2015-03-10
| | | | | | | | | | | | | | | | | | musb->int_usb already contains the correct information for musb-core to handle babble. In fact, this very check was just causing a nonsensical babble interrupt storm. With this I can get test.sh to run and, even though all tests fail with timeout, that's still better than locking up the system due to IRQ storm. Also, if I remove g_zero and load g_mass_storage, then everything works fine again. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: core: there is no connect interrupt in peripheral modeFelipe Balbi2015-03-10
| | | | | | | | MUSB does not generate a connect IRQ when working in peripheral mode. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: core: remove unnecessary reg access from resume IRQFelipe Balbi2015-03-10
| | | | | | | | | | | | when musb is operating as host and a remote wakeup fires up, a resume interrupt will be raised. At that point SUSPENDM bit is automatically cleared and RESUME bit is automatically set. Remove those two from IRQ handler. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: core: break long lineFelipe Balbi2015-03-10
| | | | | | | no functional changes, clean up only. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: core: move babble recovery inside babble checkFelipe Balbi2015-03-10
| | | | | | | | | There was already a proper place where we were checking for babble interrupts, move babble recovery there. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: dsps: return error code if reset failsFelipe Balbi2015-03-10
| | | | | | | | if reset fails, we should return a *negative* error code, not a positive value. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
* usb: musb: core: fix highspeed checkFelipe Balbi2015-03-10
| | | | | | | | | FSDEV is set for both HIGH and FULL speeds, the correct HIGHSPEED check is done through power register's HSMODE bit. Tested-by: Bin Liu <b-liu@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com>