diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2007-10-07 17:54:28 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2008-10-21 07:47:22 -0400 |
commit | bbc1cc978404105da23d505163ce9fd5598ed5b1 (patch) | |
tree | cd0e1dfba91288338784dac3f9356aeadb3e713e /drivers | |
parent | 08f85851215100d0eebf026810955ee6ad456c38 (diff) |
[PATCH] switch cdrom_{open,release,ioctl} to sane APIs
... convert to it in callers
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/block/paride/pcd.c | 8 | ||||
-rw-r--r-- | drivers/cdrom/cdrom.c | 23 | ||||
-rw-r--r-- | drivers/cdrom/gdrom.c | 7 | ||||
-rw-r--r-- | drivers/cdrom/viocd.c | 8 | ||||
-rw-r--r-- | drivers/ide/ide-cd.c | 7 | ||||
-rw-r--r-- | drivers/scsi/sr.c | 11 |
6 files changed, 33 insertions, 31 deletions
diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c index b8a994a2b013..8bd557e2a659 100644 --- a/drivers/block/paride/pcd.c +++ b/drivers/block/paride/pcd.c | |||
@@ -226,20 +226,22 @@ static int pcd_warned; /* Have we logged a phase warning ? */ | |||
226 | static int pcd_block_open(struct inode *inode, struct file *file) | 226 | static int pcd_block_open(struct inode *inode, struct file *file) |
227 | { | 227 | { |
228 | struct pcd_unit *cd = inode->i_bdev->bd_disk->private_data; | 228 | struct pcd_unit *cd = inode->i_bdev->bd_disk->private_data; |
229 | return cdrom_open(&cd->info, inode, file); | 229 | return cdrom_open(&cd->info, inode->i_bdev, file->f_mode); |
230 | } | 230 | } |
231 | 231 | ||
232 | static int pcd_block_release(struct inode *inode, struct file *file) | 232 | static int pcd_block_release(struct inode *inode, struct file *file) |
233 | { | 233 | { |
234 | struct pcd_unit *cd = inode->i_bdev->bd_disk->private_data; | 234 | struct pcd_unit *cd = inode->i_bdev->bd_disk->private_data; |
235 | return cdrom_release(&cd->info, file); | 235 | cdrom_release(&cd->info, file ? file->f_mode : 0); |
236 | return 0; | ||
236 | } | 237 | } |
237 | 238 | ||
238 | static int pcd_block_ioctl(struct inode *inode, struct file *file, | 239 | static int pcd_block_ioctl(struct inode *inode, struct file *file, |
239 | unsigned cmd, unsigned long arg) | 240 | unsigned cmd, unsigned long arg) |
240 | { | 241 | { |
241 | struct pcd_unit *cd = inode->i_bdev->bd_disk->private_data; | 242 | struct pcd_unit *cd = inode->i_bdev->bd_disk->private_data; |
242 | return cdrom_ioctl(file, &cd->info, inode, cmd, arg); | 243 | return cdrom_ioctl(&cd->info, inode->i_bdev, |
244 | file ? file->f_mode : 0, cmd, arg); | ||
243 | } | 245 | } |
244 | 246 | ||
245 | static int pcd_block_media_changed(struct gendisk *disk) | 247 | static int pcd_block_media_changed(struct gendisk *disk) |
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index e286eb5d1f6a..d16b02423d61 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c | |||
@@ -973,7 +973,7 @@ static int cdrom_close_write(struct cdrom_device_info *cdi) | |||
973 | * is in their own interest: device control becomes a lot easier | 973 | * is in their own interest: device control becomes a lot easier |
974 | * this way. | 974 | * this way. |
975 | */ | 975 | */ |
976 | int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip, struct file *fp) | 976 | int cdrom_open(struct cdrom_device_info *cdi, struct block_device *bdev, fmode_t mode) |
977 | { | 977 | { |
978 | int ret; | 978 | int ret; |
979 | 979 | ||
@@ -982,14 +982,14 @@ int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip, struct file *fp) | |||
982 | /* if this was a O_NONBLOCK open and we should honor the flags, | 982 | /* if this was a O_NONBLOCK open and we should honor the flags, |
983 | * do a quick open without drive/disc integrity checks. */ | 983 | * do a quick open without drive/disc integrity checks. */ |
984 | cdi->use_count++; | 984 | cdi->use_count++; |
985 | if ((fp->f_mode & FMODE_NDELAY) && (cdi->options & CDO_USE_FFLAGS)) { | 985 | if ((mode & FMODE_NDELAY) && (cdi->options & CDO_USE_FFLAGS)) { |
986 | ret = cdi->ops->open(cdi, 1); | 986 | ret = cdi->ops->open(cdi, 1); |
987 | } else { | 987 | } else { |
988 | ret = open_for_data(cdi); | 988 | ret = open_for_data(cdi); |
989 | if (ret) | 989 | if (ret) |
990 | goto err; | 990 | goto err; |
991 | cdrom_mmc3_profile(cdi); | 991 | cdrom_mmc3_profile(cdi); |
992 | if (fp->f_mode & FMODE_WRITE) { | 992 | if (mode & FMODE_WRITE) { |
993 | ret = -EROFS; | 993 | ret = -EROFS; |
994 | if (cdrom_open_write(cdi)) | 994 | if (cdrom_open_write(cdi)) |
995 | goto err_release; | 995 | goto err_release; |
@@ -1007,7 +1007,7 @@ int cdrom_open(struct cdrom_device_info *cdi, struct inode *ip, struct file *fp) | |||
1007 | cdi->name, cdi->use_count); | 1007 | cdi->name, cdi->use_count); |
1008 | /* Do this on open. Don't wait for mount, because they might | 1008 | /* Do this on open. Don't wait for mount, because they might |
1009 | not be mounting, but opening with O_NONBLOCK */ | 1009 | not be mounting, but opening with O_NONBLOCK */ |
1010 | check_disk_change(ip->i_bdev); | 1010 | check_disk_change(bdev); |
1011 | return 0; | 1011 | return 0; |
1012 | err_release: | 1012 | err_release: |
1013 | if (CDROM_CAN(CDC_LOCK) && cdi->options & CDO_LOCK) { | 1013 | if (CDROM_CAN(CDC_LOCK) && cdi->options & CDO_LOCK) { |
@@ -1184,7 +1184,7 @@ static int check_for_audio_disc(struct cdrom_device_info * cdi, | |||
1184 | return 0; | 1184 | return 0; |
1185 | } | 1185 | } |
1186 | 1186 | ||
1187 | int cdrom_release(struct cdrom_device_info *cdi, struct file *fp) | 1187 | void cdrom_release(struct cdrom_device_info *cdi, fmode_t mode) |
1188 | { | 1188 | { |
1189 | struct cdrom_device_ops *cdo = cdi->ops; | 1189 | struct cdrom_device_ops *cdo = cdi->ops; |
1190 | int opened_for_data; | 1190 | int opened_for_data; |
@@ -1205,7 +1205,7 @@ int cdrom_release(struct cdrom_device_info *cdi, struct file *fp) | |||
1205 | } | 1205 | } |
1206 | 1206 | ||
1207 | opened_for_data = !(cdi->options & CDO_USE_FFLAGS) || | 1207 | opened_for_data = !(cdi->options & CDO_USE_FFLAGS) || |
1208 | !(fp && fp->f_mode & FMODE_NDELAY); | 1208 | !(mode & FMODE_NDELAY); |
1209 | 1209 | ||
1210 | /* | 1210 | /* |
1211 | * flush cache on last write release | 1211 | * flush cache on last write release |
@@ -1219,7 +1219,6 @@ int cdrom_release(struct cdrom_device_info *cdi, struct file *fp) | |||
1219 | cdi->options & CDO_AUTO_EJECT && CDROM_CAN(CDC_OPEN_TRAY)) | 1219 | cdi->options & CDO_AUTO_EJECT && CDROM_CAN(CDC_OPEN_TRAY)) |
1220 | cdo->tray_move(cdi, 1); | 1220 | cdo->tray_move(cdi, 1); |
1221 | } | 1221 | } |
1222 | return 0; | ||
1223 | } | 1222 | } |
1224 | 1223 | ||
1225 | static int cdrom_read_mech_status(struct cdrom_device_info *cdi, | 1224 | static int cdrom_read_mech_status(struct cdrom_device_info *cdi, |
@@ -2662,17 +2661,17 @@ static int cdrom_ioctl_audioctl(struct cdrom_device_info *cdi, | |||
2662 | * these days. | 2661 | * these days. |
2663 | * ATAPI / SCSI specific code now mainly resides in mmc_ioctl(). | 2662 | * ATAPI / SCSI specific code now mainly resides in mmc_ioctl(). |
2664 | */ | 2663 | */ |
2665 | int cdrom_ioctl(struct file * file, struct cdrom_device_info *cdi, | 2664 | int cdrom_ioctl(struct cdrom_device_info *cdi, struct block_device *bdev, |
2666 | struct inode *ip, unsigned int cmd, unsigned long arg) | 2665 | fmode_t mode, unsigned int cmd, unsigned long arg) |
2667 | { | 2666 | { |
2668 | void __user *argp = (void __user *)arg; | 2667 | void __user *argp = (void __user *)arg; |
2669 | int ret; | 2668 | int ret; |
2670 | struct gendisk *disk = ip->i_bdev->bd_disk; | 2669 | struct gendisk *disk = bdev->bd_disk; |
2671 | 2670 | ||
2672 | /* | 2671 | /* |
2673 | * Try the generic SCSI command ioctl's first. | 2672 | * Try the generic SCSI command ioctl's first. |
2674 | */ | 2673 | */ |
2675 | ret = scsi_cmd_ioctl(disk->queue, disk, file ? file->f_mode : 0, cmd, argp); | 2674 | ret = scsi_cmd_ioctl(disk->queue, disk, mode, cmd, argp); |
2676 | if (ret != -ENOTTY) | 2675 | if (ret != -ENOTTY) |
2677 | return ret; | 2676 | return ret; |
2678 | 2677 | ||
@@ -2696,7 +2695,7 @@ int cdrom_ioctl(struct file * file, struct cdrom_device_info *cdi, | |||
2696 | case CDROM_SELECT_DISC: | 2695 | case CDROM_SELECT_DISC: |
2697 | return cdrom_ioctl_select_disc(cdi, arg); | 2696 | return cdrom_ioctl_select_disc(cdi, arg); |
2698 | case CDROMRESET: | 2697 | case CDROMRESET: |
2699 | return cdrom_ioctl_reset(cdi, ip->i_bdev); | 2698 | return cdrom_ioctl_reset(cdi, bdev); |
2700 | case CDROM_LOCKDOOR: | 2699 | case CDROM_LOCKDOOR: |
2701 | return cdrom_ioctl_lock_door(cdi, arg); | 2700 | return cdrom_ioctl_lock_door(cdi, arg); |
2702 | case CDROM_DEBUG: | 2701 | case CDROM_DEBUG: |
diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c index d6ba77a2dd7b..0959edf2afdb 100644 --- a/drivers/cdrom/gdrom.c +++ b/drivers/cdrom/gdrom.c | |||
@@ -492,12 +492,12 @@ static struct cdrom_device_ops gdrom_ops = { | |||
492 | 492 | ||
493 | static int gdrom_bdops_open(struct inode *inode, struct file *file) | 493 | static int gdrom_bdops_open(struct inode *inode, struct file *file) |
494 | { | 494 | { |
495 | return cdrom_open(gd.cd_info, inode, file); | 495 | return cdrom_open(gd.cd_info, inode->i_bdev, file->f_mode); |
496 | } | 496 | } |
497 | 497 | ||
498 | static int gdrom_bdops_release(struct inode *inode, struct file *file) | 498 | static int gdrom_bdops_release(struct inode *inode, struct file *file) |
499 | { | 499 | { |
500 | return cdrom_release(gd.cd_info, file); | 500 | return cdrom_release(gd.cd_info, file ? file->f_mode : 0); |
501 | } | 501 | } |
502 | 502 | ||
503 | static int gdrom_bdops_mediachanged(struct gendisk *disk) | 503 | static int gdrom_bdops_mediachanged(struct gendisk *disk) |
@@ -508,7 +508,8 @@ static int gdrom_bdops_mediachanged(struct gendisk *disk) | |||
508 | static int gdrom_bdops_ioctl(struct inode *inode, struct file *file, | 508 | static int gdrom_bdops_ioctl(struct inode *inode, struct file *file, |
509 | unsigned cmd, unsigned long arg) | 509 | unsigned cmd, unsigned long arg) |
510 | { | 510 | { |
511 | return cdrom_ioctl(file, gd.cd_info, inode, cmd, arg); | 511 | return cdrom_ioctl(gd.cd_info, inode->i_bdev, |
512 | file ? file->f_mode : 0, cmd, arg); | ||
512 | } | 513 | } |
513 | 514 | ||
514 | static struct block_device_operations gdrom_bdops = { | 515 | static struct block_device_operations gdrom_bdops = { |
diff --git a/drivers/cdrom/viocd.c b/drivers/cdrom/viocd.c index 031e0e1a1a3b..abc4079c3f41 100644 --- a/drivers/cdrom/viocd.c +++ b/drivers/cdrom/viocd.c | |||
@@ -154,20 +154,22 @@ static const struct file_operations proc_viocd_operations = { | |||
154 | static int viocd_blk_open(struct inode *inode, struct file *file) | 154 | static int viocd_blk_open(struct inode *inode, struct file *file) |
155 | { | 155 | { |
156 | struct disk_info *di = inode->i_bdev->bd_disk->private_data; | 156 | struct disk_info *di = inode->i_bdev->bd_disk->private_data; |
157 | return cdrom_open(&di->viocd_info, inode, file); | 157 | return cdrom_open(&di->viocd_info, inode->i_bdev, file->f_mode); |
158 | } | 158 | } |
159 | 159 | ||
160 | static int viocd_blk_release(struct inode *inode, struct file *file) | 160 | static int viocd_blk_release(struct inode *inode, struct file *file) |
161 | { | 161 | { |
162 | struct disk_info *di = inode->i_bdev->bd_disk->private_data; | 162 | struct disk_info *di = inode->i_bdev->bd_disk->private_data; |
163 | return cdrom_release(&di->viocd_info, file); | 163 | cdrom_release(&di->viocd_info, file ? file->f_mode : 0); |
164 | return 0; | ||
164 | } | 165 | } |
165 | 166 | ||
166 | static int viocd_blk_ioctl(struct inode *inode, struct file *file, | 167 | static int viocd_blk_ioctl(struct inode *inode, struct file *file, |
167 | unsigned cmd, unsigned long arg) | 168 | unsigned cmd, unsigned long arg) |
168 | { | 169 | { |
169 | struct disk_info *di = inode->i_bdev->bd_disk->private_data; | 170 | struct disk_info *di = inode->i_bdev->bd_disk->private_data; |
170 | return cdrom_ioctl(file, &di->viocd_info, inode, cmd, arg); | 171 | return cdrom_ioctl(&di->viocd_info, inode->i_bdev, |
172 | file ? file->f_mode : 0, cmd, arg); | ||
171 | } | 173 | } |
172 | 174 | ||
173 | static int viocd_blk_media_changed(struct gendisk *disk) | 175 | static int viocd_blk_media_changed(struct gendisk *disk) |
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index cd21b34fe509..87d90200b169 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -2099,7 +2099,7 @@ static int idecd_open(struct inode *inode, struct file *file) | |||
2099 | if (!info) | 2099 | if (!info) |
2100 | return -ENXIO; | 2100 | return -ENXIO; |
2101 | 2101 | ||
2102 | rc = cdrom_open(&info->devinfo, inode, file); | 2102 | rc = cdrom_open(&info->devinfo, inode->i_bdev, file->f_mode); |
2103 | 2103 | ||
2104 | if (rc < 0) | 2104 | if (rc < 0) |
2105 | ide_cd_put(info); | 2105 | ide_cd_put(info); |
@@ -2112,7 +2112,7 @@ static int idecd_release(struct inode *inode, struct file *file) | |||
2112 | struct gendisk *disk = inode->i_bdev->bd_disk; | 2112 | struct gendisk *disk = inode->i_bdev->bd_disk; |
2113 | struct cdrom_info *info = ide_drv_g(disk, cdrom_info); | 2113 | struct cdrom_info *info = ide_drv_g(disk, cdrom_info); |
2114 | 2114 | ||
2115 | cdrom_release(&info->devinfo, file); | 2115 | cdrom_release(&info->devinfo, file ? file->f_mode : 0); |
2116 | 2116 | ||
2117 | ide_cd_put(info); | 2117 | ide_cd_put(info); |
2118 | 2118 | ||
@@ -2176,7 +2176,8 @@ static int idecd_ioctl(struct inode *inode, struct file *file, | |||
2176 | 2176 | ||
2177 | err = generic_ide_ioctl(info->drive, bdev, cmd, arg); | 2177 | err = generic_ide_ioctl(info->drive, bdev, cmd, arg); |
2178 | if (err == -EINVAL) | 2178 | if (err == -EINVAL) |
2179 | err = cdrom_ioctl(file, &info->devinfo, inode, cmd, arg); | 2179 | err = cdrom_ioctl(&info->devinfo, bdev, |
2180 | file ? file->f_mode : 0, cmd, arg); | ||
2180 | 2181 | ||
2181 | return err; | 2182 | return err; |
2182 | } | 2183 | } |
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 0f17009c99d2..b92e2dac9aa9 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c | |||
@@ -480,7 +480,7 @@ static int sr_block_open(struct inode *inode, struct file *file) | |||
480 | if(!(cd = scsi_cd_get(disk))) | 480 | if(!(cd = scsi_cd_get(disk))) |
481 | return -ENXIO; | 481 | return -ENXIO; |
482 | 482 | ||
483 | if((ret = cdrom_open(&cd->cdi, inode, file)) != 0) | 483 | if((ret = cdrom_open(&cd->cdi, inode->i_bdev, file->f_mode)) != 0) |
484 | scsi_cd_put(cd); | 484 | scsi_cd_put(cd); |
485 | 485 | ||
486 | return ret; | 486 | return ret; |
@@ -488,12 +488,8 @@ static int sr_block_open(struct inode *inode, struct file *file) | |||
488 | 488 | ||
489 | static int sr_block_release(struct inode *inode, struct file *file) | 489 | static int sr_block_release(struct inode *inode, struct file *file) |
490 | { | 490 | { |
491 | int ret; | ||
492 | struct scsi_cd *cd = scsi_cd(inode->i_bdev->bd_disk); | 491 | struct scsi_cd *cd = scsi_cd(inode->i_bdev->bd_disk); |
493 | ret = cdrom_release(&cd->cdi, file); | 492 | cdrom_release(&cd->cdi, file ? file->f_mode : 0); |
494 | if(ret) | ||
495 | return ret; | ||
496 | |||
497 | scsi_cd_put(cd); | 493 | scsi_cd_put(cd); |
498 | 494 | ||
499 | return 0; | 495 | return 0; |
@@ -517,7 +513,8 @@ static int sr_block_ioctl(struct inode *inode, struct file *file, unsigned cmd, | |||
517 | return scsi_ioctl(sdev, cmd, argp); | 513 | return scsi_ioctl(sdev, cmd, argp); |
518 | } | 514 | } |
519 | 515 | ||
520 | ret = cdrom_ioctl(file, &cd->cdi, inode, cmd, arg); | 516 | ret = cdrom_ioctl(&cd->cdi, inode->i_bdev, |
517 | file ? file->f_mode : 0, cmd, arg); | ||
521 | if (ret != -ENOSYS) | 518 | if (ret != -ENOSYS) |
522 | return ret; | 519 | return ret; |
523 | 520 | ||