On Mon, 10 Dec 2012, Michal Nazarewicz wrote:

> On Mon, Dec 10 2012, Golmer Palmer <onrollo-9...@yahoo.es> wrote:
> > This message is for request to support CD-ROM boot support in the USB 
> > Gadget 
> > driver.
> >
> > Specifically, I ask for improve "g_mass_storage" driver with:
> >
> > * 2048 byte/sector support in CD mode.
> 
> Unless I'm missing something, g_mass_storage is using 2048 sector size
> for CD-ROMs.  See initialisation of blksize in fsg_lun_open() in
> storage_common.c.
> 
> > * workaround for READ TOC command with incorrect length.
> 
> Does the following help:
> 
> ----------------- >8 ---------------------------------------------------
>  drivers/usb/gadget/f_mass_storage.c |    7 ++++++-
>  1 files changed, 6 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/usb/gadget/f_mass_storage.c 
> b/drivers/usb/gadget/f_mass_storage.c
> index 5d027b3..850d779 100644
> --- a/drivers/usb/gadget/f_mass_storage.c
> +++ b/drivers/usb/gadget/f_mass_storage.c
> @@ -1823,7 +1823,12 @@ static int check_command(struct fsg_common *common, 
> int cmnd_size,
>  
>       /* Check that only command bytes listed in the mask are non-zero */
>       common->cmnd[1] &= 0x1f;                        /* Mask away the LUN */
> -     for (i = 1; i < cmnd_size; ++i) {
> +     /*
> +      * Some BIOSes put some non-zero values in READ_TOC requests in the
> +      * last two bytes -- Andreas Kemnade.  So let's exclude those.
> +      */
> +     i = common->cmnd[0] == READ_TOC ? cmnd_size - 2 : cmnd_size;
> +     while (--i >= 1) {
>               if (common->cmnd[i] && !(mask & (1 << i))) {
>                       if (curlun)
>                               curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
> ----------------- >8 ---------------------------------------------------

By the way, that's not the right way to do this.  Here's the proper 
patch.

Alan Stern



Index: usb-3.7/drivers/usb/gadget/f_mass_storage.c
===================================================================
--- usb-3.7.orig/drivers/usb/gadget/f_mass_storage.c
+++ usb-3.7/drivers/usb/gadget/f_mass_storage.c
@@ -1995,8 +1995,13 @@ static int do_scsi_command(struct fsg_co
                        goto unknown_cmnd;
                common->data_size_from_cmnd =
                        get_unaligned_be16(&common->cmnd[7]);
+               /*
+                * According to Andreas Kemnade, some BIOSes incorrectly
+                * put nonzero values in the "control" byte of READ TOC
+                * commands.  So let's accept them.
+                */
                reply = check_command(common, 10, DATA_DIR_TO_HOST,
-                                     (7<<6) | (1<<1), 1,
+                                     (1<<9) | (7<<6) | (1<<1), 1,
                                      "READ TOC");
                if (reply == 0)
                        reply = do_read_toc(common, bh);

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to