diff mbox series

[RFC,03/14] usb: composite: Properly report lsm

Message ID 0ff7d475567f10e2f5051554daaa41d2ce03aa35.1576118671.git.thinhn@synopsys.com (mailing list archive)
State New, archived
Headers show
Series usb: dwc3: Introduce DWC_usb32 | expand

Commit Message

Thinh Nguyen Dec. 12, 2019, 2:49 a.m. UTC
Use the max lane speed mantisa value from the gadget and report to the
device descriptor if available.

Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
---
 drivers/usb/gadget/composite.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

Comments

Felipe Balbi Dec. 12, 2019, 7:59 a.m. UTC | #1
Hi,

Thinh Nguyen <Thinh.Nguyen@synopsys.com> writes:
> Use the max lane speed mantisa value from the gadget and report to the
> device descriptor if available.
>
> Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
> ---
>  drivers/usb/gadget/composite.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
> index a4de5a8c0f19..cd38078d6a42 100644
> --- a/drivers/usb/gadget/composite.c
> +++ b/drivers/usb/gadget/composite.c
> @@ -682,6 +682,11 @@ static int bos_desc(struct usb_composite_dev *cdev)
>  	/* The SuperSpeedPlus USB Device Capability descriptor */
>  	if (gadget_is_superspeed_plus(cdev->gadget)) {
>  		struct usb_ssp_cap_descriptor *ssp_cap;
> +		int lsm = 10;
> +
> +		if (cdev->gadget->ops->udc_set_sublink_attr &&
> +		    cdev->gadget->max_lsm)
> +			lsm = cdev->gadget->max_lsm;
>  
>  		ssp_cap = cdev->req->buf + le16_to_cpu(bos->wTotalLength);
>  		bos->bNumDeviceCaps++;
> @@ -709,20 +714,21 @@ static int bos_desc(struct usb_composite_dev *cdev)
>  		 *   ST  = Symmetric, RX
>  		 *   LSE =  3 (Gbps)
>  		 *   LP  =  1 (SuperSpeedPlus)
> -		 *   LSM = 10 (10 Gbps)
> +		 *   LSM =  5 or 10
>  		 */
>  		ssp_cap->bmSublinkSpeedAttr[0] =
> -			cpu_to_le32((3 << 4) | (1 << 14) | (0xa << 16));
> +			cpu_to_le32((3 << 4) | (1 << 14) | (lsm << 16));

while at that, can we get rid of the magic constants?

>  		ssp_cap->bmSublinkSpeedAttr[1] =
>  			cpu_to_le32((3 << 4) | (1 << 14) |
> -				    (0xa << 16) | (1 << 7));
> +				    (lsm << 16) | (1 << 7));

ditto.
Thinh Nguyen Dec. 12, 2019, 10:10 p.m. UTC | #2
Hi,

Felipe Balbi wrote:
> Hi,
>
> Thinh Nguyen <Thinh.Nguyen@synopsys.com> writes:
>> Use the max lane speed mantisa value from the gadget and report to the
>> device descriptor if available.
>>
>> Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
>> ---
>>   drivers/usb/gadget/composite.c | 14 ++++++++++----
>>   1 file changed, 10 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
>> index a4de5a8c0f19..cd38078d6a42 100644
>> --- a/drivers/usb/gadget/composite.c
>> +++ b/drivers/usb/gadget/composite.c
>> @@ -682,6 +682,11 @@ static int bos_desc(struct usb_composite_dev *cdev)
>>   	/* The SuperSpeedPlus USB Device Capability descriptor */
>>   	if (gadget_is_superspeed_plus(cdev->gadget)) {
>>   		struct usb_ssp_cap_descriptor *ssp_cap;
>> +		int lsm = 10;
>> +
>> +		if (cdev->gadget->ops->udc_set_sublink_attr &&
>> +		    cdev->gadget->max_lsm)
>> +			lsm = cdev->gadget->max_lsm;
>>   
>>   		ssp_cap = cdev->req->buf + le16_to_cpu(bos->wTotalLength);
>>   		bos->bNumDeviceCaps++;
>> @@ -709,20 +714,21 @@ static int bos_desc(struct usb_composite_dev *cdev)
>>   		 *   ST  = Symmetric, RX
>>   		 *   LSE =  3 (Gbps)
>>   		 *   LP  =  1 (SuperSpeedPlus)
>> -		 *   LSM = 10 (10 Gbps)
>> +		 *   LSM =  5 or 10
>>   		 */
>>   		ssp_cap->bmSublinkSpeedAttr[0] =
>> -			cpu_to_le32((3 << 4) | (1 << 14) | (0xa << 16));
>> +			cpu_to_le32((3 << 4) | (1 << 14) | (lsm << 16));
> while at that, can we get rid of the magic constants?

Ok.

>
>>   		ssp_cap->bmSublinkSpeedAttr[1] =
>>   			cpu_to_le32((3 << 4) | (1 << 14) |
>> -				    (0xa << 16) | (1 << 7));
>> +				    (lsm << 16) | (1 << 7));
> ditto.
>

Thanks,
Thinh
diff mbox series

Patch

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index a4de5a8c0f19..cd38078d6a42 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -682,6 +682,11 @@  static int bos_desc(struct usb_composite_dev *cdev)
 	/* The SuperSpeedPlus USB Device Capability descriptor */
 	if (gadget_is_superspeed_plus(cdev->gadget)) {
 		struct usb_ssp_cap_descriptor *ssp_cap;
+		int lsm = 10;
+
+		if (cdev->gadget->ops->udc_set_sublink_attr &&
+		    cdev->gadget->max_lsm)
+			lsm = cdev->gadget->max_lsm;
 
 		ssp_cap = cdev->req->buf + le16_to_cpu(bos->wTotalLength);
 		bos->bNumDeviceCaps++;
@@ -709,20 +714,21 @@  static int bos_desc(struct usb_composite_dev *cdev)
 		 *   ST  = Symmetric, RX
 		 *   LSE =  3 (Gbps)
 		 *   LP  =  1 (SuperSpeedPlus)
-		 *   LSM = 10 (10 Gbps)
+		 *   LSM =  5 or 10
 		 */
 		ssp_cap->bmSublinkSpeedAttr[0] =
-			cpu_to_le32((3 << 4) | (1 << 14) | (0xa << 16));
+			cpu_to_le32((3 << 4) | (1 << 14) | (lsm << 16));
+
 		/*
 		 * bmSublinkSpeedAttr[1] =
 		 *   ST  = Symmetric, TX
 		 *   LSE =  3 (Gbps)
 		 *   LP  =  1 (SuperSpeedPlus)
-		 *   LSM = 10 (10 Gbps)
+		 *   LSM =  5 or 10
 		 */
 		ssp_cap->bmSublinkSpeedAttr[1] =
 			cpu_to_le32((3 << 4) | (1 << 14) |
-				    (0xa << 16) | (1 << 7));
+				    (lsm << 16) | (1 << 7));
 	}
 
 	return le16_to_cpu(bos->wTotalLength);