On Mon, 17 Oct 2011 19:56:20 -0700, Yuping Luo <lypingsh@xxxxxxxxx> wrote:
On Tue, Oct 18, 2011 at 4:30 AM, Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:
On Mon, 17 Oct 2011, Michal Nazarewicz wrote:
On Mon, 17 Oct 2011 02:01:48 -0700, Yuping Luo <lypingsh@xxxxxxxxx> wrote:
> here you are , :)
>
> diff --git a/drivers/usb/gadget/f_mass_storage.c
> b/drivers/usb/gadget/f_mass_storage.c
> index 524381a..6a5c42d 100644
> --- a/drivers/usb/gadget/f_mass_storage.c
> +++ b/drivers/usb/gadget/f_mass_storage.c
> @@ -379,6 +379,7 @@ struct fsg_common {
> enum data_direction data_dir;
> u32 data_size;
> u32 data_size_from_cmnd;
> + u32 data_size_is_in_blocks;
Personally, I'd make it an argument to check_command() or create a simple
wrapper for check_command() that calculates the size.
I considered making this a new argument to check_command(). In the end
I decided against it, because check_command() already has a lot of
arguments, and also it would be necessary to add the new argument to
every call (of which there are quite a few).
Using a wrapper routine is a good idea -- it didn't occur to me before.
Alan Stern
the codes only occur one time, which makes the wrapper unnecessary.
In do_scsi_command() you add a bunch of ->data_size_is_in_blocks = 1
statements. Instead of doing that, you might create a
check_command_size_in_blocks() function like so:
static int check_command_size_in_blocks(...)
{
if (*->curlun)
*->->data_size_from_cmnd <<= *->curlun->blkbits;
return check_command(...);
}
and call it instead. This would make data_size_is_in_blocks unnecessary
which IMO is a good thing since it is a hidden state.
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michał “mina86” Nazarewicz (o o)
ooo +----<email/xmpp: mpn@xxxxxxxxxx>--------------ooO--(_)--Ooo--
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html