[PATCHv2] 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
---
v2:
- Fix compile by remove extra closing )

 drivers/staging/dwc2/core.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/dwc2/core.c b/drivers/staging/dwc2/core.c
index 825c5e5..5f71fb4 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;
 }
 
@@ -2625,8 +2625,8 @@ 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) >>
-				GHWCFG2_NUM_HOST_CHAN_SHIFT);
+	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;
 	hw->fs_phy_type = (hwcfg2 & GHWCFG2_FS_PHY_TYPE_MASK) >>
-- 
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