fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / cdrom / aztcd.c
index 8503b19..ec46949 100644 (file)
                 Werner Zimmermann, August 8, 1995
         V1.70   Multisession support now is completed, but there is still not 
                 enough testing done. If you can test it, please contact me. For
                 Werner Zimmermann, August 8, 1995
         V1.70   Multisession support now is completed, but there is still not 
                 enough testing done. If you can test it, please contact me. For
-                details please read /usr/src/linux/Documentation/cdrom/aztcd
+                details please read Documentation/cdrom/aztcd
                 Werner Zimmermann, August 19, 1995
         V1.80   Modification to suit the new kernel boot procedure introduced
                 with kernel 1.3.33. Will definitely not work with older kernels.
                 Werner Zimmermann, August 19, 1995
         V1.80   Modification to suit the new kernel boot procedure introduced
                 with kernel 1.3.33. Will definitely not work with older kernels.
                         Torben Mathiasen <tmm@image.dk>
 */
 
                         Torben Mathiasen <tmm@image.dk>
 */
 
-#include <linux/version.h>
 #include <linux/blkdev.h>
 #include "aztcd.h"
 
 #include <linux/blkdev.h>
 #include "aztcd.h"
 
@@ -288,7 +287,7 @@ static volatile int azt_read_count = 1;
 
 static int azt_port = AZT_BASE_ADDR;
 
 
 static int azt_port = AZT_BASE_ADDR;
 
-MODULE_PARM(azt_port, "i");
+module_param(azt_port, int, 0);
 
 static int azt_port_auto[16] = AZT_BASE_AUTO;
 
 
 static int azt_port_auto[16] = AZT_BASE_AUTO;
 
@@ -298,7 +297,7 @@ static char azt_auto_eject = AZT_AUTO_EJECT;
 
 static int AztTimeout, AztTries;
 static DECLARE_WAIT_QUEUE_HEAD(azt_waitq);
 
 static int AztTimeout, AztTries;
 static DECLARE_WAIT_QUEUE_HEAD(azt_waitq);
-static struct timer_list delay_timer = TIMER_INITIALIZER(NULL, 0, 0);
+static DEFINE_TIMER(delay_timer, NULL, 0, 0);
 
 static struct azt_DiskInfo DiskInfo;
 static struct azt_Toc Toc[MAX_TRACKS];
 
 static struct azt_DiskInfo DiskInfo;
 static struct azt_Toc Toc[MAX_TRACKS];
@@ -312,7 +311,7 @@ static unsigned char aztIndatum;
 static unsigned long aztTimeOutCount;
 static int aztCmd = 0;
 
 static unsigned long aztTimeOutCount;
 static int aztCmd = 0;
 
-static spinlock_t aztSpin = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(aztSpin);
 
 /*###########################################################################
    Function Prototypes
 
 /*###########################################################################
    Function Prototypes
@@ -374,6 +373,7 @@ static void op_ok(void)
 }
 
 /* Wait for PA_OK = drive answers with AFL_PA_OK after receiving parameters*/
 }
 
 /* Wait for PA_OK = drive answers with AFL_PA_OK after receiving parameters*/
+#if 0
 # define PA_OK pa_ok()
 static void pa_ok(void)
 {
 # define PA_OK pa_ok()
 static void pa_ok(void)
 {
@@ -387,6 +387,7 @@ static void pa_ok(void)
                }
        } while (aztIndatum != AFL_PA_OK);
 }
                }
        } while (aztIndatum != AFL_PA_OK);
 }
+#endif
 
 /* Wait for STEN=Low = handshake signal 'AFL_.._OK available or command executed*/
 # define STEN_LOW  sten_low()
 
 /* Wait for STEN=Low = handshake signal 'AFL_.._OK available or command executed*/
 # define STEN_LOW  sten_low()
@@ -871,7 +872,7 @@ static int aztUpdateToc(void)
 /* Read the table of contents header, i.e. no. of tracks and start of first 
  * track
  */
 /* Read the table of contents header, i.e. no. of tracks and start of first 
  * track
  */
