Commit Graph

26 Commits

Author SHA1 Message Date
Linus Torvalds 03266d28ca Merge branch 'for-linus' of 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: fix possible deadlock in hidraw_read
  HID: fix kerneldoc comment for hid_input_report()
  HID: add __init/__exit macros to twinhan.c
2009-10-13 10:10:33 -07:00
Jiri Kosina b0e14951ee HID: fix possible deadlock in hidraw_read
If the loop in hidraw_read() loops more than once, then we might
end up trying to acquire already locked mutex, casuing a deadlock.

Reported-by: iceberg <iceberg@ispras.ru>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-10-12 11:25:56 +02:00
Alexey Dobriyan a99bbaf5ee headers: remove sched.h from poll.h
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2009-10-04 15:05:10 -07:00
Jiri Kosina bbe281fad6 HID: hidraw -- fix comment about accepted devices
hidraw accepts any devices, no matter if the device has
already been claimed by other HID driver (hid-input, hidraw), and
this is intended to stay. Fix up the comment to reflect reality.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-06-04 15:44:25 +02:00
Dan Carpenter 38089c658b HID: hidraw -- fix missing unlocks in unlocked_ioctl
There were 2 places that returned directly instead of releasing their
locks.  I sent a fix for this file earlier but ended up missing these
spots.  I think what happened is that I have improved my checker script
since then...  Or maybe I just screwed up.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-04-07 16:35:56 +02:00
Oliver Neukum 0361a28d3f HID: autosuspend support for USB HID
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-03-25 17:57:57 +01:00
Dan Carpenter dfd395aff4 HID: unlock properly on error paths in hidraw_ioctl()
We can't return immediately because lock_kernel() is held.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-02-17 13:25:01 +01:00
Jiri Kosina ed42350e02 Merge branch 'upstream-fixes' into for-next
Conflicts:

	drivers/hid/hid-ids.h
2009-01-04 01:04:09 +01:00
Oliver Neukum b8a832b1c0 HID: fix reference count leak hidraw
The hidraw subsystem has a bug that prevents the close syscall from ever
reaching the low level driver, leading to a resource leak. Fix by replacing
postdecrement with predecrement.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-01-04 01:01:43 +01:00
Jiri Kosina aae6c286da HID: set proper dev.parent in hidraw
We need to properly set parent of the hidraw device (which is the
corresponding physical device itself) in order to hidraw devices not
end up under virtual device tree.

Reported-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-01-04 01:00:52 +01:00
Jiri Kosina 9188e79ec3 HID: add phys and name ioctls to hidraw
The hiddev interface provides ioctl() calls which can be used
to obtain phys and raw name of the underlying device.

Add the corresponding support also into hidraw.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-01-04 01:00:51 +01:00
Oliver Neukum 7d672cd750 HID: fix locking in hidraw_open()
As open needs to sleep hidraw was wrong to call it with a spinlock held.
Furthermore, open can of course fail which needs to be handled.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2008-11-13 10:31:35 +01:00
Jiri Slaby 0f2c5945a9 HID: fix lock imbalance in hidraw
Add omitted unlock_kernel() to hidraw_ioctl().
Added in 979c407e3b
(HID: Push down BKL into ioctl handler in hidraw).

Corresponing sparse warning:
drivers/hid/hidraw.c:267:9: warning: context imbalance in 'hidraw_ioctl': wrong count at exit
drivers/hid/hidraw.c:267:9:    context 'kernel_lock': wanted 0, got 1

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2008-10-23 01:47:30 +02:00
Jiri Slaby 140ae3eb6f HID: fix hidraw_exit section mismatch
hidraw_exit() marked as __exit is called from __init function
from HID core. Remove the section placement from that function.

Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2008-10-17 18:08:22 +02:00
Greg Kroah-Hartman a9b12619f7 device create: misc: convert device_create_drvdata to device_create
Now that device_create() has been audited, rename things back to the
original call to be sane.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-10-16 09:24:43 -07:00
Jiri Kosina 2b107d629d HID: fix incorrent length condition in hidraw_write()
The bound check on the buffer length

	if (count > HID_MIN_BUFFER_SIZE)

