aboutsummaryrefslogtreecommitdiff
path: root/drivers/hid/usbhid/hid-core.c
AgeCommit message (Collapse)Author
2010-05-07HID: fix suspend crash by moving initializations earlierAlan Stern
Although the usbhid driver allocates its usbhid structure in the probe routine, several critical fields in that structure don't get initialized until usbhid_start(). However if report descriptor parsing fails then usbhid_start() is never called. This leads to problems during system suspend -- the system will freeze. This patch (as1378) fixes the bug by moving the initialization statements up into usbhid_probe(). Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Reported-by: Bruno Prémont <bonbons@linux-vserver.org> Tested-By: Bruno Prémont <bonbons@linux-vserver.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2010-02-25Merge branches 'upstream', 'raw_report_modifications' and ↵Jiri Kosina
'apple_magic_mouse' into for-linus Conflicts: drivers/hid/Kconfig
2010-02-17HID: usbhid: initialize interface pointers early enoughJiri Kosina
Move the initialization of USB interface pointers from _start() over to _probe() callback, which is where it belongs. This fixes case where interface is NULL when parsing of report descriptor fails. LKML-Reference: <20100213135720.603e5f64@neptune.home> Reported-by: Alan Stern <stern@rowland.harvard.edu> Tested-by: Bruno Prémont <bonbons@linux-vserver.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2010-02-12HID: usbhid: introduce timeout for stuck ctrl/out URBsOliver Neukum
Some devices do not react to a control request (seen on APC UPS's) resulting in a slow stream of messages, "generic-usb ... control queue full". Therefore request needs a timeout. Cc: stable@kernel.org Signed-off-by: Oliver Neukum <oliver@neukum.org> Signed-off-by: David Fries <david@fries.net> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2010-02-03HID: make raw reports possible for both feature and output reportsJiri Kosina
In commit 2da31939a42 ("Bluetooth: Implement raw output support for HIDP layer"), support for Bluetooth hid_output_raw_report was added, but it pushes the data to the intr socket instead of the ctrl one. This has been fixed by 6bf8268f9a91f1 ("Bluetooth: Use the control channel for raw HID reports") Still, it is necessary to distinguish whether the report in question should be either FEATURE or OUTPUT. For this, we have to extend the generic HID API, so that hid_output_raw_report() callback provides means to specify this value so that it can be passed down to lower level hardware drivers (currently Bluetooth and USB). Based on original patch by Bastien Nocera <hadess@hadess.net> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2010-02-02Merge branch 'master' into upstreamJiri Kosina
Conflicts: drivers/hid/hid-ids.h
2010-02-02HID: update copyrightJiri Kosina
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2010-01-12HID: make USB device id constantMárton Németh
The id_table field of the struct usb_device_id is constant in <linux/usb.h> so it is worth to make the initialization data also constant. The semantic match that finds this kind of pattern is as follows: (http://coccinelle.lip6.fr/) // <smpl> @r@ disable decl_init,const_decl_init; identifier I1, I2, x; @@ struct I1 { ... const struct I2 *x; ... }; @s@ identifier r.I1, y; identifier r.x, E; @@ struct I1 y = { .x = E, }; @c@ identifier r.I2; identifier s.E; @@ const struct I2 E[] = ... ; @depends on !c@ identifier r.I2; identifier s.E; @@ + const struct I2 E[] = ...; // </smpl> Signed-off-by: Márton Németh <nm127@freemail.hu> Cc: Julia Lawall <julia@diku.dk> Cc: cocci@diku.dk Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-12-11USB: remove the auto_pm flagAlan Stern
This patch (as1302) removes the auto_pm flag from struct usb_device. The flag's only purpose was to distinguish between autosuspends and external suspends, but that information is now available in the pm_message_t argument passed to suspend methods. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-11-05HID: fixup quirk for NCR devicesJiri Kosina
NCR devices are terminally broken by design -- they claim themselves to contain proper input applications in their HID report descriptor, but behave very badly if treated in standard way. According to NCR developers, the devices get confused when queried for reports in a standard way, rendering them unusable. NCR is shipping application called "RPSL" that can be used to drive these devices through hiddev, under the assumption that in-kernel driver doesn't perform initial report query. If it does, neither in-kernel nor hiddev-based driver can operate with these devices any more. Introduce a quirk that skips the report query for all NCR devices. The previous NOGET quirk was wrong and had been introduced because I misunderstood the nature of brokenness of these devices. Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-10-13HID: remove useless DRIVER_VERSION macroJiri Kosina
DRIVER_VERSION has no use whatosoever, it has been set to "2.6" for ages. Remove it. Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-10-13HID: fix MODULE_AUTHOR usage in HID modulesJiri Kosina
Remove unused (in usbhid module) DRIVER_AUTHOR macrco and properly use multiple MODULE_AUTHOR() instances in both modules. Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-09-17HID: consolidate connect and disconnect into core codeJiri Kosina
HID core registers input, hidraw and hiddev devices, but leaves unregistering it up to the individual driver, which is not really nice. Let's move all the logic to the core. Reported-by: Marcel Holtmann <marcel@holtmann.org> Reported-by: Brian Rogers <brian@xyzw.org> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-09-13Merge branches 'upstream', 'upstream-fixes' and 'debugfs' into for-linusJiri Kosina
2009-08-18HID: local function should be staticH Hartley Sweeten
__usbhid_submit_report() is a local function wrapped by the exported symbol usbhid_submit_report(). As such, it should be static. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-07-23HID: Avoid double spin_lock_init on usbhid->lockSergey Senozhatsky
Avoid double spin_lock_init on usbhid->lock. Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@mail.by> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-07-12headers: smp_lock.h reduxAlexey Dobriyan
* Remove smp_lock.h from files which don't need it (including some headers!) * Add smp_lock.h to files which do need it * Make smp_lock.h include conditional in hardirq.h It's needed only for one kernel_locked() usage which is under CONFIG_PREEMPT This will make hardirq.h inclusion cheaper for every PREEMPT=n config (which includes allmodconfig/allyesconfig, BTW) Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-06-12HID: use debugfs for report dumping descriptorJiri Kosina
It is a little bit inconvenient for people who have some non-standard HID hardware (usually violating the HID specification) to have to recompile kernel with CONFIG_HID_DEBUG to be able to see kernel's perspective of the HID report descriptor and observe the parsed events. Plus the messages are then mixed up inconveniently with the rest of the dmesg stuff. This patch implements /sys/kernel/debug/hid/<device>/rdesc file, which represents the kernel's view of report descriptor (both the raw report descriptor data and parsed contents). With all the device-specific debug data being available through debugfs, there is no need for keeping CONFIG_HID_DEBUG, as the 'debug' parameter to the hid module will now only output only driver-specific debugging options, which has absolutely minimal memory footprint, just a few error messages and one global flag (hid_debug). We use the current set of output formatting functions. The ones that need to be used both for one-shot rdesc seq_file and also for continuous flow of data (individual reports, as being sent by the device) distinguish according to the passed seq_file parameter, and if it is NULL, it still output to kernel ringbuffer, otherwise the corresponding seq_file is used for output. The format of the output is preserved. Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-06-04HID: no more reinitializtion is needed in post_resetJiri Kosina
No more reinitialization is needed in the post reset hook, remove the FIXME comment. While at it, clean up whitespaces in the immediate surrounding. Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-05-11HID: fix dropped device-specific quirksZoltan Karcagi
Device-specific quirks are set up correctly in their respective vendor-specific driver, then get overwritten in usbhid_parse(). This is only issue for device-specific NOGET quirks being set by driver for a few devices out there. Signed-off-by: Zoltan Karcagi <zkr@freemail.hu> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-04-29HID: fix possible deadlock in usbhid_close()Oliver Neukum
This patch switches usbhid_close() from flush_scheduled_work() to canceling the outstanding work. This fixes a possible deadlock due to work taking the mutex usbhid_close() holds. Lockdep reported the problem. Signed-off-by: Oliver Neukum <oliver@neukum.org> -- Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-03-30Merge branch 'autosuspend' into for-nextJiri Kosina
Conflicts: drivers/hid/hid-core.c
2009-03-30HID: bring back possibility to specify vid/pid ignore on module loadJiri Kosina
When hid quirks were converted to specialized driver, the HID_QUIRK_IGNORE has been moved completely, as the hid_ignore_list[] has been moved into the generic code. However userspace already got used to the possibility that modprobing usbhid with 'quirks=vid:pid:0x4' makes the device ignored by usbhid driver. So keep this quirk flag in place for backwards compatibility. Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-03-25HID: autosuspend -- fix lockup of hid on resetOliver Neukum
This fixes a use of flush_scheduled_work() in USB HID's reset logic that can deadlock. Tested-by: Valdis Kletniks <Valdis.Kletnieks@vt.edu> Signed-off-by: Oliver Neukum <oliver@neukum.name> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-03-25HID: hid_reset_resume() needs to be defined only when CONFIG_PM is setJiri Kosina
There is no point of having hid_reset_resume() when CONFIG_PM is not set, and even the corresponding .reset_resume pointer in hid_driver struct is properly ifdefed. Move the definition into the ifdef CONFIG_PM part of the source to avoid drivers/hid/usbhid/hid-core.c:1337: warning: 'hid_reset_resume' defined but not used Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-03-25HID: fix USB HID devices after STD with autosuspendOliver Neukum
This patch fixes a bug caused by reset_resume not changing the internal status flags for a device that is resumed via reset_resume. To do so the reset handlers, which correctly assume that a device is awake, can no longer do all the work of reset_resume handling. Signed-off-by: Oliver Neukum <oneukum@suse.de> Tested-by: Laurent Riffard <laurent.riffard@free.fr> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-03-25HID: do not try to compile PM code with CONFIG_PM unsetJiri Kosina
Fixes this build breakage in case when CONFIG_PM is not set drivers/hid/usbhid/hid-core.c: In function 'hid_suspend': drivers/hid/usbhid/hid-core.c:1220: error: 'struct usb_device' has no member named 'auto_pm' drivers/hid/usbhid/hid-core.c:1245: error: 'struct usb_device' has no member named 'auto_pm' drivers/hid/usbhid/hid-core.c:1258: error: 'struct usb_device' has no member named 'auto_pm' by throwing both the hid_suspend() and hid_resume() away completely in such case, as they won't be used anyway. Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-03-25HID: autosuspend support for USB HIDOliver Neukum
This uses the USB busy mechanism for aggessive autosuspend of USB HID devices. It autosuspends all opened devices supporting remote wakeup after a timeout unless - output is being done to the device - a key is being held down (remote wakeup isn't triggered upon key release) - LED(s) are lit - hiddev is opened As in the current driver closed devices will be autosuspended even if they don't support remote wakeup. The patch is quite large because output to devices is done in hard interrupt context meaning a lot a queuing and locking had to be touched. The LED stuff has been solved by means of a simple counter. Additions to the generic HID code could be avoided. In addition it now covers hidraw. It contains an embryonic version of an API to let the generic HID code tell the lower levels which capabilities with respect to power management are needed. Signed-off-by: Oliver Neukum <oneukum@suse.de> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-01-07USB: change interface to usb_lock_device_for_reset()Alan Stern
This patch (as1161) changes the interface to usb_lock_device_for_reset(). The existing interface is apparently not very clear, judging from the fact that several of its callers don't use it correctly. The new interface always returns 0 for success and it always requires the caller to unlock the device afterward. The new routine will not return immediately if it is called while the driver's probe method is running. Instead it will wait until the probe is over and the device has been unlocked. This shouldn't cause any problems; I don't know of any cases where drivers call usb_lock_device_for_reset() during probe. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Cc: Pete Zaitcev <zaitcev@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-01-04HID: use GFP_KERNEL in hid_alloc_buffersJiri Slaby
We might sleep, so no problem to use GFP_KERNEL. While at it bring the function to coding style. Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-01-04HID: usbhid, use usb_endpoint_xfer_intJiri Slaby
Use usb_endpoint_xfer_int() instead of direct use of constants. Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-01-04HID: automatically call usbhid_set_leds in usbhid driverAlan Stern
This patch (as1146c) makes usbhid automatically call usbhid_set_leds() for any device that supports the keyboard boot protocol. In theory this should be perfectly safe. BIOSes send the LED output report as part of their normal device initialization, so any keyboard device supporting the boot protocol has to be able to handle it. As a side effect, the hid-dell and hid-bright drivers are no longer needed, and the Logitech keyboard driver can be removed from hid-lg. CC: Mauro Carvalho Chehab <mchehab@redhat.com> Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-01-04HID: non-input reports can also be numberedJiri Kosina
When computing the maximal buffer size needed, we must take into account that not only input reports can be numbered. Pointed out in bugzilla #10467 Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2008-11-23HID: remove setup mutex, fix possible deadlockJiri Slaby
It causes recursive locking warning and is unneeded after introduction of STARTED flag. * Resume vs. stop is effectively solved by DISCONNECT flag. * No problem in suspend vs. start -- urb is submitted even after open which is possible after connect which is called after start. * Resume vs. start solved by STARTED flag. * Suspend vs. stop -- no problem in killing urb and timer twice. Reported-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2008-11-14HID: don't grab devices with no inputJiri Slaby
Some devices have no input interrupt endpoint. These won't be handled by usbhid, but currently they are not refused and reside on hid bus. Perform this checking earlier so that we refuse to control such a device early enough (and not pass it to the hid bus at all). Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2008-11-13HID: fix start/stop cycle in usbhid driverJiri Slaby
`stop' left out usbhid->urb* pointers and so the next `start' thought it needs to allocate nothing and used the memory pointers previously pointed to. This led to memory corruption and device malfunction. Also don't forget to clear disconnect flag on start which was left set by the previous `stop'. This fixes echo DEVICE > /sys/bus/hid/drivers/DRIVER/unbind echo DEVICE > /sys/bus/hid/drivers/DRIVER/bind failures. Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2008-10-27HID: sync on deleted io_retry timer in usbhid driverJiri Slaby
When suspending, make sure that the timer is not running any more. Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2008-10-27HID: fix oops during suspend of unbound HID devicesJiri Slaby
Usbhid structure is allocated on start invoked only from probe of some driver. When there is no driver, the structure is null and causes null-dereference oopses. Fix it by allocating the structure on probe and disconnect of the device itself. Also make sure we won't race between start and resume or stop and suspend respectively. References: http://bugzilla.kernel.org/show_bug.cgi?id=11827 Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Cc: Johannes Berg <johannes@sipsolutions.net> Cc: Andreas Schwab <schwab@suse.de> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2008-10-26Merge branch 'for-linus' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid: HID: Add support for Sony Vaio VGX-TP1E HID: fix lock imbalance in hiddev HID: fix lock imbalance in hidraw HID: fix hidbus/appletouch device binding regression HID: add hid_type to general hid struct HID: quirk for OLED devices present in ASUS G50/G70/G71 HID: Remove "default m" for Thrustmaster and Zeroplus HID: fix hidraw_exit section mismatch HID: add support for another Gyration remote control Revert "HID: Invert HWHEEL mappings for some Logitech mice"
2008-10-22HID: add hid_type to general hid structJiri Slaby
Add type to the hid structure to distinguish to which device type (now only mouse) we are talking to. Needed for per device type ignore list support. Note: this patch leaves the type as unknown for bluetooth devices, there is not support for this in the hidp code. Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2008-10-17USB: remove warn macro from HID coreGreg Kroah-Hartman
There were two stragglers that got missed in the last merge of the HID tree that forgot to change the warn() calls to dev_warn(). This patch fixes them up. Acked-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-10-14HID: remove warn() macro from usb hid driversFrom: Greg Kroah-Hartman
USB should not be having it's own printk macros, so remove warn() and use the system-wide standard of dev_warn() wherever possible. In the few places that will not work out, use a basic printk(). Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2008-10-14HID: remove info() macro from usb HID driversGreg Kroah-Hartman
USB should not be having it's own printk macros, so remove info() and use the system-wide standard of dev_info() wherever possible. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2008-10-14HID: fix a lockup regression when using force feedback on a PID deviceAnssi Hannula
Commit 8006479c9b75fb6594a7b746af3d7f1fbb68f18f introduced a spinlock in input_dev->event_lock, which is locked when handling input events. However, the hid-pidff driver sleeps when handling events as it waits for reports being sent to the device before changing the report contents again. This causes a system lockup when trying to use force feedback with a PID device, a regression introduced in 2.6.24 and 2.6.23.15. Fix it by extracting the raw report data from struct hid_report immediately when hid_submit_report() is called, therefore allowing drivers to change the contents of struct hid_report immediately without affecting the already-queued transfer. In hid-pidff, re-add the removed usbhid_wait_io() to pidff_erase_effect() instead, to prevent a full report queue from causing the submission to fail, thus not freeing up device memory. pidff_erase_effect() is not called while dev->event_lock is held. Signed-off-by: Anssi Hannula <anssi.hannula@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2008-10-14HID: remove hid-ffJiri Slaby
hid-ff.c now calls only pidff (generic driver), the special ones are now in separate drivers. Invoke pidff on all non-special directly. Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2008-10-14HID: move logitech FF processingJiri Slaby
Merge the logitech force feedback processing directly into logitech driver from the usbhid core. Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2008-10-14HID: move reset leds quirkJiri Slaby
Move the handling of the leds resetting from the core to the dell and logitech drivers. Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2008-10-14HID: move connect quirksJiri Slaby
Move connecting from usbhid to the hid layer and fix also hidp in that manner. This removes all the ignore/force hidinput/hiddev connecting quirks. Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2008-10-14HID: move sony quirksJiri Slaby
Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2008-10-14HID: remove rdesc quirk supportJiri Slaby
Remove support for both dynamic and static report descriptor quirks. There is no longer rdesc code which it would support, so it's useless. Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>