Browse Source

staging: comedi: avoid a put_device(), get_device() sequence

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>
Ian Abbott 12 years ago
parent
commit
0a7717dfe0
1 changed files with 2 additions and 1 deletions
  1. 2 1
      drivers/staging/comedi/comedidev.h

+ 2 - 1
drivers/staging/comedi/comedidev.h

@@ -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);