-static int aztGetDiskInfo()
+static int aztGetDiskInfo(void)
 {
        int limit;
        unsigned char test;
 {
        int limit;
        unsigned char test;
@@ -1165,6 +1166,7 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
        struct azt_Toc *tocPtr;
        struct cdrom_subchnl subchnl;
        struct cdrom_volctrl volctrl;
        struct azt_Toc *tocPtr;
        struct cdrom_subchnl subchnl;
        struct cdrom_volctrl volctrl;
+       void __user *argp = (void __user *)arg;
 
 #ifdef AZT_DEBUG
        printk("aztcd: starting aztcd_ioctl - Command:%x   Time: %li\n",
 
 #ifdef AZT_DEBUG
        printk("aztcd: starting aztcd_ioctl - Command:%x   Time: %li\n",
@@ -1228,8 +1230,7 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
 #ifdef AZT_DEBUG
                        printk("aztcd ioctl MULTISESSION\n");
 #endif
 #ifdef AZT_DEBUG
                        printk("aztcd ioctl MULTISESSION\n");
 #endif
-                       if (copy_from_user
-                           (&ms, (void *) arg,
+                       if (copy_from_user(&ms, argp,
                             sizeof(struct cdrom_multisession)))
                                return -EFAULT;
                        if (ms.addr_format == CDROM_MSF) {
                             sizeof(struct cdrom_multisession)))
                                return -EFAULT;
                        if (ms.addr_format == CDROM_MSF) {
@@ -1246,8 +1247,7 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
                        else
                                return -EINVAL;
                        ms.xa_flag = DiskInfo.xa;
                        else
                                return -EINVAL;
                        ms.xa_flag = DiskInfo.xa;
-                       if (copy_to_user
-                           ((void *) arg, &ms,
+                       if (copy_to_user(argp, &ms,
                             sizeof(struct cdrom_multisession)))
                                return -EFAULT;
 #ifdef AZT_DEBUG
                             sizeof(struct cdrom_multisession)))
                                return -EFAULT;
 #ifdef AZT_DEBUG
@@ -1270,7 +1270,7 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
                        return 0;
                }
        case CDROMPLAYTRKIND:   /* Play a track.  This currently ignores index. */
                        return 0;
                }
        case CDROMPLAYTRKIND:   /* Play a track.  This currently ignores index. */
-               if (copy_from_user(&ti, (void *) arg, sizeof ti))
+               if (copy_from_user(&ti, argp, sizeof ti))
                        return -EFAULT;
                if (ti.cdti_trk0 < DiskInfo.first
                    || ti.cdti_trk0 > DiskInfo.last
                        return -EFAULT;
                if (ti.cdti_trk0 < DiskInfo.first
                    || ti.cdti_trk0 > DiskInfo.last
@@ -1301,7 +1301,7 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
                  aztAudioStatus = CDROM_AUDIO_NO_STATUS;
                }
 */
                  aztAudioStatus = CDROM_AUDIO_NO_STATUS;
                }
 */
-               if (copy_from_user(&msf, (void *) arg, sizeof msf))
+               if (copy_from_user(&msf, argp, sizeof msf))
                        return -EFAULT;
                /* convert to bcd */
                azt_bin2bcd(&msf.cdmsf_min0);
                        return -EFAULT;
                /* convert to bcd */
                azt_bin2bcd(&msf.cdmsf_min0);
@@ -1333,11 +1333,11 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
        case CDROMREADTOCHDR:   /* Read the table of contents header */
                tocHdr.cdth_trk0 = DiskInfo.first;
                tocHdr.cdth_trk1 = DiskInfo.last;
        case CDROMREADTOCHDR:   /* Read the table of contents header */
                tocHdr.cdth_trk0 = DiskInfo.first;
                tocHdr.cdth_trk1 = DiskInfo.last;
-               if (copy_to_user((void *) arg, &tocHdr, sizeof tocHdr))
+               if (copy_to_user(argp, &tocHdr, sizeof tocHdr))
                        return -EFAULT;
                break;
        case CDROMREADTOCENTRY: /* Read an entry in the table of contents */
                        return -EFAULT;
                break;
        case CDROMREADTOCENTRY: /* Read an entry in the table of contents */
-               if (copy_from_user(&entry, (void *) arg, sizeof entry))
+               if (copy_from_user(&entry, argp, sizeof entry))
                        return -EFAULT;
                if ((!aztTocUpToDate) || aztDiskChanged)
                        aztUpdateToc();
                        return -EFAULT;
                if ((!aztTocUpToDate) || aztDiskChanged)
                        aztUpdateToc();
@@ -1363,12 +1363,12 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
                } else {
                        return -EINVAL;
                }
                } else {
                        return -EINVAL;
                }
-               if (copy_to_user((void *) arg, &entry, sizeof entry))
+               if (copy_to_user(argp, &entry, sizeof entry))
                        return -EFAULT;
                break;
        case CDROMSUBCHNL:      /* Get subchannel info */
                if (copy_from_user
                        return -EFAULT;
                break;
        case CDROMSUBCHNL:      /* Get subchannel info */
                if (copy_from_user
-                   (&subchnl, (void *) arg, sizeof(struct cdrom_subchnl)))
+                   (&subchnl, argp, sizeof(struct cdrom_subchnl)))
                        return -EFAULT;
                if (aztGetQChannelInfo(&qInfo) < 0) {
 #ifdef AZT_DEBUG
                        return -EFAULT;
                if (aztGetQChannelInfo(&qInfo) < 0) {
 #ifdef AZT_DEBUG
@@ -1403,16 +1403,14 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
                        subchnl.cdsc_reladdr.msf.frame =
                            azt_bcd2bin(qInfo.trackTime.frame);
                }
                        subchnl.cdsc_reladdr.msf.frame =
                            azt_bcd2bin(qInfo.trackTime.frame);
                }
-               if (copy_to_user
-                   ((void *) arg, &subchnl, sizeof(struct cdrom_subchnl)))
+               if (copy_to_user(argp, &subchnl, sizeof(struct cdrom_subchnl)))
                        return -EFAULT;
                break;
        case CDROMVOLCTRL:      /* Volume control 
                                   * With my Aztech CD268-01A volume control does not work, I can only
                                   turn the channels on (any value !=0) or off (value==0). Maybe it
                                   works better with your drive */
                        return -EFAULT;
                break;
        case CDROMVOLCTRL:      /* Volume control 
                                   * With my Aztech CD268-01A volume control does not work, I can only
                                   turn the channels on (any value !=0) or off (value==0). Maybe it
                                   works better with your drive */
-               if (copy_from_user
-                   (&volctrl, (char *) arg, sizeof(volctrl)))
+               if (copy_from_user(&volctrl, argp, sizeof(volctrl)))
                        return -EFAULT;
                azt_Play.start.min = 0x21;
                azt_Play.start.sec = 0x84;
                        return -EFAULT;
                azt_Play.start.min = 0x21;
                azt_Play.start.sec = 0x84;
@@ -1455,7 +1453,7 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
        case CDROMREADCOOKED:   /*read data in mode 1 (2048 Bytes) */
        case CDROMREADRAW:      /*read data in mode 2 (2336 Bytes) */
                {
        case CDROMREADCOOKED:   /*read data in mode 1 (2048 Bytes) */
        case CDROMREADRAW:      /*read data in mode 2 (2336 Bytes) */
                {
-                       if (copy_from_user(&msf, (void *) arg, sizeof msf))
+                       if (copy_from_user(&msf, argp, sizeof msf))
                                return -EFAULT;
                        /* convert to bcd */
                        azt_bin2bcd(&msf.cdmsf_min0);
                                return -EFAULT;
                        /* convert to bcd */
                        azt_bin2bcd(&msf.cdmsf_min0);
@@ -1474,16 +1472,11 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
                                if (DiskInfo.xa) {
                                        return -1;      /*XA Disks can't be read raw */
                                } else {
                                if (DiskInfo.xa) {
                                        return -1;      /*XA Disks can't be read raw */
                                } else {
-                                       if (sendAztCmd
-                                           (ACMD_PLAY_READ_RAW,
-                                            &azt_Play))
+                                       if (sendAztCmd(ACMD_PLAY_READ_RAW, &azt_Play))
                                                return -1;
                                        DTEN_LOW;
                                                return -1;
                                        DTEN_LOW;
-                                       insb(DATA_PORT, buf,
-                                            CD_FRAMESIZE_RAW);
-                                       if (copy_to_user
-                                           ((void *) arg, &buf,
-                                            CD_FRAMESIZE_RAW))
+                                       insb(DATA_PORT, buf, CD_FRAMESIZE_RAW);
+                                       if (copy_to_user(argp, &buf, CD_FRAMESIZE_RAW))
                                                return -EFAULT;
                                }
                        } else
                                                return -EFAULT;
                                }
                        } else
@@ -1492,14 +1485,13 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
                                        return -1;
                                DTEN_LOW;
                                insb(DATA_PORT, buf, CD_FRAMESIZE);
                                        return -1;
                                DTEN_LOW;
                                insb(DATA_PORT, buf, CD_FRAMESIZE);
-                               if (copy_to_user
-                                   ((void *) arg, &buf, CD_FRAMESIZE))
+                               if (copy_to_user(argp, &buf, CD_FRAMESIZE))
                                        return -EFAULT;
                                }
                }
                break;
        case CDROMSEEK: /*seek msf address */
                                        return -EFAULT;
                                }
                }
                break;
        case CDROMSEEK: /*seek msf address */
