Without this patch a seperate chunk of memory is allocated for the regmap
array. As the regmap is always used it makes no sense to allocate a seperate
memory block for it, this patch moves the regmap array directly into the struct
hw_bank.

Signed-off-by: Marc Kleine-Budde <m...@pengutronix.de>
---
changes since v1:
- fix regmap array size (tnx Peter)
- remove REG_BITS define

 drivers/usb/chipidea/ci.h   | 63 +++++++++++++++++++++------------------------
 drivers/usb/chipidea/core.c |  8 ------
 2 files changed, 30 insertions(+), 41 deletions(-)

diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h
index 1c94fc5..a71dc1c 100644
--- a/drivers/usb/chipidea/ci.h
+++ b/drivers/usb/chipidea/ci.h
@@ -26,6 +26,35 @@
 #define ENDPT_MAX          32
 
 /******************************************************************************
+ * REGISTERS
+ *****************************************************************************/
+/* register indices */
+enum ci_hw_regs {
+       CAP_CAPLENGTH,
+       CAP_HCCPARAMS,
+       CAP_DCCPARAMS,
+       CAP_TESTMODE,
+       CAP_LAST = CAP_TESTMODE,
+       OP_USBCMD,
+       OP_USBSTS,
+       OP_USBINTR,
+       OP_DEVICEADDR,
+       OP_ENDPTLISTADDR,
+       OP_PORTSC,
+       OP_DEVLC,
+       OP_OTGSC,
+       OP_USBMODE,
+       OP_ENDPTSETUPSTAT,
+       OP_ENDPTPRIME,
+       OP_ENDPTFLUSH,
+       OP_ENDPTSTAT,
+       OP_ENDPTCOMPLETE,
+       OP_ENDPTCTRL,
+       /* endptctrl1..15 follow */
+       OP_LAST = OP_ENDPTCTRL + ENDPT_MAX / 2,
+};
+
+/******************************************************************************
  * STRUCTURES
  *****************************************************************************/
 /**
@@ -98,7 +127,7 @@ struct hw_bank {
        void __iomem    *cap;
        void __iomem    *op;
        size_t          size;
-       void __iomem    **regmap;
+       void __iomem    *regmap[OP_LAST + 1];
 };
 
 /**
@@ -209,38 +238,6 @@ static inline void ci_role_stop(struct ci_hdrc *ci)
        ci->roles[role]->stop(ci);
 }
 
-/******************************************************************************
- * REGISTERS
- *****************************************************************************/
-/* register size */
-#define REG_BITS   (32)
-
-/* register indices */
-enum ci_hw_regs {
-       CAP_CAPLENGTH,
-       CAP_HCCPARAMS,
-       CAP_DCCPARAMS,
-       CAP_TESTMODE,
-       CAP_LAST = CAP_TESTMODE,
-       OP_USBCMD,
-       OP_USBSTS,
-       OP_USBINTR,
-       OP_DEVICEADDR,
-       OP_ENDPTLISTADDR,
-       OP_PORTSC,
-       OP_DEVLC,
-       OP_OTGSC,
-       OP_USBMODE,
-       OP_ENDPTSETUPSTAT,
-       OP_ENDPTPRIME,
-       OP_ENDPTFLUSH,
-       OP_ENDPTSTAT,
-       OP_ENDPTCOMPLETE,
-       OP_ENDPTCTRL,
-       /* endptctrl1..15 follow */
-       OP_LAST = OP_ENDPTCTRL + ENDPT_MAX / 2,
-};
-
 /**
  * hw_read: reads from a hw register
  * @reg:  register index
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 5075407..02929ee 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -123,13 +123,6 @@ static int hw_alloc_regmap(struct ci_hdrc *ci, bool is_lpm)
 {
        int i;
 
-       kfree(ci->hw_bank.regmap);
-
-       ci->hw_bank.regmap = kzalloc((OP_LAST + 1) * sizeof(void *),
-                                    GFP_KERNEL);
-       if (!ci->hw_bank.regmap)
-               return -ENOMEM;
-
        for (i = 0; i < OP_ENDPTCTRL; i++)
                ci->hw_bank.regmap[i] =
                        (i <= CAP_LAST ? ci->hw_bank.cap : ci->hw_bank.op) +
@@ -677,7 +670,6 @@ static int ci_hdrc_remove(struct platform_device *pdev)
        ci_role_destroy(ci);
        ci_hdrc_enter_lpm(ci, true);
        ci_usb_phy_destroy(ci);
-       kfree(ci->hw_bank.regmap);
 
        return 0;
 }
-- 
1.8.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to