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

This is used to simplify unit test.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/805b3ba66c2f02a52de4440212519aaa58463039.1615170625.git.chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit a192e637cf26df3ca9220e1a260a9581ecd877a8
 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I8960da58f69f09d6f3d177d13bc8daa5262d8fb7
This commit is contained in:
Chunfeng Yun
2021-03-08 10:51:56 +08:00
committed by Greg Kroah-Hartman
parent 87ba36a2bc
commit 68ae7f008d

View File

@@ -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;