diff mbox series

[1/7] usb: gadget: f_ecm: fix ecm_bitrate() for SuperSpeed and above

Message ID 20230803051810.2974-2-quic_linyyuan@quicinc.com (mailing list archive)
State Superseded
Headers show
Series remove some usage of gadget_is_{*}speed() API | expand

Commit Message

Linyu Yuan Aug. 3, 2023, 5:18 a.m. UTC
In function ecm_bitrate(), it is not good to report same speed as
super speed when gadget work at super speed plus.

Change report speed same as commit 986499b1569a ("usb: gadget: f_ncm:
fix ncm_bitrate for SuperSpeed and above.").

Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
---
 drivers/usb/gadget/function/f_ecm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Oliver Neukum Aug. 3, 2023, 6:56 a.m. UTC | #1
Hi,

On 03.08.23 07:18, Linyu Yuan wrote:
> In function ecm_bitrate(), it is not good to report same speed as
> super speed when gadget work at super speed plus.
> 
> Change report speed same as commit 986499b1569a ("usb: gadget: f_ncm:
> fix ncm_bitrate for SuperSpeed and above.").

this is very well, but it raises two questions.

1. What is the relation to decreasing the usage of gadget_is_*
This patch increases it. And why? Why not use raw speed?

2. Code like this is used in multiple gadget drivers.
Couldn't this be unified into a macro or something?

	Regards
		Oliver
Linyu Yuan Aug. 3, 2023, 7:04 a.m. UTC | #2
On 8/3/2023 2:56 PM, Oliver Neukum wrote:
> Hi,
>
> On 03.08.23 07:18, Linyu Yuan wrote:
>> In function ecm_bitrate(), it is not good to report same speed as
>> super speed when gadget work at super speed plus.
>>
>> Change report speed same as commit 986499b1569a ("usb: gadget: f_ncm:
>> fix ncm_bitrate for SuperSpeed and above.").
>
> this is very well, but it raises two questions.
>
> 1. What is the relation to decreasing the usage of gadget_is_*
> This patch increases it. And why? Why not use raw speed?


i will move this change at end of series, maybe better.


>
> 2. Code like this is used in multiple gadget drivers.
> Couldn't this be unified into a macro or something?


sure, will try it.


>
>     Regards
>         Oliver
>
diff mbox series

Patch

diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/function/f_ecm.c
index c6e63ad77a40..8da7d314602c 100644
--- a/drivers/usb/gadget/function/f_ecm.c
+++ b/drivers/usb/gadget/function/f_ecm.c
@@ -68,8 +68,10 @@  static inline struct f_ecm *func_to_ecm(struct usb_function *f)
 /* peak (theoretical) bulk transfer rate in bits-per-second */
 static inline unsigned ecm_bitrate(struct usb_gadget *g)
 {
-	if (gadget_is_superspeed(g) && g->speed == USB_SPEED_SUPER)
-		return 13 * 1024 * 8 * 1000 * 8;
+	if (gadget_is_superspeed(g) && g->speed >= USB_SPEED_SUPER_PLUS)
+		return 4250000000U;
+	else if (gadget_is_superspeed(g) && g->speed == USB_SPEED_SUPER)
+		return 3750000000U;
 	else if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH)
 		return 13 * 512 * 8 * 1000 * 8;
 	else