]> git.karo-electronics.de Git - karo-tx-linux.git/commit
staging: comedi: comedi_bond: use bitmap to record opened/closed minors
authorIan Abbott <abbotti@mev.co.uk>
Fri, 23 Aug 2013 13:45:02 +0000 (14:45 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 26 Aug 2013 13:41:56 +0000 (06:41 -0700)
commitf59ebeda209306f10e33016b510996f54cc5248e
treed81ffb943c131bfdc1f2c6b756b5ec6a0dbf15a9
parent8fe73691f905a172fa6aa6800a9c08016c460b06
staging: comedi: comedi_bond: use bitmap to record opened/closed minors

`do_dev_config()` currently records the comedi minor devices it has
opened by setting `devs_opened[minor]` to the pointer returned by
`comedi_open()`.  This is checked to avoid opening the same minor device
twice.  The pointer values in `devs_opened[]` aren't needed; we only
need to record which minor device numbers are being used.  Change
`devs_opened` to a bitmap (declared with `DECLARE_BITMAP()`) of length
`COMEDI_NUM_BOARD_MINORS` as the minor device numbers are range-checked
to fit in a bitmap of this length.  Use `test_and_set_bit()` to record
the minor device numbers we attempt to open with `comedi_open()`.

`bonding_detach()` calls `comedi_close()` to close the comedi minor
devices.  Since the minor device numbers may be repeated in its list of
bonded subdevices, it currently uses a simple `unsigned long
devs_closed` variable as a bitmap to keep track of which minor device
numbers it has already closed to avoid closing them twice.  As a single
`unsigned long` consists of less than `COMEDI_NUM_BOARD_MINORS` bits on
a 32-bit machine, change `devs_closed to a bitmap of this length using
`DECLARE_BITMAP()` and use `test_and_set_bit()` to avoid calling
`comedi_close()` more than once for each minor device number in use.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/comedi_bond.c