aboutsummaryrefslogtreecommitdiff
path: root/drivers/staging/dwc2
diff options
context:
space:
mode:
authorMatthijs Kooijman <matthijs@stdin.nl>2013-04-11 18:43:47 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-04-11 13:27:39 -0700
commit8284f93b3d8b21e30bd8fde97686433a52b49c58 (patch)
tree0a7963893ab3b1e1d16d2d1eba74dc95a244ab08 /drivers/staging/dwc2
parent050232a73c0d054750a9da92e071e26d4c571f12 (diff)
staging: dwc2: Make dwc2_set_uninitialized more specific
Before, it was a function that would set all members of a given struct containing only int members to -1. Now, it is renamed to dwc_set_all_params and it works only on the dwc2_core_params struct. This makes sure that all of the slightly dubious casting and assumptions happen inside the function instead of by the caller. Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl> Acked-by: Paul Zimmerman <paulz@synopsys.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/dwc2')
-rw-r--r--drivers/staging/dwc2/core.h4
-rw-r--r--drivers/staging/dwc2/hcd.c12
-rw-r--r--drivers/staging/dwc2/hcd.h1
3 files changed, 14 insertions, 3 deletions
diff --git a/drivers/staging/dwc2/core.h b/drivers/staging/dwc2/core.h
index 320ed00b6ce..fc075a7c1de 100644
--- a/drivers/staging/dwc2/core.h
+++ b/drivers/staging/dwc2/core.h
@@ -162,6 +162,10 @@ enum dwc2_lx_state {
* parameters define how the DWC_otg controller should be configured.
*/
struct dwc2_core_params {
+ /*
+ * Don't add any non-int members here, this will break
+ * dwc2_set_all_params!
+ */
int otg_cap;
int otg_ver;
int dma_enable;
diff --git a/drivers/staging/dwc2/hcd.c b/drivers/staging/dwc2/hcd.c
index 4d5f34e72ed..bc9c3c51be7 100644
--- a/drivers/staging/dwc2/hcd.c
+++ b/drivers/staging/dwc2/hcd.c
@@ -2679,8 +2679,15 @@ static void dwc2_hcd_release(struct dwc2_hsotg *hsotg)
dwc2_hcd_free(hsotg);
}
-static void dwc2_set_uninitialized(int *p, int size)
+/*
+ * Sets all parameters to the given value.
+ *
+ * Assumes that the dwc2_core_params struct contains only integers.
+ */
+void dwc2_set_all_params(struct dwc2_core_params *params, int value)
{
+ int *p = (int *)params;
+ size_t size = sizeof(*params) / sizeof(*p);
int i;
for (i = 0; i < size; i++)
@@ -2789,8 +2796,7 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
if (!hsotg->core_params)
goto error1;
- dwc2_set_uninitialized((int *)hsotg->core_params,
- sizeof(*hsotg->core_params) / sizeof(int));
+ dwc2_set_all_params(hsotg->core_params, -1);
/* Validate parameter values */
dwc2_set_parameters(hsotg, params);
diff --git a/drivers/staging/dwc2/hcd.h b/drivers/staging/dwc2/hcd.h
index b9f8780a38d..d071f1a05df 100644
--- a/drivers/staging/dwc2/hcd.h
+++ b/drivers/staging/dwc2/hcd.h
@@ -452,6 +452,7 @@ extern int dwc2_hcd_init(struct dwc2_hsotg *hsotg, int irq,
extern void dwc2_hcd_remove(struct dwc2_hsotg *hsotg);
extern int dwc2_set_parameters(struct dwc2_hsotg *hsotg,
struct dwc2_core_params *params);
+extern void dwc2_set_all_params(struct dwc2_core_params *params, int value);
/* Transaction Execution Functions */
extern enum dwc2_transaction_type dwc2_hcd_select_transactions(