linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Shi Hao <i.shihao.999@gmail.com>
Cc: stern@rowland.harvard.edu, linux-usb@vger.kernel.org
Subject: Re: [PATCH v5] usb-storage: Simplify protocol translation
Date: Wed, 8 Oct 2025 09:31:59 +0200	[thread overview]
Message-ID: <2025100836-uncombed-blaming-b77a@gregkh> (raw)
In-Reply-To: <20251008070420.8302-1-i.shihao.999@gmail.com>

On Wed, Oct 08, 2025 at 12:34:20PM +0530, Shi Hao wrote:
> Simplify protocol translation for usb subclasses.
> 
> As suggested by Alan Stern  to remove the switch case labels  with
> 'default'  or keep the  previous  if statements  instead of the switch
> cases and advised  reasonable value when cmnd[0] >= 0xe0 .
> 
> keep  those usb subclasses to default and simplify logic removing
> switch cases and set 6 as a reasonable value when cmnd[0] >= 0xe0
> which fallbacks  to value 6 which is old cmd_len for those subclasses.
> 
> Signed-off-by: Shi Hao <i.shihao.999@gmail.com>
> 
> ---
> 
> changes v5:
> - Reformulate as  v5  of original patch series
> - No code changes ,clarified versioning history
> 
> changes v4:
> - Simplify  protocol translation logic
> - Set reasonable default when cmnd[0] >= 0xE0
> - Remove switch-case statement
> 
> changes v3:
> - Wrap  commit message lines properly
> - Improve commit description
> - fix  checkpatch.pl script errors
> 
> changes v2:
> - Update subject commit message
> - fix  checkpatch.pl warnings
> - match from: and sign-off: name
> ---
>  drivers/usb/storage/transport.c | 21 +++++++--------------
>  1 file changed, 7 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
> index 4d01f70f39ac..14cc608052d9 100644
> --- a/drivers/usb/storage/transport.c
> +++ b/drivers/usb/storage/transport.c
> @@ -719,17 +719,9 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
>  		scsi_eh_prep_cmnd(srb, &ses, NULL, 0, sense_size);
>  
>  		/* Protocol translation per scsi opcode group */
> -		switch (us->subclass) {
> -		case USB_SC_UFI:
> -		case USB_SC_8020:
> -		case USB_SC_8070:
> -		case USB_SC_QIC:
> -			srb->cmd_len = 12;
> -			break;
> -		/* Determine cmd_len based on scsi opcode group */
> -		case USB_SC_RBC:
> -		case USB_SC_SCSI:
> -		case USB_SC_CYP_ATACB:
> +		if (us->subclass == USB_SC_RBC || us->subclass == USB_SC_SCSI ||
> +				us->subclass == USB_SC_CYP_ATACB) {
> +		/* Determine cmd_len based on SCSI opcode group */

Always remember to run scripts/checkpatch.pl before sending changes out
to others :(

thanks,

greg k-h

  reply	other threads:[~2025-10-08  7:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-03 10:46 [PATCH] usb: fix protocol translation in drivers/usb/storage/transport.c Shi Hao
2025-10-03 11:39 ` Greg KH
2025-10-03 11:40 ` Greg KH
2025-10-06 12:31 ` [PATCH v3] usb-storage: Protocol translation for scsi opcode Shi Hao
2025-10-06 13:47   ` Alan Stern
2025-10-07 11:37     ` [PATCH v4] usb-storage v4: Simplify protocol translation Shi Hao
2025-10-07 14:35       ` Alan Stern
2025-10-08  7:04         ` [PATCH v5] usb-storage: " Shi Hao
2025-10-08  7:31           ` Greg KH [this message]
2025-10-08  9:18             ` ShiHao
2025-10-08 10:04               ` Greg KH
2025-10-08 11:09                 ` [PATCH v6] usb-storage: Fix comment indentation level Shi Hao
2025-10-08 11:21                   ` Greg KH
2025-10-09 21:15 ` [PATCH] usb: fix protocol translation in drivers/usb/storage/transport.c kernel test robot

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=2025100836-uncombed-blaming-b77a@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=i.shihao.999@gmail.com \
    --cc=linux-usb@vger.kernel.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).