Commit 44b94828 authored by Chunfeng Yun's avatar Chunfeng Yun Committed by Greg Kroah-Hartman

usb: xhci-mtk: add a function to get bandwidth boundary

This is used to simplify unit test.
Signed-off-by: default avatarChunfeng Yun <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/805b3ba66c2f02a52de4440212519aaa58463039.1615170625.git.chunfeng.yun@mediatek.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 338af695
...@@ -37,6 +37,25 @@ static int is_fs_or_ls(enum usb_device_speed speed) ...@@ -37,6 +37,25 @@ static int is_fs_or_ls(enum usb_device_speed speed)
return speed == USB_SPEED_FULL || speed == USB_SPEED_LOW; 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. * get the index of bandwidth domains array which @ep belongs to.
* *
...@@ -579,13 +598,7 @@ static int check_sch_bw(struct usb_device *udev, ...@@ -579,13 +598,7 @@ static int check_sch_bw(struct usb_device *udev,
break; break;
} }
if (udev->speed == USB_SPEED_SUPER_PLUS) bw_boundary = get_bw_boundary(udev->speed);
bw_boundary = SSP_BW_BOUNDARY;
else if (udev->speed == USB_SPEED_SUPER)
bw_boundary = SS_BW_BOUNDARY;
else
bw_boundary = HS_BW_BOUNDARY;
/* check bandwidth */ /* check bandwidth */
if (min_bw > bw_boundary) if (min_bw > bw_boundary)
return -ERANGE; return -ERANGE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment