Skip to content

Commit 82799c8

Browse files
Chunfeng Yungregkh
authored andcommitted
usb: xhci-mtk: add a member of num_esit
Add a member num_esit to save the number of esit, then no need caculate it in some functions. Signed-off-by: Chunfeng Yun <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 614c8c6 commit 82799c8

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

drivers/usb/host/xhci-mtk-sch.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ static void setup_sch_info(struct xhci_ep_ctx *ep_ctx,
297297
CTX_TO_MAX_ESIT_PAYLOAD(le32_to_cpu(ep_ctx->tx_info));
298298

299299
sch_ep->esit = get_esit(ep_ctx);
300+
sch_ep->num_esit = XHCI_MTK_MAX_ESIT / sch_ep->esit;
300301
sch_ep->ep_type = ep_type;
301302
sch_ep->maxpkt = maxpkt;
302303
sch_ep->offset = 0;
@@ -401,14 +402,12 @@ static void setup_sch_info(struct xhci_ep_ctx *ep_ctx,
401402
static u32 get_max_bw(struct mu3h_sch_bw_info *sch_bw,
402403
struct mu3h_sch_ep_info *sch_ep, u32 offset)
403404
{
404-
u32 num_esit;
405405
u32 max_bw = 0;
406406
u32 bw;
407407
int i;
408408
int j;
409409

410-
num_esit = XHCI_MTK_MAX_ESIT / sch_ep->esit;
411-
for (i = 0; i < num_esit; i++) {
410+
for (i = 0; i < sch_ep->num_esit; i++) {
412411
u32 base = offset + i * sch_ep->esit;
413412

414413
for (j = 0; j < sch_ep->num_budget_microframes; j++) {
@@ -424,13 +423,11 @@ static u32 get_max_bw(struct mu3h_sch_bw_info *sch_bw,
424423
static void update_bus_bw(struct mu3h_sch_bw_info *sch_bw,
425424
struct mu3h_sch_ep_info *sch_ep, bool used)
426425
{
427-
u32 num_esit;
428426
u32 base;
429427
int i;
430428
int j;
431429

432-
num_esit = XHCI_MTK_MAX_ESIT / sch_ep->esit;
433-
for (i = 0; i < num_esit; i++) {
430+
for (i = 0; i < sch_ep->num_esit; i++) {
434431
base = sch_ep->offset + i * sch_ep->esit;
435432
for (j = 0; j < sch_ep->num_budget_microframes; j++) {
436433
if (used)
@@ -446,12 +443,11 @@ static void update_bus_bw(struct mu3h_sch_bw_info *sch_bw,
446443
static int check_fs_bus_bw(struct mu3h_sch_ep_info *sch_ep, int offset)
447444
{
448445
struct mu3h_sch_tt *tt = sch_ep->sch_tt;
449-
u32 num_esit, tmp;
446+
u32 tmp;
450447
int base;
451448
int i, j;
452449

453-
num_esit = XHCI_MTK_MAX_ESIT / sch_ep->esit;
454-
for (i = 0; i < num_esit; i++) {
450+
for (i = 0; i < sch_ep->num_esit; i++) {
455451
base = offset + i * sch_ep->esit;
456452

457453
/*
@@ -533,12 +529,10 @@ static int check_sch_tt(struct mu3h_sch_ep_info *sch_ep, u32 offset)
533529
static void update_sch_tt(struct mu3h_sch_ep_info *sch_ep, bool used)
534530
{
535531
struct mu3h_sch_tt *tt = sch_ep->sch_tt;
536-
u32 base, num_esit;
532+
u32 base;
537533
int i, j;
538534

539-
num_esit = XHCI_MTK_MAX_ESIT / sch_ep->esit;
540-
541-
for (i = 0; i < num_esit; i++) {
535+
for (i = 0; i < sch_ep->num_esit; i++) {
542536
base = sch_ep->offset + i * sch_ep->esit;
543537

544538
for (j = 0; j < sch_ep->num_budget_microframes; j++)

drivers/usb/host/xhci-mtk.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ struct mu3h_sch_bw_info {
5050
* struct mu3h_sch_ep_info: schedule information for endpoint
5151
*
5252
* @esit: unit is 125us, equal to 2 << Interval field in ep-context
53+
* @num_esit: number of @esit in a period
5354
* @num_budget_microframes: number of continuous uframes
5455
* (@repeat==1) scheduled within the interval
5556
* @bw_cost_per_microframe: bandwidth cost per microframe
@@ -79,6 +80,7 @@ struct mu3h_sch_bw_info {
7980
*/
8081
struct mu3h_sch_ep_info {
8182
u32 esit;
83+
u32 num_esit;
8284
u32 num_budget_microframes;
8385
u32 bw_cost_per_microframe;
8486
struct list_head endpoint;

0 commit comments

Comments
 (0)