Patch from abbotti@mev.co.uk (Ian Abbott):
authorFrank Mori Hess <fmhess@speakeasy.net>
Mon, 19 Jun 2006 01:21:38 +0000 (01:21 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Mon, 19 Jun 2006 01:21:38 +0000 (01:21 +0000)
The pcm3724 driver is still using the deprecated check_region() call.  Also, it
doesn't check if things were allocated properly when cleaning up in the detach
routine.

The attached patch fixes it.

comedi/drivers/pcm3724.c

index bb26a3eb78490c750c785bb00c2e147b5190ef34..f4f6644924d663177e6d10897d9285b872ee2e69 100644 (file)
@@ -272,12 +272,11 @@ static int pcm3724_attach(comedi_device *dev,comedi_devconfig *it)
 
        printk("comedi%d: pcm3724: board=%s, 0x%03x ",dev->minor,
                this_board->name,iobase);
-       if(check_region(iobase,iorange)<0){
+       if(!iobase || !request_region(iobase, iorange, "pcm3724")){
                printk("I/O port conflict\n");
                return -EIO;
        }
 
-        request_region(iobase, iorange, "pcm3724");
         dev->iobase=iobase;
        dev->board_name = this_board->name;
        printk("\n");
@@ -299,10 +298,14 @@ static int pcm3724_detach(comedi_device *dev)
 {
        int i;
 
-       for(i=0;i<dev->n_subdevices;i++){
-               subdev_8255_cleanup(dev,dev->subdevices+i);
+       if(dev->subdevices){
+               for(i=0;i<dev->n_subdevices;i++){
+                       subdev_8255_cleanup(dev,dev->subdevices+i);
+               }
+       }
+       if(dev->iobase){
+               release_region(dev->iobase,this_board->io_range);
        }
-       release_region(dev->iobase,this_board->io_range);
 
        return 0;
 }