cdrom: handle TOC
Alexander Inyukhin [Mon, 18 Aug 2008 19:40:04 +0000 (21:40 +0200)]
This patch should fix TOC handling for cdroms that can not play audio.  It
extends commit af744e3294d09d706c4eae26cffaaa68a8d40337 ("cdrom: don't
check CDC_PLAY_AUDIO in cdrom_count_tracks()") with a safety check and
non-audio ioctls support.

Since CDC_PLAY_AUDIO flag was used not only to check ability to play audio
but also to ensure that audio_ioctl was not NULL, all TOC-related
operations had to use it.

As far as I understand, now audio_ioctl is never NULL, so a sanity check
during device registration should be sufficient.

It was tested on Optiarc AD7203A device, that has no ability to play
audio.

Cc: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Borislav Petkov <petkovbb@googlemail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
[bart: remove now unneeded ->audio_ioctl check (noticed by Borislav)]
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

drivers/cdrom/cdrom.c

index d9d1b65..74031de 100644 (file)
@@ -408,7 +408,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
        ENSURE(get_last_session, CDC_MULTI_SESSION);
        ENSURE(get_mcn, CDC_MCN);
        ENSURE(reset, CDC_RESET);
-       ENSURE(audio_ioctl, CDC_PLAY_AUDIO);
        ENSURE(generic_packet, CDC_GENERIC_PACKET);
        cdi->mc_flags = 0;
        cdo->n_minors = 0;
@@ -2506,8 +2505,6 @@ static int cdrom_ioctl_get_subchnl(struct cdrom_device_info *cdi,
 
        /* cdinfo(CD_DO_IOCTL,"entering CDROMSUBCHNL\n");*/
 
-       if (!CDROM_CAN(CDC_PLAY_AUDIO))
-               return -ENOSYS;
        if (copy_from_user(&q, argp, sizeof(q)))
                return -EFAULT;
 
@@ -2538,8 +2535,6 @@ static int cdrom_ioctl_read_tochdr(struct cdrom_device_info *cdi,
 
        /* cdinfo(CD_DO_IOCTL, "entering CDROMREADTOCHDR\n"); */
 
-       if (!CDROM_CAN(CDC_PLAY_AUDIO))
-               return -ENOSYS;
        if (copy_from_user(&header, argp, sizeof(header)))
                return -EFAULT;
 
@@ -2562,8 +2557,6 @@ static int cdrom_ioctl_read_tocentry(struct cdrom_device_info *cdi,
 
        /* cdinfo(CD_DO_IOCTL, "entering CDROMREADTOCENTRY\n"); */
 
-       if (!CDROM_CAN(CDC_PLAY_AUDIO))
-               return -ENOSYS;
        if (copy_from_user(&entry, argp, sizeof(entry)))
                return -EFAULT;