Skip to content

Commit

Permalink
staging: comedi: avoid a put_device(), get_device() sequence
Browse files Browse the repository at this point in the history
In `comedi_set_hw_dev()`, if there is no change to `dev->hw_dev` (and it
is not `NULL`), don't bother putting and getting the device.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Ian Abbott authored and Greg Kroah-Hartman committed Oct 22, 2012
1 parent 7f2f7e0 commit 0a7717d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/staging/comedi/comedidev.h
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,10 @@ into comedi's buffer */
static inline void comedi_set_hw_dev(struct comedi_device *dev,
struct device *hw_dev)
{
if (dev->hw_dev == hw_dev)
return;
if (dev->hw_dev)
put_device(dev->hw_dev);

dev->hw_dev = hw_dev;
if (dev->hw_dev) {
dev->hw_dev = get_device(dev->hw_dev);
Expand Down

0 comments on commit 0a7717d

Please sign in to comment.