From: Ian Abbott Date: Fri, 8 Nov 2013 15:03:24 +0000 (+0000) Subject: staging: comedi: add rw_semaphore to protect against device detachment X-Git-Tag: v3.14-rc1~150^2~775^2~101 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2f3fdcd7ce935f6f2899ceab57dc8fe5286db3e1;p=pandora-kernel.git staging: comedi: add rw_semaphore to protect against device detachment The 'read' and 'write' file operations on comedi devices do not use the main mutex in the `struct comedi_device` to avoid contention with ioctls that may take a while to complete. However, it is necessary to protect against the device being detached while the operation is in progress. Add member `struct rw_semaphore attach_lock` to `struct comedi_device` for this purpose and initialize it on creation. The actual locking and unlocking will be implemented by subsequent patches. Tasks that are attaching or detaching comedi devices will write-acquire the new semaphore whilst also holding the main mutex in the `struct comedi_device`. Tasks that wish to protect against the comedi device being detached need to acquire either the main mutex, or read-acquire the new semaphore, or both in that order. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- Reading git-diff-tree failed