From: Shuah Khan <skhan@linuxfoundation.org>
To: shihao <i.shihao.999@gmail.com>, gregkh@linuxfoundation.org
Cc: shuah@kernel.org, linux-usb@vger.kernel.org,
Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH] usb: Fixed protocol translation in usb/storage/transport.c
Date: Tue, 7 Oct 2025 17:12:25 -0600 [thread overview]
Message-ID: <34639f0e-4af0-4fc0-8368-07b9119d6cde@linuxfoundation.org> (raw)
In-Reply-To: <20251003083124.17072-1-i.shihao.999@gmail.com>
On 10/3/25 02:31, shihao wrote:
What happened to the commit log. What are you fixing here?
How did you test this patch?
> Signed-off-by: shihao <i.shihao.999@gmail.com>
> ---
> drivers/usb/storage/transport.c | 41 ++++++++++++++++++++++++++++-----
> 1 file changed, 35 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
> index 1aa1bd26c81f..4dd6bfa86c23 100644
> --- a/drivers/usb/storage/transport.c
> +++ b/drivers/usb/storage/transport.c
> @@ -718,12 +718,41 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
>
> scsi_eh_prep_cmnd(srb, &ses, NULL, 0, sense_size);
>
> - /* FIXME: we must do the protocol translation here */
> - if (us->subclass == USB_SC_RBC || us->subclass == USB_SC_SCSI ||
> - us->subclass == USB_SC_CYP_ATACB)
> - srb->cmd_len = 6;
> - else
> - srb->cmd_len = 12;
> + /* 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 ; /* ATAPI/UFI devices always use 12-byte CDBs */
> + break;
> +
> + case USB_SC_RBC:
> + case USB_SC_SCSI:
> + case USB_SC_CYP_ATACB: /* Determine cmd_len based on SCSI opcode group */
> +
> + if(opcode <= 0x1F) /* Group 0 */
> + {
> + srb->cmd_len = 6 ;
> + }else if( opcode <= 0x7F) /* Group 1 & 2 */
> + {
> + srb->cmd_len = 10;
> + }else if(opcode <= 0x9F ) /* Group 5 */
> + {
> + srb->cmd_len = 16 ;
> + }else if(opcode <=0xBF) /* Group 6 */
> + {
> + srb->cmd_len = 12 ;
> + }else if( opcode <=0xDF) /* Group 7 */
> + {
> + srb->cmd_len = 16;
> + }else{
> + ; /* Leaving cmd_len value unchanged for 0xE0–0xFF vendor-specific*/
> +
> + }
> + break;
> + }
>
> /* issue the auto-sense command */
> scsi_set_resid(srb, 0);
thanks,
-- Shuah
prev parent reply other threads:[~2025-10-07 23:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-03 8:31 [PATCH] usb: Fixed protocol translation in usb/storage/transport.c shihao
2025-10-03 8:42 ` Greg KH
2025-10-03 17:04 ` kernel test robot
2025-10-07 23:12 ` Shuah Khan [this message]
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=34639f0e-4af0-4fc0-8368-07b9119d6cde@linuxfoundation.org \
--to=skhan@linuxfoundation.org \
--cc=gregkh@linuxfoundation.org \
--cc=i.shihao.999@gmail.com \
--cc=linux-usb@vger.kernel.org \
--cc=shuah@kernel.org \
/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