openbmc.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: i.kononenko <i.kononenko@yadro.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Felipe Balbi <balbi@kernel.org>,
	openbmc@lists.ozlabs.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [PATCH 1/6] usb:gadget:mass-storage: Improve the signature of SCSI handler function
Date: Sun, 27 Jun 2021 18:32:03 +0300	[thread overview]
Message-ID: <ded6e647-6dd9-ebd0-0ea5-b20e113bf57f@yadro.com> (raw)
In-Reply-To: <20210627141836.GC624763@rowland.harvard.edu>

Good morning, Alan!

First of all, thank you for your time to review my first patchset for 
the Linux Kernel and valuable advice on the right way of patchwriting!

On 27.06.2021 17:18, Alan Stern wrote:
> On Sun, Jun 27, 2021 at 12:18:14AM +0300, Igor Kononenko wrote:
>> SCSI command handlers currently have an ambiguous return value. This
> 
> (I dislike very much this way of writing patch descriptions.  Unless
> the reader has already looked at the email subject line and remembers
> that this patch affects the mass-storage gadget, he will think the
> sentence above is talking about command handlers in the SCSI core -- a
> completely different part of the kernel.  When writing patch
> descriptions, please do not assume that the reader already knows what
> the patch is about.)
> 
>> return value may indicate the length of the data written to the response
>> buffer and the command's processing status. Thus, the understanding of
>> command handling may be implicit.

First of all, thank you for your time to review my first patchset for the
Linux Kernel and valuable advice on the right way of patchwriting!

I noticed that the status/datasize return value pattern is pervasive for 
Linux and used through many subsystems. But for the f_mass_storage.c,
such approach use case is not documented anywhere, and implementation has 
too many magic-constant, e.g.
```
static int do_inquiry(struct fsg_common *common, struct fsg_buffhd *bh)
{
   ....
   return 36;
}
```
IMHO, this way is not giving the developer an explicit understanding of 
'what is the 36' and its origin.
If moving to the suggested way is unwanted, I'd keep the implementation 
as is with additional documentation for each function where uses this 
approach.
Additionally, I guess, define clarify macros of return value instead of 
magic numbers is required.

> 
> The return value is _not_ ambiguous.  If the value is >= 0 then it is
> a data length, otherwise it is a status.  Yes, this is implicit, but it
> is a very common pattern used throughout the kernel and everyone
> understands it.
> 
>> After this patch, the output buffer's size will be set in the
>> 'data_size_to_handle' field of 'struct fsg_common', and the command
>> handler's return value indicates only the processing status.
> 
> What is the reason for making this change?  Does it fix any problems
> or prepare the way for any future patches?  It seems like this is
> completely unnecessary.

Yes, the patch uses as part of the incoming implementation of refactoring
'usb:gadget:mass-storage:scsi' command handling.
I believed the suggested improvement would be useful for the community as 
an improvement of code.

> 
> Alan Stern
> 
>> Tested: By probing the USBGadget Mass-Storage on the YADRO VEGMAN
>> BMC(AST2500) sample, each SCSI command was sent through HOST->BMC; the
>> USBGadget MassStorage debug print showed all sent commands works
>> properly.
>>
>> Signed-off-by: Igor Kononenko <i.kononenko@yadro.com>


-- 
Best regards,

Igor Kononenko

  reply	other threads:[~2021-06-27 15:32 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-26 21:18 [PATCH 0/6] USB-gadget: mass-storage: Support DVD-like images Igor Kononenko
2021-06-26 21:18 ` [PATCH 1/6] usb:gadget:mass-storage: Improve the signature of SCSI handler function Igor Kononenko
2021-06-27 14:18   ` Alan Stern
2021-06-27 15:32     ` i.kononenko [this message]
2021-06-27 16:39       ` Alan Stern
2021-06-26 21:18 ` [PATCH 2/6] usb:gadget:mass-storage: refactoring the SCSI command handling Igor Kononenko
2021-06-26 23:29   ` kernel test robot
2021-06-27 14:23   ` Alan Stern
2021-06-27 17:14     ` i.kononenko
2021-06-28  1:06       ` Alan Stern
2021-06-28 10:38         ` i.kononenko
2021-06-26 21:18 ` [PATCH 3/6] fms: Add TOC/PMA/ATIP DVD-ROM capabilities Igor Kononenko
2021-06-27 14:29   ` Alan Stern
2021-06-27 18:45     ` i.kononenko
2021-06-28 14:31       ` Alan Stern
2021-06-26 21:18 ` [PATCH 4/6] fms: Support the DVD/BD images size over 2.1Gb Igor Kononenko
2021-06-26 21:18 ` [PATCH 5/6] FMS: Add the SCSI Get Configuration command Igor Kononenko
2021-06-27  0:44   ` kernel test robot
2021-06-27  4:42   ` kernel test robot
2021-06-28  9:53   ` Christoph Hellwig
2021-06-28 10:34     ` i.kononenko
2021-06-26 21:18 ` [PATCH 6/6] FMS: Add SCSI Read Disc Information command Igor Kononenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ded6e647-6dd9-ebd0-0ea5-b20e113bf57f@yadro.com \
    --to=i.kononenko@yadro.com \
    --cc=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=openbmc@lists.ozlabs.org \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).