X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fcdrom%2Foptcd.c;h=0b0eab4f40fa989dd9c215b089282bc8d8fa106a;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=7e9758fe7045cce03ac22e9299784b6ee509de1e;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/drivers/cdrom/optcd.c b/drivers/cdrom/optcd.c index 7e9758fe7..0b0eab4f4 100644 --- a/drivers/cdrom/optcd.c +++ b/drivers/cdrom/optcd.c @@ -116,7 +116,7 @@ static void debug(int debug_this, const char* fmt, ...) #define optcd_port optcd /* Needed for the modutils. */ static short optcd_port = OPTCD_PORTBASE; /* I/O base of drive. */ -MODULE_PARM(optcd_port, "h"); +module_param(optcd_port, short, 0); /* Drive registers, read */ #define DATA_PORT optcd_port /* Read data/status */ #define STATUS_PORT optcd_port+1 /* Indicate data/status availability */ @@ -245,7 +245,7 @@ MODULE_PARM(optcd_port, "h"); /* Busy wait until FLAG goes low. Return 0 on timeout. */ -inline static int flag_low(int flag, unsigned long timeout) +static inline int flag_low(int flag, unsigned long timeout) { int flag_high; unsigned long count = 0; @@ -264,8 +264,8 @@ inline static int flag_low(int flag, unsigned long timeout) static int sleep_timeout; /* max # of ticks to sleep */ static DECLARE_WAIT_QUEUE_HEAD(waitq); static void sleep_timer(unsigned long data); -static struct timer_list delay_timer = TIMER_INITIALIZER(sleep_timer, 0, 0); -static spinlock_t optcd_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_TIMER(delay_timer, sleep_timer, 0, 0); +static DEFINE_SPINLOCK(optcd_lock); static struct request_queue *opt_queue; /* Timer routine: wake up when desired flag goes low, @@ -381,7 +381,7 @@ static int send_seek_params(struct cdrom_msf *params) /* Wait for command execution status. Choice between busy waiting and sleeping. Return value <0 indicates timeout. */ -inline static int get_exec_status(int busy_waiting) +static inline int get_exec_status(int busy_waiting) { unsigned char exec_status; @@ -398,7 +398,7 @@ inline static int get_exec_status(int busy_waiting) /* Wait busy for extra byte of data that a command returns. Return value <0 indicates timeout. */ -inline static int get_data(int short_timeout) +static inline int get_data(int short_timeout) { unsigned char data; @@ -441,14 +441,14 @@ static int reset_drive(void) /* Facilities for asynchronous operation */ /* Read status/data availability flags FL_STEN and FL_DTEN */ -inline static int stdt_flags(void) +static inline int stdt_flags(void) { return inb(STATUS_PORT) & FL_STDT; } /* Fetch status that has previously been waited for. <0 means not available */ -inline static int fetch_status(void) +static inline int fetch_status(void) { unsigned char status; @@ -462,7 +462,7 @@ inline static int fetch_status(void) /* Fetch data that has previously been waited for. */ -inline static void fetch_data(char *buf, int n) +static inline void fetch_data(char *buf, int n) { insb(DATA_PORT, buf, n); DEBUG((DEBUG_DRIVE_IF, "fetched 0x%x bytes", n)); @@ -470,7 +470,7 @@ inline static void fetch_data(char *buf, int n) /* Flush status and data fifos */ -inline static void flush_data(void) +static inline void flush_data(void) { while ((inb(STATUS_PORT) & FL_STDT) != FL_STDT) inb(DATA_PORT); @@ -482,7 +482,7 @@ inline static void flush_data(void) /* Send a simple command and wait for response. Command codes < COMFETCH are quick response commands */ -inline static int exec_cmd(int cmd) +static inline int exec_cmd(int cmd) { int ack = send_cmd(cmd); if (ack < 0) @@ -493,7 +493,7 @@ inline static int exec_cmd(int cmd) /* Send a command with parameters. Don't wait for the response, * which consists of data blocks read from the CD. */ -inline static int exec_read_cmd(int cmd, struct cdrom_msf *params) +static inline int exec_read_cmd(int cmd, struct cdrom_msf *params) { int ack = send_cmd(cmd); if (ack < 0) @@ -503,7 +503,7 @@ inline static int exec_read_cmd(int cmd, struct cdrom_msf *params) /* Send a seek command with parameters and wait for response */ -inline static int exec_seek_cmd(int cmd, struct cdrom_msf *params) +static inline int exec_seek_cmd(int cmd, struct cdrom_msf *params) { int ack = send_cmd(cmd); if (ack < 0) @@ -516,7 +516,7 @@ inline static int exec_seek_cmd(int cmd, struct cdrom_msf *params) /* Send a command with parameters and wait for response */ -inline static int exec_long_cmd(int cmd, struct cdrom_msf *params) +static inline int exec_long_cmd(int cmd, struct cdrom_msf *params) { int ack = exec_read_cmd(cmd, params); if (ack < 0) @@ -528,7 +528,7 @@ inline static int exec_long_cmd(int cmd, struct cdrom_msf *params) /* Binary to BCD (2 digits) */ -inline static void single_bin2bcd(u_char *p) +static inline void single_bin2bcd(u_char *p) { DEBUG((DEBUG_CONV, "bin2bcd %02d", *p)); *p = (*p % 10) | ((*p / 10) << 4); @@ -565,7 +565,7 @@ static void lba2msf(int lba, struct cdrom_msf *msf) /* Two BCD digits to binary */ -inline static u_char bcd2bin(u_char bcd) +static inline u_char bcd2bin(u_char bcd) { DEBUG((DEBUG_CONV, "bcd2bin %x%02x", bcd)); return (bcd >> 4) * 10 + (bcd & 0x0f); @@ -964,7 +964,7 @@ static int update_toc(void) #endif /* MULTISESSION */ if (disk_info.multi) printk(KERN_WARNING "optcd: Multisession support experimental, " - "see linux/Documentation/cdrom/optcd\n"); + "see Documentation/cdrom/optcd\n"); DEBUG((DEBUG_TOC, "exiting update_toc")); @@ -988,7 +988,7 @@ static char buf[CD_FRAMESIZE * N_BUFS]; static volatile int buf_bn[N_BUFS], next_bn; static volatile int buf_in = 0, buf_out = NOBUF; -inline static void opt_invalidate_buffers(void) +static inline void opt_invalidate_buffers(void) { int i; @@ -1440,12 +1440,12 @@ static int cdromresume(void) } -static int cdromplaymsf(unsigned long arg) +static int cdromplaymsf(void __user *arg) { int status; struct cdrom_msf msf; - if (copy_from_user(&msf, (void *) arg, sizeof msf)) + if (copy_from_user(&msf, arg, sizeof msf)) return -EFAULT; bin2bcd(&msf); @@ -1461,13 +1461,13 @@ static int cdromplaymsf(unsigned long arg) } -static int cdromplaytrkind(unsigned long arg) +static int cdromplaytrkind(void __user *arg) { int status; struct cdrom_ti ti; struct cdrom_msf msf; - if (copy_from_user(&ti, (void *) arg, sizeof ti)) + if (copy_from_user(&ti, arg, sizeof ti)) return -EFAULT; if (ti.cdti_trk0 < disk_info.first @@ -1505,23 +1505,23 @@ static int cdromplaytrkind(unsigned long arg) } -static int cdromreadtochdr(unsigned long arg) +static int cdromreadtochdr(void __user *arg) { struct cdrom_tochdr tochdr; tochdr.cdth_trk0 = disk_info.first; tochdr.cdth_trk1 = disk_info.last; - return copy_to_user((void *)arg, &tochdr, sizeof tochdr) ? -EFAULT : 0; + return copy_to_user(arg, &tochdr, sizeof tochdr) ? -EFAULT : 0; } -static int cdromreadtocentry(unsigned long arg) +static int cdromreadtocentry(void __user *arg) { struct cdrom_tocentry entry; struct cdrom_subchnl *tocptr; - if (copy_from_user(&entry, (void *) arg, sizeof entry)) + if (copy_from_user(&entry, arg, sizeof entry)) return -EFAULT; if (entry.cdte_track == CDROM_LEADOUT) @@ -1544,17 +1544,17 @@ static int cdromreadtocentry(unsigned long arg) else if (entry.cdte_format != CDROM_MSF) return -EINVAL; - return copy_to_user((void *)arg, &entry, sizeof entry) ? -EFAULT : 0; + return copy_to_user(arg, &entry, sizeof entry) ? -EFAULT : 0; } -static int cdromvolctrl(unsigned long arg) +static int cdromvolctrl(void __user *arg) { int status; struct cdrom_volctrl volctrl; struct cdrom_msf msf; - if (copy_from_user(&volctrl, (char *) arg, sizeof volctrl)) + if (copy_from_user(&volctrl, arg, sizeof volctrl)) return -EFAULT; msf.cdmsf_min0 = 0x10; @@ -1573,12 +1573,12 @@ static int cdromvolctrl(unsigned long arg) } -static int cdromsubchnl(unsigned long arg) +static int cdromsubchnl(void __user *arg) { int status; struct cdrom_subchnl subchnl; - if (copy_from_user(&subchnl, (void *) arg, sizeof subchnl)) + if (copy_from_user(&subchnl, arg, sizeof subchnl)) return -EFAULT; if (subchnl.cdsc_format != CDROM_LBA @@ -1591,7 +1591,7 @@ static int cdromsubchnl(unsigned long arg) return -EIO; } - if (copy_to_user((void *)arg, &subchnl, sizeof subchnl)) + if (copy_to_user(arg, &subchnl, sizeof subchnl)) return -EFAULT; return 0; } @@ -1600,12 +1600,12 @@ static int cdromsubchnl(unsigned long arg) static struct gendisk *optcd_disk; -static int cdromread(unsigned long arg, int blocksize, int cmd) +static int cdromread(void __user *arg, int blocksize, int cmd) { int status; struct cdrom_msf msf; - if (copy_from_user(&msf, (void *) arg, sizeof msf)) + if (copy_from_user(&msf, arg, sizeof msf)) return -EFAULT; bin2bcd(&msf); @@ -1621,19 +1621,19 @@ static int cdromread(unsigned long arg, int blocksize, int cmd) fetch_data(optcd_disk->private_data, blocksize); - if (copy_to_user((void *)arg, optcd_disk->private_data, blocksize)) + if (copy_to_user(arg, optcd_disk->private_data, blocksize)) return -EFAULT; return 0; } -static int cdromseek(unsigned long arg) +static int cdromseek(void __user *arg) { int status; struct cdrom_msf msf; - if (copy_from_user(&msf, (void *)arg, sizeof msf)) + if (copy_from_user(&msf, arg, sizeof msf)) return -EFAULT; bin2bcd(&msf); @@ -1648,11 +1648,11 @@ static int cdromseek(unsigned long arg) #ifdef MULTISESSION -static int cdrommultisession(unsigned long arg) +static int cdrommultisession(void __user *arg) { struct cdrom_multisession ms; - if (copy_from_user(&ms, (void*) arg, sizeof ms)) + if (copy_from_user(&ms, arg, sizeof ms)) return -EFAULT; ms.addr.msf.minute = disk_info.last_session.minute; @@ -1667,7 +1667,7 @@ static int cdrommultisession(unsigned long arg) ms.xa_flag = disk_info.xa; - if (copy_to_user((void *)arg, &ms, sizeof(struct cdrom_multisession))) + if (copy_to_user(arg, &ms, sizeof(struct cdrom_multisession))) return -EFAULT; #if DEBUG_MULTIS @@ -1717,6 +1717,7 @@ static int opt_ioctl(struct inode *ip, struct file *fp, unsigned int cmd, unsigned long arg) { int status, err, retval = 0; + void __user *argp = (void __user *)arg; DEBUG((DEBUG_VFS, "starting opt_ioctl")); @@ -1767,10 +1768,10 @@ static int opt_ioctl(struct inode *ip, struct file *fp, switch (cmd) { case CDROMPAUSE: retval = cdrompause(); break; case CDROMRESUME: retval = cdromresume(); break; - case CDROMPLAYMSF: retval = cdromplaymsf(arg); break; - case CDROMPLAYTRKIND: retval = cdromplaytrkind(arg); break; - case CDROMREADTOCHDR: retval = cdromreadtochdr(arg); break; - case CDROMREADTOCENTRY: retval = cdromreadtocentry(arg); break; + case CDROMPLAYMSF: retval = cdromplaymsf(argp); break; + case CDROMPLAYTRKIND: retval = cdromplaytrkind(argp); break; + case CDROMREADTOCHDR: retval = cdromreadtochdr(argp); break; + case CDROMREADTOCENTRY: retval = cdromreadtocentry(argp); break; case CDROMSTOP: err = exec_cmd(COMSTOP); if (err < 0) { @@ -1799,8 +1800,8 @@ static int opt_ioctl(struct inode *ip, struct file *fp, } break; - case CDROMVOLCTRL: retval = cdromvolctrl(arg); break; - case CDROMSUBCHNL: retval = cdromsubchnl(arg); break; + case CDROMVOLCTRL: retval = cdromvolctrl(argp); break; + case CDROMSUBCHNL: retval = cdromsubchnl(argp); break; /* The drive detects the mode and automatically delivers the correct 2048 bytes, so we don't need these IOCTLs */ @@ -1814,7 +1815,7 @@ static int opt_ioctl(struct inode *ip, struct file *fp, break; #ifdef MULTISESSION - case CDROMMULTISESSION: retval = cdrommultisession(arg); break; + case CDROMMULTISESSION: retval = cdrommultisession(argp); break; #endif case CDROM_GET_MCN: retval = -EINVAL; break; /* not implemented */ @@ -1822,16 +1823,16 @@ static int opt_ioctl(struct inode *ip, struct file *fp, case CDROMREADRAW: /* this drive delivers 2340 bytes in raw mode */ - retval = cdromread(arg, CD_FRAMESIZE_RAW1, COMREADRAW); + retval = cdromread(argp, CD_FRAMESIZE_RAW1, COMREADRAW); break; case CDROMREADCOOKED: - retval = cdromread(arg, CD_FRAMESIZE, COMREAD); + retval = cdromread(argp, CD_FRAMESIZE, COMREAD); break; case CDROMREADALL: - retval = cdromread(arg, CD_FRAMESIZE_RAWER, COMREADALL); + retval = cdromread(argp, CD_FRAMESIZE_RAWER, COMREADALL); break; - case CDROMSEEK: retval = cdromseek(arg); break; + case CDROMSEEK: retval = cdromseek(argp); break; case CDROMPLAYBLK: retval = -EINVAL; break; /* not implemented */ case CDROMCLOSETRAY: break; /* The action was taken earlier */ default: retval = -EINVAL;