]> git.ipfire.org Git - thirdparty/linux.git/commit - drivers/comedi/comedi_fops.c
staging: comedi: add comedi_clear_board_dev()
authorIan Abbott <abbotti@mev.co.uk>
Thu, 4 Apr 2013 13:59:18 +0000 (14:59 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 5 Apr 2013 21:33:29 +0000 (14:33 -0700)
commitdb210da268ec537f8944ea5bc490184a6707c8a2
tree5a5ed884253e3c9c582484a5b4c77c282ab2220e
parentc6f5b4d587a46fc0713cecc30ef3993c59b7e41e
staging: comedi: add comedi_clear_board_dev()

Add local function `comedi_clear_board_dev()` as a safer alternative to
`comedi_clear_board_minor()` when we already have a pointer to a `struct
comedi_device`.  It uses the board minor device number stored in the
`struct comedi_device` (which must have already been initialized) and
only clears the entry in `comedi_board_minor_table[]` if it points to
the specified `struct comedi_device`.  Rather than returning the old
table entry, it returns `true` if the entry matched (and so has just
been cleared) and returns `false` otherwise.

Call `comedi_clear_board_dev()` instead of `comedi_clear_board_minor()`
in `comedi_unlocked_ioctl()` (in the code that frees a dynamically
allocated comedi device detached by the `COMEDI_DEVCONFIG` ioctl).  That
ought to return `true` but check it just in case before freeing the
device.  There is still a race condition here which needs to be dealt
with once we've implemented reference counting for `struct
comedi_device`s.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/comedi_fops.c