In general, you would have been a bit better off just doing a

        if(cd->device->use_10_for_ms) {
                cgc.cmd[0] = MODE_SENSE_10;
                cgc.cmd[8] = 128;
        } else {
                cdc.cmd[0] = MODE_SENSE;
                cgc.cmd[4] = 128;
        }

Rather than duplicating so much code.

This: 

> +     if (cd->device->use_10_for_ms) {
> +             memset(&cgc, 0, sizeof(struct cdrom_generic_command));
> +             cgc.cmd[0] = MODE_SENSE_10;
> +             cgc.cmd[2] = 0x2a;              /* page code */
> +             cgc.cmd[8] = 128;               /* allocation length */
> +             cgc.buffer = buffer;
> +             cgc.buflen = 128;
> +             cgc.quiet = 1;
> +             cgc.data_direction = SCSI_DATA_READ;
> +             cgc.timeout = SR_TIMEOUT;
> +             rc = sr_do_ioctl(cd, &cgc);
> +     }
> +
> +     /* if we got an error, return to old behavior */
> +     if (rc)
> +             cd->device->use_10_for_ms = 0;

Is slightly incorrect.  Mode sense commands can return errors for many
reasons, you need to check for ILLEGAL_REQUEST sense before assuming it
was a problem with the command.

What probably should happen is that the resetting of the flag should be
in scsi_io_completion (like it is for the use_10_for_rw flag), then the
retry and the flag reset would come for free.

James




-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to