fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / cdrom / mcdx.c
index d3cd4c1..f574962 100644 (file)
  */
 
 
-#if RCS
+#ifdef RCS
 static const char *mcdx_c_version
     = "$Id: mcdx.c,v 1.21 1997/01/26 07:12:59 davem Exp $";
 #endif
 
-#include <linux/version.h>
 #include <linux/module.h>
 
 #include <linux/errno.h>
@@ -75,10 +74,7 @@ static const char *mcdx_c_version
 #include <linux/major.h>
 #define MAJOR_NR MITSUMI_X_CDROM_MAJOR
 #include <linux/blkdev.h>
-#include <linux/devfs_fs_kernel.h>
 
-/* for compatible parameter passing with "insmod" */
-#define        mcdx_drive_map mcdx
 #include "mcdx.h"
 
 #ifndef HZ
@@ -110,20 +106,20 @@ static const char *mcdx_c_version
    The _direct_ size is the number of sectors we're allowed to skip
    directly (performing a read instead of requesting the new sector
    needed */
-const int REQUEST_SIZE = 800;  /* should be less then 255 * 4 */
-const int DIRECT_SIZE = 400;   /* should be less then REQUEST_SIZE */
+static const int REQUEST_SIZE = 800;   /* should be less then 255 * 4 */
+static const int DIRECT_SIZE = 400;    /* should be less then REQUEST_SIZE */
 
 enum drivemodes { TOC, DATA, RAW, COOKED };
 enum datamodes { MODE0, MODE1, MODE2 };
 enum resetmodes { SOFT, HARD };
 
-const int SINGLE = 0x01;       /* single speed drive (FX001S, LU) */
-const int DOUBLE = 0x02;       /* double speed drive (FX001D, ..? */
-const int DOOR = 0x04;         /* door locking capability */
-const int MULTI = 0x08;                /* multi session capability */
+static const int SINGLE = 0x01;                /* single speed drive (FX001S, LU) */
+static const int DOUBLE = 0x02;                /* double speed drive (FX001D, ..? */
+static const int DOOR = 0x04;          /* door locking capability */
+static const int MULTI = 0x08;         /* multi session capability */
 
-const unsigned char READ1X = 0xc0;
-const unsigned char READ2X = 0xc1;
+static const unsigned char READ1X = 0xc0;
+static const unsigned char READ2X = 0xc1;
 
 
 /* DECLARATIONS ****************************************************/
@@ -213,9 +209,7 @@ struct s_drive_stuff {
        repeated here to show what's going on.  And to sense, if they're
        changed elsewhere. */
 
-/* declared in blk.h */
-int mcdx_init(void);
-void do_mcdx_request(request_queue_t * q);
+static int mcdx_init(void);
 
 static int mcdx_block_open(struct inode *inode, struct file *file)
 {
@@ -233,7 +227,7 @@ static int mcdx_block_ioctl(struct inode *inode, struct file *file,
                                unsigned cmd, unsigned long arg)
 {
        struct s_drive_stuff *p = inode->i_bdev->bd_disk->private_data;
-       return cdrom_ioctl(&p->info, inode, cmd, arg);
+       return cdrom_ioctl(file, &p->info, inode, cmd, arg);
 }
 
 static int mcdx_block_media_changed(struct gendisk *disk)
@@ -307,12 +301,16 @@ static int mcdx_setattentuator(struct s_drive_stuff *,
 
 static int mcdx_drive_map[][2] = MCDX_DRIVEMAP;
 static struct s_drive_stuff *mcdx_stuffp[MCDX_NDRIVES];
-static struct s_drive_stuff *mcdx_irq_map[16] = { 0, 0, 0, 0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0, 0, 0, 0
-};
-static spinlock_t mcdx_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(mcdx_lock);
 static struct request_queue *mcdx_queue;
-MODULE_PARM(mcdx, "1-4i");
+
+/* You can only set the first two pairs, from old MODULE_PARM code.  */
+static int mcdx_set(const char *val, struct kernel_param *kp)
+{
+       get_options((char *)val, 4, (int *)mcdx_drive_map);
+       return 0;
+}
+module_param_call(mcdx, mcdx_set, NULL, NULL, 0);
 
 static struct cdrom_device_ops mcdx_dops = {
        .open           = mcdx_open,
@@ -568,7 +566,7 @@ static int mcdx_audio_ioctl(struct cdrom_device_info *cdi,
        }
 }
 
-void do_mcdx_request(request_queue_t * q)
+static void do_mcdx_request(request_queue_t * q)
 {
        struct s_drive_stuff *stuffp;
        struct request *req;
@@ -707,7 +705,7 @@ static int mcdx_open(struct cdrom_device_info *cdi, int purpose)
                xtrace(OPENCLOSE, "open() init irq generation\n");
                if (-1 == mcdx_config(stuffp, 1))
                        return -EIO;
-#if FALLBACK
+#ifdef FALLBACK
                /* Set the read speed */
                xwarn("AAA %x AAA\n", stuffp->readcmd);
                if (stuffp->readerrs)
@@ -847,17 +845,11 @@ static void mcdx_delay(struct s_drive_stuff *stuff, long jifs)
        }
 }
 
-static irqreturn_t mcdx_intr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t mcdx_intr(int irq, void *dev_id)
 {
-       struct s_drive_stuff *stuffp;
+       struct s_drive_stuff *stuffp = dev_id;
        unsigned char b;
 
-       stuffp = mcdx_irq_map[irq];
-
-       if (stuffp == NULL) {
-               xwarn("mcdx: no device for intr %d\n", irq);
-               return IRQ_NONE;
-       }
 #ifdef AK2
        if (!stuffp->busy && stuffp->pending)
                stuffp->int_err = 1;
@@ -1009,7 +1001,7 @@ static int mcdx_talk(struct s_drive_stuff *stuffp,
 
 /* MODULE STUFF ***********************************************************/
 
-int __mcdx_init(void)
+static int __init __mcdx_init(void)
 {
        int i;
        int drives = 0;
@@ -1029,7 +1021,7 @@ int __mcdx_init(void)
        return 0;
 }
 
-void __exit mcdx_exit(void)
+static void __exit mcdx_exit(void)
 {
        int i;
 
@@ -1076,7 +1068,7 @@ module_exit(mcdx_exit);
 
 /* Support functions ************************************************/
 
-int __init mcdx_init_drive(int drive)
+static int __init mcdx_init_drive(int drive)
 {
        struct s_version version;
        struct gendisk *disk;
@@ -1088,7 +1080,7 @@ int __init mcdx_init_drive(int drive)
 
        xtrace(INIT, "kmalloc space for stuffpt's\n");
        xtrace(MALLOC, "init() malloc %d bytes\n", size);
-       if (!(stuffp = kmalloc(size, GFP_KERNEL))) {
+       if (!(stuffp = kzalloc(size, GFP_KERNEL))) {
                xwarn("init() malloc failed\n");
                return 1;
        }
@@ -1104,8 +1096,6 @@ int __init mcdx_init_drive(int drive)
               sizeof(*stuffp), stuffp);
 
        /* set default values */
-       memset(stuffp, 0, sizeof(*stuffp));
-
        stuffp->present = 0;    /* this should be 0 already */
        stuffp->toc = NULL;     /* this should be NULL already */
 
@@ -1199,8 +1189,7 @@ int __init mcdx_init_drive(int drive)
        }
 
        xtrace(INIT, "init() subscribe irq and i/o\n");
-       mcdx_irq_map[stuffp->irq] = stuffp;
-       if (request_irq(stuffp->irq, mcdx_intr, SA_INTERRUPT, "mcdx", NULL)) {
+       if (request_irq(stuffp->irq, mcdx_intr, IRQF_DISABLED, "mcdx", stuffp)) {
                release_region(stuffp->wreg_data, MCDX_IO_SIZE);
                xwarn("%s=0x%03x,%d: Init failed. Can't get irq (%d).\n",
                      MCDX, stuffp->wreg_data, stuffp->irq, stuffp->irq);
@@ -1220,7 +1209,7 @@ int __init mcdx_init_drive(int drive)
        }
 
 
-#if WE_KNOW_WHY
+#ifdef WE_KNOW_WHY
        /* irq 11 -> channel register */
        outb(0x50, stuffp->wreg_chn);
 #endif
@@ -1247,8 +1236,8 @@ int __init mcdx_init_drive(int drive)
        xtrace(INIT, "init() mcdx_stuffp[%d] = %p\n", drive, stuffp);
        if (register_cdrom(&stuffp->info) != 0) {
                printk("Cannot register Mitsumi CD-ROM!\n");
-               release_region(stuffp->wreg_data, MCDX_IO_SIZE);
                free_irq(stuffp->irq, NULL);
+               release_region(stuffp->wreg_data, MCDX_IO_SIZE);
                kfree(stuffp);
                put_disk(disk);
                if (unregister_blkdev(MAJOR_NR, "mcdx") != 0)
@@ -1263,14 +1252,10 @@ int __init mcdx_init_drive(int drive)
        return 0;
 }
 
-int __init mcdx_init(void)
+static int __init mcdx_init(void)
 {
        int drive;
-#ifdef MODULE
-       xwarn("Version 2.14(hs) for " UTS_RELEASE "\n");
-#else
        xwarn("Version 2.14(hs) \n");
-#endif
 
        xwarn("$Id: mcdx.c,v 1.21 1997/01/26 07:12:59 davem Exp $\n");
 
@@ -1302,7 +1287,7 @@ static int mcdx_transfer(struct s_drive_stuff *stuffp,
 
        ans = mcdx_xfer(stuffp, p, sector, nr_sectors);
        return ans;
-#if FALLBACK
+#ifdef FALLBACK
        if (-1 == ans)
                stuffp->readerrs++;
        else