On Wed, 25 Jul 2012, Rajaram REGUPATHY wrote:

> The short_not_ok field is used by class drivers to indicate udc whether short 
> packet is expected during a particular transfer.
> In case of mass storage, during command and status phase this field is set as 
> false and set to true during data phase.
> musb driver uses this field to decide whether to program DMA for mode1.
> This code is essential for musb driver to program DMA.
> 
> Signed-off-by: Balakumar Rajendran <balakumar.rajend...@stericsson.com>
> Signed-off-by: Rajaram R <ragupathy.raja...@stericsson.com>
> ---
>  drivers/usb/gadget/f_mass_storage.c |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/usb/gadget/f_mass_storage.c 
> b/drivers/usb/gadget/f_mass_storage.c
> index f67b453..db8bf4a 100644
> --- a/drivers/usb/gadget/f_mass_storage.c
> +++ b/drivers/usb/gadget/f_mass_storage.c
> @@ -878,6 +878,7 @@ static int do_write(struct fsg_common *common)
>       unsigned int            amount;
>       ssize_t                 nwritten;
>       int                     rc;
> +     struct usb_gadget *gadget = common->cdev->gadget;
>  
>       if (curlun->ro) {
>               curlun->sense_data = SS_WRITE_PROTECTED; @@ -960,6 +961,8 @@ 
> static int do_write(struct fsg_common *common)
>                        * the bulk-out maxpacket size.
>                        */
>                       set_bulk_out_req_length(common, bh, amount);
> +                     if (!gadget_is_superspeed(gadget))
> +                             bh->outreq->short_not_ok = 1;

This new code is added everywhere set_bulk_out_req_length() is called.  
You might as well move it into that function; set short_not_ok whenever 
the gadget isn't running at SuperSpeed and the requested length is >= 
the block size.

>                       if (!start_out_transfer(common, bh))
>                               /* Dunno what to do if common->fsg is NULL */
>                               return -EIO;

The patch is wrong.  Later on in the function we have:

                        /* Did something go wrong with the transfer? */
                        if (bh->outreq->status != 0) {
                                curlun->sense_data = SS_COMMUNICATION_FAILURE;
                                curlun->sense_data_info =
                                        file_offset >> curlun->blkbits;
                                curlun->info_valid = 1;
                                break;
                        }

We don't want the "if" statement to succeed when the status is nonzero 
because a short packet was received.

Alan Stern

--
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