linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: Implement proper subclass protocol translation
@ 2025-10-10 11:30 Shi Hao
  2025-10-10 12:29 ` Greg KH
  2025-10-10 15:07 ` Alan Stern
  0 siblings, 2 replies; 4+ messages in thread
From: Shi Hao @ 2025-10-10 11:30 UTC (permalink / raw)
  To: gregkh; +Cc: i.shihao.999, linux-usb, stern, skhan

Proper protocol translation for old legacy  usb devices.

Earlier protocol translation was insufficient for old usb devices
which was padding all subclasses  such as USB_SC_RBC, USB_SC_SCSI
and USB_SC_CYP_ATACB cmd_len to 6 byte value and because It wasn't
complete It had a FIXME comment stating to fix the protocol transl
-ation for those legacy usb devices.

As a result implement proper protocol translation as per their op
code.In addition to   the old default value 6  those old legacy
usb-device subclasses needed cmd_len value  to 10, 12 , and 16
byte also .

Signed-off-by: Shi Hao <i.shihao.999@gmail.com>
---
 drivers/usb/storage/transport.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index 1aa1bd26c81f..4820b45d2a32 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -718,12 +718,25 @@ 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 */
+		/* Protocol translation per scsi opcode group */
 		if (us->subclass == USB_SC_RBC || us->subclass == USB_SC_SCSI ||
-				us->subclass == USB_SC_CYP_ATACB)
-			srb->cmd_len = 6;
-		else
+		    us->subclass == USB_SC_CYP_ATACB) {
+			/* Determine cmd_len based on scsi opcode group */
+			if (srb->cmnd[0] <= 0x1F)
+				srb->cmd_len = 6;
+			else if (srb->cmnd[0] <= 0x7F)
+				srb->cmd_len = 10;
+			else if (srb->cmnd[0] <= 0x9F)
+				srb->cmd_len = 16;
+			else if (srb->cmnd[0] <= 0xBF)
+				srb->cmd_len = 12;
+			else if (srb->cmnd[0] <= 0xDF)
+				srb->cmd_len = 16;
+			else
+				srb->cmd_len = 6;
+		} else {
 			srb->cmd_len = 12;
+		}

 		/* issue the auto-sense command */
 		scsi_set_resid(srb, 0);
--
2.51.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: Implement proper subclass protocol translation
  2025-10-10 11:30 [PATCH] usb: Implement proper subclass protocol translation Shi Hao
@ 2025-10-10 12:29 ` Greg KH
  2025-10-10 15:07 ` Alan Stern
  1 sibling, 0 replies; 4+ messages in thread
From: Greg KH @ 2025-10-10 12:29 UTC (permalink / raw)
  To: Shi Hao; +Cc: linux-usb, stern, skhan

On Fri, Oct 10, 2025 at 05:00:03PM +0530, Shi Hao wrote:
> Proper protocol translation for old legacy  usb devices.
> 
> Earlier protocol translation was insufficient for old usb devices
> which was padding all subclasses  such as USB_SC_RBC, USB_SC_SCSI
> and USB_SC_CYP_ATACB cmd_len to 6 byte value and because It wasn't
> complete It had a FIXME comment stating to fix the protocol transl
> -ation for those legacy usb devices.
> 
> As a result implement proper protocol translation as per their op
> code.In addition to   the old default value 6  those old legacy
> usb-device subclasses needed cmd_len value  to 10, 12 , and 16
> byte also .
> 
> Signed-off-by: Shi Hao <i.shihao.999@gmail.com>
> ---
>  drivers/usb/storage/transport.c | 21 +++++++++++++++++----
>  1 file changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
> index 1aa1bd26c81f..4820b45d2a32 100644
> --- a/drivers/usb/storage/transport.c
> +++ b/drivers/usb/storage/transport.c
> @@ -718,12 +718,25 @@ 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 */
> +		/* Protocol translation per scsi opcode group */
>  		if (us->subclass == USB_SC_RBC || us->subclass == USB_SC_SCSI ||
> -				us->subclass == USB_SC_CYP_ATACB)
> -			srb->cmd_len = 6;
> -		else
> +		    us->subclass == USB_SC_CYP_ATACB) {
> +			/* Determine cmd_len based on scsi opcode group */
> +			if (srb->cmnd[0] <= 0x1F)
> +				srb->cmd_len = 6;
> +			else if (srb->cmnd[0] <= 0x7F)
> +				srb->cmd_len = 10;
> +			else if (srb->cmnd[0] <= 0x9F)
> +				srb->cmd_len = 16;
> +			else if (srb->cmnd[0] <= 0xBF)
> +				srb->cmd_len = 12;
> +			else if (srb->cmnd[0] <= 0xDF)
> +				srb->cmd_len = 16;
> +			else
> +				srb->cmd_len = 6;
> +		} else {
>  			srb->cmd_len = 12;
> +		}
> 
>  		/* issue the auto-sense command */
>  		scsi_set_resid(srb, 0);
> --
> 2.51.0
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- You did not write a descriptive Subject: for the patch, allowing Greg,
  and everyone else, to know what this patch is all about.  Please read
  the section entitled "The canonical patch format" in the kernel file,
  Documentation/process/submitting-patches.rst for what a proper
  Subject: line should look like.

- This looks like a new version of a previously submitted patch, but you
  did not list below the --- line any changes from the previous version.
  Please read the section entitled "The canonical patch format" in the
  kernel file, Documentation/process/submitting-patches.rst for what
  needs to be done here to properly describe this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: Implement proper subclass protocol translation
  2025-10-10 11:30 [PATCH] usb: Implement proper subclass protocol translation Shi Hao
  2025-10-10 12:29 ` Greg KH
@ 2025-10-10 15:07 ` Alan Stern
  2025-10-11  9:37   ` ShiHao
  1 sibling, 1 reply; 4+ messages in thread
From: Alan Stern @ 2025-10-10 15:07 UTC (permalink / raw)
  To: Shi Hao; +Cc: gregkh, linux-usb, skhan

On Fri, Oct 10, 2025 at 05:00:03PM +0530, Shi Hao wrote:
> Proper protocol translation for old legacy  usb devices.
> 
> Earlier protocol translation was insufficient for old usb devices
> which was padding all subclasses  such as USB_SC_RBC, USB_SC_SCSI
> and USB_SC_CYP_ATACB cmd_len to 6 byte value and because It wasn't
> complete It had a FIXME comment stating to fix the protocol transl
> -ation for those legacy usb devices.
> 
> As a result implement proper protocol translation as per their op
> code.In addition to   the old default value 6  those old legacy
> usb-device subclasses needed cmd_len value  to 10, 12 , and 16
> byte also .

The spacing in this text is strange -- double spaces in random places, 
no space following the first '.' in the last paragraph, and an extra 
space before the second '.'.  Also, strange capitalization of the word 
"It" in two places.

> 
> Signed-off-by: Shi Hao <i.shihao.999@gmail.com>
> ---

Overall the patch is in pretty good shape.  However...

>  drivers/usb/storage/transport.c | 21 +++++++++++++++++----
>  1 file changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
> index 1aa1bd26c81f..4820b45d2a32 100644
> --- a/drivers/usb/storage/transport.c
> +++ b/drivers/usb/storage/transport.c
> @@ -718,12 +718,25 @@ 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 */
> +		/* Protocol translation per scsi opcode group */

This comment should be different.  The "per scsi opcode group" will be 
mentioned in another comment a few lines later; it's not needed here as 
well.

>  		if (us->subclass == USB_SC_RBC || us->subclass == USB_SC_SCSI ||
> -				us->subclass == USB_SC_CYP_ATACB)
> -			srb->cmd_len = 6;
> -		else
> +		    us->subclass == USB_SC_CYP_ATACB) {

Please don't change the existing indentation.

> +			/* Determine cmd_len based on scsi opcode group */
> +			if (srb->cmnd[0] <= 0x1F)
> +				srb->cmd_len = 6;
> +			else if (srb->cmnd[0] <= 0x7F)
> +				srb->cmd_len = 10;
> +			else if (srb->cmnd[0] <= 0x9F)
> +				srb->cmd_len = 16;
> +			else if (srb->cmnd[0] <= 0xBF)
> +				srb->cmd_len = 12;
> +			else if (srb->cmnd[0] <= 0xDF)
> +				srb->cmd_len = 16;
> +			else
> +				srb->cmd_len = 6;
> +		} else {

And you could add a comment here explaining that the other protocols use 
a fixed value for the command length.

>  			srb->cmd_len = 12;
> +		}
> 
>  		/* issue the auto-sense command */
>  		scsi_set_resid(srb, 0);
> --
> 2.51.0
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] usb: Implement proper subclass protocol translation
  2025-10-10 15:07 ` Alan Stern
@ 2025-10-11  9:37   ` ShiHao
  0 siblings, 0 replies; 4+ messages in thread
From: ShiHao @ 2025-10-11  9:37 UTC (permalink / raw)
  To: Alan Stern; +Cc: skhan, linux-usb, i.shihao.999, gregkh, stern

On Fri, Oct 10, 2025 at 11:07:03AM -0400, Alan Stern wrote:
> The spacing in this text is strange -- double spaces in random places, 
> no space following the first '.' in the last paragraph, and an extra 
> space before the second '.'.  Also, strange capitalization of the word 
> "It" in two places.
>
Hi Alan,

thanks for the review  and suggestions .  I have updated  the commit 
message body removed double spaces and over cappitalization of i

> > -		/* FIXME: we must do the protocol translation here */
> > +		/* Protocol translation per scsi opcode group */
> 
> This comment should be different.  The "per scsi opcode group" will be 
> mentioned in another comment a few lines later; it's not needed here as 
> well.
 
also added new comment for the protocol translation 
as you said to make it different from earlier as per op
code comment.

> >  		if (us->subclass == USB_SC_RBC || us->subclass == USB_SC_SCSI ||
> > -				us->subclass == USB_SC_CYP_ATACB)
> > -			srb->cmd_len = 6;
> > -		else
> > +		    us->subclass == USB_SC_CYP_ATACB) {
> 
> Please don't change the existing indentation.

I changed the pervious indentaion as  greg k-h told me to
do so he said to check checkpatch.pl script errors which said 
alignment should match open parenthesis  thats why i placed it
under the open parenthesis and it does not have any  checkpatch.pl 
error so far . I have checked it with the argument --strict too .
Changing the line from open parenthesis triggers checkpatch.pl 
error.

> > +			else
> > +				srb->cmd_len = 6;
> > +		} else {
> 
> And you could add a comment here explaining that the other protocols use 
> a fixed value for the command length.
> 
> >  			srb->cmd_len = 12;
> > +		}

Thanks for the suggestion of this new comment i have added it 
in the second version please check the above changes in the updated 
version and if there is anything wrong please let me know i am ready 
to make any further changes and  again thanks for you review and suggestions 
on this matter . Thanks for giving your precious time to this matter . Thank you 
so much.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-10-11  9:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-10 11:30 [PATCH] usb: Implement proper subclass protocol translation Shi Hao
2025-10-10 12:29 ` Greg KH
2025-10-10 15:07 ` Alan Stern
2025-10-11  9:37   ` ShiHao

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