diff options
author | Joe Perches <joe@perches.com> | 2014-05-04 20:05:09 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2014-05-05 16:58:06 -0400 |
commit | e1e60fda48b0eb2afebdfe7cf7c382adc00de470 (patch) | |
tree | 28db231a8f8e70833db229d18577060629317764 /drivers/cdrom | |
parent | 2e9aa08a4801d439daec4c7d1b953c27b212d423 (diff) |
cdrom: Remove cdrom_get_last_written prototype
Move the function instead.
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/cdrom')
-rw-r--r-- | drivers/cdrom/cdrom.c | 193 |
1 files changed, 97 insertions, 96 deletions
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index 332c3aee1346..fac603a16a15 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c | |||
@@ -338,7 +338,6 @@ do { \ | |||
338 | 338 | ||
339 | /* Not-exported routines. */ | 339 | /* Not-exported routines. */ |
340 | 340 | ||
341 | int cdrom_get_last_written(struct cdrom_device_info *, long *); | ||
342 | static int cdrom_get_next_writable(struct cdrom_device_info *, long *); | 341 | static int cdrom_get_next_writable(struct cdrom_device_info *, long *); |
343 | static void cdrom_count_tracks(struct cdrom_device_info *, tracktype*); | 342 | static void cdrom_count_tracks(struct cdrom_device_info *, tracktype*); |
344 | 343 | ||
@@ -2740,6 +2739,103 @@ static int cdrom_switch_blocksize(struct cdrom_device_info *cdi, int size) | |||
2740 | return cdo->generic_packet(cdi, &cgc); | 2739 | return cdo->generic_packet(cdi, &cgc); |
2741 | } | 2740 | } |
2742 | 2741 | ||
2742 | static int cdrom_get_track_info(struct cdrom_device_info *cdi, | ||
2743 | __u16 track, __u8 type, track_information *ti) | ||
2744 | { | ||
2745 | struct cdrom_device_ops *cdo = cdi->ops; | ||
2746 | struct packet_command cgc; | ||
2747 | int ret, buflen; | ||
2748 | |||
2749 | init_cdrom_command(&cgc, ti, 8, CGC_DATA_READ); | ||
2750 | cgc.cmd[0] = GPCMD_READ_TRACK_RZONE_INFO; | ||
2751 | cgc.cmd[1] = type & 3; | ||
2752 | cgc.cmd[4] = (track & 0xff00) >> 8; | ||
2753 | cgc.cmd[5] = track & 0xff; | ||
2754 | cgc.cmd[8] = 8; | ||
2755 | cgc.quiet = 1; | ||
2756 | |||
2757 | ret = cdo->generic_packet(cdi, &cgc); | ||
2758 | if (ret) | ||
2759 | return ret; | ||
2760 | |||
2761 | buflen = be16_to_cpu(ti->track_information_length) + | ||
2762 | sizeof(ti->track_information_length); | ||
2763 | |||
2764 | if (buflen > sizeof(track_information)) | ||
2765 | buflen = sizeof(track_information); | ||
2766 | |||
2767 | cgc.cmd[8] = cgc.buflen = buflen; | ||
2768 | ret = cdo->generic_packet(cdi, &cgc); | ||
2769 | if (ret) | ||
2770 | return ret; | ||
2771 | |||
2772 | /* return actual fill size */ | ||
2773 | return buflen; | ||
2774 | } | ||
2775 | |||
2776 | /* return the last written block on the CD-R media. this is for the udf | ||
2777 | file system. */ | ||
2778 | int cdrom_get_last_written(struct cdrom_device_info *cdi, long *last_written) | ||
2779 | { | ||
2780 | struct cdrom_tocentry toc; | ||
2781 | disc_information di; | ||
2782 | track_information ti; | ||
2783 | __u32 last_track; | ||
2784 | int ret = -1, ti_size; | ||
2785 | |||
2786 | if (!CDROM_CAN(CDC_GENERIC_PACKET)) | ||
2787 | goto use_toc; | ||
2788 | |||
2789 | ret = cdrom_get_disc_info(cdi, &di); | ||
2790 | if (ret < (int)(offsetof(typeof(di), last_track_lsb) | ||
2791 | + sizeof(di.last_track_lsb))) | ||
2792 | goto use_toc; | ||
2793 | |||
2794 | /* if unit didn't return msb, it's zeroed by cdrom_get_disc_info */ | ||
2795 | last_track = (di.last_track_msb << 8) | di.last_track_lsb; | ||
2796 | ti_size = cdrom_get_track_info(cdi, last_track, 1, &ti); | ||
2797 | if (ti_size < (int)offsetof(typeof(ti), track_start)) | ||
2798 | goto use_toc; | ||
2799 | |||
2800 | /* if this track is blank, try the previous. */ | ||
2801 | if (ti.blank) { | ||
2802 | if (last_track == 1) | ||
2803 | goto use_toc; | ||
2804 | last_track--; | ||
2805 | ti_size = cdrom_get_track_info(cdi, last_track, 1, &ti); | ||
2806 | } | ||
2807 | |||
2808 | if (ti_size < (int)(offsetof(typeof(ti), track_size) | ||
2809 | + sizeof(ti.track_size))) | ||
2810 | goto use_toc; | ||
2811 | |||
2812 | /* if last recorded field is valid, return it. */ | ||
2813 | if (ti.lra_v && ti_size >= (int)(offsetof(typeof(ti), last_rec_address) | ||
2814 | + sizeof(ti.last_rec_address))) { | ||
2815 | *last_written = be32_to_cpu(ti.last_rec_address); | ||
2816 | } else { | ||
2817 | /* make it up instead */ | ||
2818 | *last_written = be32_to_cpu(ti.track_start) + | ||
2819 | be32_to_cpu(ti.track_size); | ||
2820 | if (ti.free_blocks) | ||
2821 | *last_written -= (be32_to_cpu(ti.free_blocks) + 7); | ||
2822 | } | ||
2823 | return 0; | ||
2824 | |||
2825 | /* this is where we end up if the drive either can't do a | ||
2826 | GPCMD_READ_DISC_INFO or GPCMD_READ_TRACK_RZONE_INFO or if | ||
2827 | it doesn't give enough information or fails. then we return | ||
2828 | the toc contents. */ | ||
2829 | use_toc: | ||
2830 | toc.cdte_format = CDROM_MSF; | ||
2831 | toc.cdte_track = CDROM_LEADOUT; | ||
2832 | if ((ret = cdi->ops->audio_ioctl(cdi, CDROMREADTOCENTRY, &toc))) | ||
2833 | return ret; | ||
2834 | sanitize_format(&toc.cdte_addr, &toc.cdte_format, CDROM_LBA); | ||
2835 | *last_written = toc.cdte_addr.lba; | ||
2836 | return 0; | ||
2837 | } | ||
2838 | |||
2743 | static noinline int mmc_ioctl_cdrom_read_data(struct cdrom_device_info *cdi, | 2839 | static noinline int mmc_ioctl_cdrom_read_data(struct cdrom_device_info *cdi, |
2744 | void __user *arg, | 2840 | void __user *arg, |
2745 | struct packet_command *cgc, | 2841 | struct packet_command *cgc, |
@@ -3210,38 +3306,6 @@ int cdrom_ioctl(struct cdrom_device_info *cdi, struct block_device *bdev, | |||
3210 | return -ENOSYS; | 3306 | return -ENOSYS; |
3211 | } | 3307 | } |
3212 | 3308 | ||
3213 | static int cdrom_get_track_info(struct cdrom_device_info *cdi, __u16 track, __u8 type, | ||
3214 | track_information *ti) | ||
3215 | { | ||
3216 | struct cdrom_device_ops *cdo = cdi->ops; | ||
3217 | struct packet_command cgc; | ||
3218 | int ret, buflen; | ||
3219 | |||
3220 | init_cdrom_command(&cgc, ti, 8, CGC_DATA_READ); | ||
3221 | cgc.cmd[0] = GPCMD_READ_TRACK_RZONE_INFO; | ||
3222 | cgc.cmd[1] = type & 3; | ||
3223 | cgc.cmd[4] = (track & 0xff00) >> 8; | ||
3224 | cgc.cmd[5] = track & 0xff; | ||
3225 | cgc.cmd[8] = 8; | ||
3226 | cgc.quiet = 1; | ||
3227 | |||
3228 | if ((ret = cdo->generic_packet(cdi, &cgc))) | ||
3229 | return ret; | ||
3230 | |||
3231 | buflen = be16_to_cpu(ti->track_information_length) + | ||
3232 | sizeof(ti->track_information_length); | ||
3233 | |||
3234 | if (buflen > sizeof(track_information)) | ||
3235 | buflen = sizeof(track_information); | ||
3236 | |||
3237 | cgc.cmd[8] = cgc.buflen = buflen; | ||
3238 | if ((ret = cdo->generic_packet(cdi, &cgc))) | ||
3239 | return ret; | ||
3240 | |||
3241 | /* return actual fill size */ | ||
3242 | return buflen; | ||
3243 | } | ||
3244 | |||
3245 | /* requires CD R/RW */ | 3309 | /* requires CD R/RW */ |
3246 | static int cdrom_get_disc_info(struct cdrom_device_info *cdi, disc_information *di) | 3310 | static int cdrom_get_disc_info(struct cdrom_device_info *cdi, disc_information *di) |
3247 | { | 3311 | { |
@@ -3275,69 +3339,6 @@ static int cdrom_get_disc_info(struct cdrom_device_info *cdi, disc_information * | |||
3275 | return buflen; | 3339 | return buflen; |
3276 | } | 3340 | } |
3277 | 3341 | ||
3278 | /* return the last written block on the CD-R media. this is for the udf | ||
3279 | file system. */ | ||
3280 | int cdrom_get_last_written(struct cdrom_device_info *cdi, long *last_written) | ||
3281 | { | ||
3282 | struct cdrom_tocentry toc; | ||
3283 | disc_information di; | ||
3284 | track_information ti; | ||
3285 | __u32 last_track; | ||
3286 | int ret = -1, ti_size; | ||
3287 | |||
3288 | if (!CDROM_CAN(CDC_GENERIC_PACKET)) | ||
3289 | goto use_toc; | ||
3290 | |||
3291 | ret = cdrom_get_disc_info(cdi, &di); | ||
3292 | if (ret < (int)(offsetof(typeof(di), last_track_lsb) | ||
3293 | + sizeof(di.last_track_lsb))) | ||
3294 | goto use_toc; | ||
3295 | |||
3296 | /* if unit didn't return msb, it's zeroed by cdrom_get_disc_info */ | ||
3297 | last_track = (di.last_track_msb << 8) | di.last_track_lsb; | ||
3298 | ti_size = cdrom_get_track_info(cdi, last_track, 1, &ti); | ||
3299 | if (ti_size < (int)offsetof(typeof(ti), track_start)) | ||
3300 | goto use_toc; | ||
3301 | |||
3302 | /* if this track is blank, try the previous. */ | ||
3303 | if (ti.blank) { | ||
3304 | if (last_track==1) | ||
3305 | goto use_toc; | ||
3306 | last_track--; | ||
3307 | ti_size = cdrom_get_track_info(cdi, last_track, 1, &ti); | ||
3308 | } | ||
3309 | |||
3310 | if (ti_size < (int)(offsetof(typeof(ti), track_size) | ||
3311 | + sizeof(ti.track_size))) | ||
3312 | goto use_toc; | ||
3313 | |||
3314 | /* if last recorded field is valid, return it. */ | ||
3315 | if (ti.lra_v && ti_size >= (int)(offsetof(typeof(ti), last_rec_address) | ||
3316 | + sizeof(ti.last_rec_address))) { | ||
3317 | *last_written = be32_to_cpu(ti.last_rec_address); | ||
3318 | } else { | ||
3319 | /* make it up instead */ | ||
3320 | *last_written = be32_to_cpu(ti.track_start) + | ||
3321 | be32_to_cpu(ti.track_size); | ||
3322 | if (ti.free_blocks) | ||
3323 | *last_written -= (be32_to_cpu(ti.free_blocks) + 7); | ||
3324 | } | ||
3325 | return 0; | ||
3326 | |||
3327 | /* this is where we end up if the drive either can't do a | ||
3328 | GPCMD_READ_DISC_INFO or GPCMD_READ_TRACK_RZONE_INFO or if | ||
3329 | it doesn't give enough information or fails. then we return | ||
3330 | the toc contents. */ | ||
3331 | use_toc: | ||
3332 | toc.cdte_format = CDROM_MSF; | ||
3333 | toc.cdte_track = CDROM_LEADOUT; | ||
3334 | if ((ret = cdi->ops->audio_ioctl(cdi, CDROMREADTOCENTRY, &toc))) | ||
3335 | return ret; | ||
3336 | sanitize_format(&toc.cdte_addr, &toc.cdte_format, CDROM_LBA); | ||
3337 | *last_written = toc.cdte_addr.lba; | ||
3338 | return 0; | ||
3339 | } | ||
3340 | |||
3341 | /* return the next writable block. also for udf file system. */ | 3342 | /* return the next writable block. also for udf file system. */ |
3342 | static int cdrom_get_next_writable(struct cdrom_device_info *cdi, long *next_writable) | 3343 | static int cdrom_get_next_writable(struct cdrom_device_info *cdi, long *next_writable) |
3343 | { | 3344 | { |