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

2013-09-30 Thread dinguyen
From: Dinh Nguyen 

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 
Cc: Matthijs Kooijman 
Cc: Paul Zimmerman 
Cc: Greg Kroah-Hartman 
Cc: linux-...@vger.kernel.org
Cc: de...@driverdev.osuosl.org
---
 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
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2013-09-30 Thread dinguyen
From: Dinh Nguyen 

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 
Cc: Matthijs Kooijman 
Cc: Paul Zimmerman 
Cc: Greg Kroah-Hartman 
Cc: linux-...@vger.kernel.org
Cc: de...@driverdev.osuosl.org
---
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
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel