fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / cdrom / sonycd535.c
index 1d55bf8..f77ada9 100644 (file)
@@ -210,7 +210,7 @@ static int do_sony_cmd(Byte * cmd, int nCmd, Byte status[2],
 /* The base I/O address of the Sony Interface.  This is a variable (not a
    #define) so it can be easily changed via some future ioctl() */
 static unsigned int sony535_cd_base_io = CDU535_ADDRESS;
-MODULE_PARM(sony535_cd_base_io, "i");
+module_param(sony535_cd_base_io, int, 0);
 
 /*
  * The following are I/O addresses of the various registers for the drive.  The
@@ -222,7 +222,7 @@ static unsigned short command_reg;
 static unsigned short read_status_reg;
 static unsigned short data_reg;
 
-static spinlock_t sonycd535_lock = SPIN_LOCK_UNLOCKED; /* queue lock */
+static DEFINE_SPINLOCK(sonycd535_lock); /* queue lock */
 static struct request_queue *sonycd535_queue;
 
 static int initialized;                        /* Has the drive been initialized? */
@@ -322,7 +322,7 @@ disable_interrupts(void)
 }
 
 static irqreturn_t
-cdu535_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+cdu535_interrupt(int irq, void *dev_id)
 {
        disable_interrupts();
        if (waitqueue_active(&cdu535_irq_wait)) {
@@ -997,7 +997,7 @@ read_subcode(void)
  * (not BCD), so all the conversions are done.
  */
 static int
-sony_get_subchnl_info(long arg)
+sony_get_subchnl_info(void __user *arg)
 {
        struct cdrom_subchnl schi;
 
@@ -1009,7 +1009,7 @@ sony_get_subchnl_info(long arg)
        if (!sony_toc_read) {
                return -EIO;
        }
-       if (copy_from_user(&schi, (char *)arg, sizeof schi))
+       if (copy_from_user(&schi, arg, sizeof schi))
                return -EFAULT;
 
        switch (sony_audio_status) {
@@ -1025,7 +1025,7 @@ sony_get_subchnl_info(long arg)
 
        case CDROM_AUDIO_NO_STATUS:
                schi.cdsc_audiostatus = sony_audio_status;
-               if (copy_to_user((char *)arg, &schi, sizeof schi))
+               if (copy_to_user(arg, &schi, sizeof schi))
                        return -EFAULT;
                return 0;
                break;
@@ -1053,7 +1053,7 @@ sony_get_subchnl_info(long arg)
                schi.cdsc_absaddr.lba = msf_to_log(last_sony_subcode->abs_msf);
                schi.cdsc_reladdr.lba = msf_to_log(last_sony_subcode->rel_msf);
        }
-       return copy_to_user((char *)arg, &schi, sizeof schi) ? -EFAULT : 0;
+       return copy_to_user(arg, &schi, sizeof schi) ? -EFAULT : 0;
 }
 
 
@@ -1070,6 +1070,7 @@ cdu_ioctl(struct inode *inode,
        Byte cmd_buff[10], params[10];
        int  i;
        int  dsc_status;
+       void __user *argp = (void __user *)arg;
 
        if (check_drive_status() != 0)
                return -EIO;
@@ -1152,7 +1153,7 @@ cdu_ioctl(struct inode *inode,
                break;
 
        case CDROMPLAYMSF:                      /* Play starting at the given MSF address. */
-               if (copy_from_user(params, (void *)arg, 6))
+               if (copy_from_user(params, argp, 6))
                        return -EFAULT;
                spin_up_drive(status);
                set_drive_mode(SONY535_AUDIO_DRIVE_MODE, status);
@@ -1184,13 +1185,12 @@ cdu_ioctl(struct inode *inode,
 
        case CDROMREADTOCHDR:           /* Read the table of contents header */
                {
-                       struct cdrom_tochdr *hdr;
+                       struct cdrom_tochdr __user *hdr = argp;
                        struct cdrom_tochdr loc_hdr;
 
                        sony_get_toc();
                        if (!sony_toc_read)
                                return -EIO;
-                       hdr = (struct cdrom_tochdr *)arg;
                        loc_hdr.cdth_trk0 = bcd_to_int(sony_toc->first_track_num);
                        loc_hdr.cdth_trk1 = bcd_to_int(sony_toc->last_track_num);
                        if (copy_to_user(hdr, &loc_hdr, sizeof *hdr))
@@ -1201,7 +1201,7 @@ cdu_ioctl(struct inode *inode,
 
        case CDROMREADTOCENTRY: /* Read a given table of contents entry */
                {
-                       struct cdrom_tocentry *entry;
+                       struct cdrom_tocentry __user *entry = argp;
                        struct cdrom_tocentry loc_entry;
                        int  track_idx;
                        Byte *msf_val = NULL;
@@ -1210,7 +1210,6 @@ cdu_ioctl(struct inode *inode,
                        if (!sony_toc_read) {
                                return -EIO;
                        }
-                       entry = (struct cdrom_tocentry *)arg;
 
                        if (copy_from_user(&loc_entry, entry, sizeof loc_entry))
                                return -EFAULT;
@@ -1252,7 +1251,7 @@ cdu_ioctl(struct inode *inode,
                        if (!sony_toc_read)
                                return -EIO;
 
-                       if (copy_from_user(&ti, (char *)arg, sizeof ti))
+                       if (copy_from_user(&ti, argp, sizeof ti))
                                return -EFAULT;
                        if ((ti.cdti_trk0 < sony_toc->first_track_num)
                                || (sony_toc->last_track_num < ti.cdti_trk0)
@@ -1314,14 +1313,13 @@ cdu_ioctl(struct inode *inode,
                }
 
        case CDROMSUBCHNL:                      /* Get subchannel info */
-               return sony_get_subchnl_info(arg);
+               return sony_get_subchnl_info(argp);
 
        case CDROMVOLCTRL:                      /* Volume control.  What volume does this change, anyway? */
                {
                        struct cdrom_volctrl volctrl;
 
-                       if (copy_from_user(&volctrl, (char *)arg,
-                                          sizeof volctrl))
+                       if (copy_from_user(&volctrl, argp, sizeof volctrl))
                                return -EFAULT;
                        cmd_buff[0] = SONY535_SET_VOLUME;
                        cmd_buff[1] = volctrl.channel0;
@@ -1480,8 +1478,7 @@ static int __init sony535_init(void)
        /* look for the CD-ROM, follows the procedure in the DOS driver */
        inb(select_unit_reg);
        /* wait for 40 18 Hz ticks (reverse-engineered from DOS driver) */
-       set_current_state(TASK_INTERRUPTIBLE);
-       schedule_timeout((HZ+17)*40/18);
+       schedule_timeout_interruptible((HZ+17)*40/18);
        inb(result_reg);
 
        outb(0, read_status_reg);       /* does a reset? */
@@ -1530,7 +1527,7 @@ static int __init sony535_init(void)
        }
        if (sony535_irq_used > 0) {
            if (request_irq(sony535_irq_used, cdu535_interrupt,
-                                               SA_INTERRUPT, CDU535_HANDLE, NULL)) {
+                                               IRQF_DISABLED, CDU535_HANDLE, NULL)) {
                        printk("Unable to grab IRQ%d for the " CDU535_MESSAGE_NAME
                                        " driver; polling instead.\n", sony535_irq_used);
                        sony535_irq_used = 0;
@@ -1592,7 +1589,6 @@ static int __init sony535_init(void)
        cdu_disk->first_minor = 0;
        cdu_disk->fops = &cdu_fops;
        sprintf(cdu_disk->disk_name, "cdu");
-       sprintf(cdu_disk->devfs_name, "cdu535");
 
        if (!request_region(sony535_cd_base_io, 4, CDU535_HANDLE)) {
                printk(KERN_WARNING"sonycd535: Unable to request region 0x%x\n",
@@ -1607,8 +1603,7 @@ out7:
        put_disk(cdu_disk);
 out6:
        for (i = 0; i < sony_buffer_sectors; i++)
-               if (sony_buffer[i]) 
-                       kfree(sony_buffer[i]);
+               kfree(sony_buffer[i]);
 out5:
        kfree(sony_buffer);
 out4: