]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
musb_hdrc, more runtime code shrinkage
authorDavid Brownell <dbrownell@users.sourceforge.net>
Thu, 18 Jan 2007 19:40:27 +0000 (11:40 -0800)
committerTony Lindgren <tony@atomide.com>
Thu, 18 Jan 2007 19:40:27 +0000 (11:40 -0800)
Remove the annoying "singleton object" dma controller factory in favor
of a simpler scheme of direct calls to routines creating and destroying
those controller objects.  Init routines now live in the init section,
shrinking the runtime footprint by a bit.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
drivers/usb/musb/cppi_dma.c
drivers/usb/musb/dma.h
drivers/usb/musb/musbhsdma.c
drivers/usb/musb/plat_uds.c
drivers/usb/musb/tusb6010_omap.c

index ea24a86db57040b63f12db6fa34afe0a755fe88c..673b4cff321a8f4994ee857b4e6677153145be98 100644 (file)
@@ -1304,8 +1304,8 @@ void cppi_completion(struct musb *pThis, u32 rx, u32 tx)
 }
 
 /* Instantiate a software object representing a DMA controller. */
-static struct dma_controller *
-cppi_controller_new(struct musb *musb, void __iomem *pCoreBase)
+struct dma_controller *__init
+dma_controller_create(struct musb *musb, void __iomem *pCoreBase)
 {
        struct cppi             *pController;
 
@@ -1344,7 +1344,7 @@ cppi_controller_new(struct musb *musb, void __iomem *pCoreBase)
 /*
  *  Destroy a previously-instantiated DMA controller.
  */
-static void cppi_controller_destroy(struct dma_controller *c)
+void dma_controller_destroy(struct dma_controller *c)
 {
        struct cppi     *cppi;
 
@@ -1356,11 +1356,6 @@ static void cppi_controller_destroy(struct dma_controller *c)
        kfree(cppi);
 }
 
-const struct dma_controller_factory dma_controller_factory = {
-       .create =       cppi_controller_new,
-       .destroy =      cppi_controller_destroy,
-};
-
 /*
  * Context: controller irqlocked, endpoint selected
  */
index 96206131a01107f5c17e84d15e1bd35048367aaf..cececd9c28525d8c90d8f36d69127052b15790ca 100644 (file)
@@ -178,21 +178,9 @@ struct dma_controller {
 extern void musb_dma_completion(struct musb *musb, u8 bLocalEnd, u8 bTransmit);
 
 
-/**
- * struct dma_controller_factory - DMA controller factory
- * @create: create a DMA controller
- * @destroy: destroy a DMA controller
- *
- * To allow for multi-core implementations and different
- * types of cores and DMA controllers to co-exist,
- * (only at the source level; no runtime coexistence supported)
- * it is necessary to create them from factories.
- */
-struct dma_controller_factory {
-       struct dma_controller   *(*create)(struct musb *, void __iomem *);
-       void                    (*destroy)(struct dma_controller *);
-};
+extern struct dma_controller *__init
+dma_controller_create(struct musb *, void __iomem *);
 
-extern const struct dma_controller_factory dma_controller_factory;
+extern void dma_controller_destroy(struct dma_controller *);
 
 #endif /* __MUSB_DMA_H__ */
index 4344e898a1f9f7f9de9daa79976021e10688d722..41a9448541afbe0563c0a56cef187ff66f0276ca 100644 (file)
@@ -346,18 +346,16 @@ static irqreturn_t hsdma_irq(int irq, void *pPrivateData)
        return IRQ_HANDLED;
 }
 
-static void hsdma_controller_destroy(struct dma_controller *pController)
+void dma_controller_destroy(struct dma_controller *pController)
 {
        struct hsdma *pHsController = pController->pPrivateData;
 
-       if (pHsController) {
-               pHsController->Controller.pPrivateData = NULL;
-               kfree(pHsController);
-       }
+       pHsController->Controller.pPrivateData = NULL;
+       kfree(pHsController);
 }
 
-static struct dma_controller *
-hsdma_controller_new(struct musb *pThis, void __iomem *pCoreBase)
+struct dma_controller *__init
+dma_controller_create(struct musb *pThis, void __iomem *pCoreBase)
 {
        struct hsdma *pController;
        struct device *dev = pThis->controller;
@@ -387,14 +385,9 @@ hsdma_controller_new(struct musb *pThis, void __iomem *pCoreBase)
        if (request_irq(irq, hsdma_irq, SA_INTERRUPT,
                        pThis->controller->bus_id, &pController->Controller)) {
                dev_err(dev, "request_irq %d failed!\n", irq);
-               hsdma_controller_destroy(&pController->Controller);
+               kfree(pController);
                return NULL;
        }
 
        return &pController->Controller;
 }
-
-const struct dma_controller_factory dma_controller_factory = {
-       .create =       hsdma_controller_new,
-       .destroy =      hsdma_controller_destroy,
-};
index 614682dde463a6a91129c371c91d5fc6f5a45d8d..196558a6f127a28790ffccb450e6ef3aa83df2f8 100644 (file)
@@ -1616,7 +1616,7 @@ static void musb_free(struct musb *musb)
                struct dma_controller   *c = musb->pDmaController;
 
                (void) c->stop(c->pPrivateData);
-               dma_controller_factory.destroy(c);
+               dma_controller_destroy(c);
        }
 
        musb_writeb(musb->pRegs, MGC_O_HDRC_DEVCTL, 0);
@@ -1710,10 +1710,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
        if (use_dma && dev->dma_mask) {
                struct dma_controller   *c;
 
-// FIXME get rid of dma_controller_factory and just call the methods
-// directly ... then create() can be in the init section, etc
-
-               c = dma_controller_factory.create(pThis, pThis->pRegs);
+               c = dma_controller_create(pThis, pThis->pRegs);
                pThis->pDmaController = c;
                if (c)
                        (void) c->start(c->pPrivateData);
index c27f9241707426efc2bc2d06747da1b0ae50c72e..07f9efe4138c61ff8d546b6e91a17e21c2aa5cdb 100644 (file)
@@ -600,7 +600,7 @@ static void tusb_omap_dma_release(struct dma_channel *channel)
        channel = NULL;
 }
 
-static void tusb_omap_dma_cleanup(struct dma_controller *c)
+void dma_controller_destroy(struct dma_controller *c)
 {
        struct tusb_omap_dma    *tusb_dma;
        int                     i;
@@ -621,8 +621,8 @@ static void tusb_omap_dma_cleanup(struct dma_controller *c)
        kfree(tusb_dma);
 }
 
-static struct dma_controller *
-tusb_omap_dma_init(struct musb *musb, void __iomem *base)
+struct dma_controller *__init
+dma_controller_create(struct musb *musb, void __iomem *base)
 {
        void __iomem            *tusb_base = musb->ctrl_base;
        struct tusb_omap_dma    *tusb_dma;
@@ -678,12 +678,7 @@ tusb_omap_dma_init(struct musb *musb, void __iomem *base)
        return &tusb_dma->controller;
 
 cleanup:
-       tusb_omap_dma_cleanup(&tusb_dma->controller);
+       dma_controller_destroy(&tusb_dma->controller);
 
        return NULL;
 }
-
-const struct dma_controller_factory dma_controller_factory = {
-       .create =       tusb_omap_dma_init,
-       .destroy =      tusb_omap_dma_cleanup,
-};