On 12/06/2013 07:45 AM, Peter Chen wrote: > On Thu, Dec 05, 2013 at 12:32:56PM +0100, Marc Kleine-Budde wrote: >> 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 <mkl@xxxxxxxxxxxxxx> >> --- >> drivers/usb/chipidea/ci.h | 66 ++++++++++++++++++++++----------------------- >> drivers/usb/chipidea/core.c | 8 ------ >> 2 files changed, 33 insertions(+), 41 deletions(-) >> >> diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h >> index 1c94fc5..ef99d91 100644 >> --- a/drivers/usb/chipidea/ci.h >> +++ b/drivers/usb/chipidea/ci.h >> @@ -26,6 +26,38 @@ >> #define ENDPT_MAX 32 >> >> /****************************************************************************** >> + * 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, >> +}; >> + >> +/****************************************************************************** >> * STRUCTURES >> *****************************************************************************/ >> /** >> @@ -98,7 +130,7 @@ struct hw_bank { >> void __iomem *cap; >> void __iomem *op; >> size_t size; >> - void __iomem **regmap; >> + void __iomem *regmap[OP_LAST]; > > OP_LAST + 1? Yes. Why didn't the compiler detect the out of bounds access of the array? >> }; >> >> /** >> @@ -209,38 +241,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, >> -}; >> - > > Have you changed enum ci_hw_regs? If not, please delete above diff. > Meanwhile, you can help delete "#define REG_BITS (32) which" > seems no one uses it. I need to move the enum, because OP_LAST is needed in the struct hw_bank now. I'll delete the REG_BITS. Marc -- Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
Attachment:
signature.asc
Description: OpenPGP digital signature