staging: comedi: simplify comedi_set_hw_dev()
authorIan Abbott <abbotti@mev.co.uk>
Tue, 29 Jan 2013 16:20:17 +0000 (16:20 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 30 Jan 2013 04:11:41 +0000 (23:11 -0500)
commitbc3954b8147402e4495378d982cc8e708703a0f1
treee2624f32c9dea8b35e96586377a27d907a062931
parent104640606be0df6bcdb5ec7960a9c3c1278117ae
staging: comedi: simplify comedi_set_hw_dev()

Since `get_device()` and `put_device()` can take a NULL device
parameter, `comedi_set_hw_dev()` can be simplified to always call
`get_device()` for the new, possibly NULL hardware device, and
`put_device()` for the old, possibly NULL hardware device.  As long as
we do it in that order, there shouldn't be any problem with
`kref_release()` getting called unexpectedly when the new hardware
device is the old hardware device.

Simplify `comedi_set_hw_dev()` and update the comment because the
function is used for additional purposes since the old comment was
written.

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