OSDN Git Service

staging: comedi: pcmmio: remove unneeded checks on detach
authorIan Abbott <abbotti@mev.co.uk>
Tue, 20 Aug 2013 15:55:41 +0000 (16:55 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 22 Aug 2013 17:07:49 +0000 (10:07 -0700)
As pointed out by Dan carpenter for the similar pcmuio driver, there is
no need to check the pointer passed to `kfree()`, so remove that check
from `pcmmio_detach()`.

Also, check the `devpriv` (`dev->private`) pointer once, outside the
`for` loop.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/pcmmio.c

index aa3c030..574443d 100644 (file)
@@ -1156,12 +1156,13 @@ static void pcmmio_detach(struct comedi_device *dev)
        struct pcmmio_private *devpriv = dev->private;
        int i;
 
-       for (i = 0; i < MAX_ASICS; ++i) {
-               if (devpriv && devpriv->asics[i].irq)
-                       free_irq(devpriv->asics[i].irq, dev);
-       }
-       if (devpriv && devpriv->sprivs)
+       if (devpriv) {
+               for (i = 0; i < MAX_ASICS; ++i) {
+                       if (devpriv->asics[i].irq)
+                               free_irq(devpriv->asics[i].irq, dev);
+               }
                kfree(devpriv->sprivs);
+       }
        comedi_legacy_detach(dev);
 }