Commit bd12c17c authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] sparse: drivers/cdrom annotation

parent 4743adaa
...@@ -873,7 +873,7 @@ static int aztUpdateToc(void) ...@@ -873,7 +873,7 @@ static int aztUpdateToc(void)
/* Read the table of contents header, i.e. no. of tracks and start of first /* Read the table of contents header, i.e. no. of tracks and start of first
* track * track
*/ */
static int aztGetDiskInfo() static int aztGetDiskInfo(void)
{ {
int limit; int limit;
unsigned char test; unsigned char test;
...@@ -1167,6 +1167,7 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd, ...@@ -1167,6 +1167,7 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
struct azt_Toc *tocPtr; struct azt_Toc *tocPtr;
struct cdrom_subchnl subchnl; struct cdrom_subchnl subchnl;
struct cdrom_volctrl volctrl; struct cdrom_volctrl volctrl;
void __user *argp = (void __user *)arg;
#ifdef AZT_DEBUG #ifdef AZT_DEBUG
printk("aztcd: starting aztcd_ioctl - Command:%x Time: %li\n", printk("aztcd: starting aztcd_ioctl - Command:%x Time: %li\n",
...@@ -1230,8 +1231,7 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd, ...@@ -1230,8 +1231,7 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
#ifdef AZT_DEBUG #ifdef AZT_DEBUG
printk("aztcd ioctl MULTISESSION\n"); printk("aztcd ioctl MULTISESSION\n");
#endif #endif
if (copy_from_user if (copy_from_user(&ms, argp,
(&ms, (void *) arg,
sizeof(struct cdrom_multisession))) sizeof(struct cdrom_multisession)))
return -EFAULT; return -EFAULT;
if (ms.addr_format == CDROM_MSF) { if (ms.addr_format == CDROM_MSF) {
...@@ -1248,8 +1248,7 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd, ...@@ -1248,8 +1248,7 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
else else
return -EINVAL; return -EINVAL;
ms.xa_flag = DiskInfo.xa; ms.xa_flag = DiskInfo.xa;
if (copy_to_user if (copy_to_user(argp, &ms,
((void *) arg, &ms,
sizeof(struct cdrom_multisession))) sizeof(struct cdrom_multisession)))
return -EFAULT; return -EFAULT;
#ifdef AZT_DEBUG #ifdef AZT_DEBUG
...@@ -1272,7 +1271,7 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd, ...@@ -1272,7 +1271,7 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
return 0; return 0;
} }
case CDROMPLAYTRKIND: /* Play a track. This currently ignores index. */ 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; return -EFAULT;
if (ti.cdti_trk0 < DiskInfo.first if (ti.cdti_trk0 < DiskInfo.first
|| ti.cdti_trk0 > DiskInfo.last || ti.cdti_trk0 > DiskInfo.last
...@@ -1303,7 +1302,7 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd, ...@@ -1303,7 +1302,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; return -EFAULT;
/* convert to bcd */ /* convert to bcd */
azt_bin2bcd(&msf.cdmsf_min0); azt_bin2bcd(&msf.cdmsf_min0);
...@@ -1335,11 +1334,11 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd, ...@@ -1335,11 +1334,11 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
case CDROMREADTOCHDR: /* Read the table of contents header */ case CDROMREADTOCHDR: /* Read the table of contents header */
tocHdr.cdth_trk0 = DiskInfo.first; tocHdr.cdth_trk0 = DiskInfo.first;
tocHdr.cdth_trk1 = DiskInfo.last; tocHdr.cdth_trk1 = DiskInfo.last;
if (copy_to_user((void *) arg, &tocHdr, sizeof tocHdr)) if (copy_to_user(argp, &tocHdr, sizeof tocHdr))
return -EFAULT; return -EFAULT;
break; break;
case CDROMREADTOCENTRY: /* Read an entry in the table of contents */ 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; return -EFAULT;
if ((!aztTocUpToDate) || aztDiskChanged) if ((!aztTocUpToDate) || aztDiskChanged)
aztUpdateToc(); aztUpdateToc();
...@@ -1365,12 +1364,12 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd, ...@@ -1365,12 +1364,12 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
} else { } else {
return -EINVAL; return -EINVAL;
} }
if (copy_to_user((void *) arg, &entry, sizeof entry)) if (copy_to_user(argp, &entry, sizeof entry))
return -EFAULT; return -EFAULT;
break; break;
case CDROMSUBCHNL: /* Get subchannel info */ case CDROMSUBCHNL: /* Get subchannel info */
if (copy_from_user if (copy_from_user
(&subchnl, (void *) arg, sizeof(struct cdrom_subchnl))) (&subchnl, argp, sizeof(struct cdrom_subchnl)))
return -EFAULT; return -EFAULT;
if (aztGetQChannelInfo(&qInfo) < 0) { if (aztGetQChannelInfo(&qInfo) < 0) {
#ifdef AZT_DEBUG #ifdef AZT_DEBUG
...@@ -1405,16 +1404,14 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd, ...@@ -1405,16 +1404,14 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
subchnl.cdsc_reladdr.msf.frame = subchnl.cdsc_reladdr.msf.frame =
azt_bcd2bin(qInfo.trackTime.frame); azt_bcd2bin(qInfo.trackTime.frame);
} }
if (copy_to_user if (copy_to_user(argp, &subchnl, sizeof(struct cdrom_subchnl)))
((void *) arg, &subchnl, sizeof(struct cdrom_subchnl)))
return -EFAULT; return -EFAULT;
break; break;
case CDROMVOLCTRL: /* Volume control case CDROMVOLCTRL: /* Volume control
* With my Aztech CD268-01A volume control does not work, I can only * 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 turn the channels on (any value !=0) or off (value==0). Maybe it
works better with your drive */ works better with your drive */
if (copy_from_user if (copy_from_user(&volctrl, argp, sizeof(volctrl)))
(&volctrl, (char *) arg, sizeof(volctrl)))
return -EFAULT; return -EFAULT;
azt_Play.start.min = 0x21; azt_Play.start.min = 0x21;
azt_Play.start.sec = 0x84; azt_Play.start.sec = 0x84;
...@@ -1457,7 +1454,7 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd, ...@@ -1457,7 +1454,7 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
case CDROMREADCOOKED: /*read data in mode 1 (2048 Bytes) */ case CDROMREADCOOKED: /*read data in mode 1 (2048 Bytes) */
case CDROMREADRAW: /*read data in mode 2 (2336 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; return -EFAULT;
/* convert to bcd */ /* convert to bcd */
azt_bin2bcd(&msf.cdmsf_min0); azt_bin2bcd(&msf.cdmsf_min0);
...@@ -1476,16 +1473,11 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd, ...@@ -1476,16 +1473,11 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
if (DiskInfo.xa) { if (DiskInfo.xa) {
return -1; /*XA Disks can't be read raw */ return -1; /*XA Disks can't be read raw */
} else { } else {
if (sendAztCmd if (sendAztCmd(ACMD_PLAY_READ_RAW, &azt_Play))
(ACMD_PLAY_READ_RAW,
&azt_Play))
return -1; return -1;
DTEN_LOW; DTEN_LOW;
insb(DATA_PORT, buf, insb(DATA_PORT, buf, CD_FRAMESIZE_RAW);
CD_FRAMESIZE_RAW); if (copy_to_user(argp, &buf, CD_FRAMESIZE_RAW))
if (copy_to_user
((void *) arg, &buf,
CD_FRAMESIZE_RAW))
return -EFAULT; return -EFAULT;
} }
} else } else
...@@ -1494,14 +1486,13 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd, ...@@ -1494,14 +1486,13 @@ static int aztcd_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
return -1; return -1;
DTEN_LOW; DTEN_LOW;
insb(DATA_PORT, buf, CD_FRAMESIZE); insb(DATA_PORT, buf, CD_FRAMESIZE);
if (copy_to_user if (copy_to_user(argp, &buf, CD_FRAMESIZE))
((void *) arg, &buf, CD_FRAMESIZE))
return -EFAULT; return -EFAULT;
} }
} }
break; break;
case CDROMSEEK: /*seek msf address */ case CDROMSEEK: /*seek msf address */
if (copy_from_user(&msf, (void *) arg, sizeof msf)) if (copy_from_user(&msf, argp, sizeof msf))
return -EFAULT; return -EFAULT;
/* convert to bcd */ /* convert to bcd */
azt_bin2bcd(&msf.cdmsf_min0); azt_bin2bcd(&msf.cdmsf_min0);
......
...@@ -2595,10 +2595,9 @@ static int read_audio(struct cdrom_read_audio *ra) ...@@ -2595,10 +2595,9 @@ static int read_audio(struct cdrom_read_audio *ra)
retval = -EIO; retval = -EIO;
goto exit_read_audio; goto exit_read_audio;
} }
} else if (copy_to_user((char *)(ra->buf + } else if (copy_to_user(ra->buf +
(CD_FRAMESIZE_RAW (CD_FRAMESIZE_RAW
* cframe)), * cframe),
(char *)
readahead_buffer, readahead_buffer,
CD_FRAMESIZE_RAW)) { CD_FRAMESIZE_RAW)) {
retval = -EFAULT; retval = -EFAULT;
...@@ -2612,8 +2611,7 @@ static int read_audio(struct cdrom_read_audio *ra) ...@@ -2612,8 +2611,7 @@ static int read_audio(struct cdrom_read_audio *ra)
retval = -EIO; retval = -EIO;
goto exit_read_audio; goto exit_read_audio;
} }
} else if (copy_to_user((char *)(ra->buf + (CD_FRAMESIZE_RAW * } else if (copy_to_user(ra->buf + (CD_FRAMESIZE_RAW * cframe),
cframe)),
(char *)readahead_buffer, (char *)readahead_buffer,
CD_FRAMESIZE_RAW)) { CD_FRAMESIZE_RAW)) {
retval = -EFAULT; retval = -EFAULT;
...@@ -2945,6 +2943,7 @@ static int scd_audio_ioctl(struct cdrom_device_info *cdi, ...@@ -2945,6 +2943,7 @@ static int scd_audio_ioctl(struct cdrom_device_info *cdi,
static int scd_dev_ioctl(struct cdrom_device_info *cdi, static int scd_dev_ioctl(struct cdrom_device_info *cdi,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
void __user *argp = (void __user *)arg;
int i; int i;
switch (cmd) { switch (cmd) {
...@@ -2959,7 +2958,7 @@ static int scd_dev_ioctl(struct cdrom_device_info *cdi, ...@@ -2959,7 +2958,7 @@ static int scd_dev_ioctl(struct cdrom_device_info *cdi,
return -EIO; return -EIO;
} }
if (copy_from_user(&ra, (char *) arg, sizeof(ra))) if (copy_from_user(&ra, argp, sizeof(ra)))
return -EFAULT; return -EFAULT;
if (ra.nframes == 0) { if (ra.nframes == 0) {
......
...@@ -1440,12 +1440,12 @@ static int cdromresume(void) ...@@ -1440,12 +1440,12 @@ static int cdromresume(void)
} }
static int cdromplaymsf(unsigned long arg) static int cdromplaymsf(void __user *arg)
{ {
int status; int status;
struct cdrom_msf msf; struct cdrom_msf msf;
if (copy_from_user(&msf, (void *) arg, sizeof msf)) if (copy_from_user(&msf, arg, sizeof msf))
return -EFAULT; return -EFAULT;
bin2bcd(&msf); bin2bcd(&msf);
...@@ -1461,13 +1461,13 @@ static int cdromplaymsf(unsigned long arg) ...@@ -1461,13 +1461,13 @@ static int cdromplaymsf(unsigned long arg)
} }
static int cdromplaytrkind(unsigned long arg) static int cdromplaytrkind(void __user *arg)
{ {
int status; int status;
struct cdrom_ti ti; struct cdrom_ti ti;
struct cdrom_msf msf; struct cdrom_msf msf;
if (copy_from_user(&ti, (void *) arg, sizeof ti)) if (copy_from_user(&ti, arg, sizeof ti))
return -EFAULT; return -EFAULT;
if (ti.cdti_trk0 < disk_info.first if (ti.cdti_trk0 < disk_info.first
...@@ -1505,23 +1505,23 @@ static int cdromplaytrkind(unsigned long arg) ...@@ -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; struct cdrom_tochdr tochdr;
tochdr.cdth_trk0 = disk_info.first; tochdr.cdth_trk0 = disk_info.first;
tochdr.cdth_trk1 = disk_info.last; 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_tocentry entry;
struct cdrom_subchnl *tocptr; struct cdrom_subchnl *tocptr;
if (copy_from_user(&entry, (void *) arg, sizeof entry)) if (copy_from_user(&entry, arg, sizeof entry))
return -EFAULT; return -EFAULT;
if (entry.cdte_track == CDROM_LEADOUT) if (entry.cdte_track == CDROM_LEADOUT)
...@@ -1544,17 +1544,17 @@ static int cdromreadtocentry(unsigned long arg) ...@@ -1544,17 +1544,17 @@ static int cdromreadtocentry(unsigned long arg)
else if (entry.cdte_format != CDROM_MSF) else if (entry.cdte_format != CDROM_MSF)
return -EINVAL; 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; int status;
struct cdrom_volctrl volctrl; struct cdrom_volctrl volctrl;
struct cdrom_msf msf; struct cdrom_msf msf;
if (copy_from_user(&volctrl, (char *) arg, sizeof volctrl)) if (copy_from_user(&volctrl, arg, sizeof volctrl))
return -EFAULT; return -EFAULT;
msf.cdmsf_min0 = 0x10; msf.cdmsf_min0 = 0x10;
...@@ -1573,12 +1573,12 @@ static int cdromvolctrl(unsigned long arg) ...@@ -1573,12 +1573,12 @@ static int cdromvolctrl(unsigned long arg)
} }
static int cdromsubchnl(unsigned long arg) static int cdromsubchnl(void __user *arg)
{ {
int status; int status;
struct cdrom_subchnl subchnl; struct cdrom_subchnl subchnl;
if (copy_from_user(&subchnl, (void *) arg, sizeof subchnl)) if (copy_from_user(&subchnl, arg, sizeof subchnl))
return -EFAULT; return -EFAULT;
if (subchnl.cdsc_format != CDROM_LBA if (subchnl.cdsc_format != CDROM_LBA
...@@ -1591,7 +1591,7 @@ static int cdromsubchnl(unsigned long arg) ...@@ -1591,7 +1591,7 @@ static int cdromsubchnl(unsigned long arg)
return -EIO; return -EIO;
} }
if (copy_to_user((void *)arg, &subchnl, sizeof subchnl)) if (copy_to_user(arg, &subchnl, sizeof subchnl))
return -EFAULT; return -EFAULT;
return 0; return 0;
} }
...@@ -1600,12 +1600,12 @@ static int cdromsubchnl(unsigned long arg) ...@@ -1600,12 +1600,12 @@ static int cdromsubchnl(unsigned long arg)
static struct gendisk *optcd_disk; 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; int status;
struct cdrom_msf msf; struct cdrom_msf msf;
if (copy_from_user(&msf, (void *) arg, sizeof msf)) if (copy_from_user(&msf, arg, sizeof msf))
return -EFAULT; return -EFAULT;
bin2bcd(&msf); bin2bcd(&msf);
...@@ -1621,19 +1621,19 @@ static int cdromread(unsigned long arg, int blocksize, int cmd) ...@@ -1621,19 +1621,19 @@ static int cdromread(unsigned long arg, int blocksize, int cmd)
fetch_data(optcd_disk->private_data, blocksize); 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 -EFAULT;
return 0; return 0;
} }
static int cdromseek(unsigned long arg) static int cdromseek(void __user *arg)
{ {
int status; int status;
struct cdrom_msf msf; struct cdrom_msf msf;
if (copy_from_user(&msf, (void *)arg, sizeof msf)) if (copy_from_user(&msf, arg, sizeof msf))
return -EFAULT; return -EFAULT;
bin2bcd(&msf); bin2bcd(&msf);
...@@ -1648,11 +1648,11 @@ static int cdromseek(unsigned long arg) ...@@ -1648,11 +1648,11 @@ static int cdromseek(unsigned long arg)
#ifdef MULTISESSION #ifdef MULTISESSION
static int cdrommultisession(unsigned long arg) static int cdrommultisession(void __user *arg)
{ {
struct cdrom_multisession ms; struct cdrom_multisession ms;
if (copy_from_user(&ms, (void*) arg, sizeof ms)) if (copy_from_user(&ms, arg, sizeof ms))
return -EFAULT; return -EFAULT;
ms.addr.msf.minute = disk_info.last_session.minute; ms.addr.msf.minute = disk_info.last_session.minute;
...@@ -1667,7 +1667,7 @@ static int cdrommultisession(unsigned long arg) ...@@ -1667,7 +1667,7 @@ static int cdrommultisession(unsigned long arg)
ms.xa_flag = disk_info.xa; 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; return -EFAULT;
#if DEBUG_MULTIS #if DEBUG_MULTIS
...@@ -1717,6 +1717,7 @@ static int opt_ioctl(struct inode *ip, struct file *fp, ...@@ -1717,6 +1717,7 @@ static int opt_ioctl(struct inode *ip, struct file *fp,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
int status, err, retval = 0; int status, err, retval = 0;
void __user *argp = (void __user *)arg;
DEBUG((DEBUG_VFS, "starting opt_ioctl")); DEBUG((DEBUG_VFS, "starting opt_ioctl"));
...@@ -1767,10 +1768,10 @@ static int opt_ioctl(struct inode *ip, struct file *fp, ...@@ -1767,10 +1768,10 @@ static int opt_ioctl(struct inode *ip, struct file *fp,
switch (cmd) { switch (cmd) {
case CDROMPAUSE: retval = cdrompause(); break; case CDROMPAUSE: retval = cdrompause(); break;
case CDROMRESUME: retval = cdromresume(); break; case CDROMRESUME: retval = cdromresume(); break;
case CDROMPLAYMSF: retval = cdromplaymsf(arg); break; case CDROMPLAYMSF: retval = cdromplaymsf(argp); break;
case CDROMPLAYTRKIND: retval = cdromplaytrkind(arg); break; case CDROMPLAYTRKIND: retval = cdromplaytrkind(argp); break;
case CDROMREADTOCHDR: retval = cdromreadtochdr(arg); break; case CDROMREADTOCHDR: retval = cdromreadtochdr(argp); break;
case CDROMREADTOCENTRY: retval = cdromreadtocentry(arg); break; case CDROMREADTOCENTRY: retval = cdromreadtocentry(argp); break;
case CDROMSTOP: err = exec_cmd(COMSTOP); case CDROMSTOP: err = exec_cmd(COMSTOP);
if (err < 0) { if (err < 0) {
...@@ -1799,8 +1800,8 @@ static int opt_ioctl(struct inode *ip, struct file *fp, ...@@ -1799,8 +1800,8 @@ static int opt_ioctl(struct inode *ip, struct file *fp,
} }
break; break;
case CDROMVOLCTRL: retval = cdromvolctrl(arg); break; case CDROMVOLCTRL: retval = cdromvolctrl(argp); break;
case CDROMSUBCHNL: retval = cdromsubchnl(arg); break; case CDROMSUBCHNL: retval = cdromsubchnl(argp); break;
/* The drive detects the mode and automatically delivers the /* The drive detects the mode and automatically delivers the
correct 2048 bytes, so we don't need these IOCTLs */ correct 2048 bytes, so we don't need these IOCTLs */
...@@ -1814,7 +1815,7 @@ static int opt_ioctl(struct inode *ip, struct file *fp, ...@@ -1814,7 +1815,7 @@ static int opt_ioctl(struct inode *ip, struct file *fp,
break; break;
#ifdef MULTISESSION #ifdef MULTISESSION
case CDROMMULTISESSION: retval = cdrommultisession(arg); break; case CDROMMULTISESSION: retval = cdrommultisession(argp); break;
#endif #endif
case CDROM_GET_MCN: retval = -EINVAL; break; /* not implemented */ case CDROM_GET_MCN: retval = -EINVAL; break; /* not implemented */
...@@ -1822,16 +1823,16 @@ static int opt_ioctl(struct inode *ip, struct file *fp, ...@@ -1822,16 +1823,16 @@ static int opt_ioctl(struct inode *ip, struct file *fp,
case CDROMREADRAW: case CDROMREADRAW:
/* this drive delivers 2340 bytes in raw mode */ /* this drive delivers 2340 bytes in raw mode */
retval = cdromread(arg, CD_FRAMESIZE_RAW1, COMREADRAW); retval = cdromread(argp, CD_FRAMESIZE_RAW1, COMREADRAW);
break; break;
case CDROMREADCOOKED: case CDROMREADCOOKED:
retval = cdromread(arg, CD_FRAMESIZE, COMREAD); retval = cdromread(argp, CD_FRAMESIZE, COMREAD);
break; break;
case CDROMREADALL: case CDROMREADALL:
retval = cdromread(arg, CD_FRAMESIZE_RAWER, COMREADALL); retval = cdromread(argp, CD_FRAMESIZE_RAWER, COMREADALL);
break; break;
case CDROMSEEK: retval = cdromseek(arg); break; case CDROMSEEK: retval = cdromseek(argp); break;
case CDROMPLAYBLK: retval = -EINVAL; break; /* not implemented */ case CDROMPLAYBLK: retval = -EINVAL; break; /* not implemented */
case CDROMCLOSETRAY: break; /* The action was taken earlier */ case CDROMCLOSETRAY: break; /* The action was taken earlier */
default: retval = -EINVAL; default: retval = -EINVAL;
......
...@@ -716,13 +716,11 @@ static int sjcd_tray_open(void) ...@@ -716,13 +716,11 @@ static int sjcd_tray_open(void)
static int sjcd_ioctl(struct inode *ip, struct file *fp, static int sjcd_ioctl(struct inode *ip, struct file *fp,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
void __user *argp = (void __user *)arg;
#if defined( SJCD_TRACE ) #if defined( SJCD_TRACE )
printk("SJCD:ioctl\n"); printk("SJCD:ioctl\n");
#endif #endif
if (ip == NULL)
return (-EINVAL);
sjcd_get_status(); sjcd_get_status();
if (!sjcd_status_valid) if (!sjcd_status_valid)
return (-EIO); return (-EIO);
...@@ -795,7 +793,7 @@ static int sjcd_ioctl(struct inode *ip, struct file *fp, ...@@ -795,7 +793,7 @@ static int sjcd_ioctl(struct inode *ip, struct file *fp,
#if defined( SJCD_TRACE ) #if defined( SJCD_TRACE )
printk("SJCD: ioctl: playtrkind\n"); printk("SJCD: ioctl: playtrkind\n");
#endif #endif
if (!copy_from_user(&ti, (void *) arg, sizeof(ti))) { if (!copy_from_user(&ti, argp, sizeof(ti))) {
s = 0; s = 0;
if (ti.cdti_trk0 < sjcd_first_track_no) if (ti.cdti_trk0 < sjcd_first_track_no)
return (-EINVAL); return (-EINVAL);
...@@ -833,7 +831,7 @@ static int sjcd_ioctl(struct inode *ip, struct file *fp, ...@@ -833,7 +831,7 @@ static int sjcd_ioctl(struct inode *ip, struct file *fp,
printk("SJCD: ioctl: playmsf\n"); printk("SJCD: ioctl: playmsf\n");
#endif #endif
if ((s = if ((s =
verify_area(VERIFY_READ, (void *) arg, verify_area(VERIFY_READ, argp,
sizeof(sjcd_msf))) == 0) { sizeof(sjcd_msf))) == 0) {
if (sjcd_audio_status == CDROM_AUDIO_PLAY) { if (sjcd_audio_status == CDROM_AUDIO_PLAY) {
sjcd_send_cmd(SCMD_PAUSE); sjcd_send_cmd(SCMD_PAUSE);
...@@ -842,7 +840,7 @@ static int sjcd_ioctl(struct inode *ip, struct file *fp, ...@@ -842,7 +840,7 @@ static int sjcd_ioctl(struct inode *ip, struct file *fp,
CDROM_AUDIO_NO_STATUS; CDROM_AUDIO_NO_STATUS;
} }
if (copy_from_user(&sjcd_msf, (void *) arg, if (copy_from_user(&sjcd_msf, argp,
sizeof(sjcd_msf))) sizeof(sjcd_msf)))
return (-EFAULT); return (-EFAULT);
...@@ -877,7 +875,7 @@ static int sjcd_ioctl(struct inode *ip, struct file *fp, ...@@ -877,7 +875,7 @@ static int sjcd_ioctl(struct inode *ip, struct file *fp,
#endif #endif
toc_header.cdth_trk0 = sjcd_first_track_no; toc_header.cdth_trk0 = sjcd_first_track_no;
toc_header.cdth_trk1 = sjcd_last_track_no; toc_header.cdth_trk1 = sjcd_last_track_no;
if (copy_to_user((void *)arg, &toc_header, if (copy_to_user(argp, &toc_header,
sizeof(toc_header))) sizeof(toc_header)))
return -EFAULT; return -EFAULT;
return 0; return 0;
...@@ -890,11 +888,11 @@ static int sjcd_ioctl(struct inode *ip, struct file *fp, ...@@ -890,11 +888,11 @@ static int sjcd_ioctl(struct inode *ip, struct file *fp,
printk("SJCD: ioctl: readtocentry\n"); printk("SJCD: ioctl: readtocentry\n");
#endif #endif
if ((s = if ((s =
verify_area(VERIFY_WRITE, (void *) arg, verify_area(VERIFY_WRITE, argp,
sizeof(toc_entry))) == 0) { sizeof(toc_entry))) == 0) {
struct sjcd_hw_disk_info *tp; struct sjcd_hw_disk_info *tp;
if (copy_from_user(&toc_entry, (void *) arg, if (copy_from_user(&toc_entry, argp,
sizeof(toc_entry))) sizeof(toc_entry)))
return (-EFAULT); return (-EFAULT);
if (toc_entry.cdte_track == CDROM_LEADOUT) if (toc_entry.cdte_track == CDROM_LEADOUT)
...@@ -931,7 +929,7 @@ static int sjcd_ioctl(struct inode *ip, struct file *fp, ...@@ -931,7 +929,7 @@ static int sjcd_ioctl(struct inode *ip, struct file *fp,
default: default:
return (-EINVAL); return (-EINVAL);
} }
if (copy_to_user((void *) arg, &toc_entry, if (copy_to_user(argp, &toc_entry,
sizeof(toc_entry))) sizeof(toc_entry)))
s = -EFAULT; s = -EFAULT;
} }
...@@ -945,11 +943,11 @@ static int sjcd_ioctl(struct inode *ip, struct file *fp, ...@@ -945,11 +943,11 @@ static int sjcd_ioctl(struct inode *ip, struct file *fp,
printk("SJCD: ioctl: subchnl\n"); printk("SJCD: ioctl: subchnl\n");
#endif #endif
if ((s = if ((s =
verify_area(VERIFY_WRITE, (void *) arg, verify_area(VERIFY_WRITE, argp,
sizeof(subchnl))) == 0) { sizeof(subchnl))) == 0) {
struct sjcd_hw_qinfo q_info; struct sjcd_hw_qinfo q_info;
if (copy_from_user(&subchnl, (void *) arg, if (copy_from_user(&subchnl, argp,
sizeof(subchnl))) sizeof(subchnl)))
return (-EFAULT); return (-EFAULT);
...@@ -990,7 +988,7 @@ static int sjcd_ioctl(struct inode *ip, struct file *fp, ...@@ -990,7 +988,7 @@ static int sjcd_ioctl(struct inode *ip, struct file *fp,
default: default:
return (-EINVAL); return (-EINVAL);
} }
if (copy_to_user((void *) arg, &subchnl, if (copy_to_user(argp, &subchnl,
sizeof(subchnl))) sizeof(subchnl)))
s = -EFAULT; s = -EFAULT;
} }
...@@ -1004,11 +1002,11 @@ static int sjcd_ioctl(struct inode *ip, struct file *fp, ...@@ -1004,11 +1002,11 @@ static int sjcd_ioctl(struct inode *ip, struct file *fp,
printk("SJCD: ioctl: volctrl\n"); printk("SJCD: ioctl: volctrl\n");
#endif #endif
if ((s = if ((s =
verify_area(VERIFY_READ, (void *) arg, verify_area(VERIFY_READ, argp,
sizeof(vol_ctrl))) == 0) { sizeof(vol_ctrl))) == 0) {
unsigned char dummy[4]; unsigned char dummy[4];
if (copy_from_user(&vol_ctrl, (void *) arg, if (copy_from_user(&vol_ctrl, argp,
sizeof(vol_ctrl))) sizeof(vol_ctrl)))
return (-EFAULT); return (-EFAULT);
sjcd_send_4_cmd(SCMD_SET_VOLUME, sjcd_send_4_cmd(SCMD_SET_VOLUME,
...@@ -1038,8 +1036,7 @@ static int sjcd_ioctl(struct inode *ip, struct file *fp, ...@@ -1038,8 +1036,7 @@ static int sjcd_ioctl(struct inode *ip, struct file *fp,
#if defined( SJCD_TRACE ) #if defined( SJCD_TRACE )
printk("SJCD: ioctl: statistic\n"); printk("SJCD: ioctl: statistic\n");
#endif #endif
if (copy_to_user((void *)arg, &statistic, if (copy_to_user(argp, &statistic, sizeof(statistic)))
sizeof(statistic)))
return -EFAULT; return -EFAULT;
return 0; return 0;
} }
......
...@@ -997,7 +997,7 @@ read_subcode(void) ...@@ -997,7 +997,7 @@ read_subcode(void)
* (not BCD), so all the conversions are done. * (not BCD), so all the conversions are done.
*/ */
static int static int
sony_get_subchnl_info(long arg) sony_get_subchnl_info(void __user *arg)
{ {
struct cdrom_subchnl schi; struct cdrom_subchnl schi;
...@@ -1009,7 +1009,7 @@ sony_get_subchnl_info(long arg) ...@@ -1009,7 +1009,7 @@ sony_get_subchnl_info(long arg)
if (!sony_toc_read) { if (!sony_toc_read) {
return -EIO; return -EIO;
} }
if (copy_from_user(&schi, (char *)arg, sizeof schi)) if (copy_from_user(&schi, arg, sizeof schi))
return -EFAULT; return -EFAULT;
switch (sony_audio_status) { switch (sony_audio_status) {
...@@ -1025,7 +1025,7 @@ sony_get_subchnl_info(long arg) ...@@ -1025,7 +1025,7 @@ sony_get_subchnl_info(long arg)
case CDROM_AUDIO_NO_STATUS: case CDROM_AUDIO_NO_STATUS:
schi.cdsc_audiostatus = sony_audio_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 -EFAULT;
return 0; return 0;
break; break;
...@@ -1053,7 +1053,7 @@ sony_get_subchnl_info(long arg) ...@@ -1053,7 +1053,7 @@ sony_get_subchnl_info(long arg)
schi.cdsc_absaddr.lba = msf_to_log(last_sony_subcode->abs_msf); schi.cdsc_absaddr.lba = msf_to_log(last_sony_subcode->abs_msf);
schi.cdsc_reladdr.lba = msf_to_log(last_sony_subcode->rel_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, ...@@ -1070,6 +1070,7 @@ cdu_ioctl(struct inode *inode,
Byte cmd_buff[10], params[10]; Byte cmd_buff[10], params[10];
int i; int i;
int dsc_status; int dsc_status;
void __user *argp = (void __user *)arg;
if (check_drive_status() != 0) if (check_drive_status() != 0)
return -EIO; return -EIO;
...@@ -1152,7 +1153,7 @@ cdu_ioctl(struct inode *inode, ...@@ -1152,7 +1153,7 @@ cdu_ioctl(struct inode *inode,
break; break;
case CDROMPLAYMSF: /* Play starting at the given MSF address. */ 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; return -EFAULT;
spin_up_drive(status); spin_up_drive(status);
set_drive_mode(SONY535_AUDIO_DRIVE_MODE, status); set_drive_mode(SONY535_AUDIO_DRIVE_MODE, status);
...@@ -1184,13 +1185,12 @@ cdu_ioctl(struct inode *inode, ...@@ -1184,13 +1185,12 @@ cdu_ioctl(struct inode *inode,
case CDROMREADTOCHDR: /* Read the table of contents header */ case CDROMREADTOCHDR: /* Read the table of contents header */
{ {
struct cdrom_tochdr *hdr; struct cdrom_tochdr __user *hdr = argp;
struct cdrom_tochdr loc_hdr; struct cdrom_tochdr loc_hdr;
sony_get_toc(); sony_get_toc();
if (!sony_toc_read) if (!sony_toc_read)
return -EIO; return -EIO;
hdr = (struct cdrom_tochdr *)arg;
loc_hdr.cdth_trk0 = bcd_to_int(sony_toc->first_track_num); loc_hdr.cdth_trk0 = bcd_to_int(sony_toc->first_track_num);
loc_hdr.cdth_trk1 = bcd_to_int(sony_toc->last_track_num); loc_hdr.cdth_trk1 = bcd_to_int(sony_toc->last_track_num);
if (copy_to_user(hdr, &loc_hdr, sizeof *hdr)) if (copy_to_user(hdr, &loc_hdr, sizeof *hdr))
...@@ -1201,7 +1201,7 @@ cdu_ioctl(struct inode *inode, ...@@ -1201,7 +1201,7 @@ cdu_ioctl(struct inode *inode,
case CDROMREADTOCENTRY: /* Read a given table of contents entry */ case CDROMREADTOCENTRY: /* Read a given table of contents entry */
{ {
struct cdrom_tocentry *entry; struct cdrom_tocentry __user *entry = argp;
struct cdrom_tocentry loc_entry; struct cdrom_tocentry loc_entry;
int track_idx; int track_idx;
Byte *msf_val = NULL; Byte *msf_val = NULL;
...@@ -1210,7 +1210,6 @@ cdu_ioctl(struct inode *inode, ...@@ -1210,7 +1210,6 @@ cdu_ioctl(struct inode *inode,
if (!sony_toc_read) { if (!sony_toc_read) {
return -EIO; return -EIO;
} }
entry = (struct cdrom_tocentry *)arg;
if (copy_from_user(&loc_entry, entry, sizeof loc_entry)) if (copy_from_user(&loc_entry, entry, sizeof loc_entry))
return -EFAULT; return -EFAULT;
...@@ -1252,7 +1251,7 @@ cdu_ioctl(struct inode *inode, ...@@ -1252,7 +1251,7 @@ cdu_ioctl(struct inode *inode,
if (!sony_toc_read) if (!sony_toc_read)
return -EIO; return -EIO;
if (copy_from_user(&ti, (char *)arg, sizeof ti)) if (copy_from_user(&ti, argp, sizeof ti))
return -EFAULT; return -EFAULT;
if ((ti.cdti_trk0 < sony_toc->first_track_num) if ((ti.cdti_trk0 < sony_toc->first_track_num)
|| (sony_toc->last_track_num < ti.cdti_trk0) || (sony_toc->last_track_num < ti.cdti_trk0)
...@@ -1314,14 +1313,13 @@ cdu_ioctl(struct inode *inode, ...@@ -1314,14 +1313,13 @@ cdu_ioctl(struct inode *inode,
} }
case CDROMSUBCHNL: /* Get subchannel info */ 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? */ case CDROMVOLCTRL: /* Volume control. What volume does this change, anyway? */
{ {
struct cdrom_volctrl volctrl; struct cdrom_volctrl volctrl;
if (copy_from_user(&volctrl, (char *)arg, if (copy_from_user(&volctrl, argp, sizeof volctrl))
sizeof volctrl))
return -EFAULT; return -EFAULT;
cmd_buff[0] = SONY535_SET_VOLUME; cmd_buff[0] = SONY535_SET_VOLUME;
cmd_buff[1] = volctrl.channel0; cmd_buff[1] = volctrl.channel0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment