linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: btusb: Use right timeout macro to receive control message
@ 2024-02-23 10:00 Zijun Hu
  2024-02-23 11:32 ` Greg KH
  2024-02-23 11:33 ` Greg KH
  0 siblings, 2 replies; 5+ messages in thread
From: Zijun Hu @ 2024-02-23 10:00 UTC (permalink / raw)
  To: stern, gregkh; +Cc: linux-usb, usb-storage, Zijun Hu

USB driver defines macro @USB_CTRL_SET_TIMEOUT for sending control message
and @USB_CTRL_GET_TIMEOUT for receiving, but sierra_get_swoc_info() wrongly
uses @USB_CTRL_SET_TIMEOUT as argument of usb_control_msg() to receive
control message, fixed by using @USB_CTRL_GET_TIMEOUT to receive message.

Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
 drivers/usb/storage/sierra_ms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/storage/sierra_ms.c b/drivers/usb/storage/sierra_ms.c
index 177fa6cd143a..8b5a88ea4803 100644
--- a/drivers/usb/storage/sierra_ms.c
+++ b/drivers/usb/storage/sierra_ms.c
@@ -75,7 +75,7 @@ static int sierra_get_swoc_info(struct usb_device *udev,
 			0,				/* __u16 index       */
 			(void *) swocInfo,		/* void *data        */
 			sizeof(struct swoc_info),	/* __u16 size 	     */
-			USB_CTRL_SET_TIMEOUT);		/* int timeout 	     */
+			USB_CTRL_GET_TIMEOUT);		/* int timeout	     */
 
 	swocInfo->LinuxSKU = le16_to_cpu(swocInfo->LinuxSKU);
 	swocInfo->LinuxVer = le16_to_cpu(swocInfo->LinuxVer);
-- 
2.7.4


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

* Re: [PATCH] Bluetooth: btusb: Use right timeout macro to receive control message
  2024-02-23 10:00 [PATCH] Bluetooth: btusb: Use right timeout macro to receive control message Zijun Hu
@ 2024-02-23 11:32 ` Greg KH
  2024-02-23 11:33 ` Greg KH
  1 sibling, 0 replies; 5+ messages in thread
From: Greg KH @ 2024-02-23 11:32 UTC (permalink / raw)
  To: Zijun Hu; +Cc: stern, linux-usb, usb-storage

On Fri, Feb 23, 2024 at 06:00:16PM +0800, Zijun Hu wrote:
> USB driver defines macro @USB_CTRL_SET_TIMEOUT for sending control message
> and @USB_CTRL_GET_TIMEOUT for receiving, but sierra_get_swoc_info() wrongly
> uses @USB_CTRL_SET_TIMEOUT as argument of usb_control_msg() to receive
> control message, fixed by using @USB_CTRL_GET_TIMEOUT to receive message.
> 
> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
> ---
>  drivers/usb/storage/sierra_ms.c | 2 +-

Your subject line is odd :(


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

* Re: [PATCH] Bluetooth: btusb: Use right timeout macro to receive control message
  2024-02-23 10:00 [PATCH] Bluetooth: btusb: Use right timeout macro to receive control message Zijun Hu
  2024-02-23 11:32 ` Greg KH
@ 2024-02-23 11:33 ` Greg KH
  2024-02-26  6:01   ` quic_zijuhu
  1 sibling, 1 reply; 5+ messages in thread
From: Greg KH @ 2024-02-23 11:33 UTC (permalink / raw)
  To: Zijun Hu; +Cc: stern, linux-usb, usb-storage

On Fri, Feb 23, 2024 at 06:00:16PM +0800, Zijun Hu wrote:
> USB driver defines macro @USB_CTRL_SET_TIMEOUT for sending control message
> and @USB_CTRL_GET_TIMEOUT for receiving, but sierra_get_swoc_info() wrongly
> uses @USB_CTRL_SET_TIMEOUT as argument of usb_control_msg() to receive
> control message, fixed by using @USB_CTRL_GET_TIMEOUT to receive message.

You do realize they are both the same value, right?  Why don't we just
change it to USB_CTRL_TIMEOUT so that people don't think changing this
matters?

thanks,

greg k-h

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

* Re: [PATCH] Bluetooth: btusb: Use right timeout macro to receive control message
  2024-02-23 11:33 ` Greg KH
@ 2024-02-26  6:01   ` quic_zijuhu
  2024-02-26  6:19     ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: quic_zijuhu @ 2024-02-26  6:01 UTC (permalink / raw)
  To: Greg KH; +Cc: stern, linux-usb, usb-storage

On 2/23/2024 7:33 PM, Greg KH wrote:
> On Fri, Feb 23, 2024 at 06:00:16PM +0800, Zijun Hu wrote:
>> USB driver defines macro @USB_CTRL_SET_TIMEOUT for sending control message
>> and @USB_CTRL_GET_TIMEOUT for receiving, but sierra_get_swoc_info() wrongly
>> uses @USB_CTRL_SET_TIMEOUT as argument of usb_control_msg() to receive
>> control message, fixed by using @USB_CTRL_GET_TIMEOUT to receive message.
> 
> You do realize they are both the same value, right?  Why don't we just
> change it to USB_CTRL_TIMEOUT so that people don't think changing this
> matters?
> 
1)
will optimize this change title if this change is worthy after code review

2)
yes, i noticed both macros have the same value and carefully read below code block.

include/linux/usb.h:
/*
 * timeouts, in milliseconds, used for sending/receiving control messages
 * they typically complete within a few frames (msec) after they're issued
 * USB identifies 5 second timeouts, maybe more in a few cases, and a few
 * slow devices (like some MGE Ellipse UPSes) actually push that limit.
 */
#define USB_CTRL_GET_TIMEOUT	5000
#define USB_CTRL_SET_TIMEOUT	5000

3)
these two macros are introduced at the same time by Linus Torvalds with commit 1da177e4c3f4 ("Linux-2.6.12-rc2")
below is my points why it is better to keep current two macros than unifying both to one USB_CTRL_TIMEOUT

 point A)
 we can't confirm that sending always have the same timeout as receiving for various devices, it is easy to adjust individual
 macro value if sending potentially does not have the same value as receiving in future.

 point B)
 current two macros defined by usb.h has been used by many usb drivers, there are more drivers need to be corrected if macro NAME are changed.

> thanks,
> 
> greg k-h


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

* Re: [PATCH] Bluetooth: btusb: Use right timeout macro to receive control message
  2024-02-26  6:01   ` quic_zijuhu
@ 2024-02-26  6:19     ` Greg KH
  0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2024-02-26  6:19 UTC (permalink / raw)
  To: quic_zijuhu; +Cc: stern, linux-usb, usb-storage

On Mon, Feb 26, 2024 at 02:01:12PM +0800, quic_zijuhu wrote:
> On 2/23/2024 7:33 PM, Greg KH wrote:
> > On Fri, Feb 23, 2024 at 06:00:16PM +0800, Zijun Hu wrote:
> >> USB driver defines macro @USB_CTRL_SET_TIMEOUT for sending control message
> >> and @USB_CTRL_GET_TIMEOUT for receiving, but sierra_get_swoc_info() wrongly
> >> uses @USB_CTRL_SET_TIMEOUT as argument of usb_control_msg() to receive
> >> control message, fixed by using @USB_CTRL_GET_TIMEOUT to receive message.
> > 
> > You do realize they are both the same value, right?  Why don't we just
> > change it to USB_CTRL_TIMEOUT so that people don't think changing this
> > matters?
> > 
> 1)
> will optimize this change title if this change is worthy after code review

It's wrong as-is so we can't take it anyway, so yes, please fix.

> 2)
> yes, i noticed both macros have the same value and carefully read below code block.
> 
> include/linux/usb.h:
> /*
>  * timeouts, in milliseconds, used for sending/receiving control messages
>  * they typically complete within a few frames (msec) after they're issued
>  * USB identifies 5 second timeouts, maybe more in a few cases, and a few
>  * slow devices (like some MGE Ellipse UPSes) actually push that limit.
>  */
> #define USB_CTRL_GET_TIMEOUT	5000
> #define USB_CTRL_SET_TIMEOUT	5000

And so your changelog comments are wrong.

> 3)
> these two macros are introduced at the same time by Linus Torvalds with commit 1da177e4c3f4 ("Linux-2.6.12-rc2")
> below is my points why it is better to keep current two macros than unifying both to one USB_CTRL_TIMEOUT
> 
>  point A)
>  we can't confirm that sending always have the same timeout as receiving for various devices, it is easy to adjust individual
>  macro value if sending potentially does not have the same value as receiving in future.

As it has been a few decades without needing this change, I think it's
safe to make now.

>  point B)
>  current two macros defined by usb.h has been used by many usb drivers, there are more drivers need to be corrected if macro NAME are changed.

That is fine, there is no issue with changing all uses in the kernel
tree, right?

thanks,

greg k-h

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

end of thread, other threads:[~2024-02-26  6:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-23 10:00 [PATCH] Bluetooth: btusb: Use right timeout macro to receive control message Zijun Hu
2024-02-23 11:32 ` Greg KH
2024-02-23 11:33 ` Greg KH
2024-02-26  6:01   ` quic_zijuhu
2024-02-26  6:19     ` Greg KH

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