patch-2.4.0-test2 linux/drivers/cdrom/sjcd.c

Next file: linux/drivers/cdrom/sonycd535.c
Previous file: linux/drivers/cdrom/sbpcd.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test1/linux/drivers/cdrom/sjcd.c linux/drivers/cdrom/sjcd.c
@@ -58,10 +58,7 @@
 #define SJCD_VERSION_MAJOR 1
 #define SJCD_VERSION_MINOR 7
 
-#ifdef MODULE
 #include <linux/module.h>
-#endif /* MODULE */
-
 #include <linux/errno.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
@@ -1339,6 +1336,8 @@
    */
   if( fp->f_mode & 2 ) return( -EROFS );
   
+  MOD_INC_USE_COUNT;
+
   if( sjcd_open_count == 0 ){
     int s, sjcd_open_tries;
 /* We don't know that, do we? */
@@ -1360,7 +1359,7 @@
 #if defined( SJCD_DIAGNOSTIC )
 	printk( "SJCD: open: timed out when check status.\n" );
 #endif
-	return( -EIO );
+	goto err_out;
       } else if( !sjcd_media_is_available ){
 #if defined( SJCD_DIAGNOSTIC )
 	printk("SJCD: open: no disk in drive\n");
@@ -1375,10 +1374,10 @@
 #if defined( SJCD_DIAGNOSTIC )
 	    printk("SJCD: open: tray close attempt failed\n");
 #endif
-	    return( -EIO );
+	    goto err_out;
 	  }
 	  continue;
-	} else return( -EIO );
+	} else goto err_out;
       }
       break;
     }
@@ -1387,17 +1386,19 @@
 #if defined( SJCD_DIAGNOSTIC )
       printk("SJCD: open: tray lock attempt failed\n");
 #endif
-      return( -EIO );
+      goto err_out;
     }
 #if defined( SJCD_TRACE )
     printk( "SJCD: open: done\n" );
 #endif
   }
-#ifdef MODULE
-  MOD_INC_USE_COUNT;
-#endif
+
   ++sjcd_open_count;
   return( 0 );
+
+err_out:
+  MOD_DEC_USE_COUNT;
+  return( -EIO );
 }
 
 /*
@@ -1564,8 +1565,8 @@
   }
 
   printk(KERN_INFO "SJCD: Status: port=0x%x.\n", sjcd_base);
-  devfs_register (NULL, "sjcd", 0, DEVFS_FL_DEFAULT, MAJOR_NR, 0,
-		  S_IFBLK | S_IRUGO | S_IWUGO, 0, 0, &sjcd_fops, NULL);
+  devfs_register (NULL, "sjcd", DEVFS_FL_DEFAULT, MAJOR_NR, 0,
+		  S_IFBLK | S_IRUGO | S_IWUGO, &sjcd_fops, NULL);
 
   sjcd_present++;
   return( 0 );

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)