-               if (copy_from_user(&msf, (void *) arg, sizeof msf))
+               if (copy_from_user(&msf, argp, sizeof msf))
                        return -EFAULT;
                /* convert to bcd */
                azt_bin2bcd(&msf.cdmsf_min0);
                        return -EFAULT;
                /* convert to bcd */
                azt_bin2bcd(&msf.cdmsf_min0);
@@ -1715,8 +1707,8 @@ static int __init aztcd_init(void)
        printk(KERN_INFO "aztcd: (C) 1994-98 W.Zimmermann\n");
        if (azt_port == -1) {
                printk
        printk(KERN_INFO "aztcd: (C) 1994-98 W.Zimmermann\n");
        if (azt_port == -1) {
                printk
-                   ("aztcd: KernelVersion=%s DriverVersion=%s For IDE/ATAPI-drives use ide-cd.c\n",
-                    UTS_RELEASE, AZT_VERSION);
+                   ("aztcd: DriverVersion=%s For IDE/ATAPI-drives use ide-cd.c\n",
+                    AZT_VERSION);
        } else
                printk
                    ("aztcd: DriverVersion=%s BaseAddress=0x%x  For IDE/ATAPI-drives use ide-cd.c\n",
        } else
                printk
                    ("aztcd: DriverVersion=%s BaseAddress=0x%x  For IDE/ATAPI-drives use ide-cd.c\n",
@@ -1771,7 +1763,7 @@ static int __init aztcd_init(void)
                                release_region(azt_port, 4);
                        }
                }
                                release_region(azt_port, 4);
                        }
                }
-               if ((azt_port_auto[i] == 0) || (i == 16)) {
+               if ((i == 16) || (azt_port_auto[i] == 0)) {
                        printk(KERN_INFO "aztcd: no AZTECH CD-ROM drive found\n");
                        return -EIO;
                }
                        printk(KERN_INFO "aztcd: no AZTECH CD-ROM drive found\n");
                        return -EIO;
                }
@@ -1926,7 +1918,6 @@ static int __init aztcd_init(void)
        azt_disk->first_minor = 0;
        azt_disk->fops = &azt_fops;
        sprintf(azt_disk->disk_name, "aztcd");
        azt_disk->first_minor = 0;
        azt_disk->fops = &azt_fops;
        sprintf(azt_disk->disk_name, "aztcd");
-       sprintf(azt_disk->devfs_name, "aztcd");
        azt_disk->queue = azt_queue;
        add_disk(azt_disk);
        azt_invalidate_buffers();
        azt_disk->queue = azt_queue;
        add_disk(azt_disk);
        azt_invalidate_buffers();