is of course incorrent, the proper check is

	if (count > HID_MAX_BUFFER_SIZE)

Fix it.

Reported-by: Jerry Ryle <jerry@mindtribe.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2008-10-14 23:51:00 +02:00
Jiri Slaby c500c97140 HID: hid, make parsing event driven
Next step for complete hid bus, this patch includes:
- call parser either from probe or from hid-core if there is no probe.
- add ll_driver structure and centralize some stuff there (open, close...)
- split and merge usb_hid_configure and hid_probe into several functions
  to allow hooks/fixes between them

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2008-10-14 23:50:48 +02:00
Jiri Kosina b22d837006 Merge branches 'upstream' and 'upstream-fixes' into for-linus 2008-07-23 15:26:10 +02:00
Jiri Kosina 4db1c62c99 HID: fix memory leak in hidraw_release
hidraw_release() forgot to free the linked list structure, causing memory
leak.

Reported-by: Juan Marcos Diez Esteban <juan_m_diez@yahoo.es>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2008-07-23 15:25:21 +02:00
Alan Cox 979c407e3b HID: Push down BKL into ioctl handler in hidraw
In this case I simply wrapped it as code review suggests the locking
already terminally broken and I didn't want to make it first. See added
comment

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2008-07-23 15:21:55 +02:00
Greg Kroah-Hartman 0fd15a18d8 device create: hid: convert device_create to device_create_drvdata
device_create() is race-prone, so use the race-free
device_create_drvdata() instead as device_create() is going away.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-07-21 21:54:42 -07:00
Jonathan Corbet 702e57d9ef HID: cdev lock_kernel() pushdown
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2008-06-20 14:05:47 -06:00
Pavel Emelyanov ba25f9dcc4 Use helpers to obtain task pid in printks
The task_struct->pid member is going to be deprecated, so start
using the helpers (task_pid_nr/task_pid_vnr/task_pid_nr_ns) in
the kernel.

The first thing to start with is the pid, printed to dmesg - in
this case we may safely use task_pid_nr(). Besides, printks produce
more (much more) than a half of all the explicit pid usage.

[akpm@linux-foundation.org: git-drm went and changed lots of stuff]
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Cc: Dave Airlie <airlied@linux.ie>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-10-19 11:53:43 -07:00
Jiri Kosina 57d292bd7e HID: fix HIDIOCGRDESC memory access in hidraw
Fix bogus copying of data into userspace when HIDIOCGRDESC is issued.
HID-transport layer makes sure that dev->hid->rdesc is not larger than
HID_MAX_DESCRIPTOR_SIZE.

Noticed-by: Al Viro <viro@ftp.linux.org.uk>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-10-15 08:12:00 -07:00
Mariusz Kozlowski 709d27c04f HID: hidraw_connect() memleak fix
It looks like hidraw_connect() is leaking memory in case of failure.
Also it should return -ENOMEM when kzalloc fails.

Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2007-10-14 14:47:26 +02:00
Jiri Kosina 86166b7bcd HID: add hidraw interface
hidraw is an interface that is going to obsolete hiddev one
day.

Many userland applications are using libusb instead of using
kernel-provided hiddev interface. This is caused by various
reasons - the HID parser in kernel doesn't handle all the
HID hardware on the planet properly, some devices might require
its own specific quirks/drivers, etc.

hiddev interface tries to do its best to parse all the received
reports properly, and presents only parsed usages into userspace.
This is however often not enough, and that's the reason why
many userland applications just don't use hiddev at all, and
rather use libusb to read raw USB events and process them on
their own.

Another drawback of hiddev is that it is USB-specific.

hidraw interface provides userspace readers with really raw HID
reports, no matter what the low-level transport layer is (USB/BT),
and gives the userland applications all the freedom to process
the HID reports in a way they wish to.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2007-10-14 14:47:26 +02:00