[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <805b3ba66c2f02a52de4440212519aaa58463039.1615170625.git.chunfeng.yun@mediatek.com>
Date: Mon, 8 Mar 2021 10:51:56 +0800
From: Chunfeng Yun <chunfeng.yun@...iatek.com>
To: Mathias Nyman <mathias.nyman@...el.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Ikjoon Jang <ikjn@...omium.org>
CC: Chunfeng Yun <chunfeng.yun@...iatek.com>,
Matthias Brugger <matthias.bgg@...il.com>,
<linux-usb@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-mediatek@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>,
Nicolas Boichat <drinkcat@...omium.org>,
Eddie Hung <eddie.hung@...iatek.com>,
Sergei Shtylyov <sergei.shtylyov@...il.com>,
Alan Stern <stern@...land.harvard.edu>
Subject: [PATCH v2 07/18] usb: xhci-mtk: add a function to get bandwidth boundary
This is used to simplify unit test.
Signed-off-by: Chunfeng Yun <chunfeng.yun@...iatek.com>
---
v2: no changes
---
drivers/usb/host/xhci-mtk-sch.c | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/drivers/usb/host/xhci-mtk-sch.c b/drivers/usb/host/xhci-mtk-sch.c
index 9a9685f74940..8fe4481eb43d 100644
--- a/drivers/usb/host/xhci-mtk-sch.c
+++ b/drivers/usb/host/xhci-mtk-sch.c
@@ -37,6 +37,25 @@ static int is_fs_or_ls(enum usb_device_speed speed)
return speed == USB_SPEED_FULL || speed == USB_SPEED_LOW;
}
+static u32 get_bw_boundary(enum usb_device_speed speed)
+{
+ u32 boundary;
+
+ switch (speed) {
+ case USB_SPEED_SUPER_PLUS:
+ boundary = SSP_BW_BOUNDARY;
+ break;
+ case USB_SPEED_SUPER:
+ boundary = SS_BW_BOUNDARY;
+ break;
+ default:
+ boundary = HS_BW_BOUNDARY;
+ break;
+ }
+
+ return boundary;
+}
+
/*
* get the index of bandwidth domains array which @ep belongs to.
*
@@ -579,13 +598,7 @@ static int check_sch_bw(struct usb_device *udev,
break;
}
- if (udev->speed == USB_SPEED_SUPER_PLUS)
- bw_boundary = SSP_BW_BOUNDARY;
- else if (udev->speed == USB_SPEED_SUPER)
- bw_boundary = SS_BW_BOUNDARY;
- else
- bw_boundary = HS_BW_BOUNDARY;
-
+ bw_boundary = get_bw_boundary(udev->speed);
/* check bandwidth */
if (min_bw > bw_boundary)
return -ERANGE;
--
2.18.0
Powered by blists - more mailing lists