Commit 66c01883 authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Felipe Balbi

usb: musb: dma: merge ->start/stop into create/destroy

The core code creates a controller and immediately after that it calls
the ->start() callback. This one might drop an error but nobody cares.
The same thing happens in the destroy corner: First ->stop() called
followed by destroy callback. So why not merge those two into the same
function since there is no difference.
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent ff228322
...@@ -150,14 +150,11 @@ static void cppi_pool_free(struct cppi_channel *c) ...@@ -150,14 +150,11 @@ static void cppi_pool_free(struct cppi_channel *c)
c->last_processed = NULL; c->last_processed = NULL;
} }
static int cppi_controller_start(struct dma_controller *c) static void cppi_controller_start(struct cppi *controller)
{ {
struct cppi *controller;
void __iomem *tibase; void __iomem *tibase;
int i; int i;
controller = container_of(c, struct cppi, controller);
/* do whatever is necessary to start controller */ /* do whatever is necessary to start controller */
for (i = 0; i < ARRAY_SIZE(controller->tx); i++) { for (i = 0; i < ARRAY_SIZE(controller->tx); i++) {
controller->tx[i].transmit = true; controller->tx[i].transmit = true;
...@@ -212,8 +209,6 @@ static int cppi_controller_start(struct dma_controller *c) ...@@ -212,8 +209,6 @@ static int cppi_controller_start(struct dma_controller *c)
/* disable RNDIS mode, also host rx RNDIS autorequest */ /* disable RNDIS mode, also host rx RNDIS autorequest */
musb_writel(tibase, DAVINCI_RNDIS_REG, 0); musb_writel(tibase, DAVINCI_RNDIS_REG, 0);
musb_writel(tibase, DAVINCI_AUTOREQ_REG, 0); musb_writel(tibase, DAVINCI_AUTOREQ_REG, 0);
return 0;
} }
/* /*
...@@ -222,14 +217,12 @@ static int cppi_controller_start(struct dma_controller *c) ...@@ -222,14 +217,12 @@ static int cppi_controller_start(struct dma_controller *c)
* De-Init the DMA controller as necessary. * De-Init the DMA controller as necessary.
*/ */
static int cppi_controller_stop(struct dma_controller *c) static void cppi_controller_stop(struct cppi *controller)
{ {
struct cppi *controller;
void __iomem *tibase; void __iomem *tibase;
int i; int i;
struct musb *musb; struct musb *musb;
controller = container_of(c, struct cppi, controller);
musb = controller->musb; musb = controller->musb;
tibase = controller->tibase; tibase = controller->tibase;
...@@ -255,8 +248,6 @@ static int cppi_controller_stop(struct dma_controller *c) ...@@ -255,8 +248,6 @@ static int cppi_controller_stop(struct dma_controller *c)
/*disable tx/rx cppi */ /*disable tx/rx cppi */
musb_writel(tibase, DAVINCI_TXCPPI_CTRL_REG, DAVINCI_DMA_CTRL_DISABLE); musb_writel(tibase, DAVINCI_TXCPPI_CTRL_REG, DAVINCI_DMA_CTRL_DISABLE);
musb_writel(tibase, DAVINCI_RXCPPI_CTRL_REG, DAVINCI_DMA_CTRL_DISABLE); musb_writel(tibase, DAVINCI_RXCPPI_CTRL_REG, DAVINCI_DMA_CTRL_DISABLE);
return 0;
} }
/* While dma channel is allocated, we only want the core irqs active /* While dma channel is allocated, we only want the core irqs active
...@@ -1321,8 +1312,6 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *mr ...@@ -1321,8 +1312,6 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *mr
controller->tibase = mregs - DAVINCI_BASE_OFFSET; controller->tibase = mregs - DAVINCI_BASE_OFFSET;
controller->musb = musb; controller->musb = musb;
controller->controller.start = cppi_controller_start;
controller->controller.stop = cppi_controller_stop;
controller->controller.channel_alloc = cppi_channel_allocate; controller->controller.channel_alloc = cppi_channel_allocate;
controller->controller.channel_release = cppi_channel_release; controller->controller.channel_release = cppi_channel_release;
controller->controller.channel_program = cppi_channel_program; controller->controller.channel_program = cppi_channel_program;
...@@ -1351,6 +1340,7 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *mr ...@@ -1351,6 +1340,7 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *mr
controller->irq = irq; controller->irq = irq;
} }
cppi_controller_start(controller);
return &controller->controller; return &controller->controller;
} }
...@@ -1363,6 +1353,8 @@ void dma_controller_destroy(struct dma_controller *c) ...@@ -1363,6 +1353,8 @@ void dma_controller_destroy(struct dma_controller *c)
cppi = container_of(c, struct cppi, controller); cppi = container_of(c, struct cppi, controller);
cppi_controller_stop(cppi);
if (cppi->irq) if (cppi->irq)
free_irq(cppi->irq, cppi->musb); free_irq(cppi->irq, cppi->musb);
......
...@@ -1764,12 +1764,8 @@ static void musb_free(struct musb *musb) ...@@ -1764,12 +1764,8 @@ static void musb_free(struct musb *musb)
disable_irq_wake(musb->nIrq); disable_irq_wake(musb->nIrq);
free_irq(musb->nIrq, musb); free_irq(musb->nIrq, musb);
} }
if (is_dma_capable() && musb->dma_controller) { if (is_dma_capable() && musb->dma_controller)
struct dma_controller *c = musb->dma_controller; dma_controller_destroy(musb->dma_controller);
(void) c->stop(c);
dma_controller_destroy(c);
}
musb_host_free(musb); musb_host_free(musb);
} }
...@@ -1845,14 +1841,8 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) ...@@ -1845,14 +1841,8 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
pm_runtime_get_sync(musb->controller); pm_runtime_get_sync(musb->controller);
#ifndef CONFIG_MUSB_PIO_ONLY #ifndef CONFIG_MUSB_PIO_ONLY
if (use_dma && dev->dma_mask) { if (use_dma && dev->dma_mask)
struct dma_controller *c; musb->dma_controller = dma_controller_create(musb, musb->mregs);
c = dma_controller_create(musb, musb->mregs);
musb->dma_controller = c;
if (c)
(void) c->start(c);
}
#endif #endif
/* ideally this would be abstracted in platform setup */ /* ideally this would be abstracted in platform setup */
if (!is_dma_capable() || !musb->dma_controller) if (!is_dma_capable() || !musb->dma_controller)
......
...@@ -159,8 +159,6 @@ dma_channel_status(struct dma_channel *c) ...@@ -159,8 +159,6 @@ dma_channel_status(struct dma_channel *c)
* Controllers manage dma channels. * Controllers manage dma channels.
*/ */
struct dma_controller { struct dma_controller {
int (*start)(struct dma_controller *);
int (*stop)(struct dma_controller *);
struct dma_channel *(*channel_alloc)(struct dma_controller *, struct dma_channel *(*channel_alloc)(struct dma_controller *,
struct musb_hw_ep *, u8 is_tx); struct musb_hw_ep *, u8 is_tx);
void (*channel_release)(struct dma_channel *); void (*channel_release)(struct dma_channel *);
......
...@@ -37,18 +37,10 @@ ...@@ -37,18 +37,10 @@
#include "musb_core.h" #include "musb_core.h"
#include "musbhsdma.h" #include "musbhsdma.h"
static int dma_controller_start(struct dma_controller *c)
{
/* nothing to do */
return 0;
}
static void dma_channel_release(struct dma_channel *channel); static void dma_channel_release(struct dma_channel *channel);
static int dma_controller_stop(struct dma_controller *c) static void dma_controller_stop(struct musb_dma_controller *controller)
{ {
struct musb_dma_controller *controller = container_of(c,
struct musb_dma_controller, controller);
struct musb *musb = controller->private_data; struct musb *musb = controller->private_data;
struct dma_channel *channel; struct dma_channel *channel;
u8 bit; u8 bit;
...@@ -67,8 +59,6 @@ static int dma_controller_stop(struct dma_controller *c) ...@@ -67,8 +59,6 @@ static int dma_controller_stop(struct dma_controller *c)
} }
} }
} }
return 0;
} }
static struct dma_channel *dma_channel_allocate(struct dma_controller *c, static struct dma_channel *dma_channel_allocate(struct dma_controller *c,
...@@ -371,6 +361,8 @@ void dma_controller_destroy(struct dma_controller *c) ...@@ -371,6 +361,8 @@ void dma_controller_destroy(struct dma_controller *c)
struct musb_dma_controller *controller = container_of(c, struct musb_dma_controller *controller = container_of(c,
struct musb_dma_controller, controller); struct musb_dma_controller, controller);
dma_controller_stop(controller);
if (controller->irq) if (controller->irq)
free_irq(controller->irq, c); free_irq(controller->irq, c);
...@@ -397,8 +389,6 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *ba ...@@ -397,8 +389,6 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *ba
controller->private_data = musb; controller->private_data = musb;
controller->base = base; controller->base = base;
controller->controller.start = dma_controller_start;
controller->controller.stop = dma_controller_stop;
controller->controller.channel_alloc = dma_channel_allocate; controller->controller.channel_alloc = dma_channel_allocate;
controller->controller.channel_release = dma_channel_release; controller->controller.channel_release = dma_channel_release;
controller->controller.channel_program = dma_channel_program; controller->controller.channel_program = dma_channel_program;
......
...@@ -66,28 +66,6 @@ struct tusb_omap_dma { ...@@ -66,28 +66,6 @@ struct tusb_omap_dma {
unsigned multichannel:1; unsigned multichannel:1;
}; };
static int tusb_omap_dma_start(struct dma_controller *c)
{
struct tusb_omap_dma *tusb_dma;
tusb_dma = container_of(c, struct tusb_omap_dma, controller);
/* dev_dbg(musb->controller, "ep%i ch: %i\n", chdat->epnum, chdat->ch); */
return 0;
}
static int tusb_omap_dma_stop(struct dma_controller *c)
{
struct tusb_omap_dma *tusb_dma;
tusb_dma = container_of(c, struct tusb_omap_dma, controller);
/* dev_dbg(musb->controller, "ep%i ch: %i\n", chdat->epnum, chdat->ch); */
return 0;
}
/* /*
* Allocate dmareq0 to the current channel unless it's already taken * Allocate dmareq0 to the current channel unless it's already taken
*/ */
...@@ -695,8 +673,6 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *ba ...@@ -695,8 +673,6 @@ struct dma_controller *dma_controller_create(struct musb *musb, void __iomem *ba
tusb_dma->dmareq = -1; tusb_dma->dmareq = -1;
tusb_dma->sync_dev = -1; tusb_dma->sync_dev = -1;
tusb_dma->controller.start = tusb_omap_dma_start;
tusb_dma->controller.stop = tusb_omap_dma_stop;
tusb_dma->controller.channel_alloc = tusb_omap_dma_allocate; tusb_dma->controller.channel_alloc = tusb_omap_dma_allocate;
tusb_dma->controller.channel_release = tusb_omap_dma_release; tusb_dma->controller.channel_release = tusb_omap_dma_release;
tusb_dma->controller.channel_program = tusb_omap_dma_program; tusb_dma->controller.channel_program = tusb_omap_dma_program;
......
...@@ -254,10 +254,8 @@ static int ux500_dma_channel_abort(struct dma_channel *channel) ...@@ -254,10 +254,8 @@ static int ux500_dma_channel_abort(struct dma_channel *channel)
return 0; return 0;
} }
static int ux500_dma_controller_stop(struct dma_controller *c) static void ux500_dma_controller_stop(struct ux500_dma_controller *controller)
{ {
struct ux500_dma_controller *controller = container_of(c,
struct ux500_dma_controller, controller);
struct ux500_dma_channel *ux500_channel; struct ux500_dma_channel *ux500_channel;
struct dma_channel *channel; struct dma_channel *channel;
u8 ch_num; u8 ch_num;
...@@ -281,14 +279,10 @@ static int ux500_dma_controller_stop(struct dma_controller *c) ...@@ -281,14 +279,10 @@ static int ux500_dma_controller_stop(struct dma_controller *c)
if (ux500_channel->dma_chan) if (ux500_channel->dma_chan)
dma_release_channel(ux500_channel->dma_chan); dma_release_channel(ux500_channel->dma_chan);
} }
return 0;
} }
static int ux500_dma_controller_start(struct dma_controller *c) static int ux500_dma_controller_start(struct ux500_dma_controller *controller)
{ {
struct ux500_dma_controller *controller = container_of(c,
struct ux500_dma_controller, controller);
struct ux500_dma_channel *ux500_channel = NULL; struct ux500_dma_channel *ux500_channel = NULL;
struct musb *musb = controller->private_data; struct musb *musb = controller->private_data;
struct device *dev = musb->controller; struct device *dev = musb->controller;
...@@ -347,7 +341,7 @@ static int ux500_dma_controller_start(struct dma_controller *c) ...@@ -347,7 +341,7 @@ static int ux500_dma_controller_start(struct dma_controller *c)
dir, ch_num); dir, ch_num);
/* Release already allocated channels */ /* Release already allocated channels */
ux500_dma_controller_stop(c); ux500_dma_controller_stop(controller);
return -EBUSY; return -EBUSY;
} }
...@@ -369,6 +363,7 @@ void dma_controller_destroy(struct dma_controller *c) ...@@ -369,6 +363,7 @@ void dma_controller_destroy(struct dma_controller *c)
struct ux500_dma_controller *controller = container_of(c, struct ux500_dma_controller *controller = container_of(c,
struct ux500_dma_controller, controller); struct ux500_dma_controller, controller);
ux500_dma_controller_stop(controller);
kfree(controller); kfree(controller);
} }
...@@ -378,6 +373,7 @@ struct dma_controller *dma_controller_create(struct musb *musb, ...@@ -378,6 +373,7 @@ struct dma_controller *dma_controller_create(struct musb *musb,
struct ux500_dma_controller *controller; struct ux500_dma_controller *controller;
struct platform_device *pdev = to_platform_device(musb->controller); struct platform_device *pdev = to_platform_device(musb->controller);
struct resource *iomem; struct resource *iomem;
int ret;
controller = kzalloc(sizeof(*controller), GFP_KERNEL); controller = kzalloc(sizeof(*controller), GFP_KERNEL);
if (!controller) if (!controller)
...@@ -394,14 +390,15 @@ struct dma_controller *dma_controller_create(struct musb *musb, ...@@ -394,14 +390,15 @@ struct dma_controller *dma_controller_create(struct musb *musb,
controller->phy_base = (dma_addr_t) iomem->start; controller->phy_base = (dma_addr_t) iomem->start;
controller->controller.start = ux500_dma_controller_start;
controller->controller.stop = ux500_dma_controller_stop;
controller->controller.channel_alloc = ux500_dma_channel_allocate; controller->controller.channel_alloc = ux500_dma_channel_allocate;
controller->controller.channel_release = ux500_dma_channel_release; controller->controller.channel_release = ux500_dma_channel_release;
controller->controller.channel_program = ux500_dma_channel_program; controller->controller.channel_program = ux500_dma_channel_program;
controller->controller.channel_abort = ux500_dma_channel_abort; controller->controller.channel_abort = ux500_dma_channel_abort;
controller->controller.is_compatible = ux500_dma_is_compatible; controller->controller.is_compatible = ux500_dma_is_compatible;
ret = ux500_dma_controller_start(controller);
if (ret)
goto plat_get_fail;
return &controller->controller; return &controller->controller;
plat_get_fail: plat_get_fail:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment