[PATCH] staging: dwc2: Fix code that gets the nummber of host channels

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Dinh Nguyen <dinguyen@xxxxxxxxxx>

The variable host_channels of dwc2_hw_params struct is only 4-bits. Adding
a 1 to a 0xf results in a 0 for host_channels. Thus, the driver was always
thinking it had 0 host channels.

Represent the correct number of host channels by using the host_channels
variable of dwc2_core_params struct. We should do the +1 in
dwc2_set_param_host_channels();

Signed-off-by: Dinh Nguyen <dinguyen@xxxxxxxxxx>
Cc: Matthijs Kooijman <matthijs@xxxxxxxx>
Cc: Paul Zimmerman <paulz@xxxxxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Cc: linux-usb@xxxxxxxxxxxxxxx
Cc: devel@xxxxxxxxxxxxxxxxxxxx
---
 drivers/staging/dwc2/core.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c
index 93fb8f7..a2970ec 100644
--- a/drivers/staging/dwc2/core.c
+++ b/drivers/staging/dwc2/core.c
@@ -2197,7 +2197,7 @@ int dwc2_set_param_host_channels(struct dwc2_hsotg *hsotg, int val)
 		retval = -EINVAL;
 	}
 
-	hsotg->core_params->host_channels = val;
+	hsotg->core_params->host_channels = val + 1;
 	return retval;
 }
 
@@ -2627,7 +2627,7 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
 	hw->arch = (hwcfg2 & GHWCFG2_ARCHITECTURE_MASK) >>
 		   GHWCFG2_ARCHITECTURE_SHIFT;
 	hw->enable_dynamic_fifo = !!(hwcfg2 & GHWCFG2_DYNAMIC_FIFO);
-	hw->host_channels = 1 + ((hwcfg2 & GHWCFG2_NUM_HOST_CHAN_MASK) >>
+	hw->host_channels = (hwcfg2 & GHWCFG2_NUM_HOST_CHAN_MASK) >>
 				GHWCFG2_NUM_HOST_CHAN_SHIFT);
 	hw->hs_phy_type = (hwcfg2 & GHWCFG2_HS_PHY_TYPE_MASK) >>
 			  GHWCFG2_HS_PHY_TYPE_SHIFT;
-- 
1.7.9.5


_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux